-
Notifications
You must be signed in to change notification settings - Fork 477
Platform specific API #949
Changes from all commits
fe5d6f1
9625c34
66cb52d
f0bb778
09baeb4
e609190
612833a
7e8a737
dec4582
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,21 @@ | ||
<?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" | ||
xmlns:iosxct="clr-namespace:Xamarin.CommunityToolkit.UI.Views.iOSSpecific;assembly=Xamarin.CommunityToolkit" | ||
xmlns:uwpxct="clr-namespace:Xamarin.CommunityToolkit.UI.Views.WindowsSpecific;assembly=Xamarin.CommunityToolkit" | ||
Size="{x:Static local:PopupSize.Tiny}" | ||
Color="Transparent" | ||
iosxct:Popup.ArrowDirection="Up" | ||
uwpxct:Popup.BorderColor="Transparent" | ||
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.TransparentPopup"> | ||
<xct:Popup | ||
x:Class="Xamarin.CommunityToolkit.Sample.Pages.Views.Popups.TransparentPopup" | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:Xamarin.CommunityToolkit.Sample.Pages.Views.Popups" | ||
xmlns:xct="http://xamarin.com/schemas/2020/toolkit" | ||
Size="{x:Static local:PopupSize.Tiny}" | ||
Color="Transparent"> | ||
|
||
<Frame | ||
BackgroundColor="Red" | ||
CornerRadius="{OnPlatform Android='50', | ||
UWP='50', | ||
iOS='25'}" | ||
HeightRequest="{OnPlatform Android='100', | ||
UWP='50'}" | ||
WidthRequest="{OnPlatform Android='100', | ||
UWP='50'}" /> | ||
|
||
<Frame | ||
CornerRadius="{OnPlatform Android='50', UWP='50', iOS='25'}" | ||
HeightRequest="{OnPlatform Android='100', UWP='50'}" WidthRequest="{OnPlatform Android='100', UWP='50'}" | ||
BackgroundColor="Red" /> | ||
|
||
</xct:Popup> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
namespace Xamarin.CommunityToolkit.Sample.Pages.Views.Popups | ||
using Xamarin.Forms.PlatformConfiguration; | ||
using Xamarin.CommunityToolkit.PlatformConfiguration.iOSSpecific; | ||
using Xamarin.CommunityToolkit.PlatformConfiguration.WindowsSpecific; | ||
|
||
namespace Xamarin.CommunityToolkit.Sample.Pages.Views.Popups | ||
{ | ||
public partial class TransparentPopup | ||
{ | ||
public TransparentPopup() => InitializeComponent(); | ||
|
||
protected override void OnBindingContextChanged() | ||
{ | ||
base.OnBindingContextChanged(); | ||
On<iOS>().UseArrowDirection(PopoverArrowDirection.Right); | ||
On<Windows>().SetBorderColor(Xamarin.Forms.Color.Red); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Xamarin.CommunityToolkit.UI.Views; | ||
using Xamarin.Forms; | ||
using XFPC = Xamarin.Forms.PlatformConfiguration; | ||
using XCTElement = Xamarin.CommunityToolkit.UI.Views.BasePopup; | ||
|
||
namespace Xamarin.CommunityToolkit.PlatformConfiguration.WindowsSpecific | ||
{ | ||
public static class PopUp | ||
{ | ||
public static readonly BindableProperty BorderColorProperty = BindableProperty.Create( | ||
"BorderColor", typeof(Color), typeof(BasePopup), default(Color)); | ||
|
||
public static void SetBorderColor(BindableObject element, Color color) => | ||
element.SetValue(BorderColorProperty, color); | ||
|
||
public static Color GetBorderColor(BindableObject element) => | ||
(Color)element.GetValue(BorderColorProperty); | ||
|
||
public static IPlatformElementConfiguration<XFPC.Windows, XCTElement> SetBorderColor(this IPlatformElementConfiguration<XFPC.Windows, XCTElement> config, Color value) | ||
{ | ||
SetBorderColor(config.Element, value); | ||
return config; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Xamarin.CommunityToolkit.UI.Views; | ||
using Xamarin.Forms; | ||
using XFPC = Xamarin.Forms.PlatformConfiguration; | ||
using XCTElement = Xamarin.CommunityToolkit.UI.Views.BasePopup; | ||
|
||
namespace Xamarin.CommunityToolkit.PlatformConfiguration.iOSSpecific | ||
{ | ||
public static class PopUp | ||
{ | ||
public static readonly BindableProperty ArrowDirectionProperty = BindableProperty.Create( | ||
"ArrowDirection", typeof(PopoverArrowDirection), typeof(BasePopup), PopoverArrowDirection.None); | ||
|
||
public static void SetArrowDirection(BindableObject element, PopoverArrowDirection color) => | ||
element.SetValue(ArrowDirectionProperty, color); | ||
|
||
public static PopoverArrowDirection GetArrowDirection(BindableObject element) => | ||
(PopoverArrowDirection)element.GetValue(ArrowDirectionProperty); | ||
|
||
public static IPlatformElementConfiguration<XFPC.iOS, XCTElement> UseArrowDirection(this IPlatformElementConfiguration<XFPC.iOS, XCTElement> config, PopoverArrowDirection value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to use the |
||
{ | ||
SetArrowDirection(config.Element, value); | ||
return config; | ||
} | ||
} | ||
|
||
public enum PopoverArrowDirection | ||
{ | ||
None, | ||
Up, | ||
Down, | ||
Left, | ||
Right, | ||
Any, | ||
Unknown | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the use of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was added in #854 by @geskill and I approved the changes. I am not 100% sure what There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally unrelated, I think we can create an extension for this, right? I remember us doing it for something else, that will make this syntax better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of markup extension are you thinking? The
PopupSize
is a helper for the sample project to make it easier to specify size.Are you thinking about making this something that consumers of XCT could use for their Popups? That may be a really useful API.