Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unsupported targets in Device class #4491

Merged
merged 19 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ButtonGallery()
case Device.Android:
fontName = "sans-serif-light";
break;
case Device.UWP:
case Device.WinUI:
fontName = "Comic Sans MS";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public ProductCellView(string text)
var frame = new Frame
{
Content = _stack,
BackgroundColor = new[] { Device.Android, Device.UWP }.Contains(Device.RuntimePlatform) ? new Color(0.2f) : new Color(1)
BackgroundColor = new[] { Device.Android, Device.WinUI }.Contains(Device.RuntimePlatform) ? new Color(0.2f) : new Color(1)
};
_timeLabel = new Label
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static Picker CreateImageSourcePicker(string title, Action<Func<ImageSource>> on
case Device.iOS:
fontFamily = "Ionicons";
break;
case Device.UWP:
case Device.WinUI:
fontFamily = "Assets/Fonts/ionicons.ttf#ionicons";
break;
case Device.Android:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public LabelGallery()
case Device.Android:
fontName = "sans-serif-light";
break;
case Device.UWP:
case Device.WinUI:
fontName = "Comic Sans MS";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public CustomSwipeItemGallery()
}
};

if (Device.RuntimePlatform != Device.UWP)
if (Device.RuntimePlatform != Device.WinUI)
{
layout.Children.Add(GalleryBuilder.NavButton("SwipeItemView Gallery", () => new CustomSwipeItemViewGallery(), Navigation));
layout.Children.Add(GalleryBuilder.NavButton("CustomSwipeItem Size Gallery", () => new CustomSizeSwipeViewGallery(), Navigation));
Expand Down
2 changes: 1 addition & 1 deletion src/Compatibility/ControlGallery/src/Core/TestCases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public static NavigationPage GetTestCases()
default:
page.Title = "Test Cases";
break;
case Device.UWP:
case Device.WinUI:
page.Title = "Tests";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected override void Init()
case Device.iOS:
fontFamily = "Ionicons";
break;
case Device.UWP:
case Device.WinUI:
fontFamily = "Assets/Fonts/ionicons.ttf#ionicons";
break;
case Device.Android:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Bugzilla22229()
case Device.Android:
_prefix = "";
break;
case Device.UWP:
case Device.WinUI:
_prefix = "Assets/";
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected override void Init()

KeyboardFlags spellCheckForUwp = KeyboardFlags.None;

if (Device.RuntimePlatform == Device.UWP)
if (Device.RuntimePlatform == Device.WinUI)
{
spellCheckForUwp = KeyboardFlags.Spellcheck;
}
Expand All @@ -62,12 +62,12 @@ protected override void Init()
inputViews.Add(new EntryKeyboardFlags() { ClassId = "CustomRendererCapitalizeSentence", FlagsToSet = KeyboardFlags.CapitalizeSentence, FlagsToTestFor = KeyboardFlags.CapitalizeSentence });
inputViews.Add(new EntryKeyboardFlags() { ClassId = "CustomRendererCapitalizeWord", FlagsToSet = KeyboardFlags.CapitalizeWord, FlagsToTestFor = KeyboardFlags.CapitalizeWord });

if (Device.RuntimePlatform != Device.UWP)
if (Device.RuntimePlatform != Device.WinUI)
{
inputViews.Add(new EntryKeyboardFlags() { ClassId = "CustomRendererCapitalizeCharacter", FlagsToSet = KeyboardFlags.CapitalizeCharacter });
}

if (Device.RuntimePlatform == Device.UWP)
if (Device.RuntimePlatform == Device.WinUI)
{
layout.Children.Add(new Label() { Text = "Capitalization settings only work when using touch keyboard" });
layout.Children.Add(new Label() { Text = "Character doesn't do anything on UWP" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Issue1705_2()
Children.Add(_page2);
Children.Add(_page3);

if (Device.RuntimePlatform == Device.UWP)
if (Device.RuntimePlatform == Device.WinUI)
Children.Add(new HeaderIconsControlPage(this) { Title = "UWPSpecifics" });
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected override void Init()
layout.Children.Add(_result);
layout.Children.Add(button);

if (Device.RuntimePlatform == Device.UWP)
if (Device.RuntimePlatform == Device.WinUI)
layout.Children.Add(new Label { Text = "\xE76E", FontFamily = "Segoe MDL2 Assets", FontSize = 32 });

Content = layout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected override void Init()
entry2Label2.SetBinding(Label.TextProperty, new Binding(nameof(Entry.SelectionLength), stringFormat: "SelectionLength: {0}", source: entry2));

// When the Entry is in a NavPage, the Entry doesn't get first focus on UWP
string uwp_instructions = Device.RuntimePlatform == Device.UWP ? "Press Tab to focus the first entry. " : "";
string uwp_instructions = Device.RuntimePlatform == Device.WinUI ? "Press Tab to focus the first entry. " : "";

Content = new StackLayout()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static string DefaultFontFamily()
case Device.iOS:
fontFamily = "Ionicons";
break;
case Device.UWP:
case Device.WinUI:
fontFamily = "Assets/Fonts/ionicons.ttf#ionicons";
break;
case Device.Android:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected override void Init()
FontFamily = "FontAwesome5Free-Solid"
};

if (Device.RuntimePlatform == Device.UWP)
if (Device.RuntimePlatform == Device.WinUI)
((FontImageSource)button.ImageSource).FontFamily = "Assets/Fonts/fa-solid-900.ttf#Font Awesome 5 Free";

stack.Children.Add(label);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public CannotScrollRepro()
{
BackgroundColor = Colors.Aqua,
Orientation = ScrollOrientation.Horizontal,
HeightRequest = Device.RuntimePlatform == Device.UWP ? 80 : 44,
HeightRequest = Device.RuntimePlatform == Device.WinUI ? 80 : 44,
Content = buttonStack
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public PopupStackLayout()
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Start,
Orientation = this.Orientation,
WidthRequest = Device.RuntimePlatform == Device.UWP ? 20 : 50,
WidthRequest = Device.RuntimePlatform == Device.WinUI ? 20 : 50,
};

this.SetBinding(HeightRequestProperty, new Binding(nameof(Height), BindingMode.OneWay, source: showButton));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static string DefaultFontFamily()
case Device.iOS:
fontFamily = "Ionicons";
break;
case Device.UWP:
case Device.WinUI:
fontFamily = "Assets/Fonts/ionicons.ttf#ionicons";
break;
case Device.Android:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ static string DefaultFontFamily()
case Device.iOS:
fontFamily = "Ionicons";
break;
case Device.UWP:
case Device.WinUI:
fontFamily = "Assets/Fonts/ionicons.ttf#ionicons";
break;
case Device.Android:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public GroupedReorderingGallery(IItemsLayout itemsLayout)
Text = "Reordering of grouped sources is not supported on Windows!",
FontSize = 24,
FontAttributes = FontAttributes.Bold,
IsVisible = (Device.RuntimePlatform == Device.UWP),
IsVisible = (Device.RuntimePlatform == Device.WinUI),
BackgroundColor = Colors.Red
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async void UpdateItemsSourceType(ItemsSourceGenerator generator, ItemsSourceType
{
generator.GenerateItems(itemsSourceType);

if (Device.RuntimePlatform == Device.UWP && !(collectionView.ItemsSource is INotifyCollectionChanged))
if (Device.RuntimePlatform == Device.WinUI && !(collectionView.ItemsSource is INotifyCollectionChanged))
{
await DisplayAlert("Warning!", "Reordering on UWP/WinUI only works with ObservableCollections!", "OK");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public CustomSwipeItemGallery()
}
};

if (Device.RuntimePlatform != Device.UWP)
if (Device.RuntimePlatform != Device.WinUI)
{
layout.Children.Add(GalleryBuilder.NavButton("SwipeItemView Gallery", () => new CustomSwipeItemViewGallery(), Navigation));
layout.Children.Add(GalleryBuilder.NavButton("CustomSwipeItem Size Gallery", () => new CustomSizeSwipeViewGallery(), Navigation));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public SwipeItemIconGallery()
case Device.iOS:
fontFamily = "Ionicons";
break;
case Device.UWP:
case Device.WinUI:
fontFamily = "Assets/Fonts/ionicons.ttf#ionicons";
break;
case Device.Android:
Expand Down
17 changes: 17 additions & 0 deletions src/Controls/samples/Controls.Sample/Pages/Core/DevicePage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<views:BasePage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Pages.DevicePage"
xmlns:views="clr-namespace:Maui.Controls.Sample.Pages.Base"
Title="Device">
<ContentPage.Content>
<StackLayout
HorizontalOptions="Center">
<Label
Text="{OnPlatform Default='Default Platform', Android='Android', iOS='iOS', MacCatalyst='MacCatalyst', Tizen='Tizen', WinUI='WinUI'}" />
<Label
Text="{OnIdiom Default='Default Idiom', Phone='Phone', Tablet='Tablet', Desktop='Desktop', TV='TV', Watch='Watch'}" />
</StackLayout>
</ContentPage.Content>
</views:BasePage>
10 changes: 10 additions & 0 deletions src/Controls/samples/Controls.Sample/Pages/Core/DevicePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Maui.Controls.Sample.Pages
{
public partial class DevicePage
{
public DevicePage()
{
InitializeComponent();
}
}
}
10 changes: 1 addition & 9 deletions src/Controls/samples/Controls.Sample/Pages/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</views:BasePage.Resources>
<ScrollView>
<Grid
RowDefinitions="150, *, Auto, Auto"
RowDefinitions="150, *, Auto"
RowSpacing="0">
<!-- HEADER -->
<Image
Expand Down Expand Up @@ -118,14 +118,6 @@
Grid.Row="2"
Text="Microsoft Corporation © 2021"
Style="{StaticResource FooterStyle}" />
<StackLayout Orientation="Horizontal" Grid.Row="3" HorizontalOptions="Center">
<Label
Text="{OnPlatform Default='Default Platform', Android='Android', iOS='iOS', macOS='macOS', MacCatalyst='MacCatalyst', Tizen='Tizen', UWP='UWP'}"
Style="{StaticResource FooterStyle}" />
<Label
Text="{OnIdiom Default='Default Idiom', Phone='Phone', Tablet='Tablet', Desktop='Desktop', TV='TV', Watch='Watch'}"
Style="{StaticResource FooterStyle}" />
</StackLayout>
</Grid>
</ScrollView>
</views:BasePage>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ protected override IEnumerable<SectionModel> CreateItems() => new[]

new SectionModel(typeof(ClipPage), "Clip",
"Defines the outline of the contents of an element."),


new SectionModel(typeof(DevicePage), "Device",
"A number of properties and methods to help developers customize layout and functionality on a per-platform basis"),

new SectionModel(typeof(DispatcherPage), "Dispatcher",
"Managing UI thread access with dispatchers and timers."),

Expand Down
10 changes: 6 additions & 4 deletions src/Controls/src/Core/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ public static class Device
/// <include file="../../docs/Microsoft.Maui.Controls/Device.xml" path="//Member[@MemberName='Android']/Docs" />
public const string Android = "Android";
/// <include file="../../docs/Microsoft.Maui.Controls/Device.xml" path="//Member[@MemberName='UWP']/Docs" />
public const string UWP = "UWP";
[Obsolete]
internal const string UWP = "UWP";
Redth marked this conversation as resolved.
Show resolved Hide resolved
/// <include file="../../docs/Microsoft.Maui.Controls/Device.xml" path="//Member[@MemberName='macOS']/Docs" />
public const string macOS = "macOS";
internal const string macOS = "macOS";
/// <include file="../../docs/Microsoft.Maui.Controls/Device.xml" path="//Member[@MemberName='GTK']/Docs" />
public const string GTK = "GTK";
internal const string GTK = "GTK";
/// <include file="../../docs/Microsoft.Maui.Controls/Device.xml" path="//Member[@MemberName='Tizen']/Docs" />
public const string Tizen = "Tizen";
/// <include file="../../docs/Microsoft.Maui.Controls/Device.xml" path="//Member[@MemberName='WPF']/Docs" />
public const string WPF = "WPF";
internal const string WPF = "WPF";
public const string WinUI = "WinUI";
public const string MacCatalyst = "MacCatalyst";
public const string tvOS = "tvOS";

Expand Down
4 changes: 2 additions & 2 deletions src/Controls/src/Core/DeviceStateTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ void UpdateState()
case FormsDevice.iOS:
SetActive(FormsDevice.RuntimePlatform == FormsDevice.iOS);
break;
case FormsDevice.UWP:
SetActive(FormsDevice.RuntimePlatform == FormsDevice.UWP);
case FormsDevice.WinUI:
SetActive(FormsDevice.RuntimePlatform == FormsDevice.WinUI);
break;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Controls/src/Core/Shell/BaseShellItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
return new DataTemplate(() =>
{
var grid = new Grid();
if (Device.RuntimePlatform == Device.UWP)
if (Device.RuntimePlatform == Device.WinUI)
grid.ColumnSpacing = grid.RowSpacing = 0;

grid.Resources = new ResourceDictionary();
Expand Down Expand Up @@ -342,7 +342,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
var selectedState = new VisualState();
selectedState.Name = "Selected";

if (Device.RuntimePlatform != Device.UWP)
if (Device.RuntimePlatform != Device.WinUI)
{
selectedState.Setters.Add(new Setter
{
Expand Down Expand Up @@ -374,7 +374,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
columnDefinitions.Add(new ColumnDefinition { Width = 54 });
else if (Device.RuntimePlatform == Device.iOS)
columnDefinitions.Add(new ColumnDefinition { Width = 50 });
else if (Device.RuntimePlatform == Device.UWP)
else if (Device.RuntimePlatform == Device.WinUI)
columnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });

columnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star });
Expand All @@ -387,7 +387,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
sizeRequest = 24;
else if (Device.RuntimePlatform == Device.iOS)
sizeRequest = 22;
else if (Device.RuntimePlatform == Device.UWP)
else if (Device.RuntimePlatform == Device.WinUI)
sizeRequest = 16;

if (sizeRequest > 0)
Expand All @@ -396,7 +396,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
defaultImageClass.Setters.Add(new Setter() { Property = Image.WidthRequestProperty, Value = sizeRequest });
}

if (Device.RuntimePlatform == Device.UWP)
if (Device.RuntimePlatform == Device.WinUI)
{
defaultImageClass.Setters.Add(new Setter { Property = Image.HorizontalOptionsProperty, Value = LayoutOptions.Start });
defaultImageClass.Setters.Add(new Setter { Property = Image.MarginProperty, Value = new Thickness(12, 0, 12, 0) });
Expand Down Expand Up @@ -436,7 +436,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
defaultLabelClass.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = Device.GetNamedSize(NamedSize.Small, label) });
defaultLabelClass.Setters.Add(new Setter { Property = Label.FontAttributesProperty, Value = FontAttributes.Bold });
}
else if (Device.RuntimePlatform == Device.UWP)
else if (Device.RuntimePlatform == Device.WinUI)
{
defaultLabelClass.Setters.Add(new Setter { Property = Label.HorizontalOptionsProperty, Value = LayoutOptions.Start });
defaultLabelClass.Setters.Add(new Setter { Property = Label.HorizontalTextAlignmentProperty, Value = TextAlignment.Start });
Expand Down
Loading