forked from xamarin/XamarinCommunityToolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ported Popup Control from xamarin/Xamarin.Forms#9616 to Xamarin Commu…
…nity Toolkit
- Loading branch information
1 parent
e26c053
commit 50df8a6
Showing
45 changed files
with
2,358 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/CommunityToolkit/Xamarin.CommunityToolkit.Sample/Pages/Views/PopupGalleryPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<pages:BasePage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:pages="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages" | ||
xmlns:viewModels="clr-namespace:Xamarin.CommunityToolkit.Sample.ViewModels.Views" | ||
xmlns:custom="clr-namespace:Xamarin.Forms.PancakeView;assembly=Xamarin.Forms.PancakeView" | ||
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.PopupGalleryPage" | ||
Title="Popup Control" | ||
x:Name="root"> | ||
|
||
<ContentPage.BindingContext> | ||
<viewModels:PopupControlViewModel /> | ||
</ContentPage.BindingContext> | ||
|
||
<ContentPage.Resources> | ||
<ResourceDictionary> | ||
<Style x:Key="Header" TargetType="Label"> | ||
<Setter Property="VerticalOptions" Value="CenterAndExpand" /> | ||
<Setter Property="HorizontalOptions" Value="CenterAndExpand" /> | ||
<Setter Property="Margin" Value="15, 10" /> | ||
</Style> | ||
<Style TargetType="ScrollView"> | ||
<Setter Property="VerticalOptions" Value="FillAndExpand" /> | ||
</Style> | ||
<Style x:Key="ItemsLayout" TargetType="StackLayout"> | ||
<Setter Property="Spacing" Value="16" /> | ||
</Style> | ||
</ResourceDictionary> | ||
</ContentPage.Resources> | ||
|
||
<ContentPage.Content> | ||
<StackLayout> | ||
<ScrollView> | ||
<StackLayout> | ||
<Label Style="{StaticResource Header}" | ||
Text="The popup control renders native popups from the shared code. This page demonstrates a variety of different techniques for displaying native popups." /> | ||
<StackLayout Style="{StaticResource ItemsLayout}" | ||
BindableLayout.ItemsSource="{Binding Examples}"> | ||
<BindableLayout.ItemTemplate> | ||
<DataTemplate> | ||
<custom:PancakeView Style="{StaticResource card}" | ||
Margin="{StaticResource ContentPadding}"> | ||
<custom:PancakeView.GestureRecognizers> | ||
<TapGestureRecognizer Command="{Binding BindingContext.DisplayPopup, Source={x:Reference root}}" | ||
CommandParameter="{Binding Type}" /> | ||
</custom:PancakeView.GestureRecognizers> | ||
<Grid ColumnSpacing="20"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="12" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<BoxView BackgroundColor="{Binding Color}" /> | ||
<StackLayout Grid.Column="1" Spacing="8" Padding="0,24,24,24"> | ||
<Label Style="{StaticResource label_section_header}" Text="{Binding Title}" /> | ||
<Label Text="{Binding Description}" /> | ||
</StackLayout> | ||
</Grid> | ||
</custom:PancakeView> | ||
</DataTemplate> | ||
</BindableLayout.ItemTemplate> | ||
</StackLayout> | ||
</StackLayout> | ||
</ScrollView> | ||
</StackLayout> | ||
</ContentPage.Content> | ||
</pages:BasePage> |
7 changes: 7 additions & 0 deletions
7
src/CommunityToolkit/Xamarin.CommunityToolkit.Sample/Pages/Views/PopupGalleryPage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Xamarin.CommunityToolkit.Sample.Pages.Views | ||
{ | ||
public partial class PopupGalleryPage | ||
{ | ||
public PopupGalleryPage() => InitializeComponent(); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/CommunityToolkit/Xamarin.CommunityToolkit.Sample/Pages/Views/Popups/ButtonPopup.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<xct:Popup xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.UI.Views;assembly=Xamarin.CommunityToolkit" | ||
Size="{OnPlatform Android='800, 700', UWP='300, 250', iOS='250, 400'}" | ||
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.ButtonPopup"> | ||
|
||
<xct:Popup.Resources> | ||
<ResourceDictionary> | ||
<Style x:Key="Title" TargetType="Label"> | ||
<Setter Property="FontSize" Value="26" /> | ||
<Setter Property="FontAttributes" Value="Bold" /> | ||
<Setter Property="TextColor" Value="#000" /> | ||
<Setter Property="VerticalTextAlignment" Value="Center" /> | ||
<Setter Property="HorizontalTextAlignment" Value="Center" /> | ||
</Style> | ||
<Style x:Key="Divider" TargetType="BoxView"> | ||
<Setter Property="HeightRequest" Value="1" /> | ||
<Setter Property="Margin" Value="50, 25" /> | ||
<Setter Property="Color" Value="#c3c3c3" /> | ||
</Style> | ||
<Style x:Key="Content" TargetType="Label"> | ||
<Setter Property="HorizontalTextAlignment" Value="Start" /> | ||
<Setter Property="VerticalTextAlignment" Value="Center" /> | ||
</Style> | ||
<Style x:Key="PopupLayout" TargetType="StackLayout"> | ||
<Setter Property="Padding" Value="{OnPlatform Android=20, UWP=20, iOS=5}" /> | ||
</Style> | ||
<Style x:Key="ConfirmButton" TargetType="Button"> | ||
<Setter Property="VerticalOptions" Value="EndAndExpand" /> | ||
</Style> | ||
</ResourceDictionary> | ||
</xct:Popup.Resources> | ||
|
||
<xct:Popup.View> | ||
<StackLayout Style="{StaticResource PopupLayout}"> | ||
<Label Style="{StaticResource Title}" | ||
Text="Button Popup" /> | ||
<BoxView Style="{StaticResource Divider}" /> | ||
<Label Style="{StaticResource Content}" | ||
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." /> | ||
<Button Text="OKAY" | ||
Style="{StaticResource ConfirmButton}" | ||
Clicked="Button_Clicked" /> | ||
</StackLayout> | ||
</xct:Popup.View> | ||
|
||
</xct:Popup> |
9 changes: 9 additions & 0 deletions
9
src/CommunityToolkit/Xamarin.CommunityToolkit.Sample/Pages/Views/Popups/ButtonPopup.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Xamarin.CommunityToolkit.Sample.Pages.Views.Popups | ||
{ | ||
public partial class ButtonPopup | ||
{ | ||
public ButtonPopup() => InitializeComponent(); | ||
|
||
void Button_Clicked(object sender, System.EventArgs e) => Dismiss(null); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...munityToolkit/Xamarin.CommunityToolkit.Sample/Pages/Views/Popups/MultipleButtonPopup.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<xct:Popup xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.UI.Views;assembly=Xamarin.CommunityToolkit" | ||
Size="{OnPlatform Android='800, 700', UWP='300, 250', iOS='250, 400'}" | ||
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.MultipleButtonPopup"> | ||
|
||
<xct:Popup.Resources> | ||
<ResourceDictionary> | ||
<Style x:Key="Title" TargetType="Label"> | ||
<Setter Property="FontSize" Value="26" /> | ||
<Setter Property="FontAttributes" Value="Bold" /> | ||
<Setter Property="TextColor" Value="#000" /> | ||
<Setter Property="VerticalTextAlignment" Value="Center" /> | ||
<Setter Property="HorizontalTextAlignment" Value="Center" /> | ||
</Style> | ||
<Style x:Key="Divider" TargetType="BoxView"> | ||
<Setter Property="HeightRequest" Value="1" /> | ||
<Setter Property="Margin" Value="50, 25" /> | ||
<Setter Property="Color" Value="#c3c3c3" /> | ||
</Style> | ||
<Style x:Key="Content" TargetType="Label"> | ||
<Setter Property="HorizontalTextAlignment" Value="Start" /> | ||
<Setter Property="VerticalTextAlignment" Value="Center" /> | ||
</Style> | ||
<Style x:Key="PopupLayout" TargetType="StackLayout"> | ||
<Setter Property="Padding" Value="{OnPlatform Android=20, UWP=20, iOS=5}" /> | ||
</Style> | ||
<Style x:Key="CancelButton" TargetType="Button"> | ||
<Setter Property="Background" Value="#FFF" /> | ||
<Setter Property="BorderWidth" Value="1" /> | ||
<Setter Property="BorderColor" Value="Blue" /> | ||
<Setter Property="TextColor" Value="Blue" /> | ||
</Style> | ||
<Style x:Key="ButtonGroup" TargetType="StackLayout"> | ||
<Setter Property="VerticalOptions" Value="EndAndExpand" /> | ||
<Setter Property="HorizontalOptions" Value="CenterAndExpand" /> | ||
<Setter Property="Spacing" Value="20" /> | ||
<Setter Property="Orientation" Value="Horizontal" /> | ||
</Style> | ||
</ResourceDictionary> | ||
</xct:Popup.Resources> | ||
|
||
<xct:Popup.View> | ||
<StackLayout Style="{StaticResource PopupLayout}"> | ||
<Label Style="{StaticResource Title}" | ||
Text="Button Popup" /> | ||
<BoxView Style="{StaticResource Divider}" /> | ||
<Label Style="{StaticResource Content}" | ||
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 Style="{StaticResource ButtonGroup}"> | ||
<Button Text="Cancel" | ||
Style="{StaticResource CancelButton}" | ||
Clicked="Cancel_Clicked" /> | ||
<Button Text="OKAY" | ||
Clicked="Okay_Clicked" /> | ||
</StackLayout> | ||
|
||
</StackLayout> | ||
</xct:Popup.View> | ||
|
||
</xct:Popup> |
11 changes: 11 additions & 0 deletions
11
...ityToolkit/Xamarin.CommunityToolkit.Sample/Pages/Views/Popups/MultipleButtonPopup.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Xamarin.CommunityToolkit.Sample.Pages.Views.Popups | ||
{ | ||
public partial class MultipleButtonPopup | ||
{ | ||
public MultipleButtonPopup() => InitializeComponent(); | ||
|
||
void Cancel_Clicked(object sender, System.EventArgs e) => Dismiss(false); | ||
|
||
void Okay_Clicked(object sender, System.EventArgs e) => Dismiss(true); | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
...munityToolkit/Xamarin.CommunityToolkit.Sample/Pages/Views/Popups/NoLightDismissPopup.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<xct:Popup xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.UI.Views;assembly=Xamarin.CommunityToolkit" | ||
Size="{OnPlatform Android='800, 700', UWP='300, 250', iOS='250, 400'}" | ||
IsLightDismissEnabled="False" | ||
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.NoLightDismissPopup"> | ||
|
||
<xct:Popup.Resources> | ||
<ResourceDictionary> | ||
<Style x:Key="Title" TargetType="Label"> | ||
<Setter Property="FontSize" Value="26" /> | ||
<Setter Property="FontAttributes" Value="Bold" /> | ||
<Setter Property="TextColor" Value="#000" /> | ||
<Setter Property="VerticalTextAlignment" Value="Center" /> | ||
<Setter Property="HorizontalTextAlignment" Value="Center" /> | ||
</Style> | ||
<Style x:Key="Divider" TargetType="BoxView"> | ||
<Setter Property="HeightRequest" Value="1" /> | ||
<Setter Property="Margin" Value="50, 25" /> | ||
<Setter Property="Color" Value="#c3c3c3" /> | ||
</Style> | ||
<Style x:Key="Content" TargetType="Label"> | ||
<Setter Property="HorizontalTextAlignment" Value="Start" /> | ||
<Setter Property="VerticalTextAlignment" Value="Center" /> | ||
</Style> | ||
<Style x:Key="PopupLayout" TargetType="StackLayout"> | ||
<Setter Property="Padding" Value="{OnPlatform Android=20, UWP=20, iOS=5}" /> | ||
</Style> | ||
</ResourceDictionary> | ||
</xct:Popup.Resources> | ||
|
||
<xct:Popup.View> | ||
<StackLayout Style="{StaticResource PopupLayout}"> | ||
<Label | ||
Style="{StaticResource Title}" | ||
Text="Simple Popup" /> | ||
<BoxView Style="{StaticResource Divider}" /> | ||
<Label | ||
Style="{StaticResource Content}" | ||
Text="{OnPlatform | ||
Android='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.', | ||
iOS='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.', | ||
UWP='UWP Flyouts do not support toggling light dismiss mode. On UWP this will always dismiss the flyout if you tap outside of the control'}" /> | ||
<Button | ||
Text="Close" | ||
VerticalOptions="EndAndExpand" | ||
Clicked="Button_Clicked" /> | ||
</StackLayout> | ||
</xct:Popup.View> | ||
|
||
</xct:Popup> |
9 changes: 9 additions & 0 deletions
9
...ityToolkit/Xamarin.CommunityToolkit.Sample/Pages/Views/Popups/NoLightDismissPopup.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Xamarin.CommunityToolkit.Sample.Pages.Views.Popups | ||
{ | ||
public partial class NoLightDismissPopup | ||
{ | ||
public NoLightDismissPopup() => InitializeComponent(); | ||
|
||
void Button_Clicked(object sender, System.EventArgs e) => Dismiss(null); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...ityToolkit/Xamarin.CommunityToolkit.Sample/Pages/Views/Popups/OpenedEventSimplePopup.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<xct:Popup xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:xct="clr-namespace:Xamarin.CommunityToolkit.UI.Views;assembly=Xamarin.CommunityToolkit" | ||
Size="{OnPlatform Android='800, 700', UWP='300, 250', iOS='250, 350'}" | ||
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.OpenedEventSimplePopup"> | ||
|
||
<xct:Popup.Resources> | ||
<ResourceDictionary> | ||
<Style x:Key="Title" TargetType="Label"> | ||
<Setter Property="FontSize" Value="26" /> | ||
<Setter Property="FontAttributes" Value="Bold" /> | ||
<Setter Property="TextColor" Value="#000" /> | ||
<Setter Property="VerticalTextAlignment" Value="Center" /> | ||
<Setter Property="HorizontalTextAlignment" Value="Center" /> | ||
</Style> | ||
<Style x:Key="Divider" TargetType="BoxView"> | ||
<Setter Property="HeightRequest" Value="1" /> | ||
<Setter Property="Margin" Value="50, 25" /> | ||
<Setter Property="Color" Value="#c3c3c3" /> | ||
</Style> | ||
<Style x:Key="Content" TargetType="Label"> | ||
<Setter Property="HorizontalTextAlignment" Value="Start" /> | ||
<Setter Property="VerticalTextAlignment" Value="Center" /> | ||
</Style> | ||
<Style x:Key="PopupLayout" TargetType="StackLayout"> | ||
<Setter Property="Padding" Value="{OnPlatform Android=20, UWP=20, iOS=5}" /> | ||
</Style> | ||
</ResourceDictionary> | ||
</xct:Popup.Resources> | ||
|
||
<xct:Popup.View> | ||
<StackLayout Style="{StaticResource PopupLayout}"> | ||
<Label x:Name="title" | ||
Style="{StaticResource Title}" /> | ||
<BoxView Style="{StaticResource Divider}" /> | ||
<Label x:Name="message" | ||
Style="{StaticResource Content}" /> | ||
</StackLayout> | ||
</xct:Popup.View> | ||
|
||
</xct:Popup> |
21 changes: 21 additions & 0 deletions
21
...Toolkit/Xamarin.CommunityToolkit.Sample/Pages/Views/Popups/OpenedEventSimplePopup.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Xamarin.CommunityToolkit.UI.Views; | ||
|
||
namespace Xamarin.CommunityToolkit.Sample.Pages.Views.Popups | ||
{ | ||
public partial class OpenedEventSimplePopup | ||
{ | ||
public OpenedEventSimplePopup() | ||
{ | ||
InitializeComponent(); | ||
Opened += OnOpened; | ||
} | ||
|
||
void OnOpened(object sender, PopupOpenedEventArgs e) | ||
{ | ||
Opened -= OnOpened; | ||
|
||
title.Text = "Opened Event Popup"; | ||
message.Text = "The content of this popup was updated after the popup was rendered"; | ||
} | ||
} | ||
} |
Oops, something went wrong.