Permalink
Browse files

Merged PR 430284: Merge pfelts/DesignUpdates to future

Visual updates and bug fixes.
- Using a pivot instead of a custom control for navigation
  • Loading branch information...
peterfelts committed May 9, 2017
1 parent 22910e5 commit 3745a3241eaac8278a268002c7ada9d13a0a17a6
View
@@ -0,0 +1 @@
Windows UI Sample Gallery Privacy Policy===========Personal Data We Collect-------------None.How We Use Your Personal Data-------------We do not collect or transmit any personal data. We do not store any personal data. Reasons We Share Your Personal Data-------------We do not collect personal data and therefore do not share any of your personal data.Control You Have Over Your Personal Data-------------Because we do not collect any personal data we do not offer any control over the use and sharing of this information, nor do we offer access to this data.
Binary file not shown.
@@ -12,80 +12,38 @@
<Page.Resources>
<local:IsPaneOpenToVisibilityConverter x:Key="IsPaneOpenConverter" />
</Page.Resources>
<Grid>
<Grid x:Name="MainPageGrid">
<Grid.Transitions>
<TransitionCollection>
<EntranceThemeTransition x:Name="EntranceTransition" />
</TransitionCollection>
</Grid.Transitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="TitleBarRow" Height="0"/>
<RowDefinition />
</Grid.RowDefinitions>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<!-- WIDE -->
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource WideScreenWidthTrigger}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="RootPage.Background" Value="White" />
<Setter Target="MainNavigationSplitView.CompactPaneLength" Value="0" />
<Setter Target="MainNavigationWide.Visibility" Value="Visible" />
<Setter Target="HamburgerButton.Visibility" Value="Collapsed" />
<Setter Target="Row0.Height" Value="48" />
</VisualState.Setters>
</VisualState>
<!-- NARROW -->
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="{StaticResource NarrowScreenWidthTrigger}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="RootPage.Background" Value="{StaticResource DarkThemeBackgroundColorBrush}" />
<Setter Target="MainNavigationWide.Visibility" Value="Collapsed" />
<Setter Target="HamburgerButton.Visibility" Value="Visible" />
<Setter Target="Row0.Height" Value="48" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<SplitView
x:Name="MainNavigationSplitView"
DisplayMode="Overlay"
OpenPaneLength="300"
CompactPaneLength="{StaticResource BackButtonWidth}">
<SplitView.Pane>
<StackPanel>
<Button x:Name="HamburgerButtonSplitView"
Grid.Row="0"
Content="&#xE700;"
Template="{StaticResource SplitViewTogglePaneButtonTemplate}"
Style="{StaticResource SplitViewTogglePaneButtonStyle}"
FontFamily="Segoe MDL2 Assets"
Click="HamburgerButton_Click" />
<local:MainNavigation x:Name="MainNavigationNarrow" Visibility="{x:Bind Path=MainNavigationSplitView.IsPaneOpen, Converter={StaticResource IsPaneOpenConverter}, Mode=OneWay}" />
</StackPanel>
</SplitView.Pane>
<SplitView.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition x:Name="Row0" Height="50"/>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button x:Name="HamburgerButton"
Grid.Row="0"
Content="&#xE700;"
Template="{StaticResource SplitViewTogglePaneButtonTemplate}"
Style="{StaticResource SplitViewTogglePaneButtonStyle}"
FontFamily="Segoe MDL2 Assets"
Click="HamburgerButton_Click" />
<local:MainNavigation x:Name="MainNavigationWide" Grid.Row="0"/>
<Frame x:Name="MainFrame" Grid.Row="1" Navigated="MainFrame_Navigated"/>
</Grid>
</SplitView.Content>
</SplitView>
<TextBlock Grid.Row="0" Style="{ThemeResource CaptionTextBlockStyle}" Padding="59,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left">Windows UI Sample Gallery</TextBlock>
<Pivot
x:Name="MainPivot"
Grid.Row="1"
ItemsSource="{x:Bind Path=MainNavigation.MainMenuList}"
PivotItemLoading="MainPivot_PivotItemLoading"
IsHeaderItemsCarouselEnabled="False">
<Pivot.HeaderTemplate>
<DataTemplate x:DataType="local:NavigationItem">
<TextBlock Text="{x:Bind Path=DisplayName}" />
</DataTemplate>
</Pivot.HeaderTemplate>
<Pivot.ItemTemplate>
<DataTemplate x:DataType="local:NavigationItem">
<Frame
Loaded="Frame_Loaded"
x:Name="PivotItemFrame"
Navigated="MainFrame_Navigated">
</Frame>
</DataTemplate>
</Pivot.ItemTemplate>
</Pivot>
</Grid>
</Page>
@@ -15,14 +15,17 @@
using SamplesCommon;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using Windows.ApplicationModel.Core;
using Windows.Foundation;
using Windows.Foundation.Metadata;
using Windows.UI;
using Windows.UI.Composition;
using Windows.UI.Core;
using Windows.UI.Popups;
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Hosting;
@@ -40,44 +43,65 @@ public sealed partial class MainPage : Page
#endif
private static bool _areEffectsSupported;
private static bool _areEffectsFast;
private static RuntimeSupportedSDKs _runtimeCapabilities;
private static RuntimeSupportedSDKs _runtimeCapabilities;
private MainNavigationViewModel _mainNavigation;
private Frame _currentFrame;
public MainPage(Rect imageBounds)
{
_instance = this;
// Get hardware capabilities and register changed event listener
#if SDKVERSION_15063
_capabilities = CompositionCapabilities.GetForCurrentView();
_capabilities.Changed += HandleCapabilitiesChangedAsync;
_areEffectsSupported = _capabilities.AreEffectsSupported();
_areEffectsFast = _capabilities.AreEffectsFast();
#else
_areEffectsSupported = true;
_areEffectsFast = true;
#endif
_runtimeCapabilities = new RuntimeSupportedSDKs();
_currentFrame = null;
// Get hardware capabilities and register changed event listener only when targeting the
// appropriate SDK version and the runtime supports this version
if (_runtimeCapabilities.IsSdkVersionRuntimeSupported(RuntimeSupportedSDKs.SDKVERSION._15063))
{
_capabilities = CompositionCapabilities.GetForCurrentView();
_capabilities.Changed += HandleCapabilitiesChangedAsync;
_areEffectsSupported = _capabilities.AreEffectsSupported();
_areEffectsFast = _capabilities.AreEffectsFast();
}
else
{
_areEffectsSupported = true;
_areEffectsFast = true;
}
this.InitializeComponent();
_mainNavigation = new MainNavigationViewModel();
// Initialize the image loader
ImageLoader.Initialize(ElementCompositionPreview.GetElementVisual(this).Compositor);
// Show the custome splash screen
ShowCustomSplashScreen(imageBounds);
SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
}
private void OnBackRequested(object sender, BackRequestedEventArgs e)
{
if (MainFrame.CanGoBack)
{
e.Handled = true;
MainFrame.GoBack();
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = false;
#if SDKVERSION_INSIDER
// Apply acrylic styling to the navigation and caption
if (_runtimeCapabilities.IsSdkVersionRuntimeSupported(RuntimeSupportedSDKs.SDKVERSION._INSIDER))
{
// Extend the app into the titlebar so that we can apply acrylic
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
titleBar.ButtonBackgroundColor = Colors.Transparent;
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
// Apply acrylic to the main navigation
Windows.UI.Xaml.Media.AcrylicBrush myBrush = new Windows.UI.Xaml.Media.AcrylicBrush();
myBrush.BackgroundSource = Windows.UI.Xaml.Media.AcrylicBackgroundSource.HostBackdrop;
myBrush.TintColor = Color.FromArgb(255, 255, 255, 255);
myBrush.FallbackColor = Color.FromArgb(255, 255, 255, 255);
myBrush.TintOpacity = 0.6;
MainPageGrid.Background = myBrush;
TitleBarRow.Height = new GridLength(31);
}
#endif
}
public MainNavigationViewModel MainNavigation => _mainNavigation;
public static MainPage Instance
{
get { return _instance; }
@@ -104,9 +128,9 @@ private async void HandleCapabilitiesChangedAsync(CompositionCapabilities sender
_areEffectsSupported = _capabilities.AreEffectsSupported();
_areEffectsFast = _capabilities.AreEffectsFast();
if (MainFrame.Content is SampleHost host)
if (_currentFrame.Content is SampleHost host)
{
SamplePage page = (SamplePage)host.ContentFrame.Content;
SamplePage page = (SamplePage)host.Content;
page.OnCapabiliesChanged(_areEffectsSupported, _areEffectsFast);
}
@@ -209,8 +233,8 @@ private void HideCustomSplashScreen()
scaleUpSplashAnimation.Duration = duration;
// Configure the grid visual to scale from the center
Visual gridVisual = ElementCompositionPreview.GetElementVisual(MainFrame);
gridVisual.Size = new Vector2((float)MainFrame.ActualWidth, (float)MainFrame.ActualHeight);
Visual gridVisual = ElementCompositionPreview.GetElementVisual(MainPivot);
gridVisual.Size = new Vector2((float)MainPivot.ActualWidth, (float)MainPivot.ActualHeight);
gridVisual.CenterPoint = new Vector3(gridVisual.Size.X, gridVisual.Size.Y, 0) * .5f;
@@ -243,68 +267,51 @@ private void Batch_Completed(object sender, CompositionBatchCompletedEventArgs a
private void Page_Loaded(object sender, RoutedEventArgs e)
{
NavigateToPage(typeof(HomePage));
// Now that loading is complete, dismiss the custom splash screen
HideCustomSplashScreen();
}
public void NavigateToPage(Type page, object parameter = null)
{
MainFrame.Navigate(page, parameter);
}
private void MainFrame_Navigated(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
{
// Cache a reference to the current frame
_currentFrame = (Frame)sender;
// Show or hide the global back button
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
((Frame)sender).CanGoBack ?
_currentFrame.CanGoBack ?
AppViewBackButtonVisibility.Visible :
AppViewBackButtonVisibility.Collapsed;
// Close the SplitView if it's open
if (MainNavigationSplitView.IsPaneOpen)
{
MainNavigationSplitView.IsPaneOpen = false;
}
}
private void HamburgerButton_Click(object sender, RoutedEventArgs e)
public static void FeaturedSampleList_ItemClick(object sender, ItemClickEventArgs e)
{
MainNavigationSplitView.IsPaneOpen = !MainNavigationSplitView.IsPaneOpen;
if (MainNavigationSplitView.IsPaneOpen)
{
MainNavigationSplitView.OpenPaneLength = this.ActualWidth;
}
MainNavigationViewModel.NavigateToSample(sender, e);
}
private void CloseSplitViewPane()
// Load the category pages into the frame of each PivotItem
private void Frame_Loaded(object sender, RoutedEventArgs e)
{
MainNavigationSplitView.IsPaneOpen = false;
NavigationItem navItem = (NavigationItem)(((Frame)sender).DataContext);
((Frame)sender).Navigate(navItem.PageType, navItem);
}
public static void FeaturedSampleList_ItemClick(object sender, ItemClickEventArgs e)
// When navigating to a pivotitem, reload the main page and hide the back
// button
private void MainPivot_PivotItemLoading(Pivot sender, PivotItemEventArgs args)
{
SampleDefinition sample = (SampleDefinition)e.ClickedItem;
NavigationItem navItem = (NavigationItem)((((PivotItemEventArgs)args).Item).DataContext);
Frame pivotItemFrame = (Frame)(((PivotItem)args.Item).ContentTemplateRoot);
pivotItemFrame.Navigate(navItem.PageType, navItem);
foreach (SampleDefinition definition in SampleDefinitions.Definitions)
{
if (sample.Name == definition.Name)
{
MainPage.Instance.NavigateToPage(typeof(SampleHost), definition);
break;
}
}
SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed;
}
}
// This class caches and provides information about the supported
// Windows.Foundation.UniversalApiContract of the runtime
public class RuntimeSupportedSDKs
{
Dictionary<SDKVERSION, bool> _supportedSDKs;
List<SDKVERSION> _allSupportedSDKs;
List<SDKVERSION> _supportedSDKs;
public enum SDKVERSION
{
@@ -316,28 +323,23 @@ public enum SDKVERSION
public RuntimeSupportedSDKs()
{
_supportedSDKs = new Dictionary<SDKVERSION, bool>();
_allSupportedSDKs = new List<SDKVERSION>();
_supportedSDKs = new List<SDKVERSION>();
// Determine which versions of the SDK are supported on the runtime
foreach(SDKVERSION v in Enum.GetValues(typeof(SDKVERSION)))
{
bool versionSupported = false;
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", (ushort)v))
if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", (ushort)Convert.ToInt32(v)))
{
versionSupported = true;
_allSupportedSDKs.Add(v);
_supportedSDKs.Add(v);
}
_supportedSDKs.Add(v, versionSupported);
_allSupportedSDKs.Add(v);
}
}
public bool IsSdkVersionRuntimeSupported(SDKVERSION sdkVersion)
{
if (_supportedSDKs.ContainsKey(sdkVersion))
if(_supportedSDKs.Contains(sdkVersion))
{
return _supportedSDKs[sdkVersion];
return true;
}
else
{
@@ -349,7 +351,7 @@ public List<SDKVERSION> AllSupportedSdkVersions
{
get
{
return _allSupportedSDKs;
return _supportedSDKs;
}
}
}
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="WindowsUIDevLabsSampleGallery" Publisher="CN=pfelts" Version="1.1.40.0" />
<mp:PhoneIdentity PhoneProductId="0a28ae7f-335d-48e3-9f1a-f83c2b3826ea" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Identity Name="46936PHPete.Windows.UI.CompositionSampleGallery" Publisher="CN=B3C1ACF3-CF61-4DDF-9AE7-AC546C869D6E" Version="1.1.5.0" />
<mp:PhoneIdentity PhoneProductId="12b3cd41-eff7-4b21-b37a-09583604a027" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>Windows UI Sample Gallery</DisplayName>
<DisplayName>Windows.UI.Composition Sample Gallery</DisplayName>
<PublisherDisplayName>Peter Felts</PublisherDisplayName>
<Logo>Assets\StoreAssets\StoreLogo.png</Logo>
</Properties>
@@ -26,7 +26,4 @@
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
</Capabilities>
</Package>
Oops, something went wrong.

0 comments on commit 3745a32

Please sign in to comment.