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

Adds Popup Control #653

Merged
merged 46 commits into from
Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
13c2236
Ported Popup Control from Xamarin/Xamarin.Forms#9616 to Xamarin Commu…
SkyeHoefling Dec 4, 2020
829c879
Added missing async/await api
SkyeHoefling Dec 4, 2020
0fdc875
Added popup result sample and fixed uwp/android implementations
SkyeHoefling Dec 4, 2020
5723236
Renamed View->Content
SkyeHoefling Dec 4, 2020
8b14da1
Updated styles of sample popups
SkyeHoefling Dec 4, 2020
80f9ddb
Updated BorderColor to be a platform specific property for UWP
SkyeHoefling Dec 12, 2020
e313d69
Moved Android/iOS/UWP renderers to platform specific folders
SkyeHoefling Dec 12, 2020
9cac54c
Changed PopupDismissedEventArgs so it is immutable
SkyeHoefling Dec 12, 2020
fa2a061
Removed visual studio edits to sample android project
SkyeHoefling Dec 12, 2020
0eb052d
Removed = false for isDisposed as it is default
SkyeHoefling Dec 12, 2020
c3c5ad5
Normalized accessor properties for ios and uwp
SkyeHoefling Dec 12, 2020
b1a0a48
Removed performance apis since they are used internally at Xamarin.Forms
SkyeHoefling Dec 12, 2020
70e0a45
Simplified OnElementChanged to use shared method ConfigureControl
SkyeHoefling Dec 12, 2020
816066b
Removed iOS 9 code
SkyeHoefling Dec 12, 2020
44a4a92
Updated NavigationExtensions to follow Xamarin Essentials style by ad…
SkyeHoefling Dec 13, 2020
2191e02
Added Control.Cleanup invocation to dispose method
SkyeHoefling Dec 13, 2020
1a3a54d
[iOS] Removed async/await from OnDismissed since it is an event the i…
SkyeHoefling Dec 13, 2020
9901f23
Fixed comment
SkyeHoefling Dec 13, 2020
4ff12e5
Updated iOS to use WeakEventManager
SkyeHoefling Dec 13, 2020
53c06cc
changed instantiation to use default(SizeRequest)
SkyeHoefling Dec 13, 2020
b4b98a6
ios - Changed WeakEventManager so it is a protected static object on …
SkyeHoefling Dec 19, 2020
7b6c7b9
Moved sample popup code to new location
SkyeHoefling Dec 19, 2020
0aacaed
Added WeakEventManager for BasePopup events (Opened, Dismissed)
SkyeHoefling Dec 20, 2020
6ab80aa
ios - changed popover delegate to use action
SkyeHoefling Dec 20, 2020
952bdcf
Added PopOverDelegate.PopoverDismissed
TheCodeTraveler Dec 21, 2020
4286438
Updated accessor for LightDismiss to protected internal
SkyeHoefling Jan 9, 2021
c4453e3
Updated comment in LightDismiss
SkyeHoefling Jan 9, 2021
f4594be
Removed stale iOS code
SkyeHoefling Jan 9, 2021
e127ecf
Updated xml comments
SkyeHoefling Jan 9, 2021
ccc89bc
Removed obj dir from compilation in 'netstandard' projects and fixed …
SkyeHoefling Jan 10, 2021
76f01b2
removed Init method and added code to get the Context
pictos Jan 10, 2021
812332c
changed accessor of ToolkitPlatform to internal
SkyeHoefling Jan 10, 2021
2b1c7ed
Added new UI popup tests for Xaml binding vs C# binding
SkyeHoefling Jan 16, 2021
2646554
Updated XCT xmlns to use uri instead of fully qualified namespace
SkyeHoefling Jan 16, 2021
034c9f1
Added shared popup size across samples
SkyeHoefling Jan 16, 2021
ffdaf7d
Fixed popup BindingContext not working when set in XAML
SkyeHoefling Jan 17, 2021
cf1f280
Update Samples
TheCodeTraveler Jan 29, 2021
7fa6433
Add PopupDismissedEventArgs<T>
TheCodeTraveler Jan 29, 2021
dc5ea88
Add Default Values for Color and Size
TheCodeTraveler Jan 29, 2021
659f2af
Remove Unncessary `base` Keyword, per styling guide
TheCodeTraveler Jan 29, 2021
0fbc08e
Optimize originX + originX, Add missing `await`
TheCodeTraveler Jan 29, 2021
0c7febb
Update PopupAnchorViewModel.cs
TheCodeTraveler Jan 29, 2021
75d5db5
Fix orignY
TheCodeTraveler Jan 29, 2021
aa11cfa
Update PopupRenderer.ios.cs
TheCodeTraveler Jan 29, 2021
8c1dd73
Update NavigationExtensions.netstandard.macos.tvos.watchos.tizen.wpf.…
TheCodeTraveler Jan 31, 2021
9f9cd88
Added NavigableElementExtension - This allows rendering popup from Co…
SkyeHoefling Feb 1, 2021
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
5 changes: 2 additions & 3 deletions samples/XCT.Sample.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Android.Content.PM;
using Android.OS;
using Android.Runtime;
using Xamarin.Essentials;

namespace Xamarin.CommunityToolkit.Sample.Droid
{
Expand All @@ -17,14 +16,14 @@ protected override void OnCreate(Bundle savedInstanceState)
base.OnCreate(savedInstanceState);

global::Xamarin.Forms.Forms.SetFlags("CollectionView_Experimental");
Platform.Init(this, savedInstanceState);
Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
}

public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
{
Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
Expand Down
66 changes: 66 additions & 0 deletions samples/XCT.Sample/Pages/Views/PopupGalleryPage.xaml
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:PopupGalleryViewModel />
</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 samples/XCT.Sample/Pages/Views/PopupGalleryPage.xaml.cs
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();
}
}
56 changes: 56 additions & 0 deletions samples/XCT.Sample/Pages/Views/Popups/ButtonPopup.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?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="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
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">
<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>

<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>
9 changes: 9 additions & 0 deletions samples/XCT.Sample/Pages/Views/Popups/ButtonPopup.xaml.cs
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);
}
}
50 changes: 50 additions & 0 deletions samples/XCT.Sample/Pages/Views/Popups/CsharpBindingPopup.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
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">
<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>

<StackLayout Style="{StaticResource PopupLayout}">
<Label Style="{StaticResource Title}"
Text="{Binding Title}" />
<BoxView Style="{StaticResource Divider}" />
<Label Style="{StaticResource Content}"
Text="{Binding Message}" />
</StackLayout>

</xct:Popup>
13 changes: 13 additions & 0 deletions samples/XCT.Sample/Pages/Views/Popups/CsharpBindingPopup.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Xamarin.CommunityToolkit.Sample.ViewModels.Views.Popups;

namespace Xamarin.CommunityToolkit.Sample.Pages.Views.Popups
{
public partial class CsharpBindingPopup
{
public CsharpBindingPopup()
{
InitializeComponent();
BindingContext = new CsharpBindingPopupViewModel();
}
}
}
70 changes: 70 additions & 0 deletions samples/XCT.Sample/Pages/Views/Popups/MultipleButtonPopup.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
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">
<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>

<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>
11 changes: 11 additions & 0 deletions samples/XCT.Sample/Pages/Views/Popups/MultipleButtonPopup.xaml.cs
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);
}
}
60 changes: 60 additions & 0 deletions samples/XCT.Sample/Pages/Views/Popups/NoLightDismissPopup.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?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="http://xamarin.com/schemas/2020/toolkit"
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups"
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">
<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>

<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>
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);
}
}
Loading