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 12 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 @@ -88,7 +88,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 @@ -42,7 +42,7 @@ protected override void Init()

KeyboardFlags spellCheckForUwp = KeyboardFlags.None;

if (DeviceInfo.Platform == DevicePlatform.UWP)
if (DeviceInfo.Platform == DevicePlatform.WinUI)
{
spellCheckForUwp = KeyboardFlags.Spellcheck;
}
Expand All @@ -63,12 +63,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 (DeviceInfo.Platform == DevicePlatform.UWP)
if (DeviceInfo.Platform == DevicePlatform.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 @@ -43,7 +43,7 @@ public Issue1705_2()
Children.Add(_page2);
Children.Add(_page3);

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

if (DeviceInfo.Platform == DevicePlatform.UWP)
if (DeviceInfo.Platform == DevicePlatform.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 @@ -43,7 +43,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 = DeviceInfo.Platform == DevicePlatform.UWP ? "Press Tab to focus the first entry. " : "";
string uwp_instructions = DeviceInfo.Platform == DevicePlatform.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 @@ -35,7 +35,7 @@ protected override void Init()
FontFamily = "FontAwesome5Free-Solid"
};

if (DeviceInfo.Platform == DevicePlatform.UWP)
if (DeviceInfo.Platform == DevicePlatform.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 @@ -119,7 +119,7 @@ public CannotScrollRepro()
{
BackgroundColor = Colors.Aqua,
Orientation = ScrollOrientation.Horizontal,
HeightRequest = DeviceInfo.Platform == DevicePlatform.UWP ? 80 : 44,
HeightRequest = DeviceInfo.Platform == DevicePlatform.WinUI ? 80 : 44,
Content = buttonStack
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public PopupStackLayout()
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Start,
Orientation = this.Orientation,
WidthRequest = DeviceInfo.Platform == DevicePlatform.UWP ? 20 : 50,
WidthRequest = DeviceInfo.Platform == DevicePlatform.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 @@ -202,7 +202,7 @@ static string DefaultFontFamily()
var fontFamily = "";
if (DeviceInfo.Platform == DevicePlatform.iOS)
fontFamily = "Ionicons";
else if (DeviceInfo.Platform == DevicePlatform.UWP)
else if (DeviceInfo.Platform == DevicePlatform.WinUI)
fontFamily = "Assets/Fonts/ionicons.ttf#ionicons";
else
fontFamily = "fonts/ionicons.ttf#";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ static string DefaultFontFamily()
var fontFamily = "";
if (DeviceInfo.Platform == DevicePlatform.iOS)
fontFamily = "Ionicons";
else if (DeviceInfo.Platform == DevicePlatform.UWP)
else if (DeviceInfo.Platform == DevicePlatform.WinUI)
fontFamily = "Assets/Fonts/ionicons.ttf#ionicons";
else
fontFamily = "fonts/ionicons.ttf#";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public GroupedReorderingGallery(IItemsLayout itemsLayout)
Text = "Reordering of grouped sources is not supported on Windows!",
FontSize = 24,
FontAttributes = FontAttributes.Bold,
IsVisible = (DeviceInfo.Platform == DevicePlatform.UWP),
IsVisible = (DeviceInfo.Platform == DevicePlatform.WinUI),
BackgroundColor = Colors.Red
};

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

if (DeviceInfo.Platform == DevicePlatform.UWP && !(collectionView.ItemsSource is INotifyCollectionChanged))
if (DeviceInfo.Platform == DevicePlatform.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 @@ -19,7 +19,7 @@ public CustomSwipeItemGallery()
}
};

if (DeviceInfo.Platform != DevicePlatform.UWP)
if (DeviceInfo.Platform != DevicePlatform.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 @@ -146,7 +146,7 @@ static string DefaultFontFamily()
var fontFamily = "";
if (DeviceInfo.Platform == DevicePlatform.iOS)
fontFamily = "Ionicons";
else if (DeviceInfo.Platform == DevicePlatform.UWP)
else if (DeviceInfo.Platform == DevicePlatform.WinUI)
fontFamily = "Assets/Fonts/ionicons.ttf#ionicons";
else
fontFamily = "fonts/ionicons.ttf#";
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 @@ public class CoreViewModel : BaseGalleryViewModel

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
12 changes: 7 additions & 5 deletions src/Controls/src/Core/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,22 @@ public static class Device
[Obsolete("Use Essentials.DevicePlatform.Android instead.")]
public const string Android = "Android";
/// <include file="../../docs/Microsoft.Maui.Controls/Device.xml" path="//Member[@MemberName='UWP']/Docs" />
[Obsolete("Use Essentials.DevicePlatform.UWP instead.")]
public const string UWP = "UWP";
[Obsolete("Use Essentials.DevicePlatform.WinUI instead.")]
public const string UWP = WinUI;
/// <include file="../../docs/Microsoft.Maui.Controls/Device.xml" path="//Member[@MemberName='macOS']/Docs" />
[Obsolete("Use Essentials.DevicePlatform.macOS instead.")]
public const string macOS = "macOS";
internal const string macOS = "macOS";
/// <include file="../../docs/Microsoft.Maui.Controls/Device.xml" path="//Member[@MemberName='GTK']/Docs" />
[Obsolete("Use Essentials.DevicePlatform.GTK instead.")]
public const string GTK = "GTK";
internal const string GTK = "GTK";
/// <include file="../../docs/Microsoft.Maui.Controls/Device.xml" path="//Member[@MemberName='Tizen']/Docs" />
[Obsolete("Use Essentials.DevicePlatform.Tizen instead.")]
public const string Tizen = "Tizen";
[Obsolete("Use Essentials.DevicePlatform.WinUI instead.")]
public const string WinUI = "WinUI";
/// <include file="../../docs/Microsoft.Maui.Controls/Device.xml" path="//Member[@MemberName='WPF']/Docs" />
[Obsolete("Use Essentials.DevicePlatform.WPF instead.")]
public const string WPF = "WPF";
internal const string WPF = "WPF";
[Obsolete("Use Essentials.DevicePlatform.MacCatalyst instead.")]
public const string MacCatalyst = "MacCatalyst";
[Obsolete("Use Essentials.DevicePlatform.tvOS instead.")]
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 @@ -35,8 +35,8 @@ void UpdateState()
SetActive(DeviceInfo.Platform == DevicePlatform.Android);
else if (device == DevicePlatform.iOS)
SetActive(DeviceInfo.Platform == DevicePlatform.iOS);
else if (device == DevicePlatform.UWP)
SetActive(DeviceInfo.Platform == DevicePlatform.UWP);
else if (device == DevicePlatform.WinUI)
SetActive(DeviceInfo.Platform == DevicePlatform.WinUI);
}
}
}
3 changes: 2 additions & 1 deletion src/Controls/src/Core/OnPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public T Default
{
if (onPlat.Platform == null)
continue;
if (!onPlat.Platform.Contains(DeviceInfo.Platform.ToString()))
if (!onPlat.Platform.Contains(DeviceInfo.Platform.ToString()) ||
(!onPlat.Platform.Contains("UWP") && DeviceInfo.Platform == DevicePlatform.WinUI))
continue;
if (s_valueConverter == null)
continue;
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 @@ -304,7 +304,7 @@ internal static DataTemplate CreateDefaultFlyoutItemCell(string textBinding, str
return new DataTemplate(() =>
{
var grid = new Grid();
if (DeviceInfo.Platform == DevicePlatform.UWP)
if (DeviceInfo.Platform == DevicePlatform.WinUI)
grid.ColumnSpacing = grid.RowSpacing = 0;

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

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

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

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

if (DeviceInfo.Platform == DevicePlatform.UWP)
if (DeviceInfo.Platform == DevicePlatform.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 @@ -437,7 +437,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 (DeviceInfo.Platform == DevicePlatform.UWP)
else if (DeviceInfo.Platform == DevicePlatform.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