Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.
13 changes: 2 additions & 11 deletions samples/XCT.Sample/Pages/Views/Popups/ButtonPopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
Size="{x:Static local:PopupSize.Medium}"
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.ButtonPopup">

<xct:Popup.Size>
<OnPlatform x:TypeArguments="Size">
<OnPlatform.Platforms>
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
</OnPlatform.Platforms>
</OnPlatform>
</xct:Popup.Size>

<xct:Popup.Resources>
<ResourceDictionary>
<Style x:Key="Title" TargetType="Label">
Expand Down Expand Up @@ -53,4 +44,4 @@
Clicked="Button_Clicked" />
</StackLayout>

</xct:Popup>
</xct:Popup>
13 changes: 2 additions & 11 deletions samples/XCT.Sample/Pages/Views/Popups/CsharpBindingPopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
Size="{x:Static local:PopupSize.Large}"
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.CsharpBindingPopup">

<xct:Popup.Size>
<OnPlatform x:TypeArguments="Size">
<OnPlatform.Platforms>
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
</OnPlatform.Platforms>
</OnPlatform>
</xct:Popup.Size>

<xct:Popup.Resources>
<ResourceDictionary>
<Style x:Key="Title" TargetType="Label">
Expand Down Expand Up @@ -47,4 +38,4 @@
Text="{Binding Message}" />
</StackLayout>

</xct:Popup>
</xct:Popup>
13 changes: 2 additions & 11 deletions samples/XCT.Sample/Pages/Views/Popups/MultipleButtonPopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
Size="{x:Static local:PopupSize.Medium}"
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.MultipleButtonPopup">

<xct:Popup.Size>
<OnPlatform x:TypeArguments="Size">
<OnPlatform.Platforms>
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
</OnPlatform.Platforms>
</OnPlatform>
</xct:Popup.Size>

<xct:Popup.Resources>
<ResourceDictionary>
<Style x:Key="Title" TargetType="Label">
Expand Down Expand Up @@ -67,4 +58,4 @@

</StackLayout>

</xct:Popup>
</xct:Popup>
13 changes: 2 additions & 11 deletions samples/XCT.Sample/Pages/Views/Popups/NoLightDismissPopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
Size="{x:Static local:PopupSize.Medium}"
IsLightDismissEnabled="False"
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.NoLightDismissPopup">

<xct:Popup.Size>
<OnPlatform x:TypeArguments="Size">
<OnPlatform.Platforms>
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
</OnPlatform.Platforms>
</OnPlatform>
</xct:Popup.Size>

<xct:Popup.Resources>
<ResourceDictionary>
<Style x:Key="Title" TargetType="Label">
Expand Down Expand Up @@ -57,4 +48,4 @@
Clicked="Button_Clicked" />
</StackLayout>

</xct:Popup>
</xct:Popup>
13 changes: 2 additions & 11 deletions samples/XCT.Sample/Pages/Views/Popups/OpenedEventSimplePopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
Size="{x:Static local:PopupSize.Medium}"
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.OpenedEventSimplePopup">

<xct:Popup.Size>
<OnPlatform x:TypeArguments="Size">
<OnPlatform.Platforms>
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
</OnPlatform.Platforms>
</OnPlatform>
</xct:Popup.Size>

<xct:Popup.Resources>
<ResourceDictionary>
<Style x:Key="Title" TargetType="Label">
Expand Down Expand Up @@ -47,4 +38,4 @@
Style="{StaticResource Content}" />
</StackLayout>

</xct:Popup>
</xct:Popup>
15 changes: 10 additions & 5 deletions samples/XCT.Sample/Pages/Views/Popups/PopupSize.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
using Xamarin.Forms;
using Xamarin.Essentials;
using Xamarin.Forms;

namespace Xamarin.CommunityToolkit.Sample.Pages.Views.Popups
{
static class PopupSize
{
public static Size Android => new Size(1000, 1200);
// examples for fixed sizes
public static Size Tiny => new Size(100, 100);

public static Size iOS => new Size(250, 350);

public static Size UWP => new Size(300, 400);
public static Size Small => new Size(300, 300);

// examples for relative to screen sizes
public static Size Medium => new Size(0.7 * (DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density), 0.6 * (DeviceDisplay.MainDisplayInfo.Height / DeviceDisplay.MainDisplayInfo.Density));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, great idea!


public static Size Large => new Size(0.9 * (DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density), 0.8 * (DeviceDisplay.MainDisplayInfo.Height / DeviceDisplay.MainDisplayInfo.Density));
}
}
13 changes: 2 additions & 11 deletions samples/XCT.Sample/Pages/Views/Popups/ReturnResultPopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
Size="{x:Static local:PopupSize.Medium}"
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.ReturnResultPopup"
x:TypeArguments="x:String">

