diff options
author | Samantha Houts <samantha@teamredwall.com> | 2016-08-30 10:46:14 -0700 |
---|---|---|
committer | Jason Smith <jason.smith@xamarin.com> | 2016-08-30 10:46:14 -0700 |
commit | 5e553f6195e66e48688b8ab324f1bab1e9251f0a (patch) | |
tree | f8843e5e9e8afe89a05a1cc91c3b7fa05588bac7 /Xamarin.Forms.Platform.UAP/MasterDetailControl.cs | |
parent | f551654b1cfe654c579ca50978445e7cb93f287d (diff) | |
download | xamarin-forms-5e553f6195e66e48688b8ab324f1bab1e9251f0a.tar.gz xamarin-forms-5e553f6195e66e48688b8ab324f1bab1e9251f0a.tar.bz2 xamarin-forms-5e553f6195e66e48688b8ab324f1bab1e9251f0a.zip |
Platform Specifics (#301)
* Playing around with how the platform specifics interfaces etc. might work
* Sample implementation of iOS navigation translucency
* Very slightly reduced code
* Better vendor stuff
* Drop single-implemenation interfaces
* Generics on NavigationPage
* On-demand vendor stuff
* Remove functionally duplicate classes and make ControlGallery work again
* Namespace all the things. XAML test.
* Can use Effect to attach platform specific
* Attach Effect on PropertyChanging for XAML support!
* Rename IConfigPlatform interfaces for readability
* Some renaming to match the documents
* Split class files
* Clear out test-only code
* Re-namespace
* Added On method to rendered Elements
* Allow for removal of platform suffix, convenience methods on specific platforms
* Creating a gallery page for specifics
* Add rudimentary Platform Specifics gallery; make CollapseStyle work on UWP;
Add CollapsedPaneWidth specific property
* Toolbar now working with both collapse styles
* MDP now displaying Content title; toolbar routing around title
* Add a gallery for the iOS NavigationPage stuff
* Add Navigation Page as detail page to verify it works with new Toolbar options
* Make titlebar/toolbar background colors consistent
* ToolbarPlacement now working on NavigationPage
* Toolbar Placement working for tabbed and nav pages
* Fix bug where phone doesn't get default toolbar placement on start
* [Core] Add PS WindowSoftInputModeAdjust
[Core] Make Application extendable
* Toolbar placement now working on Nav, Tabbed, and Master pages on desktop/phone
Remove unnecessary style indirection
Fix build errors
* [A] Add PlatformConfigurationExtensions
* SetSoftInputMode test page
* [A] SetSoftInputMode
Known issue: Status bar color does not work in AdjustResize mode
* [Core] Add PS Blur
* [iOS] Configure renderer for blur
* Add test page
* Move to blur VisualElement for broader support
* Move test pages to gallery
* Update docs
* Use lazy initializer for PlatformConfigurationRegistry
Diffstat (limited to 'Xamarin.Forms.Platform.UAP/MasterDetailControl.cs')
-rw-r--r-- | Xamarin.Forms.Platform.UAP/MasterDetailControl.cs | 100 |
1 files changed, 92 insertions, 8 deletions
diff --git a/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs b/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs index 6787ccec..51f737f8 100644 --- a/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs +++ b/Xamarin.Forms.Platform.UAP/MasterDetailControl.cs @@ -1,7 +1,9 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media; +using Xamarin.Forms.PlatformConfiguration.WindowsSpecific; namespace Xamarin.Forms.Platform.UWP { @@ -17,9 +19,15 @@ namespace Xamarin.Forms.Platform.UWP public static readonly DependencyProperty IsPaneOpenProperty = DependencyProperty.Register("IsPaneOpen", typeof(bool), typeof(MasterDetailControl), new PropertyMetadata(default(bool))); - public static readonly DependencyProperty ShouldShowSplitModeProperty = DependencyProperty.Register("ShouldShowSplitMode", typeof(bool), typeof(MasterDetailControl), + public static readonly DependencyProperty ShouldShowSplitModeProperty = DependencyProperty.Register(nameof(ShouldShowSplitMode), typeof(bool), typeof(MasterDetailControl), new PropertyMetadata(default(bool), OnShouldShowSplitModeChanged)); + public static readonly DependencyProperty CollapseStyleProperty = DependencyProperty.Register(nameof(CollapseStyle), typeof(CollapseStyle), + typeof(MasterDetailControl), new PropertyMetadata(CollapseStyle.Full, CollapseStyleChanged)); + + public static readonly DependencyProperty CollapsedPaneWidthProperty = DependencyProperty.Register(nameof(CollapsedPaneWidth), typeof(double), typeof(MasterDetailControl), + new PropertyMetadata(48d, CollapsedPaneWidthChanged)); + public static readonly DependencyProperty DetailTitleProperty = DependencyProperty.Register("DetailTitle", typeof(string), typeof(MasterDetailControl), new PropertyMetadata(default(string))); public static readonly DependencyProperty ToolbarForegroundProperty = DependencyProperty.Register("ToolbarForeground", typeof(Brush), typeof(MasterDetailControl), @@ -37,20 +45,26 @@ namespace Xamarin.Forms.Platform.UWP public static readonly DependencyProperty MasterToolbarVisibilityProperty = DependencyProperty.Register("MasterToolbarVisibility", typeof(Visibility), typeof(MasterDetailControl), new PropertyMetadata(default(Visibility))); + public static readonly DependencyProperty ContentTogglePaneButtonVisibilityProperty = DependencyProperty.Register(nameof(ContentTogglePaneButtonVisibility), typeof(Visibility), typeof(MasterDetailControl), + new PropertyMetadata(default(Visibility))); + CommandBar _commandBar; + Border _bottomCommandBarArea; + Border _topCommandBarArea; TaskCompletionSource<CommandBar> _commandBarTcs; FrameworkElement _masterPresenter; FrameworkElement _detailPresenter; SplitView _split; + ToolbarPlacement _toolbarPlacement; - public MasterDetailControl() + public MasterDetailControl() { DefaultStyleKey = typeof(MasterDetailControl); - MasterTitleVisibility = Visibility.Collapsed; + DetailTitleVisibility = Visibility.Collapsed; - if (Device.Idiom != TargetIdiom.Phone) - MasterToolbarVisibility = Visibility.Collapsed; + + CollapseStyle = CollapseStyle.Full; } public FrameworkElement Detail @@ -148,6 +162,34 @@ namespace Xamarin.Forms.Platform.UWP set { SetValue(ShouldShowSplitModeProperty, value); } } + public CollapseStyle CollapseStyle + { + get { return (CollapseStyle)GetValue(CollapseStyleProperty); } + set { SetValue(CollapseStyleProperty, value); } + } + + public ToolbarPlacement ToolbarPlacement + { + get { return _toolbarPlacement; } + set + { + _toolbarPlacement = value; + UpdateToolbarPlacement(); + } + } + + public Visibility ContentTogglePaneButtonVisibility + { + get { return (Visibility)GetValue(ContentTogglePaneButtonVisibilityProperty); } + set { SetValue(ContentTogglePaneButtonVisibilityProperty, value); } + } + + public double CollapsedPaneWidth + { + get { return (double)GetValue(CollapsedPaneWidthProperty); } + set { SetValue(CollapsedPaneWidthProperty, value); } + } + public Brush ToolbarBackground { get { return (Brush)GetValue(ToolbarBackgroundProperty); } @@ -194,8 +236,11 @@ namespace Xamarin.Forms.Platform.UWP _detailPresenter = GetTemplateChild("DetailPresenter") as FrameworkElement; _commandBar = GetTemplateChild("CommandBar") as CommandBar; + _bottomCommandBarArea = GetTemplateChild("BottomCommandBarArea") as Border; + _topCommandBarArea = GetTemplateChild("TopCommandBarArea") as Border; - UpdateMode(); + UpdateToolbarPlacement(); + UpdateMode(); if (_commandBarTcs != null) _commandBarTcs.SetResult(_commandBar); @@ -206,6 +251,21 @@ namespace Xamarin.Forms.Platform.UWP ((MasterDetailControl)dependencyObject).UpdateMode(); } + static void CollapseStyleChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) + { + ((MasterDetailControl)dependencyObject).UpdateMode(); + } + + static void ToolbarPlacementChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) + { + ((MasterDetailControl)dependencyObject).UpdateToolbarPlacement(); + } + + static void CollapsedPaneWidthChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) + { + ((MasterDetailControl)dependencyObject).UpdateMode(); + } + void OnToggleClicked(object sender, RoutedEventArgs args) { IsPaneOpen = !IsPaneOpen; @@ -214,9 +274,33 @@ namespace Xamarin.Forms.Platform.UWP void UpdateMode() { if (_split == null) + { return; + } - _split.DisplayMode = ShouldShowSplitMode ? SplitViewDisplayMode.Inline : SplitViewDisplayMode.Overlay; + _split.DisplayMode = ShouldShowSplitMode + ? SplitViewDisplayMode.Inline + : CollapseStyle == CollapseStyle.Full ? SplitViewDisplayMode.Overlay : SplitViewDisplayMode.CompactOverlay; + + _split.CompactPaneLength = CollapsedPaneWidth; + + if (_split.DisplayMode == SplitViewDisplayMode.Inline) + { + // If we've determined that the pane will always be open, then there's no + // reason to display the show/hide pane button in the master + MasterToolbarVisibility = Visibility.Collapsed; + } + + // If we're in compact mode or the pane is always open, + // we don't need to display the content pane's toggle button + ContentTogglePaneButtonVisibility = _split.DisplayMode == SplitViewDisplayMode.Overlay + ? Visibility.Visible + : Visibility.Collapsed; + } + + void UpdateToolbarPlacement() + { + ToolbarPlacementHelper.UpdateToolbarPlacement(_commandBar, ToolbarPlacement, _bottomCommandBarArea, _topCommandBarArea); } } }
\ No newline at end of file |