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

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

2016-03-22 23:02:25 +03:00
using System;
using System.Collections.Generic;
using System.ComponentModel;
2016-03-22 23:02:25 +03:00
using System.Linq;
using Xamarin.Forms.Platform;
namespace Xamarin.Forms.Internals
2016-03-22 23:02:25 +03:00
{
// Mark as internal until renderers are ready for release after 1.0
[RenderWith(typeof(_NavigationMenuRenderer))]
[EditorBrowsable(EditorBrowsableState.Never)]
public class NavigationMenu : View, INavigationMenuController, IElementConfiguration<NavigationMenu>
2016-03-22 23:02:25 +03:00
{
readonly List<Page> _targets = new List<Page>();
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
2016-08-30 20:46:14 +03:00
readonly Lazy<PlatformConfigurationRegistry<NavigationMenu>> _platformConfigurationRegistry;
public NavigationMenu()
{
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<NavigationMenu>>(() => new PlatformConfigurationRegistry<NavigationMenu>(this));
}
2016-03-22 23:02:25 +03:00
public IEnumerable<Page> Targets
{
get { return _targets; }
set
{
if (_targets.AsEnumerable().SequenceEqual(value))
return;
foreach (Page page in value)
{
VerifyTarget(page);
}
OnPropertyChanging();
_targets.Clear();
_targets.AddRange(value);
OnPropertyChanged();
}
}
public void Add(Page target)
{
if (_targets.Contains(target))
return;
VerifyTarget(target);
OnPropertyChanging("Targets");
_targets.Add(target);
OnPropertyChanged("Targets");
}
public void Remove(Page target)
{
if (_targets.Contains(target))
{
OnPropertyChanging("Targets");
if (_targets.Remove(target))
OnPropertyChanged("Targets");
}
}
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
2016-08-30 20:46:14 +03:00
public IPlatformElementConfiguration<T, NavigationMenu> On<T>() where T : IConfigPlatform
{
return _platformConfigurationRegistry.Value.On<T>();
}
void INavigationMenuController.SendTargetSelected(Page target)
2016-03-22 23:02:25 +03:00
{
Navigation.PushAsync(target);
}
void VerifyTarget(Page target)
{
if (target.Icon == null || string.IsNullOrWhiteSpace(target.Icon.File))
throw new Exception("Icon must be set for each page before adding them to a Navigation Menu");
}
}
}