+++ /dev/null
-using System;
-
-namespace Xamarin.Forms
-{
- public interface IMasterDetailPageController
- {
- bool CanChangeIsPresented { get; set; }
-
- Rectangle DetailBounds { get; set; }
-
- Rectangle MasterBounds { get; set; }
-
- bool ShouldShowSplitMode { get; }
-
- void UpdateMasterBehavior();
-
- event EventHandler<BackButtonPressedEventArgs> BackButtonPressed;
- }
-}
\ No newline at end of file
[EditorBrowsable(EditorBrowsableState.Never)]
public class ToolbarTracker
{
- int _masterDetails;
Page _target;
public IEnumerable<Page> AdditionalTargets { get; set; }
- public bool HaveMasterDetail
- {
- get { return _masterDetails > 0; }
- }
-
- public bool SeparateMasterDetail { get; set; }
-
public Page Target
{
get { return _target; }
var result = new List<ToolbarItem>();
result.AddRange(page.ToolbarItems);
- if (page is MasterDetailPage)
- {
- var masterDetail = (MasterDetailPage)page;
- if (SeparateMasterDetail)
- {
- if (masterDetail.IsPresented)
- {
- if (masterDetail.Master != null)
- result.AddRange(GetCurrentToolbarItems(masterDetail.Master));
- }
- else
- {
- if (masterDetail.Detail != null)
- result.AddRange(GetCurrentToolbarItems(masterDetail.Detail));
- }
- }
- else
- {
- if (masterDetail.Master != null)
- result.AddRange(GetCurrentToolbarItems(masterDetail.Master));
- if (masterDetail.Detail != null)
- result.AddRange(GetCurrentToolbarItems(masterDetail.Detail));
- }
- }
- else if (page is IPageContainer<Page>)
+ if (page is IPageContainer<Page>)
{
var container = (IPageContainer<Page>)page;
if (container.CurrentPage != null)
void OnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs)
{
- if (propertyChangedEventArgs.PropertyName == NavigationPage.CurrentPageProperty.PropertyName || propertyChangedEventArgs.PropertyName == MasterDetailPage.IsPresentedProperty.PropertyName ||
- propertyChangedEventArgs.PropertyName == "Detail" || propertyChangedEventArgs.PropertyName == "Master")
+ if (propertyChangedEventArgs.PropertyName == NavigationPage.CurrentPageProperty.PropertyName)
{
EmitCollectionChanged();
}
void RegisterChildPage(Page page)
{
- if (page is MasterDetailPage)
- _masterDetails++;
-
((ObservableCollection<ToolbarItem>)page.ToolbarItems).CollectionChanged += OnCollectionChanged;
page.PropertyChanged += OnPropertyChanged;
}
if (page == null)
return;
- if (page is MasterDetailPage)
- _masterDetails++;
-
((ObservableCollection<ToolbarItem>)page.ToolbarItems).CollectionChanged += OnCollectionChanged;
page.Descendants().OfType<Page>().ForEach(RegisterChildPage);
void UnregisterChildPage(Page page)
{
- if (page is MasterDetailPage)
- _masterDetails--;
-
((ObservableCollection<ToolbarItem>)page.ToolbarItems).CollectionChanged -= OnCollectionChanged;
page.PropertyChanged -= OnPropertyChanged;
}
if (page == null)
return;
- if (page is MasterDetailPage)
- _masterDetails--;
-
((ObservableCollection<ToolbarItem>)page.ToolbarItems).CollectionChanged -= OnCollectionChanged;
page.Descendants().OfType<Page>().ForEach(UnregisterChildPage);
+++ /dev/null
-namespace Xamarin.Forms
-{
- public enum MasterBehavior
- {
- Default = 0,
- SplitOnLandscape = 1,
- Split = 2,
- Popover = 3,
- SplitOnPortrait = 4
- }
-}
\ No newline at end of file
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using Xamarin.Forms.Internals;
-using Xamarin.Forms.Platform;
-
-namespace Xamarin.Forms
-{
- [RenderWith(typeof(_MasterDetailPageRenderer))]
- public class MasterDetailPage : Page, IMasterDetailPageController, IElementConfiguration<MasterDetailPage>
- {
- public static readonly BindableProperty IsGestureEnabledProperty = BindableProperty.Create("IsGestureEnabled", typeof(bool), typeof(MasterDetailPage), true);
-
- public static readonly BindableProperty IsPresentedProperty = BindableProperty.Create("IsPresented", typeof(bool), typeof(MasterDetailPage),default(bool),
- propertyChanged: OnIsPresentedPropertyChanged, propertyChanging: OnIsPresentedPropertyChanging, defaultValueCreator : GetDefaultValue);
-
- public static readonly BindableProperty MasterBehaviorProperty = BindableProperty.Create("MasterBehavior", typeof(MasterBehavior), typeof(MasterDetailPage), default(MasterBehavior),
- propertyChanged: OnMasterBehaviorPropertyChanged);
-
- Page _detail;
-
- Rectangle _detailBounds;
-
- Page _master;
-
- Rectangle _masterBounds;
-
- public Page Detail
- {
- get { return _detail; }
- set
- {
- if (_detail != null && value == null)
- throw new ArgumentNullException("value", "Detail cannot be set to null once a value is set.");
-
- if (_detail == value)
- return;
-
- if (value.RealParent != null)
- throw new InvalidOperationException("Detail must not already have a parent.");
-
- OnPropertyChanging();
- if (_detail != null)
- InternalChildren.Remove(_detail);
- _detail = value;
- InternalChildren.Add(_detail);
- OnPropertyChanged();
- }
- }
-
- public bool IsGestureEnabled
- {
- get { return (bool)GetValue(IsGestureEnabledProperty); }
- set { SetValue(IsGestureEnabledProperty, value); }
- }
-
- public bool IsPresented
- {
- get { return (bool)GetValue(IsPresentedProperty); }
- set { SetValue(IsPresentedProperty, value); }
- }
-
- public Page Master
- {
- get { return _master; }
- set
- {
- if (_master != null && value == null)
- throw new ArgumentNullException("value", "Master cannot be set to null once a value is set");
-
- if (string.IsNullOrEmpty(value.Title))
- throw new InvalidOperationException("Title property must be set on Master page");
-
- if (_master == value)
- return;
-
- if (value.RealParent != null)
- throw new InvalidOperationException("Master must not already have a parent.");
-
- OnPropertyChanging();
- if (_master != null)
- InternalChildren.Remove(_master);
- _master = value;
- InternalChildren.Add(_master);
- OnPropertyChanged();
- }
- }
-
- public MasterBehavior MasterBehavior
- {
- get { return (MasterBehavior)GetValue(MasterBehaviorProperty); }
- set { SetValue(MasterBehaviorProperty, value); }
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool CanChangeIsPresented { get; set; } = true;
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Rectangle DetailBounds
- {
- get { return _detailBounds; }
- set
- {
- _detailBounds = value;
- if (_detail == null)
- throw new InvalidOperationException("Detail must be set before using a MasterDetailPage");
- _detail.Layout(value);
- }
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Rectangle MasterBounds
- {
- get { return _masterBounds; }
- set
- {
- _masterBounds = value;
- if (_master == null)
- throw new InvalidOperationException("Master must be set before using a MasterDetailPage");
- _master.Layout(value);
- }
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool ShouldShowSplitMode
- {
- get
- {
- if (Device.Idiom == TargetIdiom.Phone)
- return false;
-
- MasterBehavior behavior = MasterBehavior;
- DeviceOrientation orientation = Device.Info.CurrentOrientation;
-
- bool isSplitOnLandscape = (behavior == MasterBehavior.SplitOnLandscape || behavior == MasterBehavior.Default) && orientation.IsLandscape();
- bool isSplitOnPortrait = behavior == MasterBehavior.SplitOnPortrait && orientation.IsPortrait();
- return behavior == MasterBehavior.Split || isSplitOnLandscape || isSplitOnPortrait;
- }
- }
-
- public event EventHandler IsPresentedChanged;
-
- public virtual bool ShouldShowToolbarButton()
- {
- if (Device.Idiom == TargetIdiom.Phone)
- return true;
-
- MasterBehavior behavior = MasterBehavior;
- DeviceOrientation orientation = Device.Info.CurrentOrientation;
-
- bool isSplitOnLandscape = (behavior == MasterBehavior.SplitOnLandscape || behavior == MasterBehavior.Default) && orientation.IsLandscape();
- bool isSplitOnPortrait = behavior == MasterBehavior.SplitOnPortrait && orientation.IsPortrait();
- return behavior != MasterBehavior.Split && !isSplitOnLandscape && !isSplitOnPortrait;
- }
-
- protected override void LayoutChildren(double x, double y, double width, double height)
- {
- if (Master == null || Detail == null)
- throw new InvalidOperationException("Master and Detail must be set before using a MasterDetailPage");
- _master.Layout(_masterBounds);
- _detail.Layout(_detailBounds);
- }
-
- protected override void OnAppearing()
- {
- CanChangeIsPresented = true;
- UpdateMasterBehavior(this);
- base.OnAppearing();
- }
-
- protected override bool OnBackButtonPressed()
- {
- if (IsPresented)
- {
- if (Master.SendBackButtonPressed())
- return true;
- }
-
- EventHandler<BackButtonPressedEventArgs> handler = BackButtonPressed;
- if (handler != null)
- {
- var args = new BackButtonPressedEventArgs();
- handler(this, args);
- if (args.Handled)
- return true;
- }
-
- if (Detail.SendBackButtonPressed())
- {
- return true;
- }
-
- return base.OnBackButtonPressed();
- }
-
- protected override void OnParentSet()
- {
- if (RealParent != null && (Master == null || Detail == null))
- throw new InvalidOperationException("Master and Detail must be set before adding MasterDetailPage to a container");
- base.OnParentSet();
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public event EventHandler<BackButtonPressedEventArgs> BackButtonPressed;
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void UpdateMasterBehavior()
- {
- UpdateMasterBehavior(this);
- }
-
- internal static void UpdateMasterBehavior(MasterDetailPage page)
- {
- if (page.ShouldShowSplitMode)
- {
- page.SetValueCore(IsPresentedProperty, true);
- if (page.MasterBehavior != MasterBehavior.Default)
- page.CanChangeIsPresented = false;
- }
- }
-
- static void OnIsPresentedPropertyChanged(BindableObject sender, object oldValue, object newValue)
- => ((MasterDetailPage)sender).IsPresentedChanged?.Invoke(sender, EventArgs.Empty);
-
- static void OnIsPresentedPropertyChanging(BindableObject sender, object oldValue, object newValue)
- {
- var page = (MasterDetailPage)sender;
- if (!page.CanChangeIsPresented)
- throw new InvalidOperationException(string.Format("Can't change IsPresented when setting {0}", page.MasterBehavior));
- }
-
- static void OnMasterBehaviorPropertyChanged(BindableObject sender, object oldValue, object newValue)
- {
- var page = (MasterDetailPage)sender;
- UpdateMasterBehavior(page);
- }
-
- static object GetDefaultValue(BindableObject bindable)
- {
- return Device.RuntimePlatform == Device.macOS;
- }
-
- public MasterDetailPage()
- {
- _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<MasterDetailPage>>(() => new PlatformConfigurationRegistry<MasterDetailPage>(this));
- }
-
- readonly Lazy<PlatformConfigurationRegistry<MasterDetailPage>> _platformConfigurationRegistry;
-
- public new IPlatformElementConfiguration<T, MasterDetailPage> On<T>() where T : IConfigPlatform
- {
- return _platformConfigurationRegistry.Value.On<T>();
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-using System;
-using ElmSharp;
-using Xamarin.Forms.Internals;
-
-namespace Xamarin.Forms.Platform.Tizen.Native
-{
- /// <summary>
- /// The native widget which provides Xamarin.MasterDetailPage features.
- /// </summary>
- public class MasterDetailPage : Box
- {
- /// <summary>
- /// The default master behavior (a.k.a mode).
- /// </summary>
- static readonly MasterBehavior s_defaultMasterBehavior = (Device.Idiom == TargetIdiom.Phone || Device.Idiom == TargetIdiom.Watch) ? MasterBehavior.Popover : MasterBehavior.SplitOnLandscape;
-
- /// <summary>
- /// The MasterPage native container.
- /// </summary>
- readonly Canvas _masterCanvas;
-
- /// <summary>
- /// The DetailPage native container.
- /// </summary>
- readonly Canvas _detailCanvas;
-
- /// <summary>
- /// The container for <c>_masterCanvas</c> and <c>_detailCanvas</c> used in split mode.
- /// </summary>
- readonly Panes _splitPane;
-
- /// <summary>
- /// The container for <c>_masterCanvas</c> used in popover mode.
- /// </summary>
- readonly Panel _drawer;
-
- /// <summary>
- /// The <see cref="MasterBehavior"/> property value.
- /// </summary>
- MasterBehavior _masterBehavior = s_defaultMasterBehavior;
-
- /// <summary>
- /// The actual MasterDetailPage mode - either split or popover. It depends on <c>_masterBehavior</c> and screen orientation.
- /// </summary>
- MasterBehavior _internalMasterBehavior = MasterBehavior.Popover;
-
- /// <summary>
- /// The <see cref="Master"/> property value.
- /// </summary>
- EvasObject _master;
-
- /// <summary>
- /// The <see cref="Detail"/> property value.
- /// </summary>
- EvasObject _detail;
-
- /// <summary>
- /// The main widget - either <see cref="_splitPlane"/> or <see cref="_detailPage"/>, depending on the mode.
- /// </summary>
- EvasObject _mainWidget;
-
- /// <summary>
- /// The <see cref="IsGestureEnabled"/> property value.
- /// </summary>
- bool _isGestureEnabled = true;
-
- /// <summary>
- /// The portion of the screen that the MasterPage takes in Split mode.
- /// </summary>
- double _splitRatio = 0.35;
-
- /// <summary>
- /// The portion of the screen that the MasterPage takes in Popover mode.
- /// </summary>
- double _popoverRatio = 0.8;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="Xamarin.Forms.Platform.Tizen.Native.MasterDetailPage"/> class.
- /// </summary>
- /// <param name="parent">Parent evas object.</param>
- public MasterDetailPage(EvasObject parent) : base(parent)
- {
- LayoutUpdated += (s, e) =>
- {
- UpdateChildCanvasGeometry();
- };
-
- // create the controls which will hold the master and detail pages
- _masterCanvas = new Canvas(this);
- _masterCanvas.SetAlignment(-1.0, -1.0); // fill
- _masterCanvas.SetWeight(1.0, 1.0); // expand
- _masterCanvas.LayoutUpdated += (sender, e) =>
- {
- UpdatePageGeometry(_master);
- };
-
- _detailCanvas = new Canvas(this);
- _detailCanvas.SetAlignment(-1.0, -1.0); // fill
- _detailCanvas.SetWeight(1.0, 1.0); // expand
- _detailCanvas.LayoutUpdated += (sender, e) =>
- {
- UpdatePageGeometry(_detail);
- };
-
- _splitPane = new Panes(this)
- {
- AlignmentX = -1,
- AlignmentY = -1,
- WeightX = 1,
- WeightY = 1,
- IsFixed = true,
- IsHorizontal = false,
- Proportion = _splitRatio,
- };
-
- _drawer = new Panel(Forms.NativeParent);
- _drawer.SetScrollable(_isGestureEnabled);
- _drawer.SetScrollableArea(1.0);
- _drawer.Direction = PanelDirection.Left;
- _drawer.Toggled += (object sender, EventArgs e) =>
- {
- UpdateFocusPolicy();
- IsPresentedChanged?.Invoke(this, new IsPresentedChangedEventArgs(_drawer.IsOpen));
- };
-
- ConfigureLayout();
-
- // in case of the screen rotation we may need to update the choice between split
- // and popover behaviors and reconfigure the layout
- Device.Info.PropertyChanged += (s, e) =>
- {
- if (e.PropertyName == nameof(Device.Info.CurrentOrientation))
- {
- UpdateMasterBehavior();
- }
- };
- }
-
- /// <summary>
- /// Occurs when the MasterPage is shown or hidden.
- /// </summary>
- public event EventHandler<IsPresentedChangedEventArgs> IsPresentedChanged;
-
- /// <summary>
- /// Occurs when the IsPresentChangeable was changed.
- /// </summary>
- public event EventHandler<UpdateIsPresentChangeableEventArgs> UpdateIsPresentChangeable;
-
- /// <summary>
- /// Gets or sets the MasterDetailPage behavior.
- /// </summary>
- /// <value>The behavior of the <c>MasterDetailPage</c> requested by the user.</value>
- public MasterBehavior MasterBehavior
- {
- get
- {
- return _masterBehavior;
- }
-
- set
- {
- _masterBehavior = value;
- UpdateMasterBehavior();
- }
- }
-
- /// <summary>
- /// Gets the MasterDEtailPage was splited
- /// </summary>
- public bool IsSplit => _internalMasterBehavior == MasterBehavior.Split;
-
- /// <summary>
- /// Gets or sets the content of the MasterPage.
- /// </summary>
- /// <value>The MasterPage.</value>
- public EvasObject Master
- {
- get
- {
- return _master;
- }
-
- set
- {
- if (_master != value)
- {
- _master = value;
- UpdatePageGeometry(_master);
- _masterCanvas.Children.Clear();
- _masterCanvas.Children.Add(_master);
- if (!IsSplit)
- UpdateFocusPolicy();
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the content of the DetailPage.
- /// </summary>
- /// <value>The DetailPage.</value>
- public EvasObject Detail
- {
- get
- {
- return _detail;
- }
-
- set
- {
- if (_detail != value)
- {
- _detail = value;
- UpdatePageGeometry(_detail);
- _detailCanvas.Children.Clear();
- _detailCanvas.Children.Add(_detail);
- if (!IsSplit)
- UpdateFocusPolicy();
- }
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether the MasterPage is shown.
- /// </summary>
- /// <value><c>true</c> if the MasterPage is presented.</value>
- public bool IsPresented
- {
- get
- {
- return _drawer.IsOpen;
- }
-
- set
- {
- if (_drawer.IsOpen != value)
- {
- _drawer.IsOpen = value;
- }
- }
- }
-
- /// <summary>
- /// Gets or sets a value indicating whether a MasterDetailPage allows showing MasterPage with swipe gesture.
- /// </summary>
- /// <value><c>true</c> if the MasterPage can be revealed with a gesture.</value>
- public bool IsGestureEnabled
- {
- get
- {
- return _isGestureEnabled;
- }
-
- set
- {
- if (_isGestureEnabled != value)
- {
- _isGestureEnabled = value;
- // Fixme
- // Elementary panel was not support to change scrollable property on runtime
- // Please uncomment when EFL was updated
- //_drawer.SetScrollable(_isGestureEnabled);
- }
- }
- }
-
- /// <summary>
- /// Gets or Sets the portion of the screen that the MasterPage takes in split mode.
- /// </summary>
- /// <value>The portion.</value>
- public double SplitRatio
- {
- get
- {
- return _splitRatio;
- }
- set
- {
- if (_splitRatio != value)
- {
- _splitRatio = value;
- _splitPane.Proportion = _splitRatio;
- }
- }
-
- }
-
- /// <summary>
- /// Gets or sets the portion of the screen that the MasterPage takes in Popover mode.
- /// </summary>
- /// <value>The portion.</value>
- public double PopoverRatio
- {
- get
- {
- return _popoverRatio;
- }
- set
- {
- if (_popoverRatio != value)
- {
- _popoverRatio = value;
- UpdateChildCanvasGeometry();
- }
- }
- }
-
- /// <summary>
- /// Provides destruction for native element and contained elements.
- /// </summary>
- protected override void OnUnrealize()
- {
- // Views that are not belong to view tree should be unrealized.
- if (IsSplit)
- {
- _drawer.Unrealize();
- }
- else
- {
- _splitPane.Unrealize();
- }
- base.OnUnrealize();
- }
-
- /// <summary>
- /// Updates the geometry of the selected page.
- /// </summary>
- /// <param name="page">Master or Detail page to be updated.</param>
- void UpdatePageGeometry(EvasObject page)
- {
- if (page != null)
- {
- if (_master == page)
- {
- // update the geometry of the master page
- page.Geometry = _masterCanvas.Geometry;
- }
- else if (_detail == page)
- {
- // update the geometry of the detail page
- page.Geometry = _detailCanvas.Geometry;
- }
- }
- }
-
- /// <summary>
- /// Updates <see cref="_internalMasterBehavior"/> according to <see cref="MasterDetailBehavior"/> set by the user and current screen orientation.
- /// </summary>
- void UpdateMasterBehavior()
- {
- var behavior = (_masterBehavior == MasterBehavior.Default) ? s_defaultMasterBehavior : _masterBehavior;
-
- // Screen orientation affects those 2 behaviors
- if (behavior == MasterBehavior.SplitOnLandscape ||
- behavior == MasterBehavior.SplitOnPortrait)
- {
- var orientation = Device.Info.CurrentOrientation;
-
- if ((orientation.IsLandscape() && behavior == MasterBehavior.SplitOnLandscape) ||
- (orientation.IsPortrait() && behavior == MasterBehavior.SplitOnPortrait))
- {
- behavior = MasterBehavior.Split;
- }
- else
- {
- behavior = MasterBehavior.Popover;
- }
- }
-
- if (behavior != _internalMasterBehavior)
- {
- _internalMasterBehavior = behavior;
- ConfigureLayout();
- }
- }
-
- /// <summary>
- /// Composes the structure of all the necessary widgets.
- /// </summary>
- void ConfigureLayout()
- {
- _drawer.SetContent(null, true);
- _drawer.Hide();
-
- _splitPane.SetPartContent("left", null, true);
- _splitPane.SetPartContent("right", null, true);
- _splitPane.Hide();
-
- UnPackAll();
-
- // the structure for split mode and for popover mode looks differently
- if (IsSplit)
- {
- _splitPane.SetPartContent("left", _masterCanvas, true);
- _splitPane.SetPartContent("right", _detailCanvas, true);
- _splitPane.Show();
- _mainWidget = _splitPane;
- PackEnd(_splitPane);
-
- IsPresented = true;
- UpdateIsPresentChangeable?.Invoke(this, new UpdateIsPresentChangeableEventArgs(false));
- UpdateFocusPolicy(true);
- }
- else
- {
- _drawer.SetContent(_masterCanvas, true);
- _drawer.Show();
- _mainWidget = _detailCanvas;
- PackEnd(_detailCanvas);
- PackEnd(_drawer);
-
- _drawer.IsOpen = IsPresented;
- UpdateIsPresentChangeable?.Invoke(this, new UpdateIsPresentChangeableEventArgs(true));
- UpdateFocusPolicy();
- }
-
- _masterCanvas.Show();
- _detailCanvas.Show();
-
- // even though child was changed, Layout callback was not called, so i manually call layout function.
- // Layout callback was filter out when geometry was not changed in Native.Box
- UpdateChildCanvasGeometry();
- }
-
- void UpdateChildCanvasGeometry()
- {
- var bound = Geometry;
- // main widget should fill the area of the MasterDetailPage
- if (_mainWidget != null)
- {
- _mainWidget.Geometry = bound;
- }
-
- bound.Width = (int)((_popoverRatio * bound.Width));
- _drawer.Geometry = bound;
- // When a _drawer.IsOpen was false, Content of _drawer area is not allocated. So, need to manaully set the content area
- if (!IsSplit)
- _masterCanvas.Geometry = bound;
- }
-
- /// <summary>
- /// Force update the focus management
- /// </summary>
- void UpdateFocusPolicy(bool forceAllowFocusAll=false)
- {
- var master = _master as Widget;
- var detail = _detail as Widget;
-
- if(forceAllowFocusAll)
- {
- if (master != null)
- master.AllowTreeFocus = true;
- if (detail != null)
- detail.AllowTreeFocus = true;
- return;
- }
-
- if (_drawer.IsOpen)
- {
- if (detail != null)
- {
- detail.AllowTreeFocus = false;
- }
- if (master != null)
- {
- master.AllowTreeFocus = true;
- master.SetFocus(true);
- }
- }
- else
- {
- if (master != null)
- {
- master.AllowTreeFocus = false;
- }
- if (detail != null)
- {
- detail.AllowTreeFocus = true;
- detail.SetFocus(true);
- }
- }
- }
- }
-
- public class IsPresentedChangedEventArgs : EventArgs
- {
- public IsPresentedChangedEventArgs (bool isPresent)
- {
- IsPresent = isPresent;
- }
-
- /// <summary>
- /// Value of IsPresent
- /// </summary>
- public bool IsPresent { get; private set; }
- }
-
- public class UpdateIsPresentChangeableEventArgs : EventArgs
- {
- public UpdateIsPresentChangeableEventArgs(bool canChange)
- {
- CanChange = canChange;
- }
-
- /// <summary>
- /// Value of changeable
- /// </summary>
- public bool CanChange { get; private set; }
- }
-}
[assembly: ExportRenderer(typeof(CarouselPage), typeof(CarouselPageRenderer))]
[assembly: ExportRenderer(typeof(Page), typeof(PageRenderer))]
[assembly: ExportRenderer(typeof(NavigationPage), typeof(NavigationPageRenderer))]
-[assembly: ExportRenderer(typeof(MasterDetailPage), typeof(MasterDetailPageRenderer))]
[assembly: ExportRenderer(typeof(Shell), typeof(ShellRenderer))]
[assembly: ExportRenderer(typeof(Label), typeof(LabelRenderer))]
{
return false;
}
- if (parentPage is MasterDetailPage mdPage && mdPage.Master == parent && !mdPage.IsPresented)
- {
- return false;
- }
return PageIsVisible(parentPage);
}
return ret;
}
}
-}
\ No newline at end of file
+}
+++ /dev/null
-using System;
-
-namespace Xamarin.Forms.Platform.Tizen.Renderers
-{
- public class MasterDetailContainer : ElmSharp.Box, IDisposable
- {
- readonly MasterDetailPage _parent;
- readonly bool _isMaster;
-
- VisualElement _childView;
- bool _disposed;
- bool _hasAppearedToParent;
-
- IPageController PageController => ChildView as IPageController;
- IMasterDetailPageController MasterDetailPageController => _parent as IMasterDetailPageController;
-
- public MasterDetailContainer(MasterDetailPage parentElement, bool isMaster) : base(Forms.NativeParent)
- {
- _parent = parentElement;
- _isMaster = isMaster;
-
- SetLayoutCallback(OnLayoutUpdated);
- Show();
- }
-
- ~MasterDetailContainer()
- {
- Dispose(false);
- }
-
- public VisualElement ChildView
- {
- get { return _childView; }
- set
- {
- if (_childView == value)
- return;
-
- if (_childView != null)
- {
- RemoveChildView();
- }
-
- _childView = value;
-
- if (_childView == null)
- return;
-
- AddChildView(_childView);
-
- if (_hasAppearedToParent)
- {
- Device.BeginInvokeOnMainThread(() =>
- {
- if (!_disposed && _hasAppearedToParent)
- PageController?.SendAppearing();
- });
- }
- }
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected void RemoveChildView()
- {
- IVisualElementRenderer childRenderer = Platform.GetRenderer(_childView);
- if (childRenderer != null)
- {
- UnPack(childRenderer.NativeView);
- childRenderer.Dispose();
- }
- }
-
- protected void AddChildView(VisualElement childView)
- {
- IVisualElementRenderer renderer = Platform.GetOrCreateRenderer(childView);
- this.PackEnd(renderer.NativeView);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (_disposed)
- return;
-
- if (disposing)
- {
- if (_childView != null)
- {
- RemoveChildView();
- }
- SetLayoutCallback(null);
- }
- _disposed = true;
- }
-
- void OnLayoutUpdated()
- {
- if (_childView != null)
- {
- if (_isMaster)
- MasterDetailPageController.MasterBounds = this.Geometry.ToDP();
- else
- MasterDetailPageController.DetailBounds = this.Geometry.ToDP();
-
- IVisualElementRenderer renderer = Platform.GetRenderer(_childView);
- renderer.NativeView.Geometry = this.Geometry;
- }
- }
-
- public void SendAppearing()
- {
- if (_hasAppearedToParent)
- return;
-
- _hasAppearedToParent = true;
-
- PageController?.SendAppearing();
- }
-
- public void SendDisappearing()
- {
- if (!_hasAppearedToParent)
- return;
-
- _hasAppearedToParent = false;
-
- PageController?.SendDisappearing();
- }
- }
-}
\ No newline at end of file
+++ /dev/null
-using System;
-using Xamarin.Forms.Platform.Tizen.Renderers;
-
-namespace Xamarin.Forms.Platform.Tizen
-{
- public class MasterDetailPageRenderer : VisualElementRenderer<MasterDetailPage>
- {
- Native.MasterDetailPage _mdpage;
- MasterDetailContainer _masterContainer = null;
- MasterDetailContainer _detailContainer = null;
-
- /// <summary>
- /// Default constructor.
- /// </summary>
- public MasterDetailPageRenderer()
- {
- RegisterPropertyHandler(nameof(Element.Master), UpdateMasterPage);
- RegisterPropertyHandler(nameof(Element.Detail), UpdateDetailPage);
- RegisterPropertyHandler(MasterDetailPage.IsPresentedProperty,
- UpdateIsPresented);
- RegisterPropertyHandler(MasterDetailPage.MasterBehaviorProperty,
- UpdateMasterBehavior);
- RegisterPropertyHandler(MasterDetailPage.IsGestureEnabledProperty,
- UpdateIsGestureEnabled);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs<MasterDetailPage> e)
- {
- if (_mdpage == null)
- {
- _mdpage = new Native.MasterDetailPage(Forms.NativeParent)
- {
- IsPresented = e.NewElement.IsPresented,
- Master = _masterContainer = new MasterDetailContainer(Element, true),
- Detail = _detailContainer = new MasterDetailContainer(Element, false),
- };
-
- _mdpage.IsPresentedChanged += (sender, ev) =>
- {
- Element.IsPresented = ev.IsPresent;
- };
- _mdpage.UpdateIsPresentChangeable += (sender, ev) =>
- {
- (Element as IMasterDetailPageController).CanChangeIsPresented = ev.CanChange;
- };
- SetNativeView(_mdpage);
- }
-
- if (e.OldElement != null)
- {
- (e.OldElement as IMasterDetailPageController).BackButtonPressed -= OnBackButtonPressed;
- e.OldElement.Appearing -= OnMasterDetailAppearing;
- e.OldElement.Disappearing -= OnMasterDetailDisappearing;
- }
-
- if (e.NewElement != null)
- {
- (e.NewElement as IMasterDetailPageController).BackButtonPressed += OnBackButtonPressed;
- e.NewElement.Appearing += OnMasterDetailAppearing;
- e.NewElement.Disappearing += OnMasterDetailDisappearing;
- }
-
- UpdateMasterBehavior();
- base.OnElementChanged(e);
- }
-
- void OnMasterDetailDisappearing(object sender, EventArgs e)
- {
- _masterContainer?.SendDisappearing();
- _detailContainer?.SendDisappearing();
- }
-
- void OnMasterDetailAppearing(object sender, EventArgs e)
- {
- _masterContainer?.SendAppearing();
- _detailContainer?.SendAppearing();
- }
-
- protected override void OnElementReady()
- {
- base.OnElementReady();
- UpdateMasterPage(false);
- UpdateDetailPage(false);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (_masterContainer != null)
- {
- _masterContainer.Dispose();
- _masterContainer = null;
- }
-
- if (_detailContainer != null)
- {
- _detailContainer.Dispose();
- _detailContainer = null;
- }
-
- if (Element != null)
- {
- Element.Appearing -= OnMasterDetailAppearing;
- Element.Disappearing -= OnMasterDetailDisappearing;
- }
- }
-
- base.Dispose(disposing);
- }
-
- protected void UpdateMasterPageRatio(double popoverRatio, double splitRatio)
- {
- _mdpage.PopoverRatio = popoverRatio;
- _mdpage.SplitRatio = splitRatio;
- }
-
- void OnBackButtonPressed(object sender, BackButtonPressedEventArgs e)
- {
- if ((Element != null) && Element.IsPresented && !_mdpage.IsSplit)
- {
- Element.IsPresented = false;
- e.Handled = true;
- }
- }
-
- void UpdateMasterBehavior()
- {
- _mdpage.MasterBehavior = Element.MasterBehavior;
- }
-
- void UpdateMasterPage(bool isInit)
- {
- if (!isInit)
- _masterContainer.ChildView = Element.Master;
- }
-
- void UpdateDetailPage(bool isInit)
- {
- if (!isInit)
- _detailContainer.ChildView = Element.Detail;
- }
-
- void UpdateIsPresented()
- {
- // To update TabIndex order
- CustomFocusManager.StartReorderTabIndex();
-
- _mdpage.IsPresented = Element.IsPresented;
- }
-
- void UpdateIsGestureEnabled()
- {
- _mdpage.IsGestureEnabled = Element.IsGestureEnabled;
- }
- }
-}
Registered.Register(typeof(CarouselPage), () => new CarouselPageRenderer());
Registered.Register(typeof(Page), () => new PageRenderer());
Registered.Register(typeof(NavigationPage), () => new NavigationPageRenderer());
- Registered.Register(typeof(MasterDetailPage), () => new MasterDetailPageRenderer());
Registered.Register(typeof(Shell), () => new ShellRenderer());
Registered.Register(typeof(Label), () => new LabelRenderer());
Registered.Register(typeof(Button), () => new ButtonRenderer());
{
}
- internal class _MasterDetailPageRenderer
- {
- }
-
internal class _SwipeViewRenderer
{
}