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
This commit is contained in:
Родитель
f551654b1c
Коммит
5e553f6195
|
@ -236,10 +236,13 @@
|
|||
|
||||
<file src="..\Xamarin.Forms.Platform.UAP\Properties\Xamarin.Forms.Platform.UAP.rd.xml" target="lib\uap10.0\Xamarin.Forms.Platform.UAP\Properties" />
|
||||
|
||||
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\PageControl.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
|
||||
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\Resources.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
|
||||
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\FormsTextBoxStyle.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
|
||||
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\PageControl.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
|
||||
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\Resources.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
|
||||
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\FormsTextBoxStyle.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
|
||||
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\AutoSuggestStyle.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
|
||||
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\MasterDetailControlStyle.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
|
||||
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\PageControlStyle.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
|
||||
<file src="..\Xamarin.Forms.Platform.UAP\bin\$Configuration$\TabbedPageStyle.xbf" target="lib\uap10.0\Xamarin.Forms.Platform.UAP" />
|
||||
|
||||
<file src="..\Xamarin.Forms.Core\bin\$Configuration$\Xamarin.Forms.Core.dll" target="lib\uap10.0" />
|
||||
<file src="..\docs\Xamarin.Forms.Core.xml" target="lib\uap10.0" />
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace Xamarin.Forms.ControlGallery.WindowsUniversal
|
|||
#if DEBUG
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
{
|
||||
DebugSettings.EnableFrameRateCounter = true;
|
||||
// DebugSettings.EnableFrameRateCounter = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -34,3 +34,4 @@ using System.Runtime.InteropServices;
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion ("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion ("1.0.0.0")]
|
||||
[assembly: Xamarin.Forms.ResolutionGroupName("XamControl")]
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchArch>Default, i386, x86_64</MtouchArch>
|
||||
<MtouchLink>SdkOnly</MtouchLink>
|
||||
<MtouchArch>i386, x86_64</MtouchArch>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<MtouchDebug>True</MtouchDebug>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<MtouchSdkVersion>7.0</MtouchSdkVersion>
|
||||
<MtouchSdkVersion>9.3</MtouchSdkVersion>
|
||||
<MtouchProfiling>False</MtouchProfiling>
|
||||
<MtouchFastDev>False</MtouchFastDev>
|
||||
<MtouchEnableGenericValueTypeSharing>True</MtouchEnableGenericValueTypeSharing>
|
||||
|
@ -36,8 +36,12 @@
|
|||
<MtouchUseSGen>False</MtouchUseSGen>
|
||||
<MtouchUseRefCounting>False</MtouchUseRefCounting>
|
||||
<MtouchOptimizePNGs>False</MtouchOptimizePNGs>
|
||||
<MtouchI18n />
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<MtouchEnableBitcode>False</MtouchEnableBitcode>
|
||||
<OptimizePNGs>True</OptimizePNGs>
|
||||
<MtouchTlsProvider>Default</MtouchTlsProvider>
|
||||
<MtouchHttpClientHandler>HttpClientHandler</MtouchHttpClientHandler>
|
||||
<MtouchFloat32>False</MtouchFloat32>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>none</DebugType>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<local:TestNavigationPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:local="clr-namespace:Xamarin.Forms.Controls"
|
||||
xmlns:iOsSpecific="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
|
||||
x:Class="Xamarin.Forms.Controls.Issues.PlatformSpecifics_iOSTranslucentNavBarX"
|
||||
BackgroundColor="Pink"
|
||||
iOsSpecific:NavigationPage.IsNavigationBarTranslucent="true">
|
||||
</local:TestNavigationPage>
|
|
@ -0,0 +1,44 @@
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
|
||||
using Xamarin.Forms.Xaml;
|
||||
|
||||
namespace Xamarin.Forms.Controls.Issues
|
||||
{
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.None, 0, "Platform Specifics - iOS Translucent Navigation Bar XAML", PlatformAffected.iOS)]
|
||||
#if APP
|
||||
[XamlCompilation(XamlCompilationOptions.Compile)]
|
||||
#endif
|
||||
public partial class PlatformSpecifics_iOSTranslucentNavBarX : TestNavigationPage
|
||||
{
|
||||
public PlatformSpecifics_iOSTranslucentNavBarX()
|
||||
{
|
||||
#if APP
|
||||
InitializeComponent ();
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
var button = new Button { Text = "Toggle Translucent", BackgroundColor = Color.Yellow };
|
||||
|
||||
button.Clicked += (sender, args) => On<iOS>().SetIsNavigationBarTranslucent(!On<iOS>().IsNavigationBarTranslucent());
|
||||
|
||||
var content = new ContentPage
|
||||
{
|
||||
Title = "iOS Translucent Navigation Bar",
|
||||
Content = new StackLayout
|
||||
{
|
||||
VerticalOptions = LayoutOptions.Center,
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
Children = { button }
|
||||
}
|
||||
};
|
||||
|
||||
PushAsync(content);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -168,6 +168,10 @@
|
|||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39829.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39458.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla39853.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)PlatformSpecifics_iOSTranslucentNavBarX.xaml.cs">
|
||||
<DependentUpon>PlatformSpecifics_iOSTranslucentNavBarX.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)TestPages\ScreenshotConditionalApp.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla41842.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla42277.cs" />
|
||||
|
@ -557,6 +561,12 @@
|
|||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)PlatformSpecifics_iOSTranslucentNavBarX.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla42069_Page.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
using System;
|
||||
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
#if UITEST
|
||||
|
@ -10,14 +8,15 @@ using NUnit.Framework;
|
|||
|
||||
namespace Xamarin.Forms.Controls
|
||||
{
|
||||
[Preserve (AllMembers = true)]
|
||||
[Issue (IssueTracker.Github, 1, "Issue Description")]
|
||||
[Preserve(AllMembers = true)]
|
||||
[Issue(IssueTracker.Github, 1, "Issue Description")]
|
||||
public class Issue1 : TestContentPage // or TestMasterDetailPage, etc ...
|
||||
{
|
||||
protected override void Init ()
|
||||
protected override void Init()
|
||||
{
|
||||
// Initialize ui here instead of ctor
|
||||
Content = new Label {
|
||||
Content = new Label
|
||||
{
|
||||
AutomationId = "IssuePageLabel",
|
||||
Text = "See if I'm here"
|
||||
};
|
||||
|
@ -33,4 +32,4 @@ namespace Xamarin.Forms.Controls
|
|||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,8 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms.Controls.Issues;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
|
||||
|
||||
namespace Xamarin.Forms.Controls
|
||||
{
|
||||
|
@ -34,7 +35,6 @@ namespace Xamarin.Forms.Controls
|
|||
|
||||
protected override void OnAppLinkRequestReceived(Uri uri)
|
||||
{
|
||||
|
||||
var appDomain = "http://" + AppName.ToLowerInvariant() + "/";
|
||||
|
||||
if (!uri.ToString().ToLowerInvariant().StartsWith(appDomain))
|
||||
|
|
|
@ -220,6 +220,7 @@ namespace Xamarin.Forms.Controls
|
|||
public CorePageView (Page rootPage, NavigationBehavior navigationBehavior = NavigationBehavior.PushAsync)
|
||||
{
|
||||
var pages = new List<Page> {
|
||||
new PlatformSpecificsGallery() {Title = "Platform Specifics"},
|
||||
new AppLinkPageGallery {Title = "App Link Page Gallery"},
|
||||
new NestedNativeControlGalleryPage {Title = "Nested Native Controls Gallery"},
|
||||
new CellForceUpdateSizeGalleryPage {Title = "Cell Force Update Size Gallery"},
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
using System.Windows.Input;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
|
||||
|
||||
namespace Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries
|
||||
{
|
||||
public class ApplicationAndroid : ContentPage
|
||||
{
|
||||
public ApplicationAndroid(ICommand restore)
|
||||
{
|
||||
var restoreButton = new Button { Text = "Back To Gallery" };
|
||||
restoreButton.Clicked += (sender, args) => restore.Execute(null);
|
||||
|
||||
var button1 = GetButton(WindowSoftInputModeAdjust.Pan);
|
||||
var button2 = GetButton(WindowSoftInputModeAdjust.Resize);
|
||||
var buttons = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { button1, button2 }, VerticalOptions = LayoutOptions.Start };
|
||||
var entry = new Entry { Text = "1", VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.StartAndExpand };
|
||||
var layout = new RelativeLayout
|
||||
{
|
||||
VerticalOptions = LayoutOptions.StartAndExpand,
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
};
|
||||
layout.Children.Add(buttons, yConstraint: Xamarin.Forms.Constraint.RelativeToParent(parent => { return parent.Y; }));
|
||||
layout.Children.Add(entry, yConstraint: Xamarin.Forms.Constraint.RelativeToParent(parent => { return parent.Height - 100; }));
|
||||
|
||||
Content = layout;
|
||||
Title = "Application Features";
|
||||
}
|
||||
|
||||
static Button GetButton(WindowSoftInputModeAdjust value)
|
||||
{
|
||||
var button = new Button { Text = value.ToString(), Margin = 20 };
|
||||
button.Clicked += (sender, args) =>
|
||||
{
|
||||
Application.Current.On<Android>().UseWindowSoftInputModeAdjust(value);
|
||||
};
|
||||
return button;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Input;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
|
||||
using static Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries.WindowsPlatformSpecificsGalleryHelpers;
|
||||
|
||||
namespace Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries
|
||||
{
|
||||
public class MasterDetailPageWindows : MasterDetailPage
|
||||
{
|
||||
public MasterDetailPageWindows(ICommand restore)
|
||||
{
|
||||
On<Windows>()
|
||||
.SetCollapseStyle(CollapseStyle.Partial);
|
||||
MasterBehavior = MasterBehavior.Popover;
|
||||
|
||||
var master = new ContentPage { Title = "Master Detail Page" };
|
||||
var masterContent = new StackLayout { Spacing = 10, Margin = new Thickness(0, 10, 5, 0) };
|
||||
var detail = new ContentPage { Title = "This is the detail page's Title" };
|
||||
|
||||
// Build the navigation pane items
|
||||
var navItems = new List<NavItem>
|
||||
{
|
||||
new NavItem("Display Alert", "\uE171", new Command(() => DisplayAlert("Alert", "This is an alert", "OK"))),
|
||||
new NavItem("Return To Gallery", "\uE106", restore),
|
||||
new NavItem("Save", "\uE105", new Command(() => DisplayAlert("Save", "Fake save dialog", "OK"))),
|
||||
new NavItem("Audio", "\uE189", new Command(() => DisplayAlert("Audio", "Never gonna give you up...", "OK"))),
|
||||
new NavItem("Set Detail to Navigation Page", "\uE16F", new Command(() => Detail = CreateNavigationPage())),
|
||||
new NavItem("Set Detail to Content Page", "\uE160", new Command(() => Detail = detail)),
|
||||
};
|
||||
|
||||
var navList = new NavList(navItems);
|
||||
|
||||
// And add them to the navigation pane's content
|
||||
masterContent.Children.Add(navList);
|
||||
master.Content = masterContent;
|
||||
|
||||
var detailContent = new StackLayout { VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill };
|
||||
detailContent.Children.Add(new Label
|
||||
{
|
||||
Text = "Platform Features",
|
||||
FontAttributes = FontAttributes.Bold,
|
||||
HorizontalTextAlignment = TextAlignment.Center,
|
||||
VerticalTextAlignment = TextAlignment.Center
|
||||
});
|
||||
|
||||
detailContent.Children.Add(CreateCollapseStyleChanger(this));
|
||||
detailContent.Children.Add(CreateToolbarPlacementChanger(this));
|
||||
detailContent.Children.Add(CreateCollapseWidthAdjuster(this));
|
||||
detailContent.Children.Add(CreateAddRemoveToolBarItemButtons(this));
|
||||
|
||||
detail.Content = detailContent;
|
||||
|
||||
Master = master;
|
||||
|
||||
AddToolBarItems(this);
|
||||
|
||||
Detail = detail;
|
||||
}
|
||||
|
||||
static Layout CreateCollapseStyleChanger(MasterDetailPage page)
|
||||
{
|
||||
Type enumType = typeof(CollapseStyle);
|
||||
|
||||
return CreateChanger(enumType,
|
||||
Enum.GetName(enumType, page.On<Windows>().GetCollapseStyle()),
|
||||
picker =>
|
||||
{
|
||||
page.On<Windows>().SetCollapseStyle((CollapseStyle)Enum.Parse(enumType, picker.Items[picker.SelectedIndex]));
|
||||
},
|
||||
"Select Collapse Style");
|
||||
}
|
||||
|
||||
static Layout CreateCollapseWidthAdjuster(MasterDetailPage page)
|
||||
{
|
||||
var adjustCollapseWidthLabel = new Label
|
||||
{
|
||||
Text = "Adjust Collapsed Width",
|
||||
VerticalTextAlignment = TextAlignment.Center,
|
||||
VerticalOptions = LayoutOptions.Center
|
||||
};
|
||||
var adjustCollapseWidthEntry = new Entry { Text = page.On<Windows>().CollapsedPaneWidth().ToString() };
|
||||
var adjustCollapseWidthButton = new Button { Text = "Change", BackgroundColor = Color.Gray };
|
||||
adjustCollapseWidthButton.Clicked += (sender, args) =>
|
||||
{
|
||||
double newWidth;
|
||||
if (double.TryParse(adjustCollapseWidthEntry.Text, out newWidth))
|
||||
{
|
||||
page.On<Windows>().CollapsedPaneWidth(newWidth);
|
||||
}
|
||||
};
|
||||
|
||||
var adjustCollapsedWidthSection = new StackLayout
|
||||
{
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
Orientation = StackOrientation.Horizontal,
|
||||
Children = { adjustCollapseWidthLabel, adjustCollapseWidthEntry, adjustCollapseWidthButton }
|
||||
};
|
||||
|
||||
return adjustCollapsedWidthSection;
|
||||
}
|
||||
|
||||
public class NavItem
|
||||
{
|
||||
public NavItem(string text, string icon, ICommand command)
|
||||
{
|
||||
Text = text;
|
||||
Icon = icon;
|
||||
Command = command;
|
||||
}
|
||||
|
||||
public ICommand Command { get; set; }
|
||||
|
||||
public string Icon { get; set; }
|
||||
|
||||
public string Text { get; set; }
|
||||
}
|
||||
|
||||
public class NavList : ListView
|
||||
{
|
||||
public NavList(IEnumerable<NavItem> items)
|
||||
{
|
||||
ItemsSource = items;
|
||||
ItemTapped += (sender, args) => (args.Item as NavItem)?.Command.Execute(null);
|
||||
|
||||
ItemTemplate = new DataTemplate(() =>
|
||||
{
|
||||
var grid = new Grid();
|
||||
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = 48 });
|
||||
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = 200 });
|
||||
|
||||
grid.Margin = new Thickness(0, 10, 0, 10);
|
||||
|
||||
var text = new Label
|
||||
{
|
||||
VerticalOptions = LayoutOptions.Fill
|
||||
};
|
||||
text.SetBinding(Label.TextProperty, "Text");
|
||||
|
||||
var glyph = new Label
|
||||
{
|
||||
FontFamily = "Segoe MDL2 Assets",
|
||||
FontSize = 24,
|
||||
HorizontalTextAlignment = TextAlignment.Center
|
||||
};
|
||||
|
||||
glyph.SetBinding(Label.TextProperty, "Icon");
|
||||
|
||||
grid.Children.Add(glyph);
|
||||
grid.Children.Add(text);
|
||||
|
||||
Grid.SetColumn(glyph, 0);
|
||||
Grid.SetColumn(text, 1);
|
||||
|
||||
grid.WidthRequest = 48;
|
||||
|
||||
var cell = new ViewCell
|
||||
{
|
||||
View = grid
|
||||
};
|
||||
|
||||
return cell;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static NavigationPage CreateNavigationPage()
|
||||
{
|
||||
var page = new NavigationPage { Title = "This is the Navigation Page Title" };
|
||||
|
||||
page.PushAsync(CreateNavSubPage());
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
static ContentPage CreateNavSubPage()
|
||||
{
|
||||
var page = new ContentPage();
|
||||
|
||||
var label = new Label { Text = "This is content in a nav page" };
|
||||
var button = new Button() { Text = "Push Another Page"};
|
||||
|
||||
button.Clicked += (sender, args) => page.Navigation.PushAsync(CreateNavSubPage());
|
||||
|
||||
page.Content = new StackLayout { Children = { label, button } };
|
||||
|
||||
return page;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
using System.Windows.Input;
|
||||
|
||||
namespace Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries
|
||||
{
|
||||
public class NavigationPageWindows : NavigationPage
|
||||
{
|
||||
public NavigationPageWindows(ICommand restore)
|
||||
{
|
||||
PushAsync(CreateRoot(restore));
|
||||
WindowsPlatformSpecificsGalleryHelpers.AddToolBarItems(this);
|
||||
}
|
||||
|
||||
ContentPage CreateRoot(ICommand restore)
|
||||
{
|
||||
var page = new ContentPage { Title = "Content Page Title" };
|
||||
|
||||
var content = new StackLayout
|
||||
{
|
||||
VerticalOptions = LayoutOptions.Fill,
|
||||
HorizontalOptions = LayoutOptions.Fill
|
||||
};
|
||||
content.Children.Add(new Label
|
||||
{
|
||||
Text = "Navigation Page Windows Features",
|
||||
FontAttributes = FontAttributes.Bold,
|
||||
HorizontalTextAlignment = TextAlignment.Center,
|
||||
VerticalTextAlignment = TextAlignment.Center
|
||||
});
|
||||
|
||||
content.Children.Add(WindowsPlatformSpecificsGalleryHelpers.CreateToolbarPlacementChanger(this));
|
||||
content.Children.Add(WindowsPlatformSpecificsGalleryHelpers.CreateAddRemoveToolBarItemButtons(this));
|
||||
|
||||
var restoreButton = new Button { Text = "Back To Gallery" };
|
||||
restoreButton.Clicked += (sender, args) => restore.Execute(null);
|
||||
content.Children.Add(restoreButton);
|
||||
|
||||
var navButton = new Button { Text = "Push Page (with no title)" };
|
||||
navButton.Clicked += (sender, args) => PushAsync(CreatePageWithNoTitle());
|
||||
content.Children.Add(navButton);
|
||||
|
||||
page.Content = content;
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
ContentPage CreatePageWithNoTitle()
|
||||
{
|
||||
var page = new ContentPage { };
|
||||
|
||||
var content = new StackLayout
|
||||
{
|
||||
VerticalOptions = LayoutOptions.Fill,
|
||||
HorizontalOptions = LayoutOptions.Fill
|
||||
};
|
||||
content.Children.Add(new Label
|
||||
{
|
||||
Text = "Page 2",
|
||||
FontAttributes = FontAttributes.Bold,
|
||||
HorizontalTextAlignment = TextAlignment.Center,
|
||||
VerticalTextAlignment = TextAlignment.Center
|
||||
});
|
||||
|
||||
page.Content = content;
|
||||
|
||||
return page;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
using System.Windows.Input;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
|
||||
|
||||
namespace Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries
|
||||
{
|
||||
public class NavigationPageiOS : NavigationPage
|
||||
{
|
||||
public static NavigationPageiOS Create(ICommand restore)
|
||||
{
|
||||
var restoreButton = new Button { Text = "Back To Gallery" };
|
||||
restoreButton.Clicked += (sender, args) => restore.Execute(null);
|
||||
|
||||
var translucentToggleButton = new Button { Text = "Toggle Translucent NavBar" };
|
||||
|
||||
var content = new ContentPage
|
||||
{
|
||||
Title = "Navigation Page Features",
|
||||
Content = new StackLayout
|
||||
{
|
||||
VerticalOptions = LayoutOptions.Center,
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
Children = { translucentToggleButton, restoreButton }
|
||||
}
|
||||
};
|
||||
|
||||
var navPage = new NavigationPageiOS(content, restore);
|
||||
|
||||
translucentToggleButton.Clicked += (sender, args) => navPage.On<iOS>().SetIsNavigationBarTranslucent(!navPage.On<iOS>().IsNavigationBarTranslucent());
|
||||
|
||||
return navPage;
|
||||
}
|
||||
|
||||
public NavigationPageiOS(Page root, ICommand restore) : base(root)
|
||||
{
|
||||
BackgroundColor = Color.Pink;
|
||||
On<iOS>().EnableTranslucentNavigationBar();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
using System.Windows.Input;
|
||||
|
||||
namespace Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries
|
||||
{
|
||||
public class TabbedPageWindows : TabbedPage
|
||||
{
|
||||
public TabbedPageWindows(ICommand restore)
|
||||
{
|
||||
Children.Add(CreateFirstPage(restore));
|
||||
Children.Add(CreateSecondPage());
|
||||
WindowsPlatformSpecificsGalleryHelpers.AddToolBarItems(this);
|
||||
}
|
||||
|
||||
ContentPage CreateFirstPage(ICommand restore)
|
||||
{
|
||||
var page = new ContentPage { Title = "Content Page Title" };
|
||||
|
||||
var content = new StackLayout
|
||||
{
|
||||
VerticalOptions = LayoutOptions.Fill,
|
||||
HorizontalOptions = LayoutOptions.Fill
|
||||
};
|
||||
content.Children.Add(new Label
|
||||
{
|
||||
Text = "Tabbed Page Windows Features",
|
||||
FontAttributes = FontAttributes.Bold,
|
||||
HorizontalTextAlignment = TextAlignment.Center,
|
||||
VerticalTextAlignment = TextAlignment.Center
|
||||
});
|
||||
|
||||
content.Children.Add(WindowsPlatformSpecificsGalleryHelpers.CreateToolbarPlacementChanger(this));
|
||||
content.Children.Add(WindowsPlatformSpecificsGalleryHelpers.CreateAddRemoveToolBarItemButtons(this));
|
||||
|
||||
var restoreButton = new Button { Text = "Back To Gallery" };
|
||||
restoreButton.Clicked += (sender, args) => restore.Execute(null);
|
||||
content.Children.Add(restoreButton);
|
||||
|
||||
page.Content = content;
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
static Page CreateSecondPage()
|
||||
{
|
||||
var cp = new ContentPage { Title = "Second Content Page" };
|
||||
|
||||
var content = new StackLayout
|
||||
{
|
||||
VerticalOptions = LayoutOptions.Fill,
|
||||
HorizontalOptions = LayoutOptions.Fill
|
||||
};
|
||||
content.Children.Add(new Label
|
||||
{
|
||||
Text = "Page 2",
|
||||
FontAttributes = FontAttributes.Bold,
|
||||
HorizontalTextAlignment = TextAlignment.Center,
|
||||
VerticalTextAlignment = TextAlignment.Center
|
||||
});
|
||||
|
||||
cp.Content = content;
|
||||
|
||||
return cp;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
using System.Windows.Input;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
|
||||
|
||||
namespace Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries
|
||||
{
|
||||
public class VisualElementiOS : ContentPage
|
||||
{
|
||||
public VisualElementiOS(ICommand restore)
|
||||
{
|
||||
var restoreButton = new Button { Text = "Back To Gallery" };
|
||||
restoreButton.Clicked += (sender, args) => restore.Execute(null);
|
||||
|
||||
var image = new Image { Source = ImageSource.FromFile("crimson.jpg") };
|
||||
var box = new BoxView { HeightRequest = 300, WidthRequest = 600 };
|
||||
box.On<iOS>().UseBlurEffect(BlurEffectStyle.Light);
|
||||
Button button1 = GetButton(box, BlurEffectStyle.None);
|
||||
Button button2 = GetButton(box, BlurEffectStyle.ExtraLight);
|
||||
Button button3 = GetButton(box, BlurEffectStyle.Light);
|
||||
Button button4 = GetButton(box, BlurEffectStyle.Dark);
|
||||
var buttons = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { button1, button2, button3, button4 } };
|
||||
|
||||
Content = new StackLayout { Children = { buttons, new AbsoluteLayout { Children = { image, box } } } };
|
||||
Title = "Visual Element Features";
|
||||
}
|
||||
|
||||
Button GetButton(BoxView box, BlurEffectStyle value)
|
||||
{
|
||||
var button1 = new Button { Text = value.ToString(), Margin = 25 };
|
||||
button1.Clicked += (s, e) => { box.On<iOS>().UseBlurEffect(value); };
|
||||
return button1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
|
||||
|
||||
namespace Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries
|
||||
{
|
||||
internal static class WindowsPlatformSpecificsGalleryHelpers
|
||||
{
|
||||
const string CommandBarActionTitle = "Hey!";
|
||||
const string CommandBarActionMessage = "Command Bar Item Clicked";
|
||||
const string CommandBarActionDismiss = "OK";
|
||||
|
||||
public static void AddToolBarItems(Page page)
|
||||
{
|
||||
Action action = () => page.DisplayAlert(CommandBarActionTitle, CommandBarActionMessage, CommandBarActionDismiss);
|
||||
|
||||
var tb1 = new ToolbarItem("Primary 1", "coffee.png", action, ToolbarItemOrder.Primary)
|
||||
{
|
||||
IsEnabled = true,
|
||||
AutomationId = "toolbaritem_primary1"
|
||||
};
|
||||
|
||||
var tb2 = new ToolbarItem("Primary 2", "coffee.png", action, ToolbarItemOrder.Primary)
|
||||
{
|
||||
IsEnabled = true,
|
||||
AutomationId = "toolbaritem_primary2"
|
||||
};
|
||||
|
||||
var tb3 = new ToolbarItem("Seconday 1", "coffee.png", action, ToolbarItemOrder.Secondary)
|
||||
{
|
||||
IsEnabled = true,
|
||||
AutomationId = "toolbaritem_secondary3"
|
||||
};
|
||||
|
||||
var tb4 = new ToolbarItem("Secondary 2", "coffee.png", action, ToolbarItemOrder.Secondary)
|
||||
{
|
||||
IsEnabled = true,
|
||||
AutomationId = "toolbaritem_secondary4"
|
||||
};
|
||||
|
||||
page.ToolbarItems.Add(tb1);
|
||||
page.ToolbarItems.Add(tb2);
|
||||
page.ToolbarItems.Add(tb3);
|
||||
page.ToolbarItems.Add(tb4);
|
||||
}
|
||||
|
||||
public static Layout CreateChanger(Type enumType, string defaultOption, Action<Picker> selectedIndexChanged, string label)
|
||||
{
|
||||
var picker = new Picker();
|
||||
string[] options = Enum.GetNames(enumType);
|
||||
foreach (string option in options)
|
||||
{
|
||||
picker.Items.Add(option);
|
||||
}
|
||||
|
||||
picker.SelectedIndex = options.IndexOf(defaultOption);
|
||||
|
||||
picker.SelectedIndexChanged += (sender, args) =>
|
||||
{
|
||||
selectedIndexChanged(picker);
|
||||
};
|
||||
|
||||
var changerLabel = new Label { Text = label, VerticalOptions = LayoutOptions.Center };
|
||||
|
||||
var layout = new Grid
|
||||
{
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
ColumnDefinitions = new ColumnDefinitionCollection
|
||||
{
|
||||
new ColumnDefinition { Width = 150 },
|
||||
new ColumnDefinition { Width = 100 }
|
||||
},
|
||||
Children = { changerLabel, picker }
|
||||
};
|
||||
|
||||
Grid.SetColumn(changerLabel, 0);
|
||||
Grid.SetColumn(picker, 1);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
public static Layout CreateToolbarPlacementChanger(Page page)
|
||||
{
|
||||
Type enumType = typeof(ToolbarPlacement);
|
||||
|
||||
return CreateChanger(enumType,
|
||||
Enum.GetName(enumType, page.On<Windows>().GetToolbarPlacement()),
|
||||
picker =>
|
||||
{
|
||||
page.On<Windows>().SetToolbarPlacement((ToolbarPlacement)Enum.Parse(enumType, picker.Items[picker.SelectedIndex]));
|
||||
}, "Select Toolbar Placement");
|
||||
}
|
||||
|
||||
public static Layout CreateAddRemoveToolBarItemButtons(Page page)
|
||||
{
|
||||
var layout = new StackLayout { Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.Center };
|
||||
layout.Children.Add(new Label { Text = "Toolbar Items:" });
|
||||
|
||||
var buttonLayout = new StackLayout
|
||||
{
|
||||
Orientation = StackOrientation.Horizontal,
|
||||
HorizontalOptions = LayoutOptions.Center
|
||||
};
|
||||
|
||||
layout.Children.Add(buttonLayout);
|
||||
|
||||
var addPrimary = new Button { Text = "Add Primary", BackgroundColor = Color.Gray };
|
||||
var addSecondary = new Button { Text = "Add Secondary", BackgroundColor = Color.Gray };
|
||||
var remove = new Button { Text = "Remove", BackgroundColor = Color.Gray };
|
||||
|
||||
buttonLayout.Children.Add(addPrimary);
|
||||
buttonLayout.Children.Add(addSecondary);
|
||||
buttonLayout.Children.Add(remove);
|
||||
|
||||
Action action = () => page.DisplayAlert(CommandBarActionTitle, CommandBarActionMessage, CommandBarActionDismiss);
|
||||
|
||||
addPrimary.Clicked += (sender, args) =>
|
||||
{
|
||||
int index = page.ToolbarItems.Count(item => item.Order == ToolbarItemOrder.Primary) + 1;
|
||||
page.ToolbarItems.Add(new ToolbarItem($"Primary {index}", "coffee.png", action, ToolbarItemOrder.Primary));
|
||||
};
|
||||
|
||||
addSecondary.Clicked += (sender, args) =>
|
||||
{
|
||||
int index = page.ToolbarItems.Count(item => item.Order == ToolbarItemOrder.Secondary) + 1;
|
||||
page.ToolbarItems.Add(new ToolbarItem($"Secondary {index}", "coffee.png", action, ToolbarItemOrder.Secondary));
|
||||
};
|
||||
|
||||
remove.Clicked += (sender, args) =>
|
||||
{
|
||||
if (page.ToolbarItems.Any())
|
||||
{
|
||||
page.ToolbarItems.RemoveAt(0);
|
||||
}
|
||||
};
|
||||
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
using Xamarin.Forms.Controls.GalleryPages.PlatformSpecificsGalleries;
|
||||
|
||||
namespace Xamarin.Forms.Controls
|
||||
{
|
||||
public class PlatformSpecificsGallery : ContentPage
|
||||
{
|
||||
Page _originalRoot;
|
||||
|
||||
public PlatformSpecificsGallery()
|
||||
{
|
||||
var mdpWindowsButton = new Button { Text = "Master Detail Page (Windows)" };
|
||||
var npWindowsButton = new Button { Text = "Navigation Page (Windows)" };
|
||||
var tbWindowsButton = new Button { Text = "Tabbed Page (Windows)" };
|
||||
var navpageiOSButton = new Button() { Text = "Navigation Page (iOS)" };
|
||||
var viselemiOSButton = new Button() { Text = "Visual Element (iOS)" };
|
||||
var appAndroidButton = new Button() { Text = "Application (Android)" };
|
||||
|
||||
mdpWindowsButton.Clicked += (sender, args) => { SetRoot(new MasterDetailPageWindows(new Command(RestoreOriginal))); };
|
||||
npWindowsButton.Clicked += (sender, args) => { SetRoot(new NavigationPageWindows(new Command(RestoreOriginal))); };
|
||||
tbWindowsButton.Clicked += (sender, args) => { SetRoot(new TabbedPageWindows(new Command(RestoreOriginal))); };
|
||||
navpageiOSButton.Clicked += (sender, args) => { SetRoot(NavigationPageiOS.Create(new Command(RestoreOriginal))); };
|
||||
viselemiOSButton.Clicked += (sender, args) => { SetRoot(new VisualElementiOS(new Command(RestoreOriginal))); };
|
||||
appAndroidButton.Clicked += (sender, args) => { SetRoot(new ApplicationAndroid(new Command(RestoreOriginal))); };
|
||||
|
||||
Content = new StackLayout
|
||||
{
|
||||
Children = { mdpWindowsButton, npWindowsButton, tbWindowsButton, navpageiOSButton, viselemiOSButton, appAndroidButton }
|
||||
};
|
||||
}
|
||||
|
||||
void SetRoot(Page page)
|
||||
{
|
||||
var app = Application.Current as App;
|
||||
if (app == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_originalRoot = app.MainPage;
|
||||
app.SetMainPage(page);
|
||||
}
|
||||
|
||||
void RestoreOriginal()
|
||||
{
|
||||
if (_originalRoot == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var app = Application.Current as App;
|
||||
app?.SetMainPage(_originalRoot);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -99,8 +99,16 @@
|
|||
<DependentUpon>ControlTemplateXamlPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="GalleryPages\LayoutPerformanceGallery.cs" />
|
||||
<Compile Include="GalleryPages\PlatformSpecificsGalleries\MasterDetailPageWindows.cs" />
|
||||
<Compile Include="GalleryPages\NavigationPropertiesGallery.cs" />
|
||||
<Compile Include="ControlGalleryPages\ListViewSelectionColor.cs" />
|
||||
<Compile Include="GalleryPages\PlatformSpecificsGalleries\NavigationPageiOS.cs" />
|
||||
<Compile Include="GalleryPages\PlatformSpecificsGalleries\NavigationPageWindows.cs" />
|
||||
<Compile Include="GalleryPages\PlatformSpecificsGalleries\ApplicationAndroid.cs" />
|
||||
<Compile Include="GalleryPages\PlatformSpecificsGalleries\TabbedPageWindows.cs" />
|
||||
<Compile Include="GalleryPages\PlatformSpecificsGalleries\VisualElementiOS.cs" />
|
||||
<Compile Include="GalleryPages\PlatformSpecificsGalleries\WindowsPlatformSpecificsGalleryHelpers.cs" />
|
||||
<Compile Include="GalleryPages\PlatformSpecificsGallery.cs" />
|
||||
<Compile Include="LegacyRepro\Page1.xaml.cs">
|
||||
<DependentUpon>Page1.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
|
|
@ -0,0 +1,227 @@
|
|||
using NUnit.Framework;
|
||||
using ImAVendor.Forms.PlatformConfiguration.iOS;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
|
||||
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
|
||||
|
||||
namespace Xamarin.Forms.Core.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class PlatformSpecificsTests
|
||||
{
|
||||
[Test]
|
||||
public void VendorPlatformProperty()
|
||||
{
|
||||
var x = new MasterDetailPage();
|
||||
|
||||
Assert.IsTrue(x.On<iOS>().GetVendorFoo());
|
||||
|
||||
x.On<iOS>().SetVendorFoo(false);
|
||||
|
||||
Assert.IsFalse(x.On<iOS>().GetVendorFoo());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConsumeVendorSetting()
|
||||
{
|
||||
var x = new MasterDetailPage();
|
||||
x.On<iOS>().SetVendorFoo(false);
|
||||
|
||||
Assert.IsFalse(x.On<iOS>().GetVendorFoo());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Properties()
|
||||
{
|
||||
var x = new MasterDetailPage();
|
||||
x.On<Android>().SetSomeAndroidThing(42);
|
||||
|
||||
Assert.IsTrue(x.On<Android>().GetSomeAndroidThing() == 42);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConvenienceConfiguration()
|
||||
{
|
||||
var x = new MasterDetailPage();
|
||||
|
||||
x.On<Android>().UseTabletDefaults();
|
||||
|
||||
Assert.IsTrue(x.On<Android>().GetSomeAndroidThing() == 10);
|
||||
Assert.IsTrue(x.On<Android>().GetSomeOtherAndroidThing() == 45);
|
||||
|
||||
x.On<Android>().UsePhabletDefaults();
|
||||
|
||||
Assert.IsTrue(x.On<Android>().GetSomeAndroidThing() == 8);
|
||||
Assert.IsTrue(x.On<Android>().GetSomeOtherAndroidThing() == 40);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NavigationPageiOSConfiguration()
|
||||
{
|
||||
var x = new NavigationPage();
|
||||
|
||||
x.On<iOS>().SetIsNavigationBarTranslucent(true);
|
||||
|
||||
Assert.IsTrue(x.On<iOS>().IsNavigationBarTranslucent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace ImAVendor.Forms.PlatformConfiguration.iOS
|
||||
{
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using FormsElement = Xamarin.Forms.MasterDetailPage;
|
||||
|
||||
public static class MasterDetailPage
|
||||
{
|
||||
public static readonly BindableProperty FooProperty =
|
||||
BindableProperty.Create("VendorFoo", typeof(bool),
|
||||
typeof(MasterDetailPage), true);
|
||||
|
||||
public static void SetVendorFoo(BindableObject element, bool value)
|
||||
{
|
||||
element.SetValue(FooProperty, value);
|
||||
}
|
||||
|
||||
public static bool GetVendorFoo(BindableObject element)
|
||||
{
|
||||
return (bool)element.GetValue(FooProperty);
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<iOS, FormsElement> SetVendorFoo(this IPlatformElementConfiguration<iOS, FormsElement> config, bool value)
|
||||
{
|
||||
SetVendorFoo(config.Element, value);
|
||||
return config;
|
||||
}
|
||||
|
||||
public static bool GetVendorFoo(this IPlatformElementConfiguration<iOS, FormsElement> mdp)
|
||||
{
|
||||
return GetVendorFoo(mdp.Element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace ImAVendor.Forms.PlatformConfiguration.iOS
|
||||
{
|
||||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using FormsElement = Xamarin.Forms.NavigationPage;
|
||||
|
||||
public static class NavigationPage
|
||||
{
|
||||
const string NavBarTranslucentEffectName = "XamControl.NavigationPageTranslucentEffect";
|
||||
|
||||
public static readonly BindableProperty IsNavigationBarTranslucentProperty =
|
||||
BindableProperty.CreateAttached("IsNavigationBarTranslucent", typeof(bool),
|
||||
typeof(NavigationPage), false, propertyChanging: IsNavigationBarTranslucentPropertyChanging);
|
||||
|
||||
public static bool GetIsNavigationBarTranslucent(BindableObject element)
|
||||
{
|
||||
return (bool)element.GetValue(IsNavigationBarTranslucentProperty);
|
||||
}
|
||||
|
||||
public static void SetIsNavigationBarTranslucent(BindableObject element, bool value)
|
||||
{
|
||||
element.SetValue(IsNavigationBarTranslucentProperty, value);
|
||||
}
|
||||
|
||||
public static bool IsNavigationBarTranslucentVendor(this IPlatformElementConfiguration<iOS, FormsElement> config)
|
||||
{
|
||||
return GetIsNavigationBarTranslucent(config.Element);
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<iOS, FormsElement> EnableTranslucentNavigationBarVendor(this IPlatformElementConfiguration<iOS, FormsElement> config, bool value)
|
||||
{
|
||||
SetIsNavigationBarTranslucent(config.Element, value);
|
||||
return config;
|
||||
}
|
||||
|
||||
static void IsNavigationBarTranslucentPropertyChanging(BindableObject bindable, object oldValue, object newValue)
|
||||
{
|
||||
AttachEffect(bindable as FormsElement);
|
||||
}
|
||||
|
||||
static void AttachEffect(FormsElement element)
|
||||
{
|
||||
IElementController controller = element;
|
||||
if (controller == null || controller.EffectIsAttached(NavBarTranslucentEffectName))
|
||||
return;
|
||||
|
||||
element.Effects.Add(Effect.Resolve(NavBarTranslucentEffectName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Xamarin.Forms.PlatformConfiguration.AndroidSpecific
|
||||
{
|
||||
using FormsElement = Xamarin.Forms.MasterDetailPage;
|
||||
|
||||
public static class MasterDetailPage
|
||||
{
|
||||
public static readonly BindableProperty SomeAndroidThingProperty =
|
||||
BindableProperty.Create("SomeAndroidThing", typeof(int),
|
||||
typeof(MasterDetailPage), 1);
|
||||
|
||||
public static readonly BindableProperty SomeOtherAndroidThingProperty =
|
||||
BindableProperty.Create("SomeOtherAndroidThing", typeof(int),
|
||||
typeof(MasterDetailPage), 1);
|
||||
|
||||
public static int GetSomeAndroidThing(BindableObject element)
|
||||
{
|
||||
return (int)element.GetValue(SomeAndroidThingProperty);
|
||||
}
|
||||
|
||||
public static void SetSomeAndroidThing(BindableObject element, int value)
|
||||
{
|
||||
element.SetValue(SomeAndroidThingProperty, value);
|
||||
}
|
||||
|
||||
public static int GetSomeOtherAndroidThing(BindableObject element)
|
||||
{
|
||||
return (int)element.GetValue(SomeOtherAndroidThingProperty);
|
||||
}
|
||||
|
||||
public static void SetSomeOtherAndroidThing(BindableObject element, int value)
|
||||
{
|
||||
element.SetValue(SomeOtherAndroidThingProperty, value);
|
||||
}
|
||||
|
||||
public static int GetSomeAndroidThing(this IPlatformElementConfiguration<Android, FormsElement> config)
|
||||
{
|
||||
return (int)config.Element.GetValue(SomeAndroidThingProperty);
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<Android, FormsElement> SetSomeAndroidThing(this IPlatformElementConfiguration<Android, FormsElement> config,
|
||||
int value)
|
||||
{
|
||||
config.Element.SetValue(SomeAndroidThingProperty, value);
|
||||
return config;
|
||||
}
|
||||
|
||||
public static int GetSomeOtherAndroidThing(this IPlatformElementConfiguration<Android, FormsElement> config)
|
||||
{
|
||||
return (int)config.Element.GetValue(SomeOtherAndroidThingProperty);
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<Android, FormsElement> SetSomeOtherAndroidThing(this IPlatformElementConfiguration<Android, FormsElement> config, int value)
|
||||
{
|
||||
config.Element.SetValue(SomeOtherAndroidThingProperty, value);
|
||||
return config;
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<Android, FormsElement> UseTabletDefaults(this IPlatformElementConfiguration<Android, FormsElement> config)
|
||||
{
|
||||
config.SetSomeAndroidThing(10);
|
||||
config.SetSomeOtherAndroidThing(45);
|
||||
return config;
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<Android, FormsElement> UsePhabletDefaults(this IPlatformElementConfiguration<Android, FormsElement> config)
|
||||
{
|
||||
config.SetSomeAndroidThing(8);
|
||||
config.SetSomeOtherAndroidThing(40);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -122,6 +122,7 @@
|
|||
<Compile Include="PageTests.cs" />
|
||||
<Compile Include="PanGestureRecognizerUnitTests.cs" />
|
||||
<Compile Include="PinTests.cs" />
|
||||
<Compile Include="PlatformSpecificsTests.cs" />
|
||||
<Compile Include="PointTests.cs" />
|
||||
<Compile Include="PositionTests.cs" />
|
||||
<Compile Include="ProgressBarTests.cs" />
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
using System;
|
||||
using Xamarin.Forms.Platform;
|
||||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_ActivityIndicatorRenderer))]
|
||||
public class ActivityIndicator : View
|
||||
public class ActivityIndicator : View, IElementConfiguration<ActivityIndicator>
|
||||
{
|
||||
public static readonly BindableProperty IsRunningProperty = BindableProperty.Create("IsRunning", typeof(bool), typeof(ActivityIndicator), default(bool));
|
||||
|
||||
public static readonly BindableProperty ColorProperty = BindableProperty.Create("Color", typeof(Color), typeof(ActivityIndicator), Color.Default);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<ActivityIndicator>> _platformConfigurationRegistry;
|
||||
|
||||
public ActivityIndicator()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<ActivityIndicator>>(() => new PlatformConfigurationRegistry<ActivityIndicator>(this));
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return (Color)GetValue(ColorProperty); }
|
||||
|
@ -20,5 +28,9 @@ namespace Xamarin.Forms
|
|||
get { return (bool)GetValue(IsRunningProperty); }
|
||||
set { SetValue(IsRunningProperty, value); }
|
||||
}
|
||||
public IPlatformElementConfiguration<T, ActivityIndicator> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,10 +6,11 @@ using Xamarin.Forms.Platform;
|
|||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
public class Application : Element, IResourcesProvider, IApplicationController
|
||||
public class Application : Element, IResourcesProvider, IApplicationController, IElementConfiguration<Application>
|
||||
{
|
||||
static Application s_current;
|
||||
readonly Task<IDictionary<string, object>> _propertiesTask;
|
||||
readonly Lazy<PlatformConfigurationRegistry<Application>> _platformConfigurationRegistry;
|
||||
|
||||
IAppIndexingProvider _appIndexProvider;
|
||||
bool _isSaving;
|
||||
|
@ -32,6 +33,7 @@ namespace Xamarin.Forms
|
|||
|
||||
SystemResources = DependencyService.Get<ISystemResourcesProvider>().GetSystemResources();
|
||||
SystemResources.ValuesChanged += OnParentResourcesChanged;
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Application>>(() => new PlatformConfigurationRegistry<Application>(this));
|
||||
}
|
||||
|
||||
public IAppLinks AppLinks
|
||||
|
@ -146,6 +148,11 @@ namespace Xamarin.Forms
|
|||
await SetPropertiesAsync();
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, Application> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
|
||||
protected virtual void OnAppLinkRequestReceived(Uri uri)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -4,16 +4,28 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_BoxViewRenderer))]
|
||||
public class BoxView : View
|
||||
public class BoxView : View, IElementConfiguration<BoxView>
|
||||
{
|
||||
public static readonly BindableProperty ColorProperty = BindableProperty.Create("Color", typeof(Color), typeof(BoxView), Color.Default);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<BoxView>> _platformConfigurationRegistry;
|
||||
|
||||
public BoxView()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<BoxView>>(() => new PlatformConfigurationRegistry<BoxView>(this));
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return (Color)GetValue(ColorProperty); }
|
||||
set { SetValue(ColorProperty, value); }
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, BoxView> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
|
||||
[Obsolete("Use OnMeasure")]
|
||||
protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_ButtonRenderer))]
|
||||
public class Button : View, IFontElement, IButtonController
|
||||
public class Button : View, IFontElement, IButtonController, IElementConfiguration<Button>
|
||||
{
|
||||
public static readonly BindableProperty CommandProperty = BindableProperty.Create("Command", typeof(ICommand), typeof(Button), null, propertyChanged: (bo, o, n) => ((Button)bo).OnCommandChanged());
|
||||
|
||||
|
@ -43,6 +43,8 @@ namespace Xamarin.Forms
|
|||
propertyChanging: (bindable, oldvalue, newvalue) => ((Button)bindable).OnSourcePropertyChanging((ImageSource)oldvalue, (ImageSource)newvalue),
|
||||
propertyChanged: (bindable, oldvalue, newvalue) => ((Button)bindable).OnSourcePropertyChanged((ImageSource)oldvalue, (ImageSource)newvalue));
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<Button>> _platformConfigurationRegistry;
|
||||
|
||||
bool _cancelEvents;
|
||||
|
||||
const double DefaultSpacing = 10;
|
||||
|
@ -144,6 +146,16 @@ namespace Xamarin.Forms
|
|||
|
||||
public event EventHandler Clicked;
|
||||
|
||||
public Button()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Button>>(() => new PlatformConfigurationRegistry<Button>(this));
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, Button> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
|
||||
protected override void OnBindingContextChanged()
|
||||
{
|
||||
FileImageSource image = Image;
|
||||
|
|
|
@ -1,10 +1,23 @@
|
|||
using System;
|
||||
using Xamarin.Forms.Platform;
|
||||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_CarouselPageRenderer))]
|
||||
public class CarouselPage : MultiPage<ContentPage>
|
||||
public class CarouselPage : MultiPage<ContentPage>, IElementConfiguration<CarouselPage>
|
||||
{
|
||||
readonly Lazy<PlatformConfigurationRegistry<CarouselPage>> _platformConfigurationRegistry;
|
||||
|
||||
public CarouselPage()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<CarouselPage>>(() => new PlatformConfigurationRegistry<CarouselPage>(this));
|
||||
}
|
||||
|
||||
public new IPlatformElementConfiguration<T, CarouselPage> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
|
||||
protected override ContentPage CreateDefault(object item)
|
||||
{
|
||||
var page = new ContentPage();
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
public class Configuration<TPlatform, TElement> : IPlatformElementConfiguration<TPlatform, TElement>
|
||||
where TPlatform : IConfigPlatform
|
||||
where TElement : Element
|
||||
|
||||
{
|
||||
public Configuration(TElement element)
|
||||
{
|
||||
Element = element;
|
||||
}
|
||||
|
||||
public TElement Element { get; }
|
||||
|
||||
public static Configuration<TPlatform, TElement> Create(TElement element)
|
||||
{
|
||||
return new Configuration<TPlatform, TElement>(element);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_DatePickerRenderer))]
|
||||
public class DatePicker : View
|
||||
public class DatePicker : View, IElementConfiguration<DatePicker>
|
||||
{
|
||||
public static readonly BindableProperty FormatProperty = BindableProperty.Create(nameof(Format), typeof(string), typeof(DatePicker), "d");
|
||||
|
||||
|
@ -19,6 +19,13 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty TextColorProperty = BindableProperty.Create(nameof(TextColor), typeof(Color), typeof(DatePicker), Color.Default);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<DatePicker>> _platformConfigurationRegistry;
|
||||
|
||||
public DatePicker()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<DatePicker>>(() => new PlatformConfigurationRegistry<DatePicker>(this));
|
||||
}
|
||||
|
||||
public DateTime Date
|
||||
{
|
||||
get { return (DateTime)GetValue(DateProperty); }
|
||||
|
@ -103,5 +110,10 @@ namespace Xamarin.Forms
|
|||
{
|
||||
return (DateTime)value <= ((DatePicker)bindable).MaximumDate;
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, DatePicker> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_EditorRenderer))]
|
||||
public class Editor : InputView, IFontElement
|
||||
public class Editor : InputView, IFontElement, IElementConfiguration<Editor>
|
||||
{
|
||||
public static readonly BindableProperty TextProperty = BindableProperty.Create("Text", typeof(string), typeof(Editor), null, BindingMode.TwoWay, propertyChanged: (bindable, oldValue, newValue) =>
|
||||
{
|
||||
|
@ -21,6 +21,7 @@ namespace Xamarin.Forms
|
|||
public static readonly BindableProperty FontAttributesProperty = BindableProperty.Create("FontAttributes", typeof(FontAttributes), typeof(Editor), FontAttributes.None);
|
||||
|
||||
public static readonly BindableProperty TextColorProperty = BindableProperty.Create("TextColor", typeof(Color), typeof(Editor), Color.Default);
|
||||
readonly Lazy<PlatformConfigurationRegistry<Editor>> _platformConfigurationRegistry;
|
||||
|
||||
public string Text
|
||||
{
|
||||
|
@ -57,6 +58,16 @@ namespace Xamarin.Forms
|
|||
|
||||
public event EventHandler<TextChangedEventArgs> TextChanged;
|
||||
|
||||
public Editor()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Editor>>(() => new PlatformConfigurationRegistry<Editor>(this));
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, Editor> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
|
||||
internal void SendCompleted()
|
||||
{
|
||||
EventHandler handler = Completed;
|
||||
|
|
|
@ -254,6 +254,16 @@ namespace Xamarin.Forms
|
|||
SetValueCore(property, value);
|
||||
}
|
||||
|
||||
bool IElementController.EffectIsAttached(string name)
|
||||
{
|
||||
foreach (var effect in Effects)
|
||||
{
|
||||
if (effect.ResolveId == name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
object INameScope.FindByName(string name)
|
||||
{
|
||||
INameScope namescope = GetNameScope();
|
||||
|
|
|
@ -4,7 +4,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_EntryRenderer))]
|
||||
public class Entry : InputView, IFontElement, IEntryController
|
||||
public class Entry : InputView, IFontElement, IEntryController, IElementConfiguration<Entry>
|
||||
{
|
||||
public static readonly BindableProperty PlaceholderProperty = BindableProperty.Create("Placeholder", typeof(string), typeof(Entry), default(string));
|
||||
|
||||
|
@ -25,6 +25,13 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty FontAttributesProperty = BindableProperty.Create("FontAttributes", typeof(FontAttributes), typeof(Entry), FontAttributes.None);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<Entry>> _platformConfigurationRegistry;
|
||||
|
||||
public Entry()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Entry>>(() => new PlatformConfigurationRegistry<Entry>(this));
|
||||
}
|
||||
|
||||
public TextAlignment HorizontalTextAlignment
|
||||
{
|
||||
get { return (TextAlignment)GetValue(HorizontalTextAlignmentProperty); }
|
||||
|
@ -95,5 +102,10 @@ namespace Xamarin.Forms
|
|||
|
||||
entry.TextChanged?.Invoke(entry, new TextChangedEventArgs((string)oldValue, (string)newValue));
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, Entry> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +1,22 @@
|
|||
using System;
|
||||
using Xamarin.Forms.Platform;
|
||||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
[ContentProperty("Content")]
|
||||
[RenderWith(typeof(_FrameRenderer))]
|
||||
public class Frame : ContentView
|
||||
public class Frame : ContentView, IElementConfiguration<Frame>
|
||||
{
|
||||
public static readonly BindableProperty OutlineColorProperty = BindableProperty.Create("OutlineColor", typeof(Color), typeof(Frame), Color.Default);
|
||||
|
||||
public static readonly BindableProperty HasShadowProperty = BindableProperty.Create("HasShadow", typeof(bool), typeof(Frame), true);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<Frame>> _platformConfigurationRegistry;
|
||||
|
||||
public Frame()
|
||||
{
|
||||
Padding = new Size(20, 20);
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Frame>>(() => new PlatformConfigurationRegistry<Frame>(this));
|
||||
}
|
||||
|
||||
public bool HasShadow
|
||||
|
@ -26,5 +30,10 @@ namespace Xamarin.Forms
|
|||
get { return (Color)GetValue(OutlineColorProperty); }
|
||||
set { SetValue(OutlineColorProperty, value); }
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, Frame> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
public interface IConfigElement<out T> where T : Element
|
||||
{
|
||||
T Element { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
public interface IConfigPlatform { }
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
public interface IElementConfiguration<out TElement> where TElement : Element
|
||||
{
|
||||
IPlatformElementConfiguration<T, TElement> On<T>() where T : IConfigPlatform;
|
||||
}
|
||||
}
|
|
@ -6,6 +6,8 @@ namespace Xamarin.Forms
|
|||
{
|
||||
IEffectControlProvider EffectControlProvider { get; set; }
|
||||
|
||||
bool EffectIsAttached(string name);
|
||||
|
||||
void SetValueFromRenderer(BindableProperty property, object value);
|
||||
void SetValueFromRenderer(BindablePropertyKey propertyKey, object value);
|
||||
ReadOnlyCollection<Element> LogicalChildren { get; }
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
public interface IPlatformElementConfiguration<out TPlatform, out TElement> : IConfigElement<TElement>
|
||||
where TPlatform : IConfigPlatform
|
||||
where TElement : Element
|
||||
{
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_ImageRenderer))]
|
||||
public class Image : View, IImageController
|
||||
public class Image : View, IImageController, IElementConfiguration<Image>
|
||||
{
|
||||
public static readonly BindableProperty SourceProperty = BindableProperty.Create("Source", typeof(ImageSource), typeof(Image), default(ImageSource),
|
||||
propertyChanging: OnSourcePropertyChanging, propertyChanged: OnSourcePropertyChanged);
|
||||
|
@ -20,6 +20,13 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty IsLoadingProperty = IsLoadingPropertyKey.BindableProperty;
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<Image>> _platformConfigurationRegistry;
|
||||
|
||||
public Image()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Image>>(() => new PlatformConfigurationRegistry<Image>(this));
|
||||
}
|
||||
|
||||
public Aspect Aspect
|
||||
{
|
||||
get { return (Aspect)GetValue(AspectProperty); }
|
||||
|
@ -157,5 +164,10 @@ namespace Xamarin.Forms
|
|||
{
|
||||
SetValue(IsLoadingPropertyKey, isLoading);
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, Image> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,17 +7,19 @@ namespace Xamarin.Forms
|
|||
{
|
||||
[ContentProperty("Text")]
|
||||
[RenderWith(typeof(_LabelRenderer))]
|
||||
public class Label : View, IFontElement
|
||||
public class Label : View, IFontElement, IElementConfiguration<Label>
|
||||
{
|
||||
public static readonly BindableProperty HorizontalTextAlignmentProperty = BindableProperty.Create("HorizontalTextAlignment", typeof(TextAlignment), typeof(Label), TextAlignment.Start,
|
||||
propertyChanged: OnHorizontalTextAlignmentPropertyChanged);
|
||||
|
||||
[Obsolete("XAlignProperty is obsolete. Please use HorizontalTextAlignmentProperty instead.")] public static readonly BindableProperty XAlignProperty = HorizontalTextAlignmentProperty;
|
||||
[Obsolete("XAlignProperty is obsolete. Please use HorizontalTextAlignmentProperty instead.")]
|
||||
public static readonly BindableProperty XAlignProperty = HorizontalTextAlignmentProperty;
|
||||
|
||||
public static readonly BindableProperty VerticalTextAlignmentProperty = BindableProperty.Create("VerticalTextAlignment", typeof(TextAlignment), typeof(Label), TextAlignment.Start,
|
||||
propertyChanged: OnVerticalTextAlignmentPropertyChanged);
|
||||
|
||||
[Obsolete("YAlignProperty is obsolete. Please use VerticalTextAlignmentProperty instead.")] public static readonly BindableProperty YAlignProperty = VerticalTextAlignmentProperty;
|
||||
[Obsolete("YAlignProperty is obsolete. Please use VerticalTextAlignmentProperty instead.")]
|
||||
public static readonly BindableProperty YAlignProperty = VerticalTextAlignmentProperty;
|
||||
|
||||
public static readonly BindableProperty TextColorProperty = BindableProperty.Create("TextColor", typeof(Color), typeof(Label), Color.Default);
|
||||
|
||||
|
@ -50,6 +52,13 @@ namespace Xamarin.Forms
|
|||
public static readonly BindableProperty LineBreakModeProperty = BindableProperty.Create("LineBreakMode", typeof(LineBreakMode), typeof(Label), LineBreakMode.WordWrap,
|
||||
propertyChanged: (bindable, oldvalue, newvalue) => ((Label)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged));
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<Label>> _platformConfigurationRegistry;
|
||||
|
||||
public Label()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Label>>(() => new PlatformConfigurationRegistry<Label>(this));
|
||||
}
|
||||
|
||||
bool _cancelEvents;
|
||||
|
||||
[Obsolete("Please use the Font attributes which are on the class itself. Obsoleted in v1.3.0")]
|
||||
|
@ -284,5 +293,10 @@ namespace Xamarin.Forms
|
|||
label.OnPropertyChanged(nameof(YAlign));
|
||||
#pragma warning restore 0618
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, Label> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ using Xamarin.Forms.Internals;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_ListViewRenderer))]
|
||||
public class ListView : ItemsView<Cell>, IListViewController
|
||||
public class ListView : ItemsView<Cell>, IListViewController, IElementConfiguration<ListView>
|
||||
|
||||
{
|
||||
public static readonly BindableProperty IsPullToRefreshEnabledProperty = BindableProperty.Create("IsPullToRefreshEnabled", typeof(bool), typeof(ListView), false);
|
||||
|
@ -43,6 +43,8 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty SeparatorColorProperty = BindableProperty.Create("SeparatorColor", typeof(Color), typeof(ListView), Color.Default);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<ListView>> _platformConfigurationRegistry;
|
||||
|
||||
BindingBase _groupDisplayBinding;
|
||||
|
||||
BindingBase _groupShortNameBinding;
|
||||
|
@ -64,6 +66,7 @@ namespace Xamarin.Forms
|
|||
|
||||
TemplatedItems.IsGroupingEnabledProperty = IsGroupingEnabledProperty;
|
||||
TemplatedItems.GroupHeaderTemplateProperty = GroupHeaderTemplateProperty;
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<ListView>>(() => new PlatformConfigurationRegistry<ListView>(this));
|
||||
}
|
||||
|
||||
public ListView([Parameter("CachingStrategy")] ListViewCachingStrategy cachingStrategy) : this()
|
||||
|
@ -573,5 +576,10 @@ namespace Xamarin.Forms
|
|||
var template = (DataTemplate)value;
|
||||
return template.CreateContent() is View;
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, ListView> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Xamarin.Forms.Platform;
|
||||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_MasterDetailPageRenderer))]
|
||||
public class MasterDetailPage : Page, IMasterDetailPageController
|
||||
public class MasterDetailPage : Page, IMasterDetailPageController, IElementConfiguration<MasterDetailPage>
|
||||
{
|
||||
public static readonly BindableProperty IsGestureEnabledProperty = BindableProperty.Create("IsGestureEnabled", typeof(bool), typeof(MasterDetailPage), true);
|
||||
|
||||
|
@ -237,5 +238,17 @@ namespace Xamarin.Forms
|
|||
var page = (MasterDetailPage)sender;
|
||||
UpdateMasterBehavior(page);
|
||||
}
|
||||
|
||||
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>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,10 +7,17 @@ namespace Xamarin.Forms
|
|||
{
|
||||
// Mark as internal until renderers are ready for release after 1.0
|
||||
[RenderWith(typeof(_NavigationMenuRenderer))]
|
||||
internal class NavigationMenu : View
|
||||
internal class NavigationMenu : View, IElementConfiguration<NavigationMenu>
|
||||
{
|
||||
readonly List<Page> _targets = new List<Page>();
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<NavigationMenu>> _platformConfigurationRegistry;
|
||||
|
||||
public NavigationMenu()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<NavigationMenu>>(() => new PlatformConfigurationRegistry<NavigationMenu>(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Page> Targets
|
||||
{
|
||||
get { return _targets; }
|
||||
|
@ -52,6 +59,11 @@ namespace Xamarin.Forms
|
|||
}
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, NavigationMenu> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
|
||||
internal void SendTargetSelected(Page target)
|
||||
{
|
||||
TargetSelected(target);
|
||||
|
|
|
@ -8,7 +8,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_NavigationPageRenderer))]
|
||||
public class NavigationPage : Page, IPageContainer<Page>, INavigationPageController
|
||||
public class NavigationPage : Page, IPageContainer<Page>, INavigationPageController, IElementConfiguration<NavigationPage>
|
||||
{
|
||||
public static readonly BindableProperty BackButtonTitleProperty = BindableProperty.CreateAttached("BackButtonTitle", typeof(string), typeof(Page), null);
|
||||
|
||||
|
@ -27,9 +27,11 @@ namespace Xamarin.Forms
|
|||
|
||||
static readonly BindablePropertyKey CurrentPagePropertyKey = BindableProperty.CreateReadOnly("CurrentPage", typeof(Page), typeof(NavigationPage), null);
|
||||
public static readonly BindableProperty CurrentPageProperty = CurrentPagePropertyKey.BindableProperty;
|
||||
|
||||
|
||||
public NavigationPage()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<NavigationPage>>(() => new PlatformConfigurationRegistry<NavigationPage>(this));
|
||||
|
||||
Navigation = new NavigationImpl(this);
|
||||
}
|
||||
|
||||
|
@ -441,5 +443,12 @@ namespace Xamarin.Forms
|
|||
Owner.RemovePage(page);
|
||||
}
|
||||
}
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<NavigationPage>> _platformConfigurationRegistry;
|
||||
|
||||
public new IPlatformElementConfiguration<T, NavigationPage> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,12 +4,14 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_OpenGLViewRenderer))]
|
||||
public sealed class OpenGLView : View, IOpenGlViewController
|
||||
public sealed class OpenGLView : View, IOpenGlViewController, IElementConfiguration<OpenGLView>
|
||||
{
|
||||
#region Statics
|
||||
|
||||
public static readonly BindableProperty HasRenderLoopProperty = BindableProperty.Create("HasRenderLoop", typeof(bool), typeof(OpenGLView), default(bool));
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<OpenGLView>> _platformConfigurationRegistry;
|
||||
|
||||
#endregion
|
||||
|
||||
public bool HasRenderLoop
|
||||
|
@ -34,5 +36,15 @@ namespace Xamarin.Forms
|
|||
}
|
||||
|
||||
event EventHandler DisplayRequested;
|
||||
|
||||
public OpenGLView()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<OpenGLView>>(() => new PlatformConfigurationRegistry<OpenGLView>(this));
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, OpenGLView> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_PageRenderer))]
|
||||
public class Page : VisualElement, ILayout, IPageController
|
||||
public class Page : VisualElement, ILayout, IPageController, IElementConfiguration<Page>
|
||||
{
|
||||
public const string BusySetSignalName = "Xamarin.BusySet";
|
||||
|
||||
|
@ -35,6 +35,8 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty IconProperty = BindableProperty.Create("Icon", typeof(FileImageSource), typeof(Page), default(FileImageSource));
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<Page>> _platformConfigurationRegistry;
|
||||
|
||||
bool _allocatedFlag;
|
||||
Rectangle _containerArea;
|
||||
|
||||
|
@ -53,6 +55,7 @@ namespace Xamarin.Forms
|
|||
toolbarItems.CollectionChanged += OnToolbarItemsCollectionChanged;
|
||||
ToolbarItems = toolbarItems;
|
||||
PageController.InternalChildren.CollectionChanged += InternalChildrenOnCollectionChanged;
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Page>>(() => new PlatformConfigurationRegistry<Page>(this));
|
||||
}
|
||||
|
||||
public string BackgroundImage
|
||||
|
@ -401,5 +404,10 @@ namespace Xamarin.Forms
|
|||
}
|
||||
return !any;
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, Page> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_PickerRenderer))]
|
||||
public class Picker : View
|
||||
public class Picker : View, IElementConfiguration<Picker>
|
||||
{
|
||||
public static readonly BindableProperty TextColorProperty = BindableProperty.Create(nameof(TextColor), typeof(Color), typeof(Picker), Color.Default);
|
||||
|
||||
|
@ -20,10 +20,13 @@ namespace Xamarin.Forms
|
|||
eh(bindable, EventArgs.Empty);
|
||||
}, coerceValue: CoerceSelectedIndex);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<Picker>> _platformConfigurationRegistry;
|
||||
|
||||
public Picker()
|
||||
{
|
||||
Items = new ObservableList<string>();
|
||||
((ObservableList<string>)Items).CollectionChanged += OnItemsCollectionChanged;
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Picker>>(() => new PlatformConfigurationRegistry<Picker>(this));
|
||||
}
|
||||
|
||||
public IList<string> Items { get; }
|
||||
|
@ -58,5 +61,10 @@ namespace Xamarin.Forms
|
|||
{
|
||||
SelectedIndex = SelectedIndex.Clamp(-1, Items.Count - 1);
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, Picker> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
namespace Xamarin.Forms.PlatformConfiguration.AndroidSpecific
|
||||
{
|
||||
using FormsElement = Forms.Application;
|
||||
|
||||
public enum WindowSoftInputModeAdjust
|
||||
{
|
||||
Pan,
|
||||
Resize
|
||||
}
|
||||
|
||||
public static class Application
|
||||
{
|
||||
public static readonly BindableProperty WindowSoftInputModeAdjustProperty =
|
||||
BindableProperty.Create("WindowSoftInputModeAdjust", typeof(WindowSoftInputModeAdjust),
|
||||
typeof(Application), WindowSoftInputModeAdjust.Pan);
|
||||
|
||||
public static WindowSoftInputModeAdjust GetWindowSoftInputModeAdjust(BindableObject element)
|
||||
{
|
||||
return (WindowSoftInputModeAdjust)element.GetValue(WindowSoftInputModeAdjustProperty);
|
||||
}
|
||||
|
||||
public static void SetWindowSoftInputModeAdjust(BindableObject element, WindowSoftInputModeAdjust value)
|
||||
{
|
||||
element.SetValue(WindowSoftInputModeAdjustProperty, value);
|
||||
}
|
||||
|
||||
public static WindowSoftInputModeAdjust GetWindowSoftInputModeAdjust(this IPlatformElementConfiguration<Android, FormsElement> config)
|
||||
{
|
||||
return GetWindowSoftInputModeAdjust(config.Element);
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<Android, FormsElement> UseWindowSoftInputModeAdjust(this IPlatformElementConfiguration<Android, FormsElement> config, WindowSoftInputModeAdjust value)
|
||||
{
|
||||
SetWindowSoftInputModeAdjust(config.Element, value);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
namespace Xamarin.Forms.PlatformConfiguration
|
||||
{
|
||||
public sealed class Android : IConfigPlatform { }
|
||||
public sealed class iOS : IConfigPlatform { }
|
||||
public sealed class Windows : IConfigPlatform { }
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
namespace Xamarin.Forms.PlatformConfiguration.WindowsSpecific
|
||||
{
|
||||
public enum CollapseStyle
|
||||
{
|
||||
Full,
|
||||
Partial
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
using System;
|
||||
|
||||
namespace Xamarin.Forms.PlatformConfiguration.WindowsSpecific
|
||||
{
|
||||
using FormsElement = Forms.MasterDetailPage;
|
||||
|
||||
public static class MasterDetailPage
|
||||
{
|
||||
#region CollapsedStyle
|
||||
|
||||
public static readonly BindableProperty CollapseStyleProperty =
|
||||
BindableProperty.CreateAttached("CollapseStyle", typeof(CollapseStyle),
|
||||
typeof(MasterDetailPage), CollapseStyle.Full);
|
||||
|
||||
public static CollapseStyle GetCollapseStyle(BindableObject element)
|
||||
{
|
||||
return (CollapseStyle)element.GetValue(CollapseStyleProperty);
|
||||
}
|
||||
|
||||
public static void SetCollapseStyle(BindableObject element, CollapseStyle collapseStyle)
|
||||
{
|
||||
element.SetValue(CollapseStyleProperty, collapseStyle);
|
||||
}
|
||||
|
||||
public static CollapseStyle GetCollapseStyle(this IPlatformElementConfiguration<Windows, FormsElement> config)
|
||||
{
|
||||
return (CollapseStyle)config.Element.GetValue(CollapseStyleProperty);
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<Windows, FormsElement> SetCollapseStyle(
|
||||
this IPlatformElementConfiguration<Windows, FormsElement> config, CollapseStyle value)
|
||||
{
|
||||
config.Element.SetValue(CollapseStyleProperty, value);
|
||||
return config;
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<Windows, FormsElement> UsePartialCollapse(
|
||||
this IPlatformElementConfiguration<Windows, FormsElement> config)
|
||||
{
|
||||
SetCollapseStyle(config, CollapseStyle.Partial);
|
||||
return config;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CollapsedPaneWidth
|
||||
|
||||
public static readonly BindableProperty CollapsedPaneWidthProperty =
|
||||
BindableProperty.CreateAttached("CollapsedPaneWidth", typeof(double),
|
||||
typeof(MasterDetailPage), 48d, validateValue: (bindable, value) => (double)value >= 0);
|
||||
|
||||
public static double GetCollapsedPaneWidth(BindableObject element)
|
||||
{
|
||||
return (double)element.GetValue(CollapsedPaneWidthProperty);
|
||||
}
|
||||
|
||||
public static void SetCollapsedPaneWidth(BindableObject element, double collapsedPaneWidth)
|
||||
{
|
||||
element.SetValue(CollapsedPaneWidthProperty, collapsedPaneWidth);
|
||||
}
|
||||
|
||||
public static double CollapsedPaneWidth(this IPlatformElementConfiguration<Windows, FormsElement> config)
|
||||
{
|
||||
return (double)config.Element.GetValue(CollapsedPaneWidthProperty);
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<Windows, FormsElement> CollapsedPaneWidth(
|
||||
this IPlatformElementConfiguration<Windows, FormsElement> config, double value)
|
||||
{
|
||||
config.Element.SetValue(CollapsedPaneWidthProperty, value);
|
||||
return config;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Xamarin.Forms.PlatformConfiguration.WindowsSpecific
|
||||
{
|
||||
using FormsElement = Forms.Page;
|
||||
|
||||
public static class Page
|
||||
{
|
||||
#region ToolbarPlacement
|
||||
|
||||
public static readonly BindableProperty ToolbarPlacementProperty =
|
||||
BindableProperty.CreateAttached("ToolbarPlacement", typeof(ToolbarPlacement),
|
||||
typeof(Page), ToolbarPlacement.Default);
|
||||
|
||||
public static ToolbarPlacement GetToolbarPlacement(BindableObject element)
|
||||
{
|
||||
return (ToolbarPlacement)element.GetValue(ToolbarPlacementProperty);
|
||||
}
|
||||
|
||||
public static void SetToolbarPlacement(BindableObject element, ToolbarPlacement toolbarPlacement)
|
||||
{
|
||||
element.SetValue(ToolbarPlacementProperty, toolbarPlacement);
|
||||
}
|
||||
|
||||
public static ToolbarPlacement GetToolbarPlacement(this IPlatformElementConfiguration<Windows, FormsElement> config)
|
||||
{
|
||||
return (ToolbarPlacement)config.Element.GetValue(ToolbarPlacementProperty);
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<Windows, FormsElement> SetToolbarPlacement(
|
||||
this IPlatformElementConfiguration<Windows, FormsElement> config, ToolbarPlacement value)
|
||||
{
|
||||
config.Element.SetValue(ToolbarPlacementProperty, value);
|
||||
return config;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
namespace Xamarin.Forms.PlatformConfiguration.WindowsSpecific
|
||||
{
|
||||
public enum ToolbarPlacement
|
||||
{
|
||||
/// <summary>
|
||||
/// Default will place the Toolbar at the bottom of the screen on phones and
|
||||
/// at the top of the screen on larger devices
|
||||
/// </summary>
|
||||
Default,
|
||||
|
||||
/// <summary>
|
||||
/// Always place the Toolbar at the top of the screen
|
||||
/// </summary>
|
||||
Top,
|
||||
|
||||
/// <summary>
|
||||
/// Always place the Toolbar at the bottom of the screen
|
||||
/// </summary>
|
||||
Bottom
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
namespace Xamarin.Forms.PlatformConfiguration.iOSSpecific
|
||||
{
|
||||
|
||||
public enum BlurEffectStyle
|
||||
{
|
||||
None,
|
||||
/// <summary>
|
||||
/// Available in iOS 8.0 and later.
|
||||
/// </summary>
|
||||
ExtraLight,
|
||||
/// <summary>
|
||||
/// Available in iOS 8.0 and later.
|
||||
/// </summary>
|
||||
Light,
|
||||
/// <summary>
|
||||
/// Available in iOS 8.0 and later.
|
||||
/// </summary>
|
||||
Dark
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
namespace Xamarin.Forms.PlatformConfiguration.iOSSpecific
|
||||
{
|
||||
using FormsElement = Forms.NavigationPage;
|
||||
|
||||
public static class NavigationPage
|
||||
{
|
||||
public static readonly BindableProperty IsNavigationBarTranslucentProperty =
|
||||
BindableProperty.Create("IsNavigationBarTranslucent", typeof(bool),
|
||||
typeof(NavigationPage), false);
|
||||
|
||||
public static bool GetIsNavigationBarTranslucent(BindableObject element)
|
||||
{
|
||||
return (bool)element.GetValue(IsNavigationBarTranslucentProperty);
|
||||
}
|
||||
|
||||
public static void SetIsNavigationBarTranslucent(BindableObject element, bool value)
|
||||
{
|
||||
element.SetValue(IsNavigationBarTranslucentProperty, value);
|
||||
}
|
||||
|
||||
public static bool IsNavigationBarTranslucent(this IPlatformElementConfiguration<iOS, FormsElement> config)
|
||||
{
|
||||
return GetIsNavigationBarTranslucent(config.Element);
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<iOS, FormsElement> SetIsNavigationBarTranslucent(this IPlatformElementConfiguration<iOS, FormsElement> config, bool value)
|
||||
{
|
||||
SetIsNavigationBarTranslucent(config.Element, value);
|
||||
return config;
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<iOS, FormsElement> EnableTranslucentNavigationBar(this IPlatformElementConfiguration<iOS, FormsElement> config)
|
||||
{
|
||||
SetIsNavigationBarTranslucent(config.Element, true);
|
||||
return config;
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<iOS, FormsElement>DisableTranslucentNavigationBar(this IPlatformElementConfiguration<iOS, FormsElement> config)
|
||||
{
|
||||
SetIsNavigationBarTranslucent(config.Element, false);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
|
||||
namespace Xamarin.Forms.PlatformConfiguration.iOSSpecific
|
||||
{
|
||||
using FormsElement = Forms.VisualElement;
|
||||
|
||||
public static class VisualElement
|
||||
{
|
||||
public static readonly BindableProperty BlurEffectProperty =
|
||||
BindableProperty.Create("BlurEffect", typeof(BlurEffectStyle),
|
||||
typeof(VisualElement), BlurEffectStyle.None);
|
||||
|
||||
public static BlurEffectStyle GetBlurEffect(BindableObject element)
|
||||
{
|
||||
return (BlurEffectStyle)element.GetValue(BlurEffectProperty);
|
||||
}
|
||||
|
||||
public static void SetBlurEffect(BindableObject element, BlurEffectStyle value)
|
||||
{
|
||||
element.SetValue(BlurEffectProperty, value);
|
||||
}
|
||||
|
||||
public static BlurEffectStyle GetBlurEffect(this IPlatformElementConfiguration<iOS, FormsElement> config)
|
||||
{
|
||||
return GetBlurEffect(config.Element);
|
||||
}
|
||||
|
||||
public static IPlatformElementConfiguration<iOS, FormsElement> UseBlurEffect(this IPlatformElementConfiguration<iOS, FormsElement> config, BlurEffectStyle value)
|
||||
{
|
||||
SetBlurEffect(config.Element, value);
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
/// <summary>
|
||||
/// Helper that handles storing and lookup of platform specifics implementations
|
||||
/// </summary>
|
||||
/// <typeparam name="TElement">The Element type</typeparam>
|
||||
internal class PlatformConfigurationRegistry<TElement> : IElementConfiguration<TElement>
|
||||
where TElement : Element
|
||||
{
|
||||
readonly TElement _element;
|
||||
readonly Dictionary<Type, object> _platformSpecifics = new Dictionary<Type, object>();
|
||||
|
||||
internal PlatformConfigurationRegistry(TElement element)
|
||||
{
|
||||
_element = element;
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, TElement> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
if (_platformSpecifics.ContainsKey(typeof(T)))
|
||||
{
|
||||
return (IPlatformElementConfiguration<T, TElement>)_platformSpecifics[typeof(T)];
|
||||
}
|
||||
|
||||
var emptyConfig = Configuration<T, TElement>.Create(_element);
|
||||
|
||||
_platformSpecifics.Add(typeof(T), emptyConfig);
|
||||
|
||||
return emptyConfig;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,21 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms.Platform;
|
||||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_ProgressBarRenderer))]
|
||||
public class ProgressBar : View
|
||||
public class ProgressBar : View, IElementConfiguration<ProgressBar>
|
||||
{
|
||||
public static readonly BindableProperty ProgressProperty = BindableProperty.Create("Progress", typeof(double), typeof(ProgressBar), 0d, coerceValue: (bo, v) => ((double)v).Clamp(0, 1));
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<ProgressBar>> _platformConfigurationRegistry;
|
||||
|
||||
public ProgressBar()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<ProgressBar>>(() => new PlatformConfigurationRegistry<ProgressBar>(this));
|
||||
}
|
||||
|
||||
public double Progress
|
||||
{
|
||||
get { return (double)GetValue(ProgressProperty); }
|
||||
|
@ -22,5 +30,10 @@ namespace Xamarin.Forms
|
|||
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, ProgressBar> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ namespace Xamarin.Forms
|
|||
{
|
||||
[ContentProperty("Content")]
|
||||
[RenderWith(typeof(_ScrollViewRenderer))]
|
||||
public class ScrollView : Layout, IScrollViewController
|
||||
public class ScrollView : Layout, IScrollViewController, IElementConfiguration<ScrollView>
|
||||
{
|
||||
public static readonly BindableProperty OrientationProperty = BindableProperty.Create("Orientation", typeof(ScrollOrientation), typeof(ScrollView), ScrollOrientation.Vertical);
|
||||
|
||||
|
@ -22,6 +22,8 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty ContentSizeProperty = ContentSizePropertyKey.BindableProperty;
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<ScrollView>> _platformConfigurationRegistry;
|
||||
|
||||
View _content;
|
||||
|
||||
TaskCompletionSource<bool> _scrollCompletionSource;
|
||||
|
@ -68,6 +70,11 @@ namespace Xamarin.Forms
|
|||
private set { SetValue(ScrollYPropertyKey, value); }
|
||||
}
|
||||
|
||||
public ScrollView()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<ScrollView>>(() => new PlatformConfigurationRegistry<ScrollView>(this));
|
||||
}
|
||||
|
||||
Point IScrollViewController.GetScrollPositionForElement(VisualElement item, ScrollToPosition pos)
|
||||
{
|
||||
ScrollToPosition position = pos;
|
||||
|
@ -133,6 +140,11 @@ namespace Xamarin.Forms
|
|||
|
||||
public event EventHandler<ScrolledEventArgs> Scrolled;
|
||||
|
||||
public IPlatformElementConfiguration<T, ScrollView> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
|
||||
public Task ScrollToAsync(double x, double y, bool animated)
|
||||
{
|
||||
var args = new ScrollToRequestedEventArgs(x, y, animated);
|
||||
|
|
|
@ -5,7 +5,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_SearchBarRenderer))]
|
||||
public class SearchBar : View, IFontElement, ISearchBarController
|
||||
public class SearchBar : View, IFontElement, ISearchBarController, IElementConfiguration<SearchBar>
|
||||
{
|
||||
public static readonly BindableProperty SearchCommandProperty = BindableProperty.Create("SearchCommand", typeof(ICommand), typeof(SearchBar), null, propertyChanged: OnCommandChanged);
|
||||
|
||||
|
@ -37,6 +37,8 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty PlaceholderColorProperty = BindableProperty.Create("PlaceholderColor", typeof(Color), typeof(SearchBar), Color.Default);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<SearchBar>> _platformConfigurationRegistry;
|
||||
|
||||
public Color CancelButtonColor
|
||||
{
|
||||
get { return (Color)GetValue(CancelButtonColorProperty); }
|
||||
|
@ -113,6 +115,11 @@ namespace Xamarin.Forms
|
|||
|
||||
public event EventHandler<TextChangedEventArgs> TextChanged;
|
||||
|
||||
public SearchBar()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<SearchBar>>(() => new PlatformConfigurationRegistry<SearchBar>(this));
|
||||
}
|
||||
|
||||
void ISearchBarController.OnSearchButtonPressed()
|
||||
{
|
||||
ICommand cmd = SearchCommand;
|
||||
|
@ -152,5 +159,10 @@ namespace Xamarin.Forms
|
|||
self.IsEnabledCore = true;
|
||||
}
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, SearchBar> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_SliderRenderer))]
|
||||
public class Slider : View
|
||||
public class Slider : View, IElementConfiguration<Slider>
|
||||
{
|
||||
public static readonly BindableProperty MinimumProperty = BindableProperty.Create("Minimum", typeof(double), typeof(Slider), 0d, validateValue: (bindable, value) =>
|
||||
{
|
||||
|
@ -40,11 +40,14 @@ namespace Xamarin.Forms
|
|||
eh(slider, new ValueChangedEventArgs((double)oldValue, (double)newValue));
|
||||
});
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<Slider>> _platformConfigurationRegistry;
|
||||
|
||||
public Slider()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Slider>>(() => new PlatformConfigurationRegistry<Slider>(this));
|
||||
}
|
||||
|
||||
public Slider(double min, double max, double val)
|
||||
public Slider(double min, double max, double val) : this()
|
||||
{
|
||||
if (min >= max)
|
||||
throw new ArgumentOutOfRangeException("min");
|
||||
|
@ -81,5 +84,10 @@ namespace Xamarin.Forms
|
|||
}
|
||||
|
||||
public event EventHandler<ValueChangedEventArgs> ValueChanged;
|
||||
|
||||
public IPlatformElementConfiguration<T, Slider> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_StepperRenderer))]
|
||||
public class Stepper : View
|
||||
public class Stepper : View, IElementConfiguration<Stepper>
|
||||
{
|
||||
public static readonly BindableProperty MaximumProperty = BindableProperty.Create("Maximum", typeof(double), typeof(Stepper), 100.0, validateValue: (bindable, value) =>
|
||||
{
|
||||
|
@ -42,8 +42,11 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty IncrementProperty = BindableProperty.Create("Increment", typeof(double), typeof(Stepper), 1.0);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<Stepper>> _platformConfigurationRegistry;
|
||||
|
||||
public Stepper()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Stepper>>(() => new PlatformConfigurationRegistry<Stepper>(this));
|
||||
}
|
||||
|
||||
public Stepper(double min, double max, double val, double increment)
|
||||
|
@ -90,5 +93,10 @@ namespace Xamarin.Forms
|
|||
}
|
||||
|
||||
public event EventHandler<ValueChangedEventArgs> ValueChanged;
|
||||
|
||||
public IPlatformElementConfiguration<T, Stepper> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_SwitchRenderer))]
|
||||
public class Switch : View
|
||||
public class Switch : View, IElementConfiguration<Switch>
|
||||
{
|
||||
public static readonly BindableProperty IsToggledProperty = BindableProperty.Create("IsToggled", typeof(bool), typeof(Switch), false, propertyChanged: (bindable, oldValue, newValue) =>
|
||||
{
|
||||
|
@ -13,6 +13,13 @@ namespace Xamarin.Forms
|
|||
eh(bindable, new ToggledEventArgs((bool)newValue));
|
||||
}, defaultBindingMode: BindingMode.TwoWay);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<Switch>> _platformConfigurationRegistry;
|
||||
|
||||
public Switch()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Switch>>(() => new PlatformConfigurationRegistry<Switch>(this));
|
||||
}
|
||||
|
||||
public bool IsToggled
|
||||
{
|
||||
get { return (bool)GetValue(IsToggledProperty); }
|
||||
|
@ -20,5 +27,10 @@ namespace Xamarin.Forms
|
|||
}
|
||||
|
||||
public event EventHandler<ToggledEventArgs> Toggled;
|
||||
|
||||
public IPlatformElementConfiguration<T, Switch> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +1,17 @@
|
|||
using System;
|
||||
using Xamarin.Forms.Platform;
|
||||
|
||||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_TabbedPageRenderer))]
|
||||
public class TabbedPage : MultiPage<Page>
|
||||
public class TabbedPage : MultiPage<Page>, IElementConfiguration<TabbedPage>
|
||||
{
|
||||
public static readonly BindableProperty BarBackgroundColorProperty = BindableProperty.Create(nameof(BarBackgroundColor), typeof(Color), typeof(TabbedPage), Color.Default);
|
||||
|
||||
public static readonly BindableProperty BarTextColorProperty = BindableProperty.Create(nameof(BarTextColor), typeof(Color), typeof(TabbedPage), Color.Default);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<TabbedPage>> _platformConfigurationRegistry;
|
||||
|
||||
public Color BarBackgroundColor
|
||||
{
|
||||
get
|
||||
|
@ -41,5 +44,15 @@ namespace Xamarin.Forms
|
|||
|
||||
return page;
|
||||
}
|
||||
|
||||
public TabbedPage()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<TabbedPage>>(() => new PlatformConfigurationRegistry<TabbedPage>(this));
|
||||
}
|
||||
|
||||
public new IPlatformElementConfiguration<T, TabbedPage> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,12 +9,14 @@ namespace Xamarin.Forms
|
|||
{
|
||||
[ContentProperty("Root")]
|
||||
[RenderWith(typeof(_TableViewRenderer))]
|
||||
public class TableView : View, ITableViewController
|
||||
public class TableView : View, ITableViewController, IElementConfiguration<TableView>
|
||||
{
|
||||
public static readonly BindableProperty RowHeightProperty = BindableProperty.Create("RowHeight", typeof(int), typeof(TableView), -1);
|
||||
|
||||
public static readonly BindableProperty HasUnevenRowsProperty = BindableProperty.Create("HasUnevenRows", typeof(bool), typeof(TableView), false);
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<TableView>> _platformConfigurationRegistry;
|
||||
|
||||
readonly TableSectionModel _tableModel;
|
||||
|
||||
TableIntent _intent = TableIntent.Data;
|
||||
|
@ -29,6 +31,7 @@ namespace Xamarin.Forms
|
|||
{
|
||||
VerticalOptions = HorizontalOptions = LayoutOptions.FillAndExpand;
|
||||
Model = _tableModel = new TableSectionModel(this, root);
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<TableView>>(() => new PlatformConfigurationRegistry<TableView>(this));
|
||||
}
|
||||
|
||||
public bool HasUnevenRows
|
||||
|
@ -127,6 +130,11 @@ namespace Xamarin.Forms
|
|||
remove { ModelChanged -= value; }
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, TableView> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
|
||||
void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
OnModelChanged();
|
||||
|
|
|
@ -4,7 +4,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_TimePickerRenderer))]
|
||||
public class TimePicker : View
|
||||
public class TimePicker : View, IElementConfiguration<TimePicker>
|
||||
{
|
||||
public static readonly BindableProperty FormatProperty = BindableProperty.Create(nameof(Format), typeof(string), typeof(TimePicker), "t");
|
||||
|
||||
|
@ -16,6 +16,13 @@ namespace Xamarin.Forms
|
|||
return time.TotalHours < 24 && time.TotalMilliseconds >= 0;
|
||||
});
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<TimePicker>> _platformConfigurationRegistry;
|
||||
|
||||
public TimePicker()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<TimePicker>>(() => new PlatformConfigurationRegistry<TimePicker>(this));
|
||||
}
|
||||
|
||||
public string Format
|
||||
{
|
||||
get { return (string)GetValue(FormatProperty); }
|
||||
|
@ -33,5 +40,10 @@ namespace Xamarin.Forms
|
|||
get { return (TimeSpan)GetValue(TimeProperty); }
|
||||
set { SetValue(TimeProperty, value); }
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, TimePicker> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ using Xamarin.Forms.Platform;
|
|||
namespace Xamarin.Forms
|
||||
{
|
||||
[RenderWith(typeof(_WebViewRenderer))]
|
||||
public class WebView : View
|
||||
public class WebView : View, IElementConfiguration<WebView>
|
||||
{
|
||||
public static readonly BindableProperty SourceProperty = BindableProperty.Create("Source", typeof(WebViewSource), typeof(WebView), default(WebViewSource),
|
||||
propertyChanging: (bindable, oldvalue, newvalue) =>
|
||||
|
@ -32,6 +32,13 @@ namespace Xamarin.Forms
|
|||
|
||||
public static readonly BindableProperty CanGoForwardProperty = CanGoForwardPropertyKey.BindableProperty;
|
||||
|
||||
readonly Lazy<PlatformConfigurationRegistry<WebView>> _platformConfigurationRegistry;
|
||||
|
||||
public WebView()
|
||||
{
|
||||
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<WebView>>(() => new PlatformConfigurationRegistry<WebView>(this));
|
||||
}
|
||||
|
||||
public bool CanGoBack
|
||||
{
|
||||
get { return (bool)GetValue(CanGoBackProperty); }
|
||||
|
@ -122,5 +129,10 @@ namespace Xamarin.Forms
|
|||
if (handler != null)
|
||||
handler(this, args);
|
||||
}
|
||||
|
||||
public IPlatformElementConfiguration<T, WebView> On<T>() where T : IConfigPlatform
|
||||
{
|
||||
return _platformConfigurationRegistry.Value.On<T>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -87,6 +87,19 @@
|
|||
<Compile Include="DateChangedEventArgs.cs" />
|
||||
<Compile Include="DelegateLogListener.cs" />
|
||||
<Compile Include="EnumerableExtensions.cs" />
|
||||
<Compile Include="PlatformConfiguration\AndroidSpecific\Application.cs" />
|
||||
<Compile Include="PlatformConfiguration\ExtensionPoints.cs" />
|
||||
<Compile Include="PlatformConfiguration\iOSSpecific\BlurEffectStyle.cs" />
|
||||
<Compile Include="PlatformConfiguration\iOSSpecific\NavigationPage.cs" />
|
||||
<Compile Include="PlatformConfiguration\iOSSpecific\VisualElement.cs" />
|
||||
<Compile Include="PlatformConfiguration\WindowsSpecific\MasterDetailPage.cs" />
|
||||
<Compile Include="PlatformConfiguration\WindowsSpecific\CollapseStyle.cs" />
|
||||
<Compile Include="Configuration.cs" />
|
||||
<Compile Include="IConfigElement.cs" />
|
||||
<Compile Include="IConfigPlatform.cs" />
|
||||
<Compile Include="IElementConfiguration.cs" />
|
||||
<Compile Include="IPlatformElementConfiguration.cs" />
|
||||
<Compile Include="PlatformConfigurationRegistry.cs" />
|
||||
<Compile Include="IFontElement.cs" />
|
||||
<Compile Include="DependencyAttribute.cs" />
|
||||
<Compile Include="DependencyFetchTarget.cs" />
|
||||
|
@ -195,6 +208,8 @@
|
|||
<Compile Include="PanUpdatedEventArgs.cs" />
|
||||
<Compile Include="Performance.cs" />
|
||||
<Compile Include="PinchGestureUpdatedEventArgs.cs" />
|
||||
<Compile Include="PlatformConfiguration\WindowsSpecific\Page.cs" />
|
||||
<Compile Include="PlatformConfiguration\WindowsSpecific\ToolbarPlacement.cs" />
|
||||
<Compile Include="PlatformEffect.cs" />
|
||||
<Compile Include="PointTypeConverter.cs" />
|
||||
<Compile Include="Internals\PreserveAttribute.cs" />
|
||||
|
|
|
@ -14,6 +14,7 @@ using Android.Util;
|
|||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Xamarin.Forms.Platform.Android.AppCompat;
|
||||
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
|
||||
using AToolbar = Android.Support.V7.Widget.Toolbar;
|
||||
using AColor = Android.Graphics.Color;
|
||||
using AlertDialog = Android.Support.V7.App.AlertDialog;
|
||||
|
@ -142,7 +143,6 @@ namespace Xamarin.Forms.Platform.Android
|
|||
callback(resultCode, data);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnCreate(Bundle savedInstanceState)
|
||||
{
|
||||
if (!AllowFragmentRestore)
|
||||
|
@ -167,7 +167,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
SetSupportActionBar(bar);
|
||||
|
||||
Window.SetSoftInputMode(SoftInput.AdjustPan);
|
||||
SetSoftInputMode();
|
||||
|
||||
_layout = new ARelativeLayout(BaseContext);
|
||||
SetContentView(_layout);
|
||||
|
@ -179,29 +179,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
OnStateChanged();
|
||||
|
||||
_statusBarUnderlay = new global::Android.Views.View(this);
|
||||
var layoutParameters = new ARelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, GetStatusBarHeight()) { AlignWithParent = true };
|
||||
layoutParameters.AddRule(LayoutRules.AlignTop);
|
||||
_statusBarUnderlay.LayoutParameters = layoutParameters;
|
||||
_layout.AddView(_statusBarUnderlay);
|
||||
|
||||
if (Forms.IsLollipopOrNewer)
|
||||
{
|
||||
Window.DecorView.SystemUiVisibility = (StatusBarVisibility)(SystemUiFlags.LayoutFullscreen | SystemUiFlags.LayoutStable);
|
||||
Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
|
||||
Window.SetStatusBarColor(AColor.Transparent);
|
||||
|
||||
int primaryColorDark = GetColorPrimaryDark();
|
||||
|
||||
if (primaryColorDark != 0)
|
||||
{
|
||||
int r = AColor.GetRedComponent(primaryColorDark);
|
||||
int g = AColor.GetGreenComponent(primaryColorDark);
|
||||
int b = AColor.GetBlueComponent(primaryColorDark);
|
||||
int a = AColor.GetAlphaComponent(primaryColorDark);
|
||||
SetStatusBarColor(AColor.Argb(a, r, g, b));
|
||||
}
|
||||
}
|
||||
AddStatusBarUnderlay();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
|
@ -302,10 +280,39 @@ namespace Xamarin.Forms.Platform.Android
|
|||
return _statusBarHeight = result;
|
||||
}
|
||||
|
||||
void AddStatusBarUnderlay()
|
||||
{
|
||||
_statusBarUnderlay = new global::Android.Views.View(this);
|
||||
|
||||
var layoutParameters = new ARelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, GetStatusBarHeight()) { AlignWithParent = true };
|
||||
layoutParameters.AddRule(LayoutRules.AlignTop);
|
||||
_statusBarUnderlay.LayoutParameters = layoutParameters;
|
||||
_layout.AddView(_statusBarUnderlay);
|
||||
|
||||
if (Forms.IsLollipopOrNewer)
|
||||
{
|
||||
Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
|
||||
Window.SetStatusBarColor(AColor.Transparent);
|
||||
|
||||
int primaryColorDark = GetColorPrimaryDark();
|
||||
|
||||
if (primaryColorDark != 0)
|
||||
{
|
||||
int r = AColor.GetRedComponent(primaryColorDark);
|
||||
int g = AColor.GetGreenComponent(primaryColorDark);
|
||||
int b = AColor.GetBlueComponent(primaryColorDark);
|
||||
int a = AColor.GetAlphaComponent(primaryColorDark);
|
||||
SetStatusBarColor(AColor.Argb(a, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AppOnPropertyChanged(object sender, PropertyChangedEventArgs args)
|
||||
{
|
||||
if (args.PropertyName == "MainPage")
|
||||
InternalSetPage(_application.MainPage);
|
||||
if (args.PropertyName == PlatformConfiguration.AndroidSpecific.Application.WindowSoftInputModeAdjustProperty.PropertyName)
|
||||
SetSoftInputMode();
|
||||
}
|
||||
|
||||
void CheckForAppLink(Intent intent)
|
||||
|
@ -441,6 +448,45 @@ namespace Xamarin.Forms.Platform.Android
|
|||
InternalSetPage(_application.MainPage);
|
||||
}
|
||||
|
||||
void SetSoftInputMode()
|
||||
{
|
||||
SoftInput adjust = SoftInput.AdjustPan;
|
||||
|
||||
if (Xamarin.Forms.Application.Current != null)
|
||||
{
|
||||
var elementValue = Xamarin.Forms.Application.Current.OnThisPlatform().GetWindowSoftInputModeAdjust();
|
||||
switch (elementValue)
|
||||
{
|
||||
default:
|
||||
case WindowSoftInputModeAdjust.Pan:
|
||||
adjust = SoftInput.AdjustPan;
|
||||
break;
|
||||
|
||||
case WindowSoftInputModeAdjust.Resize:
|
||||
adjust = SoftInput.AdjustResize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Window.SetSoftInputMode(adjust);
|
||||
SetStatusBarVisibility(adjust);
|
||||
}
|
||||
|
||||
void SetStatusBarVisibility(SoftInput mode)
|
||||
{
|
||||
if (!Forms.IsLollipopOrNewer)
|
||||
return;
|
||||
|
||||
if (mode == SoftInput.AdjustResize)
|
||||
{
|
||||
Window.DecorView.SystemUiVisibility = (StatusBarVisibility)(SystemUiFlags.Immersive);
|
||||
}
|
||||
else
|
||||
Window.DecorView.SystemUiVisibility = (StatusBarVisibility)(SystemUiFlags.LayoutFullscreen | SystemUiFlags.LayoutStable);
|
||||
|
||||
_layout?.Invalidate();
|
||||
}
|
||||
|
||||
void UpdateProgressBarVisibility(bool isBusy)
|
||||
{
|
||||
if (!Forms.SupportsProgress)
|
||||
|
|
|
@ -7,6 +7,7 @@ using Android.Content.Res;
|
|||
using Android.OS;
|
||||
using Android.Views;
|
||||
using Android.Widget;
|
||||
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
|
||||
|
||||
namespace Xamarin.Forms.Platform.Android
|
||||
{
|
||||
|
@ -126,6 +127,8 @@ namespace Xamarin.Forms.Platform.Android
|
|||
|
||||
base.OnCreate(savedInstanceState);
|
||||
|
||||
SetSoftInputMode();
|
||||
|
||||
_layout = new LinearLayout(BaseContext);
|
||||
SetContentView(_layout);
|
||||
|
||||
|
@ -221,6 +224,8 @@ namespace Xamarin.Forms.Platform.Android
|
|||
{
|
||||
if (args.PropertyName == "MainPage")
|
||||
InternalSetPage(_application.MainPage);
|
||||
if (args.PropertyName == PlatformConfiguration.AndroidSpecific.Application.WindowSoftInputModeAdjustProperty.PropertyName)
|
||||
SetSoftInputMode();
|
||||
}
|
||||
|
||||
void InternalSetPage(Page page)
|
||||
|
@ -307,6 +312,28 @@ namespace Xamarin.Forms.Platform.Android
|
|||
InternalSetPage(_application.MainPage);
|
||||
}
|
||||
|
||||
void SetSoftInputMode()
|
||||
{
|
||||
SoftInput adjust = SoftInput.AdjustPan;
|
||||
|
||||
if (Xamarin.Forms.Application.Current != null)
|
||||
{
|
||||
var elementValue = Xamarin.Forms.Application.Current.OnThisPlatform().GetWindowSoftInputModeAdjust();
|
||||
switch (elementValue)
|
||||
{
|
||||
default:
|
||||
case WindowSoftInputModeAdjust.Pan:
|
||||
adjust = SoftInput.AdjustPan;
|
||||
break;
|
||||
case WindowSoftInputModeAdjust.Resize:
|
||||
adjust = SoftInput.AdjustResize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Window.SetSoftInputMode(adjust);
|
||||
}
|
||||
|
||||
void UpdateProgressBarVisibility(bool isBusy)
|
||||
{
|
||||
if (!Forms.SupportsProgress)
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
namespace Xamarin.Forms.Platform.Android
|
||||
{
|
||||
public static class PlatformConfigurationExtensions
|
||||
{
|
||||
public static IPlatformElementConfiguration<PlatformConfiguration.Android, T> OnThisPlatform<T>(this T element)
|
||||
where T : Element, IElementConfiguration<T>
|
||||
{
|
||||
return (element).On<PlatformConfiguration.Android>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -147,6 +147,7 @@
|
|||
<Compile Include="OnMeasureDelegate.cs" />
|
||||
<Compile Include="PanGestureHandler.cs" />
|
||||
<Compile Include="PinchGestureHandler.cs" />
|
||||
<Compile Include="PlatformConfigurationExtensions.cs" />
|
||||
<Compile Include="PlatformEffect.cs" />
|
||||
<Compile Include="LayoutExtensions.cs" />
|
||||
<Compile Include="Renderers\AHorizontalScrollView.cs" />
|
||||
|
|
|
@ -6,32 +6,23 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
{
|
||||
public class FormsCommandBar : CommandBar
|
||||
{
|
||||
Windows.UI.Xaml.Controls.Button _moreButton;
|
||||
// TODO Once 10.0.14393.0 is available, enable dynamic overflow: https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.commandbar.isdynamicoverflowenabled.aspx
|
||||
|
||||
public FormsCommandBar()
|
||||
{
|
||||
PrimaryCommands.VectorChanged += OnCommandsChanged;
|
||||
SecondaryCommands.VectorChanged += OnCommandsChanged;
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
_moreButton = GetTemplateChild("MoreButton") as Windows.UI.Xaml.Controls.Button;
|
||||
UpdateMore();
|
||||
UpdateVisibility();
|
||||
}
|
||||
|
||||
void OnCommandsChanged(IObservableVector<ICommandBarElement> sender, IVectorChangedEventArgs args)
|
||||
{
|
||||
UpdateMore();
|
||||
UpdateVisibility();
|
||||
}
|
||||
|
||||
void UpdateMore()
|
||||
void UpdateVisibility()
|
||||
{
|
||||
if (_moreButton == null)
|
||||
return;
|
||||
|
||||
_moreButton.Visibility = PrimaryCommands.Count > 0 || SecondaryCommands.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
||||
Visibility = PrimaryCommands.Count + SecondaryCommands.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:uwp="using:Xamarin.Forms.Platform.UWP">
|
||||
<Style TargetType="uwp:MasterDetailControl">
|
||||
<Setter Property="ToolbarForeground" Value="{ThemeResource DefaultTextForegroundThemeBrush}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="uwp:MasterDetailControl">
|
||||
<SplitView x:Name="SplitView" IsPaneOpen="{Binding IsPaneOpen,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}" DisplayMode="Overlay">
|
||||
<SplitView.Pane>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" Visibility="{TemplateBinding MasterToolbarVisibility}" Background="{TemplateBinding ToolbarBackground}">
|
||||
<Button Name="PaneTogglePane" Style="{ThemeResource PaneButton}" Foreground="{TemplateBinding ToolbarForeground}" />
|
||||
<TextBlock Margin="10,0,0,0" Style="{ThemeResource TitleTextBlockStyle}" VerticalAlignment="Center" Text="{TemplateBinding MasterTitle}" Visibility="{TemplateBinding MasterTitleVisibility}" Foreground="{TemplateBinding ToolbarForeground}"/>
|
||||
</StackPanel>
|
||||
<ContentPresenter x:Name="MasterPresenter" Grid.Row="1" Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Master}" />
|
||||
</Grid>
|
||||
</SplitView.Pane>
|
||||
<SplitView.Content>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid x:Name="TitleBar" Background="{TemplateBinding ToolbarBackground}" HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" Background="{TemplateBinding ToolbarBackground}" >
|
||||
|
||||
<Button Name="ContentTogglePane" Style="{ThemeResource PaneButton}" Foreground="{TemplateBinding ToolbarForeground}"
|
||||
Visibility="{TemplateBinding ContentTogglePaneButtonVisibility}" />
|
||||
|
||||
<Border Height="{ThemeResource TitleBarHeight}" Visibility="{TemplateBinding DetailTitleVisibility}">
|
||||
<TextBlock Text="{TemplateBinding DetailTitle}" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="{TemplateBinding ToolbarForeground}" Style="{ThemeResource TitleTextBlockStyle}" />
|
||||
</Border>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<Border x:Name="TopCommandBarArea" Grid.Column="1" HorizontalAlignment="Stretch">
|
||||
<uwp:FormsCommandBar x:Name="CommandBar" VerticalContentAlignment="Top" Background="{TemplateBinding ToolbarBackground}" Height="{ThemeResource TitleBarHeight}" />
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<ContentPresenter x:Name="DetailPresenter" Grid.Row="1" Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Detail}" />
|
||||
|
||||
<Border x:Name="BottomCommandBarArea" Grid.Row="2" HorizontalAlignment="Stretch"></Border>
|
||||
</Grid>
|
||||
</SplitView.Content>
|
||||
</SplitView>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
|
@ -6,6 +6,8 @@ using Windows.UI.Xaml.Automation;
|
|||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
|
||||
using Specifics = Xamarin.Forms.PlatformConfiguration.WindowsSpecific.MasterDetailPage;
|
||||
|
||||
namespace Xamarin.Forms.Platform.UWP
|
||||
{
|
||||
|
@ -56,7 +58,7 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
set { Control.ToolbarForeground = value; }
|
||||
}
|
||||
|
||||
IPageController PageController => Element as IPageController;
|
||||
IPageController PageController => Element as IPageController;
|
||||
|
||||
IMasterDetailPageController MasterDetailPageController => Element as IMasterDetailPageController;
|
||||
|
||||
|
@ -68,11 +70,9 @@ IPageController PageController => Element as IPageController;
|
|||
{
|
||||
if (_showTitle == value)
|
||||
return;
|
||||
|
||||
_showTitle = value;
|
||||
if (_showTitle)
|
||||
Control.DetailTitleVisibility = Visibility.Visible;
|
||||
else
|
||||
Control.DetailTitleVisibility = Visibility.Collapsed;
|
||||
Control.DetailTitleVisibility = _showTitle ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ IPageController PageController => Element as IPageController;
|
|||
{
|
||||
Control = new MasterDetailControl();
|
||||
Control.Loaded += OnControlLoaded;
|
||||
Control.Unloaded += OnControlUnlaoded;
|
||||
Control.Unloaded += OnControlUnloaded;
|
||||
Control.SizeChanged += OnNativeSizeChanged;
|
||||
|
||||
Control.RegisterPropertyChangedCallback(MasterDetailControl.IsPaneOpenProperty, OnIsPaneOpenChanged);
|
||||
|
@ -148,7 +148,12 @@ IPageController PageController => Element as IPageController;
|
|||
|
||||
if (!string.IsNullOrEmpty(e.NewElement.AutomationId))
|
||||
Control.SetValue(AutomationProperties.AutomationIdProperty, e.NewElement.AutomationId);
|
||||
}
|
||||
|
||||
#if WINDOWS_UWP
|
||||
UpdateToolbarPlacement();
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
|
@ -159,8 +164,12 @@ IPageController PageController => Element as IPageController;
|
|||
UpdateMaster();
|
||||
else if (e.PropertyName == "Detail")
|
||||
UpdateDetail();
|
||||
else if (e.PropertyName == "ShouldShowSplitMode")
|
||||
else if (e.PropertyName == nameof(MasterDetailControl.ShouldShowSplitMode)
|
||||
|| e.PropertyName == Specifics.CollapseStyleProperty.PropertyName
|
||||
|| e.PropertyName == Specifics.CollapsedPaneWidthProperty.PropertyName)
|
||||
UpdateMode();
|
||||
else if(e.PropertyName == PlatformConfiguration.WindowsSpecific.Page.ToolbarPlacementProperty.PropertyName)
|
||||
UpdateToolbarPlacement();
|
||||
}
|
||||
|
||||
void ClearDetail()
|
||||
|
@ -202,7 +211,7 @@ IPageController PageController => Element as IPageController;
|
|||
UpdateBounds();
|
||||
}
|
||||
|
||||
void OnControlUnlaoded(object sender, RoutedEventArgs routedEventArgs)
|
||||
void OnControlUnloaded(object sender, RoutedEventArgs routedEventArgs)
|
||||
{
|
||||
PageController?.SendDisappearing();
|
||||
}
|
||||
|
@ -264,6 +273,7 @@ IPageController PageController => Element as IPageController;
|
|||
return;
|
||||
|
||||
Control.DetailTitle = (_detail as NavigationPage)?.CurrentPage?.Title ?? _detail.Title ?? Element?.Title;
|
||||
(this as ITitleProvider).ShowTitle = !string.IsNullOrEmpty(Control.DetailTitle);
|
||||
}
|
||||
|
||||
void UpdateIsPresented()
|
||||
|
@ -291,10 +301,18 @@ IPageController PageController => Element as IPageController;
|
|||
|
||||
void UpdateMode()
|
||||
{
|
||||
Control.CollapseStyle = Element.OnThisPlatform().GetCollapseStyle();
|
||||
Control.CollapsedPaneWidth = Element.OnThisPlatform().CollapsedPaneWidth();
|
||||
Control.ShouldShowSplitMode = MasterDetailPageController.ShouldShowSplitMode;
|
||||
}
|
||||
|
||||
#if WINDOWS_UWP
|
||||
|
||||
void UpdateToolbarPlacement()
|
||||
{
|
||||
Control.ToolbarPlacement = Element.OnThisPlatform().GetToolbarPlacement();
|
||||
}
|
||||
|
||||
public void BindForegroundColor(AppBar appBar)
|
||||
{
|
||||
SetAppBarForegroundBinding(appBar);
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:uwp="using:Xamarin.Forms.Platform.UWP">
|
||||
<Style TargetType="uwp:PageControl">
|
||||
<Setter Property="ContentMargin" Value="0" />
|
||||
<Setter Property="TitleBrush" Value="{ThemeResource DefaultTextForegroundThemeBrush}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="uwp:PageControl">
|
||||
<Grid Background="{TemplateBinding Background}">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid x:Name="TitleBar" Background="{TemplateBinding ToolbarBackground}" HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Height="{ThemeResource TitleBarHeight}" Visibility="{TemplateBinding TitleVisibility}">
|
||||
<TextBlock Text="{Binding Title}" VerticalAlignment="Center" Padding="10,0,0,0" Foreground="{TemplateBinding TitleBrush}" Style="{ThemeResource TitleTextBlockStyle}" />
|
||||
</Border>
|
||||
|
||||
<Border x:Name="TopCommandBarArea" Grid.Column="1" HorizontalAlignment="Stretch">
|
||||
<uwp:FormsCommandBar x:Name="CommandBar" Background="{TemplateBinding ToolbarBackground}" Height="{ThemeResource TitleBarHeight}" />
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<ContentPresenter Margin="{TemplateBinding ContentMargin}" ContentTransitions="{TemplateBinding ContentTransitions}" x:Name="presenter" Grid.Row="1" />
|
||||
|
||||
<Border x:Name="BottomCommandBarArea" Grid.Row="2" HorizontalAlignment="Stretch"></Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
|
@ -5,8 +5,11 @@
|
|||
x:Class="Xamarin.Forms.Platform.UWP.Resources">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="PageControlStyle.xaml" />
|
||||
<ResourceDictionary Source="FormsTextBoxStyle.xaml" />
|
||||
<ResourceDictionary Source="AutoSuggestStyle.xaml" />
|
||||
<ResourceDictionary Source="MasterDetailControlStyle.xaml" />
|
||||
<ResourceDictionary Source="TabbedPageStyle.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<uwp:CaseConverter x:Key="LowerConverter" ConvertToUpper="False" />
|
||||
|
@ -247,52 +250,7 @@
|
|||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="uwp:MasterDetailControl">
|
||||
<Setter Property="ToolbarForeground" Value="{ThemeResource DefaultTextForegroundThemeBrush}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="uwp:MasterDetailControl">
|
||||
<SplitView x:Name="SplitView" IsPaneOpen="{Binding IsPaneOpen,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}" DisplayMode="Overlay">
|
||||
<SplitView.Pane>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal" Visibility="{TemplateBinding MasterToolbarVisibility}" Background="{TemplateBinding ToolbarBackground}">
|
||||
<Button Name="PaneTogglePane" Style="{ThemeResource PaneButton}" Foreground="{TemplateBinding ToolbarForeground}" />
|
||||
<TextBlock Style="{ThemeResource TitleTextBlockStyle}" VerticalAlignment="Center" Text="{TemplateBinding MasterTitle}" Visibility="{TemplateBinding MasterTitleVisibility}" Foreground="{TemplateBinding ToolbarForeground}"/>
|
||||
</StackPanel>
|
||||
|
||||
<ContentPresenter x:Name="MasterPresenter" Grid.Row="1" Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Master}" />
|
||||
</Grid>
|
||||
</SplitView.Pane>
|
||||
<SplitView.Content>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<uwp:FormsCommandBar x:Name="CommandBar" Grid.Row="0" Foreground="{TemplateBinding ToolbarForeground}" Background="{TemplateBinding ToolbarBackground}" Visibility="{TemplateBinding DetailTitleVisibility}" VerticalContentAlignment="Top">
|
||||
<uwp:FormsCommandBar.Content>
|
||||
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||
<Button Name="ContentTogglePane" Style="{ThemeResource PaneButton}" Foreground="{TemplateBinding ToolbarForeground}" Visibility="{Binding ElementName=SplitView,Path=IsPaneOpen,Converter={StaticResource InvertedBoolVisibilityConverter}}" />
|
||||
<ContentControl VerticalAlignment="Top" VerticalContentAlignment="Center" Height="{StaticResource TitleBarHeight}">
|
||||
<TextBlock Text="{TemplateBinding DetailTitle}" Margin="10,0,0,0" Foreground="{TemplateBinding ToolbarForeground}" Style="{ThemeResource TitleTextBlockStyle}" />
|
||||
</ContentControl>
|
||||
</StackPanel>
|
||||
</uwp:FormsCommandBar.Content>
|
||||
</uwp:FormsCommandBar>
|
||||
|
||||
<ContentPresenter x:Name="DetailPresenter" Grid.Row="1" Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Detail}" />
|
||||
</Grid>
|
||||
</SplitView.Content>
|
||||
</SplitView>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
|
||||
<Style x:Key="FormsListViewItem" TargetType="ListViewItem">
|
||||
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
|
||||
|
@ -470,215 +428,6 @@
|
|||
</uwp:EntryCellTextBox>
|
||||
</DataTemplate>
|
||||
|
||||
<Style x:Key="TabbedPageStyle" TargetType="uwp:FormsPivot">
|
||||
<Setter Property="HeaderTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Name="TabbedPageHeaderTextBlock" Text="{Binding Title}" Style="{ThemeResource BodyTextBlockStyle}" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
<Setter Property="ItemTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<uwp:TabbedPagePresenter Content="{Binding}" ContentTemplate="{ThemeResource ContainedPageTemplate}" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="uwp:FormsPivot">
|
||||
<Grid x:Name="RootElement" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="NavigationButtonsVisibility">
|
||||
<VisualState x:Name="NavigationButtonsHidden"/>
|
||||
<VisualState x:Name="NavigationButtonsVisible">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NextButton">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsEnabled" Storyboard.TargetName="NextButton">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="True"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PreviousButton">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsEnabled" Storyboard.TargetName="PreviousButton">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="True"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="HeaderStates">
|
||||
<VisualState x:Name="HeaderDynamic"/>
|
||||
<VisualState x:Name="HeaderStatic">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Header">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="StaticHeader">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<uwp:FormsCommandBar x:Name="CommandBar" Grid.Row="0" VerticalContentAlignment="Top" Background="{TemplateBinding ToolbarBackground}" Visibility="{TemplateBinding ToolbarVisibility}" >
|
||||
<uwp:FormsCommandBar.Content>
|
||||
<ContentControl VerticalAlignment="Top" VerticalContentAlignment="Center" Height="{ThemeResource TitleBarHeight}" >
|
||||
<TextBlock Text="{TemplateBinding Title}" VerticalAlignment="Center" Padding="10,0,0,0" Foreground="{TemplateBinding ToolbarForeground}" Style="{ThemeResource TitleTextBlockStyle}" />
|
||||
</ContentControl>
|
||||
</uwp:FormsCommandBar.Content>
|
||||
</uwp:FormsCommandBar>
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.Resources>
|
||||
<ControlTemplate x:Key="NextTemplate" TargetType="Button">
|
||||
<Border x:Name="Root" BorderBrush="{ThemeResource SystemControlForegroundTransparentBrush}" BorderThickness="{ThemeResource PivotNavButtonBorderThemeThickness}" Background="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal"/>
|
||||
<VisualState x:Name="PointerOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Root">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Arrow">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Pressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Root">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Arrow">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<FontIcon x:Name="Arrow" Foreground="{ThemeResource SystemControlForegroundAltMediumHighBrush}" FontSize="12" FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="" HorizontalAlignment="Center" MirroredWhenRightToLeft="True" UseLayoutRounding="False" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="PreviousTemplate" TargetType="Button">
|
||||
<Border x:Name="Root" BorderBrush="{ThemeResource SystemControlForegroundTransparentBrush}" BorderThickness="{ThemeResource PivotNavButtonBorderThemeThickness}" Background="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal"/>
|
||||
<VisualState x:Name="PointerOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Root">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Arrow">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Pressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Root">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Arrow">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<FontIcon x:Name="Arrow" Foreground="{ThemeResource SystemControlForegroundAltMediumHighBrush}" FontSize="12" FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="" HorizontalAlignment="Center" MirroredWhenRightToLeft="True" UseLayoutRounding="False" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Grid.Resources>
|
||||
<ScrollViewer x:Name="ScrollViewer" BringIntoViewOnFocusChange="False" HorizontalSnapPointsAlignment="Center" HorizontalSnapPointsType="MandatorySingle" HorizontalScrollBarVisibility="Hidden" Margin="{TemplateBinding Padding}" Template="{StaticResource ScrollViewerScrollBarlessTemplate}" VerticalSnapPointsType="None" VerticalScrollBarVisibility="Disabled" VerticalScrollMode="Disabled" VerticalContentAlignment="Stretch" ZoomMode="Disabled">
|
||||
<PivotPanel x:Name="Panel" VerticalAlignment="Stretch">
|
||||
<Grid x:Name="PivotLayoutElement">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.RenderTransform>
|
||||
<CompositeTransform x:Name="PivotLayoutElementTranslateTransform"/>
|
||||
</Grid.RenderTransform>
|
||||
<ContentPresenter x:Name="LeftHeaderPresenter" ContentTemplate="{TemplateBinding LeftHeaderTemplate}" Content="{TemplateBinding LeftHeader}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
<ContentControl x:Name="HeaderClipper" Grid.Column="1" HorizontalContentAlignment="Stretch" UseSystemFocusVisuals="True">
|
||||
<ContentControl.Clip>
|
||||
<RectangleGeometry x:Name="HeaderClipperGeometry"/>
|
||||
</ContentControl.Clip>
|
||||
<Grid Name="TabbedPageHeaderGrid" Background="{TemplateBinding ToolbarBackground}">
|
||||
<PivotHeaderPanel x:Name="StaticHeader" Visibility="Collapsed"/>
|
||||
<PivotHeaderPanel x:Name="Header">
|
||||
<PivotHeaderPanel.RenderTransform>
|
||||
<TransformGroup>
|
||||
<CompositeTransform x:Name="HeaderTranslateTransform"/>
|
||||
<CompositeTransform x:Name="HeaderOffsetTranslateTransform"/>
|
||||
</TransformGroup>
|
||||
</PivotHeaderPanel.RenderTransform>
|
||||
</PivotHeaderPanel>
|
||||
</Grid>
|
||||
</ContentControl>
|
||||
<Button x:Name="PreviousButton" Background="Transparent" Grid.Column="1" HorizontalAlignment="Left" Height="36" IsTabStop="False" IsEnabled="False" Margin="{ThemeResource PivotNavButtonMargin}" Opacity="0" Template="{StaticResource PreviousTemplate}" UseSystemFocusVisuals="False" VerticalAlignment="Top" Width="20"/>
|
||||
<Button x:Name="NextButton" Background="Transparent" Grid.Column="1" HorizontalAlignment="Right" Height="36" IsTabStop="False" IsEnabled="False" Margin="{ThemeResource PivotNavButtonMargin}" Opacity="0" Template="{StaticResource NextTemplate}" UseSystemFocusVisuals="False" VerticalAlignment="Top" Width="20"/>
|
||||
<ContentPresenter x:Name="RightHeaderPresenter" ContentTemplate="{TemplateBinding RightHeaderTemplate}" Content="{TemplateBinding RightHeader}" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
<ItemsPresenter x:Name="PivotItemPresenter" Grid.ColumnSpan="3" Grid.Row="1">
|
||||
<ItemsPresenter.RenderTransform>
|
||||
<TransformGroup>
|
||||
<TranslateTransform x:Name="ItemsPresenterTranslateTransform"/>
|
||||
<CompositeTransform x:Name="ItemsPresenterCompositeTransform"/>
|
||||
</TransformGroup>
|
||||
</ItemsPresenter.RenderTransform>
|
||||
</ItemsPresenter>
|
||||
</Grid>
|
||||
</PivotPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style x:Key="PageControlDefaultStyle" TargetType="uwp:PageControl">
|
||||
<Setter Property="ContentMargin" Value="0" />
|
||||
<Setter Property="TitleBrush" Value="{ThemeResource DefaultTextForegroundThemeBrush}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="uwp:PageControl">
|
||||
<Grid Background="{TemplateBinding Background}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<uwp:FormsCommandBar x:Name="CommandBar" Grid.Row="0" VerticalContentAlignment="Top" Background="{TemplateBinding NavigationBarBackground}" Visibility="{Binding ShowNavigationBar,RelativeSource={RelativeSource Mode=TemplatedParent},Converter={StaticResource BoolVisibilityConverter}}">
|
||||
<uwp:FormsCommandBar.Content>
|
||||
<ContentControl VerticalAlignment="Top" VerticalContentAlignment="Center" Height="{ThemeResource TitleBarHeight}">
|
||||
<TextBlock Text="{Binding Title}" VerticalAlignment="Center" Padding="10,0,0,0" Foreground="{TemplateBinding TitleBrush}" Style="{ThemeResource TitleTextBlockStyle}" />
|
||||
</ContentControl>
|
||||
</uwp:FormsCommandBar.Content>
|
||||
</uwp:FormsCommandBar>
|
||||
|
||||
<ContentPresenter Margin="{TemplateBinding ContentMargin}" ContentTransitions="{TemplateBinding ContentTransitions}" x:Name="presenter" Grid.Row="1" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="uwp:StepperControl">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
|
@ -697,8 +446,6 @@
|
|||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="uwp:PageControl" BasedOn="{StaticResource PageControlDefaultStyle}" />
|
||||
|
||||
<Style TargetType="TextBox">
|
||||
<Setter Property="Margin" Value="0" />
|
||||
</Style>
|
||||
|
|
|
@ -7,6 +7,7 @@ using Windows.UI.Xaml.Automation;
|
|||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Xamarin.Forms.Internals;
|
||||
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
|
||||
using WGrid = Windows.UI.Xaml.Controls.Grid;
|
||||
|
||||
namespace Xamarin.Forms.Platform.UWP
|
||||
|
@ -40,302 +41,320 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
}
|
||||
}
|
||||
|
||||
public class TabbedPageRenderer : IVisualElementRenderer, ITitleProvider, IToolbarProvider
|
||||
{
|
||||
const string TabBarHeaderTextBlockName = "TabbedPageHeaderTextBlock";
|
||||
const string TabBarHeaderGridName = "TabbedPageHeaderGrid";
|
||||
|
||||
Color _barBackgroundColor;
|
||||
Color _barTextColor;
|
||||
bool _disposed;
|
||||
bool _showTitle;
|
||||
VisualElementTracker<Page, Pivot> _tracker;
|
||||
public class TabbedPageRenderer : IVisualElementRenderer, ITitleProvider, IToolbarProvider
|
||||
{
|
||||
const string TabBarHeaderTextBlockName = "TabbedPageHeaderTextBlock";
|
||||
const string TabBarHeaderGridName = "TabbedPageHeaderGrid";
|
||||
|
||||
Color _barBackgroundColor;
|
||||
Color _barTextColor;
|
||||
bool _disposed;
|
||||
bool _showTitle;
|
||||
VisualElementTracker<Page, Pivot> _tracker;
|
||||
|
||||
ITitleProvider TitleProvider => this;
|
||||
|
||||
public FormsPivot Control { get; private set; }
|
||||
ITitleProvider TitleProvider => this;
|
||||
|
||||
public FormsPivot Control { get; private set; }
|
||||
|
||||
public TabbedPage Element { get; private set; }
|
||||
|
||||
protected VisualElementTracker<Page, Pivot> Tracker
|
||||
{
|
||||
get { return _tracker; }
|
||||
set
|
||||
{
|
||||
if (_tracker == value)
|
||||
return;
|
||||
|
||||
if (_tracker != null)
|
||||
_tracker.Dispose();
|
||||
|
||||
_tracker = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
Brush ITitleProvider.BarBackgroundBrush
|
||||
{
|
||||
set { Control.ToolbarBackground = value; }
|
||||
}
|
||||
|
||||
Brush ITitleProvider.BarForegroundBrush
|
||||
{
|
||||
set { Control.ToolbarForeground = value; }
|
||||
}
|
||||
|
||||
IPageController PageController => Element as IPageController;
|
||||
|
||||
bool ITitleProvider.ShowTitle
|
||||
{
|
||||
get { return _showTitle; }
|
||||
|
||||
set
|
||||
{
|
||||
if (_showTitle == value)
|
||||
return;
|
||||
_showTitle = value;
|
||||
|
||||
UpdateBarVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
string ITitleProvider.Title
|
||||
{
|
||||
get { return (string)Control?.Title; }
|
||||
|
||||
set
|
||||
{
|
||||
if (Control != null && _showTitle)
|
||||
Control.Title = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<CommandBar> GetCommandBarAsync()
|
||||
{
|
||||
return (Control as IToolbarProvider)?.GetCommandBarAsync();
|
||||
}
|
||||
|
||||
public FrameworkElement ContainerElement
|
||||
{
|
||||
get { return Control; }
|
||||
}
|
||||
|
||||
VisualElement IVisualElementRenderer.Element
|
||||
{
|
||||
get { return Element; }
|
||||
}
|
||||
|
||||
public event EventHandler<VisualElementChangedEventArgs> ElementChanged;
|
||||
|
||||
public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
|
||||
{
|
||||
var constraint = new Windows.Foundation.Size(widthConstraint, heightConstraint);
|
||||
|
||||
double oldWidth = Control.Width;
|
||||
double oldHeight = Control.Height;
|
||||
|
||||
Control.Height = double.NaN;
|
||||
Control.Width = double.NaN;
|
||||
|
||||
Control.Measure(constraint);
|
||||
var result = new Size(Math.Ceiling(Control.DesiredSize.Width), Math.Ceiling(Control.DesiredSize.Height));
|
||||
|
||||
Control.Width = oldWidth;
|
||||
Control.Height = oldHeight;
|
||||
|
||||
return new SizeRequest(result);
|
||||
}
|
||||
|
||||
public void SetElement(VisualElement element)
|
||||
{
|
||||
if (element != null && !(element is TabbedPage))
|
||||
throw new ArgumentException("Element must be a TabbedPage", "element");
|
||||
|
||||
TabbedPage oldElement = Element;
|
||||
Element = (TabbedPage)element;
|
||||
|
||||
if (oldElement != null)
|
||||
{
|
||||
oldElement.PropertyChanged -= OnElementPropertyChanged;
|
||||
((INotifyCollectionChanged)oldElement.Children).CollectionChanged -= OnPagesChanged;
|
||||
}
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
if (Control == null)
|
||||
{
|
||||
Control = new FormsPivot { Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["TabbedPageStyle"], };
|
||||
|
||||
Control.SelectionChanged += OnSelectionChanged;
|
||||
|
||||
Tracker = new BackgroundTracker<Pivot>(Windows.UI.Xaml.Controls.Control.BackgroundProperty) { Element = (Page)element, Control = Control, Container = Control };
|
||||
|
||||
Control.Loaded += OnLoaded;
|
||||
Control.Unloaded += OnUnloaded;
|
||||
}
|
||||
|
||||
Control.DataContext = Element;
|
||||
OnPagesChanged(Element.Children, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||
|
||||
UpdateCurrentPage();
|
||||
|
||||
((INotifyCollectionChanged)Element.Children).CollectionChanged += OnPagesChanged;
|
||||
element.PropertyChanged += OnElementPropertyChanged;
|
||||
|
||||
if (!string.IsNullOrEmpty(element.AutomationId))
|
||||
Control.SetValue(AutomationProperties.AutomationIdProperty, element.AutomationId);
|
||||
}
|
||||
|
||||
OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposing || _disposed)
|
||||
return;
|
||||
|
||||
_disposed = true;
|
||||
PageController?.SendDisappearing();
|
||||
SetElement(null);
|
||||
Tracker = null;
|
||||
}
|
||||
|
||||
protected virtual void OnElementChanged(VisualElementChangedEventArgs e)
|
||||
{
|
||||
EventHandler<VisualElementChangedEventArgs> changed = ElementChanged;
|
||||
if (changed != null)
|
||||
changed(this, e);
|
||||
}
|
||||
|
||||
void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(TabbedPage.CurrentPage))
|
||||
{
|
||||
UpdateCurrentPage();
|
||||
UpdateBarTextColor();
|
||||
UpdateBarBackgroundColor();
|
||||
}
|
||||
else if (e.PropertyName == TabbedPage.BarTextColorProperty.PropertyName)
|
||||
UpdateBarTextColor();
|
||||
else if (e.PropertyName == TabbedPage.BarBackgroundColorProperty.PropertyName)
|
||||
UpdateBarBackgroundColor();
|
||||
}
|
||||
|
||||
void OnLoaded(object sender, RoutedEventArgs args)
|
||||
{
|
||||
PageController?.SendAppearing();
|
||||
UpdateBarTextColor();
|
||||
UpdateBarBackgroundColor();
|
||||
}
|
||||
|
||||
void OnPagesChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
e.Apply(Element.Children, Control.Items);
|
||||
|
||||
// Potential performance issue, UpdateLayout () is called for every page change
|
||||
Control.UpdateLayout();
|
||||
}
|
||||
|
||||
void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (Element == null)
|
||||
return;
|
||||
|
||||
Page page = e.AddedItems.Count > 0 ? (Page)e.AddedItems[0] : null;
|
||||
Page currentPage = Element.CurrentPage;
|
||||
if (currentPage == page)
|
||||
return;
|
||||
((IPageController)currentPage)?.SendDisappearing();
|
||||
Element.CurrentPage = page;
|
||||
((IPageController)page)?.SendAppearing();
|
||||
}
|
||||
|
||||
void OnUnloaded(object sender, RoutedEventArgs args)
|
||||
{
|
||||
PageController?.SendDisappearing();
|
||||
}
|
||||
|
||||
Brush GetBarBackgroundBrush()
|
||||
{
|
||||
object defaultColor = Windows.UI.Xaml.Application.Current.Resources["SystemControlBackgroundChromeMediumLowBrush"];
|
||||
if (Element.BarBackgroundColor.IsDefault && defaultColor != null)
|
||||
return (Brush)defaultColor;
|
||||
return Element.BarBackgroundColor.ToBrush();
|
||||
}
|
||||
|
||||
Brush GetBarForegroundBrush()
|
||||
{
|
||||
object defaultColor = Windows.UI.Xaml.Application.Current.Resources["ApplicationForegroundThemeBrush"];
|
||||
if (Element.BarTextColor.IsDefault && defaultColor != null)
|
||||
return (Brush)defaultColor;
|
||||
return Element.BarTextColor.ToBrush();
|
||||
}
|
||||
|
||||
void UpdateBarBackgroundColor()
|
||||
{
|
||||
if (Element == null) return;
|
||||
var barBackgroundColor = Element.BarBackgroundColor;
|
||||
|
||||
if (barBackgroundColor == _barBackgroundColor) return;
|
||||
_barBackgroundColor = barBackgroundColor;
|
||||
|
||||
var controlToolbarBackground = Control.ToolbarBackground;
|
||||
if (controlToolbarBackground == null && barBackgroundColor.IsDefault) return;
|
||||
|
||||
var brush = GetBarBackgroundBrush();
|
||||
if (brush == controlToolbarBackground) return;
|
||||
|
||||
TitleProvider.BarBackgroundBrush = brush;
|
||||
|
||||
foreach (WGrid tabBarGrid in Control.GetDescendantsByName<WGrid>(TabBarHeaderGridName))
|
||||
{
|
||||
tabBarGrid.Background = brush;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateBarTextColor()
|
||||
{
|
||||
if (Element == null) return;
|
||||
var barTextColor = Element.BarTextColor;
|
||||
|
||||
if (barTextColor == _barTextColor) return;
|
||||
_barTextColor = barTextColor;
|
||||
|
||||
var controlToolbarForeground = Control.ToolbarForeground;
|
||||
if (controlToolbarForeground == null && barTextColor.IsDefault) return;
|
||||
|
||||
var brush = GetBarForegroundBrush();
|
||||
if (brush == controlToolbarForeground)
|
||||
return;
|
||||
|
||||
TitleProvider.BarForegroundBrush = brush;
|
||||
|
||||
foreach (TextBlock tabBarTextBlock in Control.GetDescendantsByName<TextBlock>(TabBarHeaderTextBlockName))
|
||||
{
|
||||
tabBarTextBlock.Foreground = brush;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateBarVisibility()
|
||||
{
|
||||
Control.ToolbarVisibility = _showTitle ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
void UpdateCurrentPage()
|
||||
{
|
||||
Page page = Element.CurrentPage;
|
||||
|
||||
var nav = page as NavigationPage;
|
||||
TitleProvider.ShowTitle = nav != null;
|
||||
|
||||
if (page == null)
|
||||
return;
|
||||
|
||||
Control.SelectedItem = page;
|
||||
}
|
||||
}
|
||||
public TabbedPage Element { get; private set; }
|
||||
|
||||
protected VisualElementTracker<Page, Pivot> Tracker
|
||||
{
|
||||
get { return _tracker; }
|
||||
set
|
||||
{
|
||||
if (_tracker == value)
|
||||
return;
|
||||
|
||||
if (_tracker != null)
|
||||
_tracker.Dispose();
|
||||
|
||||
_tracker = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
Brush ITitleProvider.BarBackgroundBrush
|
||||
{
|
||||
set { Control.ToolbarBackground = value; }
|
||||
}
|
||||
|
||||
Brush ITitleProvider.BarForegroundBrush
|
||||
{
|
||||
set { Control.ToolbarForeground = value; }
|
||||
}
|
||||
|
||||
IPageController PageController => Element as IPageController;
|
||||
|
||||
bool ITitleProvider.ShowTitle
|
||||
{
|
||||
get { return _showTitle; }
|
||||
|
||||
set
|
||||
{
|
||||
if (_showTitle == value)
|
||||
return;
|
||||
_showTitle = value;
|
||||
|
||||
UpdateTitleVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
string ITitleProvider.Title
|
||||
{
|
||||
get { return (string)Control?.Title; }
|
||||
|
||||
set
|
||||
{
|
||||
if (Control != null && _showTitle)
|
||||
Control.Title = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<CommandBar> GetCommandBarAsync()
|
||||
{
|
||||
return (Control as IToolbarProvider)?.GetCommandBarAsync();
|
||||
}
|
||||
|
||||
public FrameworkElement ContainerElement
|
||||
{
|
||||
get { return Control; }
|
||||
}
|
||||
|
||||
VisualElement IVisualElementRenderer.Element
|
||||
{
|
||||
get { return Element; }
|
||||
}
|
||||
|
||||
public event EventHandler<VisualElementChangedEventArgs> ElementChanged;
|
||||
|
||||
public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
|
||||
{
|
||||
var constraint = new Windows.Foundation.Size(widthConstraint, heightConstraint);
|
||||
|
||||
double oldWidth = Control.Width;
|
||||
double oldHeight = Control.Height;
|
||||
|
||||
Control.Height = double.NaN;
|
||||
Control.Width = double.NaN;
|
||||
|
||||
Control.Measure(constraint);
|
||||
var result = new Size(Math.Ceiling(Control.DesiredSize.Width), Math.Ceiling(Control.DesiredSize.Height));
|
||||
|
||||
Control.Width = oldWidth;
|
||||
Control.Height = oldHeight;
|
||||
|
||||
return new SizeRequest(result);
|
||||
}
|
||||
|
||||
public void SetElement(VisualElement element)
|
||||
{
|
||||
if (element != null && !(element is TabbedPage))
|
||||
throw new ArgumentException("Element must be a TabbedPage", "element");
|
||||
|
||||
TabbedPage oldElement = Element;
|
||||
Element = (TabbedPage)element;
|
||||
|
||||
if (oldElement != null)
|
||||
{
|
||||
oldElement.PropertyChanged -= OnElementPropertyChanged;
|
||||
((INotifyCollectionChanged)oldElement.Children).CollectionChanged -= OnPagesChanged;
|
||||
}
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
if (Control == null)
|
||||
{
|
||||
Control = new FormsPivot
|
||||
{
|
||||
Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["TabbedPageStyle"],
|
||||
};
|
||||
|
||||
Control.SelectionChanged += OnSelectionChanged;
|
||||
|
||||
Tracker = new BackgroundTracker<Pivot>(Windows.UI.Xaml.Controls.Control.BackgroundProperty)
|
||||
{
|
||||
Element = (Page)element,
|
||||
Control = Control,
|
||||
Container = Control
|
||||
};
|
||||
|
||||
Control.Loaded += OnLoaded;
|
||||
Control.Unloaded += OnUnloaded;
|
||||
}
|
||||
|
||||
Control.DataContext = Element;
|
||||
OnPagesChanged(Element.Children,
|
||||
new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
|
||||
|
||||
UpdateCurrentPage();
|
||||
UpdateToolbarPlacement();
|
||||
|
||||
((INotifyCollectionChanged)Element.Children).CollectionChanged += OnPagesChanged;
|
||||
element.PropertyChanged += OnElementPropertyChanged;
|
||||
|
||||
if (!string.IsNullOrEmpty(element.AutomationId))
|
||||
Control.SetValue(AutomationProperties.AutomationIdProperty, element.AutomationId);
|
||||
}
|
||||
|
||||
OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposing || _disposed)
|
||||
return;
|
||||
|
||||
_disposed = true;
|
||||
PageController?.SendDisappearing();
|
||||
SetElement(null);
|
||||
Tracker = null;
|
||||
}
|
||||
|
||||
protected virtual void OnElementChanged(VisualElementChangedEventArgs e)
|
||||
{
|
||||
EventHandler<VisualElementChangedEventArgs> changed = ElementChanged;
|
||||
if (changed != null)
|
||||
changed(this, e);
|
||||
}
|
||||
|
||||
void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(TabbedPage.CurrentPage))
|
||||
{
|
||||
UpdateCurrentPage();
|
||||
UpdateBarTextColor();
|
||||
UpdateBarBackgroundColor();
|
||||
}
|
||||
else if (e.PropertyName == TabbedPage.BarTextColorProperty.PropertyName)
|
||||
UpdateBarTextColor();
|
||||
else if (e.PropertyName == TabbedPage.BarBackgroundColorProperty.PropertyName)
|
||||
UpdateBarBackgroundColor();
|
||||
else if (e.PropertyName == PlatformConfiguration.WindowsSpecific.Page.ToolbarPlacementProperty.PropertyName)
|
||||
UpdateToolbarPlacement();
|
||||
}
|
||||
|
||||
void OnLoaded(object sender, RoutedEventArgs args)
|
||||
{
|
||||
PageController?.SendAppearing();
|
||||
UpdateBarTextColor();
|
||||
UpdateBarBackgroundColor();
|
||||
}
|
||||
|
||||
void OnPagesChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
e.Apply(Element.Children, Control.Items);
|
||||
|
||||
// Potential performance issue, UpdateLayout () is called for every page change
|
||||
Control.UpdateLayout();
|
||||
}
|
||||
|
||||
void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (Element == null)
|
||||
return;
|
||||
|
||||
Page page = e.AddedItems.Count > 0 ? (Page)e.AddedItems[0] : null;
|
||||
Page currentPage = Element.CurrentPage;
|
||||
if (currentPage == page)
|
||||
return;
|
||||
((IPageController)currentPage)?.SendDisappearing();
|
||||
Element.CurrentPage = page;
|
||||
((IPageController)page)?.SendAppearing();
|
||||
}
|
||||
|
||||
void OnUnloaded(object sender, RoutedEventArgs args)
|
||||
{
|
||||
PageController?.SendDisappearing();
|
||||
}
|
||||
|
||||
Brush GetBarBackgroundBrush()
|
||||
{
|
||||
object defaultColor =
|
||||
Windows.UI.Xaml.Application.Current.Resources["SystemControlBackgroundChromeMediumLowBrush"];
|
||||
if (Element.BarBackgroundColor.IsDefault && defaultColor != null)
|
||||
return (Brush)defaultColor;
|
||||
return Element.BarBackgroundColor.ToBrush();
|
||||
}
|
||||
|
||||
Brush GetBarForegroundBrush()
|
||||
{
|
||||
object defaultColor = Windows.UI.Xaml.Application.Current.Resources["ApplicationForegroundThemeBrush"];
|
||||
if (Element.BarTextColor.IsDefault && defaultColor != null)
|
||||
return (Brush)defaultColor;
|
||||
return Element.BarTextColor.ToBrush();
|
||||
}
|
||||
|
||||
void UpdateBarBackgroundColor()
|
||||
{
|
||||
if (Element == null) return;
|
||||
var barBackgroundColor = Element.BarBackgroundColor;
|
||||
|
||||
if (barBackgroundColor == _barBackgroundColor) return;
|
||||
_barBackgroundColor = barBackgroundColor;
|
||||
|
||||
var controlToolbarBackground = Control.ToolbarBackground;
|
||||
if (controlToolbarBackground == null && barBackgroundColor.IsDefault) return;
|
||||
|
||||
var brush = GetBarBackgroundBrush();
|
||||
if (brush == controlToolbarBackground) return;
|
||||
|
||||
TitleProvider.BarBackgroundBrush = brush;
|
||||
|
||||
foreach (WGrid tabBarGrid in Control.GetDescendantsByName<WGrid>(TabBarHeaderGridName))
|
||||
{
|
||||
tabBarGrid.Background = brush;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateBarTextColor()
|
||||
{
|
||||
if (Element == null) return;
|
||||
var barTextColor = Element.BarTextColor;
|
||||
|
||||
if (barTextColor == _barTextColor) return;
|
||||
_barTextColor = barTextColor;
|
||||
|
||||
var controlToolbarForeground = Control.ToolbarForeground;
|
||||
if (controlToolbarForeground == null && barTextColor.IsDefault) return;
|
||||
|
||||
var brush = GetBarForegroundBrush();
|
||||
if (brush == controlToolbarForeground)
|
||||
return;
|
||||
|
||||
TitleProvider.BarForegroundBrush = brush;
|
||||
|
||||
foreach (TextBlock tabBarTextBlock in Control.GetDescendantsByName<TextBlock>(TabBarHeaderTextBlockName))
|
||||
{
|
||||
tabBarTextBlock.Foreground = brush;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateTitleVisibility()
|
||||
{
|
||||
Control.TitleVisibility = _showTitle ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
void UpdateCurrentPage()
|
||||
{
|
||||
Page page = Element.CurrentPage;
|
||||
|
||||
var nav = page as NavigationPage;
|
||||
TitleProvider.ShowTitle = nav != null;
|
||||
|
||||
if (page == null)
|
||||
return;
|
||||
|
||||
Control.SelectedItem = page;
|
||||
}
|
||||
|
||||
void UpdateToolbarPlacement()
|
||||
{
|
||||
Control.ToolbarPlacement = Element.OnThisPlatform().GetToolbarPlacement();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:uwp="using:Xamarin.Forms.Platform.UWP">
|
||||
<Style x:Key="TabbedPageStyle" TargetType="uwp:FormsPivot">
|
||||
<Setter Property="HeaderTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<TextBlock Name="TabbedPageHeaderTextBlock" Text="{Binding Title}" Style="{ThemeResource BodyTextBlockStyle}" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
<Setter Property="ItemTemplate">
|
||||
<Setter.Value>
|
||||
<DataTemplate>
|
||||
<uwp:TabbedPagePresenter Content="{Binding}" ContentTemplate="{ThemeResource ContainedPageTemplate}" />
|
||||
</DataTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="uwp:FormsPivot">
|
||||
<Grid x:Name="RootElement" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="NavigationButtonsVisibility">
|
||||
<VisualState x:Name="NavigationButtonsHidden"/>
|
||||
<VisualState x:Name="NavigationButtonsVisible">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="NextButton">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsEnabled" Storyboard.TargetName="NextButton">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="True"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PreviousButton">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="1"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="IsEnabled" Storyboard.TargetName="PreviousButton">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="True"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
<VisualStateGroup x:Name="HeaderStates">
|
||||
<VisualState x:Name="HeaderDynamic"/>
|
||||
<VisualState x:Name="HeaderStatic">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="Header">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="StaticHeader">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
|
||||
<Grid x:Name="TitleBar" Background="{TemplateBinding ToolbarBackground}" HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Height="{ThemeResource TitleBarHeight}" Visibility="{TemplateBinding TitleVisibility}">
|
||||
<TextBlock Text="{Binding Title}" VerticalAlignment="Center" Padding="10,0,0,0" Foreground="{TemplateBinding ToolbarForeground}" Style="{ThemeResource TitleTextBlockStyle}" />
|
||||
</Border>
|
||||
|
||||
<Border x:Name="TopCommandBarArea" Grid.Column="1" HorizontalAlignment="Stretch">
|
||||
<uwp:FormsCommandBar x:Name="CommandBar" VerticalContentAlignment="Top" Background="{TemplateBinding ToolbarBackground}" Height="{ThemeResource TitleBarHeight}" />
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.Resources>
|
||||
<ControlTemplate x:Key="NextTemplate" TargetType="Button">
|
||||
<Border x:Name="Root" BorderBrush="{ThemeResource SystemControlForegroundTransparentBrush}" BorderThickness="{ThemeResource PivotNavButtonBorderThemeThickness}" Background="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal"/>
|
||||
<VisualState x:Name="PointerOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Root">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Arrow">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Pressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Root">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Arrow">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<FontIcon x:Name="Arrow" Foreground="{ThemeResource SystemControlForegroundAltMediumHighBrush}" FontSize="12" FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="" HorizontalAlignment="Center" MirroredWhenRightToLeft="True" UseLayoutRounding="False" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
<ControlTemplate x:Key="PreviousTemplate" TargetType="Button">
|
||||
<Border x:Name="Root" BorderBrush="{ThemeResource SystemControlForegroundTransparentBrush}" BorderThickness="{ThemeResource PivotNavButtonBorderThemeThickness}" Background="{ThemeResource SystemControlBackgroundBaseMediumLowBrush}">
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal"/>
|
||||
<VisualState x:Name="PointerOver">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Root">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Arrow">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
<VisualState x:Name="Pressed">
|
||||
<Storyboard>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Root">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightBaseMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="Arrow">
|
||||
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAltMediumHighBrush}"/>
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
<FontIcon x:Name="Arrow" Foreground="{ThemeResource SystemControlForegroundAltMediumHighBrush}" FontSize="12" FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="" HorizontalAlignment="Center" MirroredWhenRightToLeft="True" UseLayoutRounding="False" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Grid.Resources>
|
||||
<ScrollViewer x:Name="ScrollViewer" BringIntoViewOnFocusChange="False" HorizontalSnapPointsAlignment="Center" HorizontalSnapPointsType="MandatorySingle" HorizontalScrollBarVisibility="Hidden" Margin="{TemplateBinding Padding}" Template="{StaticResource ScrollViewerScrollBarlessTemplate}" VerticalSnapPointsType="None" VerticalScrollBarVisibility="Disabled" VerticalScrollMode="Disabled" VerticalContentAlignment="Stretch" ZoomMode="Disabled">
|
||||
<PivotPanel x:Name="Panel" VerticalAlignment="Stretch">
|
||||
<Grid x:Name="PivotLayoutElement">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.RenderTransform>
|
||||
<CompositeTransform x:Name="PivotLayoutElementTranslateTransform"/>
|
||||
</Grid.RenderTransform>
|
||||
<ContentPresenter x:Name="LeftHeaderPresenter" ContentTemplate="{TemplateBinding LeftHeaderTemplate}" Content="{TemplateBinding LeftHeader}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
<ContentControl x:Name="HeaderClipper" Grid.Column="1" HorizontalContentAlignment="Stretch" UseSystemFocusVisuals="True">
|
||||
<ContentControl.Clip>
|
||||
<RectangleGeometry x:Name="HeaderClipperGeometry"/>
|
||||
</ContentControl.Clip>
|
||||
<Grid Name="TabbedPageHeaderGrid" Background="{TemplateBinding ToolbarBackground}">
|
||||
<PivotHeaderPanel x:Name="StaticHeader" Visibility="Collapsed"/>
|
||||
<PivotHeaderPanel x:Name="Header">
|
||||
<PivotHeaderPanel.RenderTransform>
|
||||
<TransformGroup>
|
||||
<CompositeTransform x:Name="HeaderTranslateTransform"/>
|
||||
<CompositeTransform x:Name="HeaderOffsetTranslateTransform"/>
|
||||
</TransformGroup>
|
||||
</PivotHeaderPanel.RenderTransform>
|
||||
</PivotHeaderPanel>
|
||||
</Grid>
|
||||
</ContentControl>
|
||||
<Button x:Name="PreviousButton" Background="Transparent" Grid.Column="1" HorizontalAlignment="Left" Height="36" IsTabStop="False" IsEnabled="False" Margin="{ThemeResource PivotNavButtonMargin}" Opacity="0" Template="{StaticResource PreviousTemplate}" UseSystemFocusVisuals="False" VerticalAlignment="Top" Width="20"/>
|
||||
<Button x:Name="NextButton" Background="Transparent" Grid.Column="1" HorizontalAlignment="Right" Height="36" IsTabStop="False" IsEnabled="False" Margin="{ThemeResource PivotNavButtonMargin}" Opacity="0" Template="{StaticResource NextTemplate}" UseSystemFocusVisuals="False" VerticalAlignment="Top" Width="20"/>
|
||||
<ContentPresenter x:Name="RightHeaderPresenter" ContentTemplate="{TemplateBinding RightHeaderTemplate}" Content="{TemplateBinding RightHeader}" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
<ItemsPresenter x:Name="PivotItemPresenter" Grid.ColumnSpan="3" Grid.Row="1">
|
||||
<ItemsPresenter.RenderTransform>
|
||||
<TransformGroup>
|
||||
<TranslateTransform x:Name="ItemsPresenterTranslateTransform"/>
|
||||
<CompositeTransform x:Name="ItemsPresenterCompositeTransform"/>
|
||||
</TransformGroup>
|
||||
</ItemsPresenter.RenderTransform>
|
||||
</ItemsPresenter>
|
||||
</Grid>
|
||||
</PivotPanel>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
<Border x:Name="BottomCommandBarArea" Grid.Row="2" HorizontalAlignment="Stretch"></Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
|
@ -0,0 +1,46 @@
|
|||
using Windows.UI.Xaml.Controls;
|
||||
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
|
||||
|
||||
namespace Xamarin.Forms.Platform.UWP
|
||||
{
|
||||
internal class ToolbarPlacementHelper
|
||||
{
|
||||
public static void UpdateToolbarPlacement(CommandBar toolbar, ToolbarPlacement toolbarPlacement, Border bottomCommandBarArea, Border topCommandBarArea)
|
||||
{
|
||||
if (toolbar == null || bottomCommandBarArea == null || topCommandBarArea == null)
|
||||
{
|
||||
// Haven't applied the template yet, so we're not ready to do this
|
||||
return;
|
||||
}
|
||||
|
||||
// Figure out what's hosting the command bar right now
|
||||
var current = toolbar.Parent as Border;
|
||||
|
||||
// And figure out where it should be
|
||||
Border target;
|
||||
|
||||
switch (toolbarPlacement)
|
||||
{
|
||||
case ToolbarPlacement.Top:
|
||||
target = topCommandBarArea;
|
||||
break;
|
||||
case ToolbarPlacement.Bottom:
|
||||
target = bottomCommandBarArea;
|
||||
break;
|
||||
case ToolbarPlacement.Default:
|
||||
default:
|
||||
target = Device.Idiom == TargetIdiom.Phone ? bottomCommandBarArea : topCommandBarArea;
|
||||
break;
|
||||
}
|
||||
|
||||
if (current == null || target == null || current == target)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove the command bar from its current host and add it to the new one
|
||||
current.Child = null;
|
||||
target.Child = toolbar;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -164,6 +164,9 @@
|
|||
<Compile Include="..\Xamarin.Forms.Platform.WinRT\NativeViewWrapperRenderer.cs">
|
||||
<Link>NativeViewWrapperRenderer.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Xamarin.Forms.Platform.WinRT\PlatformConfigurationExtensions.cs">
|
||||
<Link>PlatformConfigurationExtensions.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Xamarin.Forms.Platform.WinRT\PlatformEffect.cs">
|
||||
<Link>PlatformEffect.cs</Link>
|
||||
</Compile>
|
||||
|
@ -183,6 +186,7 @@
|
|||
</Compile>
|
||||
<Compile Include="StepperControl.cs" />
|
||||
<Compile Include="TabbedPageRenderer.cs" />
|
||||
<Compile Include="ToolbarPlacementHelper.cs" />
|
||||
<Content Include="Properties\Xamarin.Forms.Platform.UAP.rd.xml" />
|
||||
<Compile Include="..\Xamarin.Forms.Core\Properties\GlobalAssemblyInfo.cs">
|
||||
<Link>Properties\GlobalAssemblyInfo.cs</Link>
|
||||
|
@ -432,14 +436,26 @@
|
|||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="MasterDetailControlStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="PageControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="PageControlStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Resources.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="TabbedPageStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Xamarin.Forms.Core\Xamarin.Forms.Core.csproj">
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
|
||||
|
||||
#if WINDOWS_UWP
|
||||
|
||||
|
@ -12,7 +13,7 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
{
|
||||
public class FormsPivot : Pivot, IToolbarProvider
|
||||
{
|
||||
public static readonly DependencyProperty ToolbarVisibilityProperty = DependencyProperty.Register(nameof(ToolbarVisibility), typeof(Visibility), typeof(FormsPivot),
|
||||
public static readonly DependencyProperty TitleVisibilityProperty = DependencyProperty.Register(nameof(TitleVisibility), typeof(Visibility), typeof(FormsPivot),
|
||||
new PropertyMetadata(Visibility.Collapsed));
|
||||
|
||||
public static readonly DependencyProperty ToolbarForegroundProperty = DependencyProperty.Register(nameof(ToolbarForeground), typeof(Brush), typeof(FormsPivot), new PropertyMetadata(default(Brush)));
|
||||
|
@ -20,10 +21,14 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
public static readonly DependencyProperty ToolbarBackgroundProperty = DependencyProperty.Register(nameof(ToolbarBackground), typeof(Brush), typeof(FormsPivot), new PropertyMetadata(default(Brush)));
|
||||
|
||||
CommandBar _commandBar;
|
||||
|
||||
#if WINDOWS_UWP
|
||||
Border _bottomCommandBarArea;
|
||||
Border _topCommandBarArea;
|
||||
#endif
|
||||
TaskCompletionSource<CommandBar> _commandBarTcs;
|
||||
ToolbarPlacement _toolbarPlacement;
|
||||
|
||||
public Brush ToolbarBackground
|
||||
public Brush ToolbarBackground
|
||||
{
|
||||
get { return (Brush)GetValue(ToolbarBackgroundProperty); }
|
||||
set { SetValue(ToolbarBackgroundProperty, value); }
|
||||
|
@ -35,12 +40,24 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
set { SetValue(ToolbarForegroundProperty, value); }
|
||||
}
|
||||
|
||||
public Visibility ToolbarVisibility
|
||||
public Visibility TitleVisibility
|
||||
{
|
||||
get { return (Visibility)GetValue(ToolbarVisibilityProperty); }
|
||||
set { SetValue(ToolbarVisibilityProperty, value); }
|
||||
get { return (Visibility)GetValue(TitleVisibilityProperty); }
|
||||
set { SetValue(TitleVisibilityProperty, value); }
|
||||
}
|
||||
|
||||
public ToolbarPlacement ToolbarPlacement
|
||||
{
|
||||
get { return _toolbarPlacement; }
|
||||
set
|
||||
{
|
||||
_toolbarPlacement = value;
|
||||
#if WINDOWS_UWP
|
||||
UpdateToolbarPlacement();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Task<CommandBar> IToolbarProvider.GetCommandBarAsync()
|
||||
{
|
||||
if (_commandBar != null)
|
||||
|
@ -54,12 +71,24 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
protected override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
_commandBar = GetTemplateChild("CommandBar") as CommandBar;
|
||||
|
||||
#if WINDOWS_UWP
|
||||
_bottomCommandBarArea = GetTemplateChild("BottomCommandBarArea") as Border;
|
||||
_topCommandBarArea = GetTemplateChild("TopCommandBarArea") as Border;
|
||||
UpdateToolbarPlacement();
|
||||
#endif
|
||||
|
||||
TaskCompletionSource<CommandBar> tcs = _commandBarTcs;
|
||||
if (tcs != null)
|
||||
{
|
||||
tcs.SetResult(_commandBar);
|
||||
}
|
||||
tcs?.SetResult(_commandBar);
|
||||
}
|
||||
|
||||
#if WINDOWS_UWP
|
||||
void UpdateToolbarPlacement()
|
||||
{
|
||||
ToolbarPlacementHelper.UpdateToolbarPlacement(_commandBar, ToolbarPlacement, _bottomCommandBarArea, _topCommandBarArea);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -436,7 +436,8 @@
|
|||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Height="79" Background="{TemplateBinding NavigationBarBackground}" Visibility="{Binding ShowNavigationBar,RelativeSource={RelativeSource Mode=TemplatedParent},Converter={StaticResource BoolVisibilityConverter}}">
|
||||
<Grid Height="79" Background="{TemplateBinding NavigationBarBackground}"
|
||||
Visibility="{TemplateBinding TitleVisibility}">
|
||||
<TextBlock Margin="10,0,0,0" Name="title" Foreground="{TemplateBinding TitleBrush}" VerticalAlignment="Center" Style="{ThemeResource HeaderTextBlockStyle}" Text="{Binding Title}" />
|
||||
</Grid>
|
||||
<ContentPresenter x:Name="presenter" Grid.Row="1" ContentTransitions="{TemplateBinding ContentTransitions}" />
|
||||
|
|
|
@ -187,7 +187,7 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
return;
|
||||
_showTitle = value;
|
||||
|
||||
Control.ToolbarVisibility = _showTitle ? Visibility.Visible : Visibility.Collapsed;
|
||||
Control.TitleVisibility = _showTitle ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -327,7 +327,8 @@
|
|||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0" Grid.Column="0" Height="79" VerticalAlignment="Center" Background="{TemplateBinding NavigationBarBackground}" Visibility="{Binding ShowNavigationBar,RelativeSource={RelativeSource Mode=TemplatedParent},Converter={StaticResource BoolVisibilityConverter}}">
|
||||
<Grid Grid.Row="0" Grid.Column="0" Height="79" VerticalAlignment="Center" Background="{TemplateBinding NavigationBarBackground}"
|
||||
Visibility="{TemplateBinding TitleVisibility}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" MinWidth="{Binding TitleInset,RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<ColumnDefinition Width="*" />
|
||||
|
|
|
@ -13,6 +13,8 @@ using Windows.UI.Xaml.Input;
|
|||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
using Xamarin.Forms.Internals;
|
||||
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
|
||||
|
||||
#if WINDOWS_UWP
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Core;
|
||||
|
@ -72,7 +74,7 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
{
|
||||
set
|
||||
{
|
||||
_container.NavigationBarBackground = value;
|
||||
_container.ToolbarBackground = value;
|
||||
UpdateTitleOnParents();
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +99,7 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
return;
|
||||
|
||||
_showTitle = value;
|
||||
UpdateNavigationBarVisible();
|
||||
UpdateTitleVisible();
|
||||
UpdateTitleOnParents();
|
||||
}
|
||||
}
|
||||
|
@ -187,6 +189,7 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
LookupRelevantParents();
|
||||
UpdateTitleColor();
|
||||
UpdateNavigationBarBackground();
|
||||
UpdateToolbarPlacement();
|
||||
Element.PropertyChanged += OnElementPropertyChanged;
|
||||
((INavigationPageController)Element).PushRequested += OnPushRequested;
|
||||
((INavigationPageController)Element).PopRequested += OnPopRequested;
|
||||
|
@ -258,6 +261,7 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
return Element.BarTextColor.ToBrush();
|
||||
}
|
||||
|
||||
// TODO EZH Why don't this and GetToolBarProvider ever get called on either platform?
|
||||
Task<CommandBar> GetCommandBarAsync()
|
||||
{
|
||||
var platform = (Platform)Element.Platform;
|
||||
|
@ -332,7 +336,7 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
else if (e.PropertyName == NavigationPage.BackButtonTitleProperty.PropertyName)
|
||||
UpdateBackButtonTitle();
|
||||
else if (e.PropertyName == NavigationPage.HasNavigationBarProperty.PropertyName)
|
||||
UpdateNavigationBarVisible();
|
||||
UpdateTitleVisible();
|
||||
}
|
||||
|
||||
void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
|
@ -343,6 +347,8 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
UpdateNavigationBarBackground();
|
||||
else if (e.PropertyName == Page.PaddingProperty.PropertyName)
|
||||
UpdatePadding();
|
||||
else if (e.PropertyName == PlatformConfiguration.WindowsSpecific.Page.ToolbarPlacementProperty.PropertyName)
|
||||
UpdateToolbarPlacement();
|
||||
}
|
||||
|
||||
void OnLoaded(object sender, RoutedEventArgs args)
|
||||
|
@ -434,7 +440,7 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
|
||||
IVisualElementRenderer renderer = page.GetOrCreateRenderer();
|
||||
|
||||
UpdateNavigationBarVisible();
|
||||
UpdateTitleVisible();
|
||||
UpdateTitleOnParents();
|
||||
|
||||
if (isAnimated && _transition == null)
|
||||
|
@ -484,16 +490,16 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
(this as ITitleProvider).BarBackgroundBrush = GetBarBackgroundBrush();
|
||||
}
|
||||
|
||||
void UpdateNavigationBarVisible()
|
||||
void UpdateTitleVisible()
|
||||
{
|
||||
UpdateTitleOnParents();
|
||||
|
||||
bool showing = _container.ShowNavigationBar;
|
||||
bool newValue = GetIsNavBarPossible() && NavigationPage.GetHasNavigationBar(_currentPage);
|
||||
bool showing = _container.TitleVisibility == Visibility.Visible;
|
||||
bool newValue = GetIsNavBarPossible() && NavigationPage.GetHasNavigationBar(_currentPage) && !string.IsNullOrEmpty(_currentPage.Title);
|
||||
if (showing == newValue)
|
||||
return;
|
||||
|
||||
_container.ShowNavigationBar = newValue;
|
||||
_container.TitleVisibility = newValue ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
// Force ContentHeight/Width to update, doesn't work from inside PageControl for some reason
|
||||
_container.UpdateLayout();
|
||||
|
@ -510,6 +516,18 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
(this as ITitleProvider).BarForegroundBrush = GetBarForegroundBrush();
|
||||
}
|
||||
|
||||
void UpdateToolbarPlacement()
|
||||
{
|
||||
#if WINDOWS_UWP
|
||||
if (_container == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_container.ToolbarPlacement = Element.OnThisPlatform().GetToolbarPlacement();
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma warning disable 1998 // considered for removal
|
||||
async void UpdateTitleOnParents()
|
||||
#pragma warning restore 1998
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
using System.Threading.Tasks;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
|
||||
|
||||
#if WINDOWS_UWP
|
||||
|
||||
|
@ -11,7 +14,7 @@ namespace Xamarin.Forms.Platform.UWP
|
|||
namespace Xamarin.Forms.Platform.WinRT
|
||||
#endif
|
||||
{
|
||||
public sealed partial class PageControl : IToolbarProvider
|
||||
public sealed partial class PageControl : IToolbarProvider
|
||||
{
|
||||
public static readonly DependencyProperty InvisibleBackButtonCollapsedProperty = DependencyProperty.Register("InvisibleBackButtonCollapsed", typeof(bool), typeof(PageControl),
|
||||
new PropertyMetadata(true, OnInvisibleBackButtonCollapsedChanged));
|
||||
|
@ -19,9 +22,9 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
public static readonly DependencyProperty ShowBackButtonProperty = DependencyProperty.Register("ShowBackButton", typeof(bool), typeof(PageControl),
|
||||
new PropertyMetadata(false, OnShowBackButtonChanged));
|
||||
|
||||
public static readonly DependencyProperty ShowNavigationBarProperty = DependencyProperty.Register("ShowNavigationBar", typeof(bool), typeof(PageControl), new PropertyMetadata(true));
|
||||
public static readonly DependencyProperty TitleVisibilityProperty = DependencyProperty.Register(nameof(TitleVisibility), typeof(Visibility), typeof(PageControl), new PropertyMetadata(Visibility.Visible));
|
||||
|
||||
public static readonly DependencyProperty NavigationBarBackgroundProperty = DependencyProperty.Register("NavigationBarBackground", typeof(Brush), typeof(PageControl),
|
||||
public static readonly DependencyProperty ToolbarBackgroundProperty = DependencyProperty.Register(nameof(ToolbarBackground), typeof(Brush), typeof(PageControl),
|
||||
new PropertyMetadata(default(Brush)));
|
||||
|
||||
public static readonly DependencyProperty BackButtonTitleProperty = DependencyProperty.Register("BackButtonTitle", typeof(string), typeof(PageControl), new PropertyMetadata(false));
|
||||
|
@ -36,10 +39,17 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
AppBarButton _backButton;
|
||||
CommandBar _commandBar;
|
||||
|
||||
TaskCompletionSource<CommandBar> _commandBarTcs;
|
||||
Windows.UI.Xaml.Controls.ContentPresenter _presenter;
|
||||
#if WINDOWS_UWP
|
||||
ToolbarPlacement _toolbarPlacement;
|
||||
Border _bottomCommandBarArea;
|
||||
Border _topCommandBarArea;
|
||||
#endif
|
||||
|
||||
public PageControl()
|
||||
TaskCompletionSource<CommandBar> _commandBarTcs;
|
||||
Windows.UI.Xaml.Controls.ContentPresenter _presenter;
|
||||
|
||||
|
||||
public PageControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
@ -72,22 +82,34 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
set { SetValue(InvisibleBackButtonCollapsedProperty, value); }
|
||||
}
|
||||
|
||||
public Brush NavigationBarBackground
|
||||
public Brush ToolbarBackground
|
||||
{
|
||||
get { return (Brush)GetValue(NavigationBarBackgroundProperty); }
|
||||
set { SetValue(NavigationBarBackgroundProperty, value); }
|
||||
get { return (Brush)GetValue(ToolbarBackgroundProperty); }
|
||||
set { SetValue(ToolbarBackgroundProperty, value); }
|
||||
}
|
||||
|
||||
#if WINDOWS_UWP
|
||||
public ToolbarPlacement ToolbarPlacement
|
||||
{
|
||||
get { return _toolbarPlacement; }
|
||||
set
|
||||
{
|
||||
_toolbarPlacement = value;
|
||||
UpdateToolbarPlacement();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public bool ShowBackButton
|
||||
{
|
||||
get { return (bool)GetValue(ShowBackButtonProperty); }
|
||||
set { SetValue(ShowBackButtonProperty, value); }
|
||||
}
|
||||
|
||||
public bool ShowNavigationBar
|
||||
public Visibility TitleVisibility
|
||||
{
|
||||
get { return (bool)GetValue(ShowNavigationBarProperty); }
|
||||
set { SetValue(ShowNavigationBarProperty, value); }
|
||||
get { return (Visibility)GetValue(TitleVisibilityProperty); }
|
||||
set { SetValue(TitleVisibilityProperty, value); }
|
||||
}
|
||||
|
||||
public Brush TitleBrush
|
||||
|
@ -125,12 +147,14 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
_presenter = GetTemplateChild("presenter") as Windows.UI.Xaml.Controls.ContentPresenter;
|
||||
|
||||
_commandBar = GetTemplateChild("CommandBar") as CommandBar;
|
||||
#if WINDOWS_UWP
|
||||
_bottomCommandBarArea = GetTemplateChild("BottomCommandBarArea") as Border;
|
||||
_topCommandBarArea = GetTemplateChild("TopCommandBarArea") as Border;
|
||||
UpdateToolbarPlacement();
|
||||
#endif
|
||||
|
||||
TaskCompletionSource<CommandBar> tcs = _commandBarTcs;
|
||||
if (tcs != null)
|
||||
{
|
||||
tcs.SetResult(_commandBar);
|
||||
}
|
||||
tcs?.SetResult(_commandBar);
|
||||
}
|
||||
|
||||
void OnBackClicked(object sender, RoutedEventArgs e)
|
||||
|
@ -162,5 +186,12 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
|
||||
_backButton.Opacity = ShowBackButton ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if WINDOWS_UWP
|
||||
void UpdateToolbarPlacement()
|
||||
{
|
||||
ToolbarPlacementHelper.UpdateToolbarPlacement(_commandBar, ToolbarPlacement, _bottomCommandBarArea, _topCommandBarArea);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -506,8 +506,8 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
return _page.BottomAppBar as CommandBar;
|
||||
#else
|
||||
IToolbarProvider provider = GetToolbarProvider();
|
||||
var titleProvider = provider as ITitleProvider;
|
||||
if (provider == null || (titleProvider != null && !titleProvider.ShowTitle))
|
||||
//var titleProvider = provider as ITitleProvider;
|
||||
if (provider == null) // || (titleProvider != null && !titleProvider.ShowTitle))
|
||||
return null;
|
||||
|
||||
return await provider.GetCommandBarAsync();
|
||||
|
@ -521,6 +521,7 @@ namespace Xamarin.Forms.Platform.WinRT
|
|||
_page.BottomAppBar = commandBar;
|
||||
return commandBar;
|
||||
#else
|
||||
|
||||
var bar = new FormsCommandBar();
|
||||
if (Device.Idiom != TargetIdiom.Phone)
|
||||
bar.Style = (Windows.UI.Xaml.Style)Windows.UI.Xaml.Application.Current.Resources["TitleToolbar"];
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#if WINDOWS_UWP
|
||||
|
||||
namespace Xamarin.Forms.Platform.UWP
|
||||
#else
|
||||
|
||||
namespace Xamarin.Forms.Platform.WinRT
|
||||
#endif
|
||||
{
|
||||
public static class PlatformConfigurationExtensions
|
||||
{
|
||||
public static IPlatformElementConfiguration<PlatformConfiguration.Windows, T> OnThisPlatform<T>(this T element)
|
||||
where T : Element, IElementConfiguration<T>
|
||||
{
|
||||
return (element).On<PlatformConfiguration.Windows>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -66,6 +66,7 @@
|
|||
<Compile Include="..\Xamarin.Forms.Core\Properties\GlobalAssemblyInfo.cs">
|
||||
<Link>Properties\GlobalAssemblyInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="PlatformConfigurationExtensions.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(OS)' != 'Unix' ">
|
||||
<Compile Include="BrushHelpers.cs" />
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
namespace Xamarin.Forms.Platform.iOS
|
||||
{
|
||||
public static class PlatformConfigurationExtensions
|
||||
{
|
||||
public static IPlatformElementConfiguration<PlatformConfiguration.iOS, T> OnThisPlatform<T>(this T element)
|
||||
where T : Element, IElementConfiguration<T>
|
||||
{
|
||||
return (element).On<PlatformConfiguration.iOS>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
|
||||
#if __UNIFIED__
|
||||
using UIKit;
|
||||
using CoreGraphics;
|
||||
|
@ -23,7 +24,6 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
public class BoxRenderer : VisualElementRenderer<BoxView>
|
||||
{
|
||||
UIColor _colorToRenderer;
|
||||
|
||||
SizeF _previousSize;
|
||||
|
||||
public override void Draw(RectangleF rect)
|
||||
|
|
|
@ -7,7 +7,7 @@ using System.Linq;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
|
||||
#if __UNIFIED__
|
||||
using UIKit;
|
||||
using CoreGraphics;
|
||||
|
@ -21,9 +21,9 @@ using SizeF = CoreGraphics.CGSize;
|
|||
using PointF = CoreGraphics.CGPoint;
|
||||
|
||||
#else
|
||||
using nfloat=System.Single;
|
||||
using nint=System.Int32;
|
||||
using nuint=System.UInt32;
|
||||
using nfloat = System.Single;
|
||||
using nint = System.Int32;
|
||||
using nuint = System.UInt32;
|
||||
#endif
|
||||
|
||||
namespace Xamarin.Forms.Platform.iOS
|
||||
|
@ -49,6 +49,8 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
var parentingViewController = (ParentingViewController)ViewControllers.Last();
|
||||
UpdateLeftBarButtonItem(parentingViewController);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
Page Current { get; set; }
|
||||
|
@ -181,7 +183,10 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
base.ViewDidLoad();
|
||||
|
||||
if (Forms.IsiOS7OrNewer)
|
||||
NavigationBar.Translucent = false;
|
||||
{
|
||||
|
||||
UpdateTranslucent();
|
||||
}
|
||||
else
|
||||
WantsFullScreenLayout = false;
|
||||
|
||||
|
@ -437,6 +442,18 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
UpdateBackgroundColor();
|
||||
else if (e.PropertyName == NavigationPage.CurrentPageProperty.PropertyName)
|
||||
Current = ((NavigationPage)Element).CurrentPage;
|
||||
else if (e.PropertyName == PlatformConfiguration.iOSSpecific.NavigationPage.IsNavigationBarTranslucentProperty.PropertyName)
|
||||
UpdateTranslucent();
|
||||
}
|
||||
|
||||
void UpdateTranslucent()
|
||||
{
|
||||
if (!Forms.IsiOS7OrNewer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NavigationBar.Translucent = ((NavigationPage)Element).OnThisPlatform().IsNavigationBarTranslucent();
|
||||
}
|
||||
|
||||
void InsertPageBefore(Page page, Page before)
|
||||
|
@ -481,7 +498,7 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
if (page == null)
|
||||
throw new ArgumentNullException("page");
|
||||
if (page == Current)
|
||||
throw new NotSupportedException(); // should never happen as NavPage protecs against this
|
||||
throw new NotSupportedException(); // should never happen as NavPage protects against this
|
||||
|
||||
var target = Platform.GetRenderer(page).ViewController.ParentViewController;
|
||||
|
||||
|
@ -807,6 +824,7 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
public override void ViewWillAppear(bool animated)
|
||||
{
|
||||
UpdateNavigationBarVisibility(animated);
|
||||
EdgesForExtendedLayout = UIRectEdge.None;
|
||||
base.ViewWillAppear(animated);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ using System.Collections.ObjectModel;
|
|||
using System.Collections.Specialized;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
|
||||
|
||||
#if __UNIFIED__
|
||||
using UIKit;
|
||||
#else
|
||||
|
@ -13,6 +15,7 @@ using MonoTouch.UIKit;
|
|||
using RectangleF = CoreGraphics.CGRect;
|
||||
using SizeF = CoreGraphics.CGSize;
|
||||
using PointF = CoreGraphics.CGPoint;
|
||||
using CoreGraphics;
|
||||
|
||||
#else
|
||||
using nfloat=System.Single;
|
||||
|
@ -44,6 +47,9 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
VisualElementPackager _packager;
|
||||
VisualElementTracker _tracker;
|
||||
|
||||
UIVisualEffectView _blur;
|
||||
BlurEffectStyle _previousBlur;
|
||||
|
||||
protected VisualElementRenderer() : base(RectangleF.Empty)
|
||||
{
|
||||
_propertyChangedHandler = OnElementPropertyChanged;
|
||||
|
@ -180,6 +186,17 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
return new SizeF(0, 0);
|
||||
}
|
||||
|
||||
public override void Draw(RectangleF rect)
|
||||
{
|
||||
base.Draw(rect);
|
||||
if (_blur != null)
|
||||
{
|
||||
_blur.Frame = rect;
|
||||
if (_blur.Superview == null)
|
||||
Superview.Add(_blur);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if ((_flags & VisualElementRendererFlags.Disposed) != 0)
|
||||
|
@ -220,6 +237,9 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
var changed = ElementChanged;
|
||||
if (changed != null)
|
||||
changed(this, e);
|
||||
|
||||
if (e.NewElement != null)
|
||||
SetBlur((BlurEffectStyle)e.NewElement.GetValue(PlatformConfiguration.iOSSpecific.VisualElement.BlurEffectProperty));
|
||||
}
|
||||
|
||||
protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
|
@ -228,6 +248,8 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
SetBackgroundColor(Element.BackgroundColor);
|
||||
else if (e.PropertyName == Layout.IsClippedToBoundsProperty.PropertyName)
|
||||
UpdateClipToBounds();
|
||||
else if (e.PropertyName == PlatformConfiguration.iOSSpecific.VisualElement.BlurEffectProperty.PropertyName)
|
||||
SetBlur((BlurEffectStyle)Element.GetValue(PlatformConfiguration.iOSSpecific.VisualElement.BlurEffectProperty));
|
||||
}
|
||||
|
||||
protected virtual void OnRegisterEffect(PlatformEffect effect)
|
||||
|
@ -248,6 +270,44 @@ namespace Xamarin.Forms.Platform.iOS
|
|||
BackgroundColor = color.ToUIColor();
|
||||
}
|
||||
|
||||
protected virtual void SetBlur(BlurEffectStyle blur)
|
||||
{
|
||||
if (_previousBlur == blur)
|
||||
return;
|
||||
|
||||
_previousBlur = blur;
|
||||
|
||||
if (_blur != null)
|
||||
{
|
||||
_blur.RemoveFromSuperview();
|
||||
_blur = null;
|
||||
}
|
||||
|
||||
if (blur == BlurEffectStyle.None)
|
||||
{
|
||||
SetNeedsDisplay();
|
||||
return;
|
||||
}
|
||||
|
||||
UIBlurEffect blurEffect;
|
||||
switch (blur)
|
||||
{
|
||||
default:
|
||||
case BlurEffectStyle.ExtraLight:
|
||||
blurEffect = UIBlurEffect.FromStyle(UIBlurEffectStyle.ExtraLight);
|
||||
break;
|
||||
case BlurEffectStyle.Light:
|
||||
blurEffect = UIBlurEffect.FromStyle(UIBlurEffectStyle.Light);
|
||||
break;
|
||||
case BlurEffectStyle.Dark:
|
||||
blurEffect = UIBlurEffect.FromStyle(UIBlurEffectStyle.Dark);
|
||||
break;
|
||||
}
|
||||
|
||||
_blur = new UIVisualEffectView(blurEffect);
|
||||
SetNeedsDisplay();
|
||||
}
|
||||
|
||||
protected virtual void UpdateNativeWidget()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
<Compile Include="ContextScrollViewDelegate.cs" />
|
||||
<Compile Include="EffectUtilities.cs" />
|
||||
<Compile Include="Extensions\CellExtensions.cs" />
|
||||
<Compile Include="Extensions\PlatformConfigurationExtensions.cs" />
|
||||
<Compile Include="Forms.cs" />
|
||||
<Compile Include="GlobalCloseContextGestureRecognizer.cs" />
|
||||
<Compile Include="Extensions\ArrayExtensions.cs" />
|
||||
|
|
|
@ -133,6 +133,7 @@
|
|||
<Compile Include="ExportImageSourceHandlerAttribute.cs" />
|
||||
<Compile Include="ExportRendererAttribute.cs" />
|
||||
<Compile Include="Extensions\ArrayExtensions.cs" />
|
||||
<Compile Include="Extensions\PlatformConfigurationExtensions.cs" />
|
||||
<Compile Include="NativeViewWrapper.cs" />
|
||||
<Compile Include="NativeViewWrapperRenderer.cs" />
|
||||
<Compile Include="PlatformEffect.cs" />
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<forms:MasterDetailPage xmlns="clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
xmlns:forms="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:windowsSpecific="clr-namespace:Xamarin.Forms.PlatformConfiguration.WindowsSpecific;assembly=Xamarin.Forms.Core"
|
||||
x:Class="Xamarin.Forms.Xaml.UnitTests.PlatformSpecific"
|
||||
windowsSpecific:MasterDetailPage.CollapseStyle="Partial"
|
||||
windowsSpecific:MasterDetailPage.CollapsedPaneWidth="96"
|
||||
x:Name="TestMDP">
|
||||
<forms:MasterDetailPage.Master>
|
||||
<forms:ContentPage x:Name="masterPage" Title="Platform Specifics" />
|
||||
</forms:MasterDetailPage.Master>
|
||||
<forms:MasterDetailPage.Detail>
|
||||
<forms:NavigationPage>
|
||||
<x:Arguments>
|
||||
<forms:ContentPage />
|
||||
</x:Arguments>
|
||||
</forms:NavigationPage>
|
||||
</forms:MasterDetailPage.Detail>
|
||||
</forms:MasterDetailPage>
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Xamarin.Forms;
|
||||
using NUnit.Framework;
|
||||
using Xamarin.Forms.PlatformConfiguration;
|
||||
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
|
||||
|
||||
namespace Xamarin.Forms.Xaml.UnitTests
|
||||
{
|
||||
public partial class PlatformSpecific : MasterDetailPage
|
||||
{
|
||||
public PlatformSpecific()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public PlatformSpecific(bool useCompiledXaml)
|
||||
{
|
||||
//this stub will be replaced at compile time
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
class Tests
|
||||
{
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void PlatformSpecificPropertyIsSet(bool useCompiledXaml)
|
||||
{
|
||||
var layout = new PlatformSpecific(useCompiledXaml);
|
||||
Assert.AreEqual(layout.On<Windows>().GetCollapseStyle(), CollapseStyle.Partial);
|
||||
Assert.AreEqual(layout.On<Windows>().CollapsedPaneWidth(), 96d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -85,6 +85,9 @@
|
|||
<DependentUpon>Bz41296.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LoaderTests.cs" />
|
||||
<Compile Include="PlatformSpecifics.xaml.cs">
|
||||
<DependentUpon>PlatformSpecifics.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ViewExtensionsTest.cs" />
|
||||
<Compile Include="MarkupExpressionParserTests.cs" />
|
||||
<Compile Include="MarkupExtensionTests.cs" />
|
||||
|
@ -655,4 +658,9 @@
|
|||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="PlatformSpecifics.xaml">
|
||||
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -0,0 +1,116 @@
|
|||
<Type Name="Application" FullName="Xamarin.Forms.PlatformConfiguration.AndroidSpecific.Application">
|
||||
<TypeSignature Language="C#" Value="public static class Application" />
|
||||
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed beforefieldinit Application extends System.Object" />
|
||||
<AssemblyInfo>
|
||||
<AssemblyName>Xamarin.Forms.Core</AssemblyName>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
</AssemblyInfo>
|
||||
<Base>
|
||||
<BaseTypeName>System.Object</BaseTypeName>
|
||||
</Base>
|
||||
<Interfaces />
|
||||
<Docs>
|
||||
<summary>To be added.</summary>
|
||||
<remarks>To be added.</remarks>
|
||||
</Docs>
|
||||
<Members>
|
||||
<Member MemberName="GetWindowSoftInputModeAdjust">
|
||||
<MemberSignature Language="C#" Value="public static Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust GetWindowSoftInputModeAdjust (Xamarin.Forms.BindableObject element);" />
|
||||
<MemberSignature Language="ILAsm" Value=".method public static hidebysig valuetype Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust GetWindowSoftInputModeAdjust(class Xamarin.Forms.BindableObject element) cil managed" />
|
||||
<MemberType>Method</MemberType>
|
||||
<AssemblyInfo>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
</AssemblyInfo>
|
||||
<ReturnValue>
|
||||
<ReturnType>Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust</ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters>
|
||||
<Parameter Name="element" Type="Xamarin.Forms.BindableObject" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<param name="element">To be added.</param>
|
||||
<summary>To be added.</summary>
|
||||
<returns>To be added.</returns>
|
||||
<remarks>To be added.</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="GetWindowSoftInputModeAdjust">
|
||||
<MemberSignature Language="C#" Value="public static Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust GetWindowSoftInputModeAdjust (this Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.Android,Xamarin.Forms.Application> config);" />
|
||||
<MemberSignature Language="ILAsm" Value=".method public static hidebysig valuetype Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust GetWindowSoftInputModeAdjust(class Xamarin.Forms.IPlatformElementConfiguration`2<class Xamarin.Forms.PlatformConfiguration.Android, class Xamarin.Forms.Application> config) cil managed" />
|
||||
<MemberType>Method</MemberType>
|
||||
<AssemblyInfo>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
</AssemblyInfo>
|
||||
<ReturnValue>
|
||||
<ReturnType>Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust</ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters>
|
||||
<Parameter Name="config" Type="Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.Android,Xamarin.Forms.Application>" RefType="this" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<param name="config">To be added.</param>
|
||||
<summary>To be added.</summary>
|
||||
<returns>To be added.</returns>
|
||||
<remarks>To be added.</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="SetWindowSoftInputModeAdjust">
|
||||
<MemberSignature Language="C#" Value="public static void SetWindowSoftInputModeAdjust (Xamarin.Forms.BindableObject element, Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust value);" />
|
||||
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void SetWindowSoftInputModeAdjust(class Xamarin.Forms.BindableObject element, valuetype Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust value) cil managed" />
|
||||
<MemberType>Method</MemberType>
|
||||
<AssemblyInfo>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
</AssemblyInfo>
|
||||
<ReturnValue>
|
||||
<ReturnType>System.Void</ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters>
|
||||
<Parameter Name="element" Type="Xamarin.Forms.BindableObject" />
|
||||
<Parameter Name="value" Type="Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<param name="element">To be added.</param>
|
||||
<param name="value">To be added.</param>
|
||||
<summary>To be added.</summary>
|
||||
<remarks>To be added.</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="UseWindowSoftInputModeAdjust">
|
||||
<MemberSignature Language="C#" Value="public static Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.Android,Xamarin.Forms.Application> UseWindowSoftInputModeAdjust (this Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.Android,Xamarin.Forms.Application> config, Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust value);" />
|
||||
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class Xamarin.Forms.IPlatformElementConfiguration`2<class Xamarin.Forms.PlatformConfiguration.Android, class Xamarin.Forms.Application> UseWindowSoftInputModeAdjust(class Xamarin.Forms.IPlatformElementConfiguration`2<class Xamarin.Forms.PlatformConfiguration.Android, class Xamarin.Forms.Application> config, valuetype Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust value) cil managed" />
|
||||
<MemberType>Method</MemberType>
|
||||
<AssemblyInfo>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
</AssemblyInfo>
|
||||
<ReturnValue>
|
||||
<ReturnType>Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.Android,Xamarin.Forms.Application></ReturnType>
|
||||
</ReturnValue>
|
||||
<Parameters>
|
||||
<Parameter Name="config" Type="Xamarin.Forms.IPlatformElementConfiguration<Xamarin.Forms.PlatformConfiguration.Android,Xamarin.Forms.Application>" RefType="this" />
|
||||
<Parameter Name="value" Type="Xamarin.Forms.PlatformConfiguration.AndroidSpecific.WindowSoftInputModeAdjust" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<param name="config">To be added.</param>
|
||||
<param name="value">To be added.</param>
|
||||
<summary>To be added.</summary>
|
||||
<returns>To be added.</returns>
|
||||
<remarks>To be added.</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName="WindowSoftInputModeAdjustProperty">
|
||||
<MemberSignature Language="C#" Value="public static readonly Xamarin.Forms.BindableProperty WindowSoftInputModeAdjustProperty;" />
|
||||
<MemberSignature Language="ILAsm" Value=".field public static initonly class Xamarin.Forms.BindableProperty WindowSoftInputModeAdjustProperty" />
|
||||
<MemberType>Field</MemberType>
|
||||
<AssemblyInfo>
|
||||
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||
</AssemblyInfo>
|
||||
<ReturnValue>
|
||||
<ReturnType>Xamarin.Forms.BindableProperty</ReturnType>
|
||||
</ReturnValue>
|
||||
<Docs>
|
||||
<summary>To be added.</summary>
|
||||
<remarks>To be added.</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
</Members>
|
||||
</Type>
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче