Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit ab0df7f

Browse files
authored
[Android] Converting dimensions to pixels in popup renderer (#856)
* [Android] Converting dimensions to pixels in popup renderer * Add fixed and relative to screen sizes instead of platform specific sizes. * Update ButtonPopup size. * Update CsharpBindingPopup size. * Update MultipleButtonPopup size. * Update NoLightDismissPopup size. * Update OpenedEventSimplePopup size. * Update ReturnResultPopup size. * Update SimplePopup size. * Update ToggleSizePopup size. * Update TransparentPopup size. * Update XamlBindingPopup size.
1 parent c9b606a commit ab0df7f

File tree

12 files changed

+52
-121
lines changed

12 files changed

+52
-121
lines changed

samples/XCT.Sample/Pages/Views/Popups/ButtonPopup.xaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
55
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
6+
Size="{x:Static local:PopupSize.Medium}"
67
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.ButtonPopup">
78

8-
<xct:Popup.Size>
9-
<OnPlatform x:TypeArguments="Size">
10-
<OnPlatform.Platforms>
11-
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
12-
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
13-
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
14-
</OnPlatform.Platforms>
15-
</OnPlatform>
16-
</xct:Popup.Size>
17-
189
<xct:Popup.Resources>
1910
<ResourceDictionary>
2011
<Style x:Key="Title" TargetType="Label">
@@ -53,4 +44,4 @@
5344
Clicked="Button_Clicked" />
5445
</StackLayout>
5546

56-
</xct:Popup>
47+
</xct:Popup>

samples/XCT.Sample/Pages/Views/Popups/CsharpBindingPopup.xaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
55
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
6+
Size="{x:Static local:PopupSize.Large}"
67
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.CsharpBindingPopup">
78

8-
<xct:Popup.Size>
9-
<OnPlatform x:TypeArguments="Size">
10-
<OnPlatform.Platforms>
11-
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
12-
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
13-
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
14-
</OnPlatform.Platforms>
15-
</OnPlatform>
16-
</xct:Popup.Size>
17-
189
<xct:Popup.Resources>
1910
<ResourceDictionary>
2011
<Style x:Key="Title" TargetType="Label">
@@ -47,4 +38,4 @@
4738
Text="{Binding Message}" />
4839
</StackLayout>
4940

50-
</xct:Popup>
41+
</xct:Popup>

samples/XCT.Sample/Pages/Views/Popups/MultipleButtonPopup.xaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
55
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
6+
Size="{x:Static local:PopupSize.Medium}"
67
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.MultipleButtonPopup">
78

8-
<xct:Popup.Size>
9-
<OnPlatform x:TypeArguments="Size">
10-
<OnPlatform.Platforms>
11-
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
12-
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
13-
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
14-
</OnPlatform.Platforms>
15-
</OnPlatform>
16-
</xct:Popup.Size>
17-
189
<xct:Popup.Resources>
1910
<ResourceDictionary>
2011
<Style x:Key="Title" TargetType="Label">
@@ -67,4 +58,4 @@
6758

6859
</StackLayout>
6960

70-
</xct:Popup>
61+
</xct:Popup>

samples/XCT.Sample/Pages/Views/Popups/NoLightDismissPopup.xaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,10 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
55
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
6+
Size="{x:Static local:PopupSize.Medium}"
67
IsLightDismissEnabled="False"
78
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.NoLightDismissPopup">
89

9-
<xct:Popup.Size>
10-
<OnPlatform x:TypeArguments="Size">
11-
<OnPlatform.Platforms>
12-
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
13-
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
14-
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
15-
</OnPlatform.Platforms>
16-
</OnPlatform>
17-
</xct:Popup.Size>
18-
1910
<xct:Popup.Resources>
2011
<ResourceDictionary>
2112
<Style x:Key="Title" TargetType="Label">
@@ -57,4 +48,4 @@
5748
Clicked="Button_Clicked" />
5849
</StackLayout>
5950

60-
</xct:Popup>
51+
</xct:Popup>

samples/XCT.Sample/Pages/Views/Popups/OpenedEventSimplePopup.xaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
55
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
6+
Size="{x:Static local:PopupSize.Medium}"
67
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.OpenedEventSimplePopup">
78

8-
<xct:Popup.Size>
9-
<OnPlatform x:TypeArguments="Size">
10-
<OnPlatform.Platforms>
11-
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
12-
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
13-
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
14-
</OnPlatform.Platforms>
15-
</OnPlatform>
16-
</xct:Popup.Size>
17-
189
<xct:Popup.Resources>
1910
<ResourceDictionary>
2011
<Style x:Key="Title" TargetType="Label">
@@ -47,4 +38,4 @@
4738
Style="{StaticResource Content}" />
4839
</StackLayout>
4940

50-
</xct:Popup>
41+
</xct:Popup>
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
using Xamarin.Forms;
1+
using Xamarin.Essentials;
2+
using Xamarin.Forms;
23

34
namespace Xamarin.CommunityToolkit.Sample.Pages.Views.Popups
45
{
56
static class PopupSize
67
{
7-
public static Size Android => new Size(1000, 1200);
8+
// examples for fixed sizes
9+
public static Size Tiny => new Size(100, 100);
810

9-
public static Size iOS => new Size(250, 350);
10-
11-
public static Size UWP => new Size(300, 400);
11+
public static Size Small => new Size(300, 300);
12+
13+
// examples for relative to screen sizes
14+
public static Size Medium => new Size(0.7 * (DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density), 0.6 * (DeviceDisplay.MainDisplayInfo.Height / DeviceDisplay.MainDisplayInfo.Density));
15+
16+
public static Size Large => new Size(0.9 * (DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density), 0.8 * (DeviceDisplay.MainDisplayInfo.Height / DeviceDisplay.MainDisplayInfo.Density));
1217
}
1318
}

samples/XCT.Sample/Pages/Views/Popups/ReturnResultPopup.xaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,10 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
55
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
6+
Size="{x:Static local:PopupSize.Medium}"
67
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.ReturnResultPopup"
78
x:TypeArguments="x:String">
89

9-
<xct:Popup.Size>
10-
<OnPlatform x:TypeArguments="Size">
11-
<OnPlatform.Platforms>
12-
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
13-
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
14-
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
15-
</OnPlatform.Platforms>
16-
</OnPlatform>
17-
</xct:Popup.Size>
18-
1910
<xct:Popup.Resources>
2011
<ResourceDictionary>
2112
<Style x:Key="Title" TargetType="Label">
@@ -54,4 +45,4 @@
5445
Clicked="Button_Clicked" />
5546
</StackLayout>
5647

57-
</xct:Popup>
48+
</xct:Popup>

samples/XCT.Sample/Pages/Views/Popups/SimplePopup.xaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
55
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
6+
Size="{x:Static local:PopupSize.Small}"
67
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.SimplePopup">
78

8-
<xct:Popup.Size>
9-
<OnPlatform x:TypeArguments="Size">
10-
<OnPlatform.Platforms>
11-
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
12-
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
13-
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
14-
</OnPlatform.Platforms>
15-
</OnPlatform>
16-
</xct:Popup.Size>
17-
189
<xct:Popup.Resources>
1910
<ResourceDictionary>
2011
<Style x:Key="Title" TargetType="Label">
@@ -47,4 +38,4 @@
4738
Text="This is a native popup with a Xamarin.Forms View being rendered. The behaviors of the popup will confirm to 100% native look and feel, but still allows you to use your Xamarin.Forms controls." />
4839
</StackLayout>
4940

50-
</xct:Popup>
41+
</xct:Popup>

samples/XCT.Sample/Pages/Views/Popups/ToggleSizePopup.xaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,9 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
55
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
6+
Size="{x:Static local:PopupSize.Medium}"
67
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.ToggleSizePopup">
78

8-
<xct:Popup.Size>
9-
<OnPlatform x:TypeArguments="Size">
10-
<OnPlatform.Platforms>
11-
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
12-
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
13-
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
14-
</OnPlatform.Platforms>
15-
</OnPlatform>
16-
</xct:Popup.Size>
17-
189
<xct:Popup.Resources>
1910
<ResourceDictionary>
2011
<Style x:Key="Title" TargetType="Label">
@@ -53,4 +44,4 @@
5344
Clicked="Button_Clicked" />
5445
</StackLayout>
5546

56-
</xct:Popup>
47+
</xct:Popup>

samples/XCT.Sample/Pages/Views/Popups/TransparentPopup.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
<xct:Popup xmlns="http://xamarin.com/schemas/2014/forms"
33
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
44
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
5+
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
56
xmlns:uwpxct="clr-namespace:Xamarin.CommunityToolkit.UI.Views.WindowsSpecific;assembly=Xamarin.CommunityToolkit"
6-
Size="{OnPlatform Android='200, 200', UWP='100, 100', iOS='100, 100'}"
7+
Size="{x:Static local:PopupSize.Tiny}"
78
Color="Transparent"
89
uwpxct:Popup.BorderColor="Transparent"
910
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.TransparentPopup">
@@ -13,4 +14,4 @@
1314
HeightRequest="{OnPlatform Android='100', UWP='50'}" WidthRequest="{OnPlatform Android='100', UWP='50'}"
1415
BackgroundColor="Red" />
1516

16-
</xct:Popup>
17+
</xct:Popup>

0 commit comments

Comments
 (0)