Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gallery design improvements #88

Merged
merged 10 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions CommunityToolkit.App.Shared/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@

<SolidColorBrush x:Key="BackgroundColorBrush"
Color="{ThemeResource SolidBackgroundFillColorBase}" />
<SolidColorBrush x:Key="WindowCaptionBackground"
Color="Transparent" />
<SolidColorBrush x:Key="WindowCaptionBackgroundDisabled"
Color="Transparent" />

<!-- PathData for the GitHub icon -->
<x:String x:Key="GithubIcon">M21.7999992370605,0L19.220495223999,0.26007080078125 16.81787109375,1.00595712661743 14.6436157226563,2.18616962432861 12.7492189407349,3.74921894073486 11.1861696243286,5.64361572265625 10.0059566497803,7.81787109375 9.26007080078125,10.2204961776733 9,12.8000001907349 9.65248012542725,16.8459720611572 11.4694375991821,20.3591785430908 14.2401514053345,23.1291217803955 17.7539005279541,24.9453010559082 18.4305686950684,24.8080005645752 18.6273498535156,24.3296756744385 18.6207065582275,23.4247951507568 18.609375,21.9468746185303 16.4340572357178,22.0373229980469 15.1187467575073,21.4822216033936 14.4708204269409,20.7821025848389 14.2976503372192,20.4375 13.8297338485718,19.5214366912842 13.3685493469238,18.947265625 12.8765497207642,18.5656261444092 12.3995819091797,18.1091804504395 12.4844465255737,17.87890625 12.7874250411987,17.7974605560303 12.9647998809814,17.7875003814697 13.8134965896606,18.0311241149902 14.4276065826416,18.4802703857422 14.8007507324219,18.9127178192139 14.926549911499,19.1062507629395 15.8880548477173,20.1437015533447 16.9443283081055,20.494140625 17.9229640960693,20.416259765625 18.6515502929688,20.1687507629395 18.9645938873291,19.1242198944092 19.4640502929688,18.4593753814697 17.3543262481689,18.0241260528564 15.4833002090454,17.014066696167 14.1450357437134,15.1450166702271 13.6336002349854,12.1328001022339 13.9853601455688,10.2268438339233 14.9500007629395,8.69764995574951 14.7027282714844,7.54188776016235 14.7441072463989,6.53565359115601 15.0765495300293,5.30859994888306 15.2825078964233,5.28076791763306 15.9191312789917,5.34375619888306 17.0145378112793,5.71729135513306 18.596851348877,6.62109994888306 21.799976348877,6.19062519073486 25.004674911499,6.62265014648438 26.5845413208008,5.71818733215332 27.6791000366211,5.34472513198853 28.315746307373,5.28210020065308 28.5218753814697,5.31015014648438 28.8556652069092,6.53784370422363 28.8976573944092,7.5438346862793 28.6499996185303,8.69764995574951 29.6154251098633,10.2268533706665 29.9656257629395,12.1328001022339 29.453296661377,15.1497011184692 28.1123065948486,17.0164012908936 26.2366523742676,18.020601272583 24.120325088501,18.4500007629395 24.7275562286377,19.3355484008789 24.9890747070313,20.8187503814697 24.9804744720459,23.0584030151367 24.9718742370605,24.3312511444092 25.1693305969238,24.8128852844238 25.8531246185303,24.9453010559082 29.3641395568848,23.1273632049561 32.1326217651367,20.3568344116211 33.948070526123,16.8442134857178 34.5999984741211,12.8000001907349 34.3399276733398,10.2204961776733 33.5940399169922,7.81787109375 32.4138298034668,5.64361572265625 30.8507804870605,3.74921894073486 28.9563827514648,2.18616962432861 26.7821273803711,1.00595712661743 24.3795032501221,0.26007080078125 21.7999992370605,0z</x:String>
Expand Down
10 changes: 0 additions & 10 deletions CommunityToolkit.App.Shared/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
#endif
rootFrame.Navigate(typeof(AppLoadingView), e.Arguments);

SetTitleBar();
// Ensure the current window is active
currentWindow.Activate();
}
Expand All @@ -66,13 +65,4 @@ void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}

private void SetTitleBar()
{
#if WINDOWS_UWP
var viewTitleBar = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar;
viewTitleBar.ButtonBackgroundColor = Windows.UI.Colors.Transparent;
viewTitleBar.ButtonInactiveBackgroundColor = Windows.UI.Colors.Transparent;
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Attributes\PackageProjectUrlAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Behaviors\NavigateToUriAction.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\TitleBar\TitleBar.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\TitleBar\TitleBar.UWP.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\TitleBar\TitleBar.WASDK.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\TitleBar\TitleBar.Properties.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Converters\StringToUriConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)DocOrSampleTemplateSelector.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helpers\BackgroundHelper.cs" />
Expand Down
118 changes: 118 additions & 0 deletions CommunityToolkit.App.Shared/Controls/TitleBar/TitleBar.Properties.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace CommunityToolkit.App.Shared.Controls;

