maui-linux/Xamarin.Forms.Core/SwipeView.cs

124 строки
4.2 KiB
C#
Исходник Обычный вид История

SwipeView (#7603) * Implemented SwipeView Spec * Fixed close SwipeView when scrolling ScrollView in iOS * Removed unnecessary SwipeItemInvokedEventArgs * Separate ISwipeItem in a new file * Changed BaseSwipeEventArgs to be abstract * Changed SwipeView SwipeItems properties to use OneWay BindingMode * SwipeDirectionHelpers is now no EditorBrowsable * Removed unnecessary ContextItem * Changed SwipeItems base type from BO to Element * Added defaultValueCreator for SwipeItems (and new sample) * Changes in UWP SwipeViewRenderer to change some SwipeItems validations * Renamed CustomSwipeItem to SwipeItemView Added Close method Added new SwipeView sample in Core Gallery Propagate BindingContext from SwipeView to SwipeItems Fixed bug in Android where occasionally was not rendering the SwipeItem (BindableLayout) * Moved command execution from the renderers to the abstraction * Implemented Close method on UWP Fixed issue to notify SwipeItems changes (add/remove) on UWP Implemented Uri IconSource (fix SwipeItem using an Url on UWP) * Updated CustomSwipeItem samples * Fixed issue on Android (not rendering SwipeItem occasionally) * Avoid use MessagingCenter to close the SwipeView when scrolling * Added new Core Gallery sample using custom size SwipeItems Fixed icon position on Android with big SwipeItems Fixed custom SwipeItem size issue * Fixed vertical swipe threshold calc * Created ISwipeViewController Moved SwipeItemView to a new class Moved SwipeEventArgs to a new class Changes in touch events in Android to have the same behavior as in Android * Unsubscribe CollectionChanged from the OldElement on UWP renderer * Allow open the swipeView if the width of the SwipeItems exceeds the width of the SwipeView Fixed Android SwipeItem icon position calc issue * Updated SwipeItems to use ISwipeViewController * Fixed typo * Fixed typo * - remove EditorBrowsable * Changed SwipeTransitionMode enum values * - fix samsung fussiness * - fix compile error for UAP
2019-11-23 03:47:01 +03:00
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
SwipeView (#7603) * Implemented SwipeView Spec * Fixed close SwipeView when scrolling ScrollView in iOS * Removed unnecessary SwipeItemInvokedEventArgs * Separate ISwipeItem in a new file * Changed BaseSwipeEventArgs to be abstract * Changed SwipeView SwipeItems properties to use OneWay BindingMode * SwipeDirectionHelpers is now no EditorBrowsable * Removed unnecessary ContextItem * Changed SwipeItems base type from BO to Element * Added defaultValueCreator for SwipeItems (and new sample) * Changes in UWP SwipeViewRenderer to change some SwipeItems validations * Renamed CustomSwipeItem to SwipeItemView Added Close method Added new SwipeView sample in Core Gallery Propagate BindingContext from SwipeView to SwipeItems Fixed bug in Android where occasionally was not rendering the SwipeItem (BindableLayout) * Moved command execution from the renderers to the abstraction * Implemented Close method on UWP Fixed issue to notify SwipeItems changes (add/remove) on UWP Implemented Uri IconSource (fix SwipeItem using an Url on UWP) * Updated CustomSwipeItem samples * Fixed issue on Android (not rendering SwipeItem occasionally) * Avoid use MessagingCenter to close the SwipeView when scrolling * Added new Core Gallery sample using custom size SwipeItems Fixed icon position on Android with big SwipeItems Fixed custom SwipeItem size issue * Fixed vertical swipe threshold calc * Created ISwipeViewController Moved SwipeItemView to a new class Moved SwipeEventArgs to a new class Changes in touch events in Android to have the same behavior as in Android * Unsubscribe CollectionChanged from the OldElement on UWP renderer * Allow open the swipeView if the width of the SwipeItems exceeds the width of the SwipeView Fixed Android SwipeItem icon position calc issue * Updated SwipeItems to use ISwipeViewController * Fixed typo * Fixed typo * - remove EditorBrowsable * Changed SwipeTransitionMode enum values * - fix samsung fussiness * - fix compile error for UAP
2019-11-23 03:47:01 +03:00
using Xamarin.Forms.Platform;
namespace Xamarin.Forms
{
[ContentProperty("Content")]
[RenderWith(typeof(_SwipeViewRenderer))]
public class SwipeView : ContentView, IElementConfiguration<SwipeView>, ISwipeViewController
{
readonly Lazy<PlatformConfigurationRegistry<SwipeView>> _platformConfigurationRegistry;
public SwipeView()
{
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<SwipeView>>(() => new PlatformConfigurationRegistry<SwipeView>(this));
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static void VerifySwipeViewFlagEnabled(
string constructorHint = null,
[CallerMemberName] string memberName = "")
{
ExperimentalFlags.VerifyFlagEnabled(nameof(SwipeView), ExperimentalFlags.SwipeViewExperimental, memberName: memberName);
}
public static readonly BindableProperty LeftItemsProperty =
BindableProperty.Create(nameof(LeftItems), typeof(SwipeItems), typeof(SwipeView), null, BindingMode.OneWay, null, defaultValueCreator: SwipeItemsDefaultValueCreator,
propertyChanged: OnSwipeItemsChanged);
public static readonly BindableProperty RightItemsProperty =
BindableProperty.Create(nameof(RightItems), typeof(SwipeItems), typeof(SwipeView), null, BindingMode.OneWay, null, defaultValueCreator: SwipeItemsDefaultValueCreator);
public static readonly BindableProperty TopItemsProperty =
BindableProperty.Create(nameof(TopItems), typeof(SwipeItems), typeof(SwipeView), null, BindingMode.OneWay, null, defaultValueCreator: SwipeItemsDefaultValueCreator);
public static readonly BindableProperty BottomItemsProperty =
BindableProperty.Create(nameof(BottomItems), typeof(SwipeItems), typeof(SwipeView), null, BindingMode.OneWay, null, defaultValueCreator: SwipeItemsDefaultValueCreator);
SwipeView (#7603) * Implemented SwipeView Spec * Fixed close SwipeView when scrolling ScrollView in iOS * Removed unnecessary SwipeItemInvokedEventArgs * Separate ISwipeItem in a new file * Changed BaseSwipeEventArgs to be abstract * Changed SwipeView SwipeItems properties to use OneWay BindingMode * SwipeDirectionHelpers is now no EditorBrowsable * Removed unnecessary ContextItem * Changed SwipeItems base type from BO to Element * Added defaultValueCreator for SwipeItems (and new sample) * Changes in UWP SwipeViewRenderer to change some SwipeItems validations * Renamed CustomSwipeItem to SwipeItemView Added Close method Added new SwipeView sample in Core Gallery Propagate BindingContext from SwipeView to SwipeItems Fixed bug in Android where occasionally was not rendering the SwipeItem (BindableLayout) * Moved command execution from the renderers to the abstraction * Implemented Close method on UWP Fixed issue to notify SwipeItems changes (add/remove) on UWP Implemented Uri IconSource (fix SwipeItem using an Url on UWP) * Updated CustomSwipeItem samples * Fixed issue on Android (not rendering SwipeItem occasionally) * Avoid use MessagingCenter to close the SwipeView when scrolling * Added new Core Gallery sample using custom size SwipeItems Fixed icon position on Android with big SwipeItems Fixed custom SwipeItem size issue * Fixed vertical swipe threshold calc * Created ISwipeViewController Moved SwipeItemView to a new class Moved SwipeEventArgs to a new class Changes in touch events in Android to have the same behavior as in Android * Unsubscribe CollectionChanged from the OldElement on UWP renderer * Allow open the swipeView if the width of the SwipeItems exceeds the width of the SwipeView Fixed Android SwipeItem icon position calc issue * Updated SwipeItems to use ISwipeViewController * Fixed typo * Fixed typo * - remove EditorBrowsable * Changed SwipeTransitionMode enum values * - fix samsung fussiness * - fix compile error for UAP
2019-11-23 03:47:01 +03:00
public SwipeItems LeftItems
{
get { return (SwipeItems)GetValue(LeftItemsProperty); }
set { SetValue(LeftItemsProperty, value); }
}
public SwipeItems RightItems
{
get { return (SwipeItems)GetValue(RightItemsProperty); }
set { SetValue(RightItemsProperty, value); }
}
public SwipeItems TopItems
{
get { return (SwipeItems)GetValue(TopItemsProperty); }
set { SetValue(TopItemsProperty, value); }
}
public SwipeItems BottomItems
{
get { return (SwipeItems)GetValue(BottomItemsProperty); }
set { SetValue(BottomItemsProperty, value); }
}
static void OnSwipeItemsChanged(BindableObject bindable, object oldValue, object newValue)
{
((SwipeView)bindable).UpdateSwipeItemsParent((SwipeItems)newValue);
}
SwipeView (#7603) * Implemented SwipeView Spec * Fixed close SwipeView when scrolling ScrollView in iOS * Removed unnecessary SwipeItemInvokedEventArgs * Separate ISwipeItem in a new file * Changed BaseSwipeEventArgs to be abstract * Changed SwipeView SwipeItems properties to use OneWay BindingMode * SwipeDirectionHelpers is now no EditorBrowsable * Removed unnecessary ContextItem * Changed SwipeItems base type from BO to Element * Added defaultValueCreator for SwipeItems (and new sample) * Changes in UWP SwipeViewRenderer to change some SwipeItems validations * Renamed CustomSwipeItem to SwipeItemView Added Close method Added new SwipeView sample in Core Gallery Propagate BindingContext from SwipeView to SwipeItems Fixed bug in Android where occasionally was not rendering the SwipeItem (BindableLayout) * Moved command execution from the renderers to the abstraction * Implemented Close method on UWP Fixed issue to notify SwipeItems changes (add/remove) on UWP Implemented Uri IconSource (fix SwipeItem using an Url on UWP) * Updated CustomSwipeItem samples * Fixed issue on Android (not rendering SwipeItem occasionally) * Avoid use MessagingCenter to close the SwipeView when scrolling * Added new Core Gallery sample using custom size SwipeItems Fixed icon position on Android with big SwipeItems Fixed custom SwipeItem size issue * Fixed vertical swipe threshold calc * Created ISwipeViewController Moved SwipeItemView to a new class Moved SwipeEventArgs to a new class Changes in touch events in Android to have the same behavior as in Android * Unsubscribe CollectionChanged from the OldElement on UWP renderer * Allow open the swipeView if the width of the SwipeItems exceeds the width of the SwipeView Fixed Android SwipeItem icon position calc issue * Updated SwipeItems to use ISwipeViewController * Fixed typo * Fixed typo * - remove EditorBrowsable * Changed SwipeTransitionMode enum values * - fix samsung fussiness * - fix compile error for UAP
2019-11-23 03:47:01 +03:00
public event EventHandler<SwipeStartedEventArgs> SwipeStarted;
public event EventHandler<SwipeChangingEventArgs> SwipeChanging;
public event EventHandler<SwipeEndedEventArgs> SwipeEnded;
public event EventHandler CloseRequested;
public void Close()
{
CloseRequested?.Invoke(this, EventArgs.Empty);
}
void ISwipeViewController.SendSwipeStarted(SwipeStartedEventArgs args) => SwipeStarted?.Invoke(this, args);
void ISwipeViewController.SendSwipeChanging(SwipeChangingEventArgs args) => SwipeChanging?.Invoke(this, args);
void ISwipeViewController.SendSwipeEnded(SwipeEndedEventArgs args) => SwipeEnded?.Invoke(this, args);
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
object bc = BindingContext;
if (LeftItems != null)
SetInheritedBindingContext(LeftItems, bc);
if (RightItems != null)
SetInheritedBindingContext(RightItems, bc);
if (TopItems != null)
SetInheritedBindingContext(TopItems, bc);
if (BottomItems != null)
SetInheritedBindingContext(BottomItems, bc);
}
SwipeItems SwipeItemsDefaultValueCreator() => new SwipeItems();
static object SwipeItemsDefaultValueCreator(BindableObject bindable)
{
return ((SwipeView)bindable).SwipeItemsDefaultValueCreator();
}
public IPlatformElementConfiguration<T, SwipeView> On<T>() where T : IConfigPlatform
{
return _platformConfigurationRegistry.Value.On<T>();
}
void UpdateSwipeItemsParent(SwipeItems swipeItems)
{
swipeItems.Parent = this;
foreach (var swipeItem in swipeItems)
((VisualElement)swipeItem).Parent = swipeItems;
}
SwipeView (#7603) * Implemented SwipeView Spec * Fixed close SwipeView when scrolling ScrollView in iOS * Removed unnecessary SwipeItemInvokedEventArgs * Separate ISwipeItem in a new file * Changed BaseSwipeEventArgs to be abstract * Changed SwipeView SwipeItems properties to use OneWay BindingMode * SwipeDirectionHelpers is now no EditorBrowsable * Removed unnecessary ContextItem * Changed SwipeItems base type from BO to Element * Added defaultValueCreator for SwipeItems (and new sample) * Changes in UWP SwipeViewRenderer to change some SwipeItems validations * Renamed CustomSwipeItem to SwipeItemView Added Close method Added new SwipeView sample in Core Gallery Propagate BindingContext from SwipeView to SwipeItems Fixed bug in Android where occasionally was not rendering the SwipeItem (BindableLayout) * Moved command execution from the renderers to the abstraction * Implemented Close method on UWP Fixed issue to notify SwipeItems changes (add/remove) on UWP Implemented Uri IconSource (fix SwipeItem using an Url on UWP) * Updated CustomSwipeItem samples * Fixed issue on Android (not rendering SwipeItem occasionally) * Avoid use MessagingCenter to close the SwipeView when scrolling * Added new Core Gallery sample using custom size SwipeItems Fixed icon position on Android with big SwipeItems Fixed custom SwipeItem size issue * Fixed vertical swipe threshold calc * Created ISwipeViewController Moved SwipeItemView to a new class Moved SwipeEventArgs to a new class Changes in touch events in Android to have the same behavior as in Android * Unsubscribe CollectionChanged from the OldElement on UWP renderer * Allow open the swipeView if the width of the SwipeItems exceeds the width of the SwipeView Fixed Android SwipeItem icon position calc issue * Updated SwipeItems to use ISwipeViewController * Fixed typo * Fixed typo * - remove EditorBrowsable * Changed SwipeTransitionMode enum values * - fix samsung fussiness * - fix compile error for UAP
2019-11-23 03:47:01 +03:00
}
}