<xct:Popup.Size>
<OnPlatform x:TypeArguments="Size">
<OnPlatform.Platforms>
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
</OnPlatform.Platforms>
</OnPlatform>
</xct:Popup.Size>

<xct:Popup.Resources>
<ResourceDictionary>
<Style x:Key="Title" TargetType="Label">
Expand Down Expand Up @@ -54,4 +45,4 @@
Clicked="Button_Clicked" />
</StackLayout>

</xct:Popup>
</xct:Popup>
13 changes: 2 additions & 11 deletions samples/XCT.Sample/Pages/Views/Popups/SimplePopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
Size="{x:Static local:PopupSize.Small}"
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.SimplePopup">

<xct:Popup.Size>
<OnPlatform x:TypeArguments="Size">
<OnPlatform.Platforms>
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
</OnPlatform.Platforms>
</OnPlatform>
</xct:Popup.Size>

<xct:Popup.Resources>
<ResourceDictionary>
<Style x:Key="Title" TargetType="Label">
Expand Down Expand Up @@ -47,4 +38,4 @@
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." />
</StackLayout>

</xct:Popup>
</xct:Popup>
13 changes: 2 additions & 11 deletions samples/XCT.Sample/Pages/Views/Popups/ToggleSizePopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
Size="{x:Static local:PopupSize.Medium}"
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.ToggleSizePopup">

<xct:Popup.Size>
<OnPlatform x:TypeArguments="Size">
<OnPlatform.Platforms>
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
</OnPlatform.Platforms>
</OnPlatform>
</xct:Popup.Size>

<xct:Popup.Resources>
<ResourceDictionary>
<Style x:Key="Title" TargetType="Label">
Expand Down Expand Up @@ -53,4 +44,4 @@
Clicked="Button_Clicked" />
</StackLayout>

</xct:Popup>
</xct:Popup>
5 changes: 3 additions & 2 deletions samples/XCT.Sample/Pages/Views/Popups/TransparentPopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<xct:Popup xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
xmlns:uwpxct="clr-namespace:Xamarin.CommunityToolkit.UI.Views.WindowsSpecific;assembly=Xamarin.CommunityToolkit"
Size="{OnPlatform Android='200, 200', UWP='100, 100', iOS='100, 100'}"
Size="{x:Static local:PopupSize.Tiny}"
Color="Transparent"
uwpxct:Popup.BorderColor="Transparent"
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.TransparentPopup">
Expand All @@ -13,4 +14,4 @@
HeightRequest="{OnPlatform Android='100', UWP='50'}" WidthRequest="{OnPlatform Android='100', UWP='50'}"
BackgroundColor="Red" />

</xct:Popup>
</xct:Popup>
13 changes: 2 additions & 11 deletions samples/XCT.Sample/Pages/Views/Popups/XamlBindingPopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
xmlns:vm="clr-namespace:Xamarin.CommunityToolkit.Sample.ViewModels.Views.Popups"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
Size="{x:Static local:PopupSize.Large}"
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.XamlBindingPopup">

<xct:Popup.Size>
<OnPlatform x:TypeArguments="Size">
<OnPlatform.Platforms>
<On Platform="Android" Value="{x:Static local:PopupSize.Android}" />
<On Platform="UWP" Value="{x:Static local:PopupSize.UWP}" />
<On Platform="iOS" Value="{x:Static local:PopupSize.iOS}" />
</OnPlatform.Platforms>
</OnPlatform>
</xct:Popup.Size>

<xct:Popup.BindingContext>
<vm:XamlBindingPopupViewModel />
</xct:Popup.BindingContext>
Expand Down Expand Up @@ -52,4 +43,4 @@
Text="{Binding Message}" />
</StackLayout>

</xct:Popup>
</xct:Popup>