public partial class TitleBar : Control
{
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(nameof(Icon), typeof(ImageSource), typeof(TitleBar), new PropertyMetadata(default(ImageSource)));

public static readonly DependencyProperty TitleProperty = DependencyProperty.Register(nameof(Title), typeof(string), typeof(TitleBar), new PropertyMetadata(default(string)));

public static readonly DependencyProperty SubtitleProperty = DependencyProperty.Register(nameof(Subtitle), typeof(string), typeof(TitleBar), new PropertyMetadata(default(string)));

public static readonly DependencyProperty ContentProperty = DependencyProperty.Register(nameof(Content), typeof(object), typeof(TitleBar), new PropertyMetadata(null));

public static readonly DependencyProperty FooterProperty = DependencyProperty.Register(nameof(Footer), typeof(object), typeof(TitleBar), new PropertyMetadata(null));

public static readonly DependencyProperty IsBackButtonVisibleProperty = DependencyProperty.Register(nameof(IsBackButtonVisible), typeof(bool), typeof(TitleBar), new PropertyMetadata(false, IsBackButtonVisibleChanged));

public static readonly DependencyProperty IsPaneButtonVisibleProperty = DependencyProperty.Register(nameof(IsPaneButtonVisible), typeof(bool), typeof(TitleBar), new PropertyMetadata(false, IsPaneButtonVisibleChanged));

public static readonly DependencyProperty ConfigureTitleBarProperty = DependencyProperty.Register(nameof(ConfigureTitleBar), typeof(bool), typeof(TitleBar), new PropertyMetadata(true, ConfigureTitleBarChanged));

public static readonly DependencyProperty DisplayModeProperty = DependencyProperty.Register(nameof(DisplayMode), typeof(DisplayMode), typeof(TitleBar), new PropertyMetadata(DisplayMode.Standard, DisplayModeChanged));

#if WINAPPSDK
public static readonly DependencyProperty WindowProperty = DependencyProperty.Register(nameof(Window), typeof(Window), typeof(TitleBar), new PropertyMetadata(null));
#endif

public ImageSource Icon
{
get => (ImageSource)GetValue(IconProperty);
set => SetValue(IconProperty, value);
}

public string Title
{
get => (string)GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}

public string Subtitle
{
get => (string)GetValue(SubtitleProperty);
set => SetValue(SubtitleProperty, value);
}

public object Content
{
get => (object)GetValue(ContentProperty);
set => SetValue(ContentProperty, value);
}

public object Footer
{
get => (object)GetValue(FooterProperty);
set => SetValue(FooterProperty, value);
}

public DisplayMode DisplayMode
{
get => (DisplayMode)GetValue(DisplayModeProperty);
set => SetValue(DisplayModeProperty, value);
}

public bool IsBackButtonVisible
{
get => (bool)GetValue(IsBackButtonVisibleProperty);
set => SetValue(IsBackButtonVisibleProperty, value);
}

public bool IsPaneButtonVisible
{
get => (bool)GetValue(IsPaneButtonVisibleProperty);
set => SetValue(IsPaneButtonVisibleProperty, value);
}

public bool ConfigureTitleBar
{
get => (bool)GetValue(ConfigureTitleBarProperty);
set => SetValue(ConfigureTitleBarProperty, value);
}

#if WINAPPSDK
public Window Window
{
get => (Window)GetValue(WindowProperty);
set => SetValue(WindowProperty, value);
}
#endif

private static void IsBackButtonVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((TitleBar)d).Update();
}

private static void IsPaneButtonVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((TitleBar)d).Update();
}

private static void ConfigureTitleBarChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((TitleBar)d).SetTitleBar();
}

private static void DisplayModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((TitleBar)d).SetTitleBar();
}
}

public enum DisplayMode
{
Standard,
Tall
}
59 changes: 59 additions & 0 deletions CommunityToolkit.App.Shared/Controls/TitleBar/TitleBar.UWP.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#if WINDOWS_UWP && !HAS_UNO
using Windows.ApplicationModel.Core;
using Windows.UI.ViewManagement;
using Windows.UI;

namespace CommunityToolkit.App.Shared.Controls;

public partial class TitleBar : Control
{
private void SetUWPTitleBar()
{
if (ConfigureTitleBar)
{
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged -= this.TitleBar_LayoutMetricsChanged;
CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged += this.TitleBar_LayoutMetricsChanged;
Window.Current.Activated -= this.Current_Activated;
Window.Current.Activated += this.Current_Activated;
Window.Current.SetTitleBar(_dragRegion);
ApplicationView.GetForCurrentView().TitleBar.ButtonBackgroundColor = Colors.Transparent;
ApplicationView.GetForCurrentView().TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
}
else
{
CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = false;
Window.Current.Activated -= this.Current_Activated;
CoreApplication.GetCurrentView().TitleBar.LayoutMetricsChanged -= this.TitleBar_LayoutMetricsChanged;
Window.Current.SetTitleBar(null);
}
}

private void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e)
{
if (e.WindowActivationState == Windows.UI.Core.CoreWindowActivationState.Deactivated)
{
VisualStateManager.GoToState(this, WindowDeactivatedState, true);
}
else
{
VisualStateManager.GoToState(this, WindowActivatedState, true);
}
}

private void TitleBar_LayoutMetricsChanged(CoreApplicationViewTitleBar sender, object args)
{
if (_titleBar != null)
{
ColumnDefinition Left = (ColumnDefinition)_titleBar.GetTemplateChild(PartLeftPaddingColumn);
ColumnDefinition Right = (ColumnDefinition)_titleBar.GetTemplateChild(PartRightPaddingColumn);
Left.Width = new GridLength(CoreApplication.GetCurrentView().TitleBar.SystemOverlayLeftInset);
Right.Width = new GridLength(CoreApplication.GetCurrentView().TitleBar.SystemOverlayRightInset);
}
}
}
#endif
Loading