Implementing themes for Calendar.

This commit is contained in:
Burak Kaan Köse
2024-12-28 20:42:03 +01:00
parent 5f1d411b28
commit 95b8f54b27
25 changed files with 353 additions and 230 deletions

View File

@@ -8,8 +8,8 @@
xmlns:local="using:Wino.Calendar"
xmlns:styles="using:Wino.Calendar.Styles">
<Application.Resources>
<controls:XamlControlsResources>
<controls:XamlControlsResources.MergedDictionaries>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<core:CoreGeneric />
@@ -30,8 +30,8 @@
<!-- Last item must always be the default theme. -->
<ResourceDictionary Source="ms-appx:///Wino.Core.UWP/AppThemes/Mica.xaml" />
</controls:XamlControlsResources.MergedDictionaries>
</controls:XamlControlsResources>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</core:WinoApplication>

View File

@@ -18,6 +18,7 @@ using Wino.Core.Domain.Exceptions;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Synchronization;
using Wino.Core.UWP;
using Wino.Core.ViewModels;
using Wino.Messaging.Client.Connection;
using Wino.Messaging.Server;
using Wino.Services;
@@ -78,6 +79,7 @@ namespace Wino.Calendar
services.AddSingleton(typeof(CalendarPageViewModel));
services.AddTransient(typeof(CalendarSettingsPageViewModel));
services.AddTransient(typeof(AccountManagementViewModel));
services.AddTransient(typeof(PersonalizationPageViewModel));
}
#endregion

View File

@@ -1,6 +1,7 @@
using System;
using System.Windows.Input;
using CommunityToolkit.Diagnostics;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
@@ -16,8 +17,14 @@ namespace Wino.Calendar.Controls
public static readonly DependencyProperty HighlightedDateRangeProperty = DependencyProperty.Register(nameof(HighlightedDateRange), typeof(DateRange), typeof(WinoCalendarView), new PropertyMetadata(null, new PropertyChangedCallback(OnHighlightedDateRangeChanged)));
public static readonly DependencyProperty VisibleDateBackgroundProperty = DependencyProperty.Register(nameof(VisibleDateBackground), typeof(Brush), typeof(WinoCalendarView), new PropertyMetadata(null, new PropertyChangedCallback(OnPropertiesChanged)));
public static readonly DependencyProperty TodayBackgroundBrushProperty = DependencyProperty.Register(nameof(TodayBackgroundBrush), typeof(Brush), typeof(WinoCalendarView), new PropertyMetadata(null));
public static readonly DependencyProperty DateClickedCommandProperty = DependencyProperty.Register(nameof(DateClickedCommand), typeof(ICommand), typeof(WinoCalendarView), new PropertyMetadata(null));
public static readonly DependencyProperty TodayBackgroundColorProperty = DependencyProperty.Register(nameof(TodayBackgroundColor), typeof(Color), typeof(WinoCalendarView), new PropertyMetadata(null));
public Color TodayBackgroundColor
{
get { return (Color)GetValue(TodayBackgroundColorProperty); }
set { SetValue(TodayBackgroundColorProperty, value); }
}
/// <summary>
/// Gets or sets the command to execute when a date is picked.
@@ -44,11 +51,7 @@ namespace Wino.Calendar.Controls
set { SetValue(VisibleDateBackgroundProperty, value); }
}
public Brush TodayBackgroundBrush
{
get { return (Brush)GetValue(TodayBackgroundBrushProperty); }
set { SetValue(TodayBackgroundBrushProperty, value); }
}
private CalendarView CalendarView;
@@ -117,7 +120,7 @@ namespace Wino.Calendar.Controls
public void UpdateVisibleDateRangeBackgrounds()
{
if (HighlightedDateRange == null || VisibleDateBackground == null || TodayBackgroundBrush == null || CalendarView == null) return;
if (HighlightedDateRange == null || VisibleDateBackground == null || TodayBackgroundColor == null || CalendarView == null) return;
var markDateCalendarDayItems = WinoVisualTreeHelper.FindDescendants<CalendarViewDayItem>(CalendarView);
@@ -129,7 +132,7 @@ namespace Wino.Calendar.Controls
if (calendarDayItem.Date.Date == DateTime.Today.Date)
{
border.Background = TodayBackgroundBrush;
border.Background = new SolidColorBrush(TodayBackgroundColor);
}
else if (calendarDayItem.Date.Date >= HighlightedDateRange.StartDate.Date && calendarDayItem.Date.Date < HighlightedDateRange.EndDate.Date)
{

View File

@@ -26,6 +26,8 @@ namespace Wino.Calendar.Services
return typeof(CalendarSettingsPage);
case WinoPage.AccountManagementPage:
return typeof(AccountManagementPage);
case WinoPage.PersonalizationPage:
return typeof(PersonalizationPage);
default:
throw new Exception("Page is not implemented yet.");
}

File diff suppressed because one or more lines are too long

View File

@@ -4,20 +4,24 @@
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<!-- CalendarControl -->
<SolidColorBrush x:Key="CalendarSeperatorBrush">#D9D9D9</SolidColorBrush>
<SolidColorBrush x:Key="CalendarFieldWorkingHoursBackgroundBrush">#ffffff</SolidColorBrush>
<SolidColorBrush x:Key="CalendarFieldWorkingNonHoursBackgroundBrush">#f9f9f9</SolidColorBrush>
<SolidColorBrush x:Key="CalendarFieldWorkingHoursBackgroundBrush">#32000000</SolidColorBrush>
<SolidColorBrush x:Key="CalendarFieldSelectedBackgroundBrush">#ebebeb</SolidColorBrush>
<SolidColorBrush x:Key="WinoCalendarViewBorderBrush">Yellow</SolidColorBrush>
<!-- CalendarView -->
<SolidColorBrush x:Key="WinoCalendarViewBorderBrush">#2e86de</SolidColorBrush>
<SolidColorBrush x:Key="WinoCalendarViewVisibleDayBackgroundBrush">#dfe4ea</SolidColorBrush>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<!-- CalendarControl -->
<SolidColorBrush x:Key="CalendarSeperatorBrush">#000000</SolidColorBrush>
<SolidColorBrush x:Key="CalendarFieldWorkingHoursBackgroundBrush">#262626</SolidColorBrush>
<SolidColorBrush x:Key="CalendarFieldWorkingNonHoursBackgroundBrush">#1a1a1a</SolidColorBrush>
<SolidColorBrush x:Key="CalendarFieldWorkingHoursBackgroundBrush">#32262626</SolidColorBrush>
<SolidColorBrush x:Key="CalendarFieldSelectedBackgroundBrush">#121212</SolidColorBrush>
<!-- CalendarView -->
<SolidColorBrush x:Key="WinoCalendarViewBorderBrush">#3d3d3d</SolidColorBrush>
<SolidColorBrush x:Key="WinoCalendarViewVisibleDayBackgroundBrush">#4b4b4b</SolidColorBrush>

View File

@@ -28,6 +28,7 @@
<DataTemplate x:Key="FlipTemplate" x:DataType="models:DayRangeRenderModel">
<Grid
x:Name="RootGrid"
Background="Transparent"
ColumnSpacing="0"
RowSpacing="0">
<Grid.RowDefinitions>
@@ -110,6 +111,7 @@
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
ActiveCanvas="{x:Bind ActiveCanvas, Mode=TwoWay}"
Background="Transparent"
IsTabStop="False"
ItemTemplate="{StaticResource FlipTemplate}"
ItemsSource="{TemplateBinding DayRanges}"

View File

@@ -13,6 +13,7 @@
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
DefaultLabelPosition="Right">
<CommandBar.PrimaryCommands>
<!-- Today -->
<AppBarButton x:Name="PART_TodayButton" Label="Today">
@@ -34,6 +35,7 @@
<!-- Week -->
<!-- TODO: Work week -->
<AppBarToggleButton x:Name="PART_WeekToggle" Label="Week">
<AppBarToggleButton.Icon>
<PathIcon Data="F1 M 4.921875 18.75 C 4.433594 18.75 3.966471 18.650717 3.520508 18.452148 C 3.074544 18.25358 2.683919 17.986654 2.348633 17.651367 C 2.013346 17.31608 1.746419 16.925455 1.547852 16.479492 C 1.349284 16.033529 1.25 15.566406 1.25 15.078125 L 1.25 4.921875 C 1.25 4.433594 1.349284 3.966473 1.547852 3.520508 C 1.746419 3.074545 2.013346 2.68392 2.348633 2.348633 C 2.683919 2.013348 3.074544 1.74642 3.520508 1.547852 C 3.966471 1.349285 4.433594 1.25 4.921875 1.25 L 15.078125 1.25 C 15.566406 1.25 16.033527 1.349285 16.479492 1.547852 C 16.925455 1.74642 17.31608 2.013348 17.651367 2.348633 C 17.986652 2.68392 18.25358 3.074545 18.452148 3.520508 C 18.650715 3.966473 18.75 4.433594 18.75 4.921875 L 18.75 15.078125 C 18.75 15.566406 18.650715 16.033529 18.452148 16.479492 C 18.25358 16.925455 17.986652 17.31608 17.651367 17.651367 C 17.31608 17.986654 16.925455 18.25358 16.479492 18.452148 C 16.033527 18.650717 15.566406 18.75 15.078125 18.75 Z M 15.048828 17.5 C 15.374349 17.5 15.685221 17.433268 15.981445 17.299805 C 16.277668 17.166342 16.538086 16.987305 16.762695 16.762695 C 16.987305 16.538086 17.16634 16.27767 17.299805 15.981445 C 17.433268 15.685222 17.5 15.37435 17.5 15.048828 L 17.5 4.951172 C 17.5 4.625651 17.433268 4.314779 17.299805 4.018555 C 17.16634 3.722332 16.987305 3.461914 16.762695 3.237305 C 16.538086 3.012695 16.277668 2.83366 15.981445 2.700195 C 15.685221 2.566732 15.374349 2.5 15.048828 2.5 L 4.951172 2.5 C 4.625651 2.5 4.314778 2.566732 4.018555 2.700195 C 3.722331 2.83366 3.461914 3.012695 3.237305 3.237305 C 3.012695 3.461914 2.833659 3.722332 2.700195 4.018555 C 2.566732 4.314779 2.5 4.625651 2.5 4.951172 L 2.5 15.048828 C 2.5 15.37435 2.566732 15.685222 2.700195 15.981445 C 2.833659 16.27767 3.012695 16.538086 3.237305 16.762695 C 3.461914 16.987305 3.722331 17.166342 4.018555 17.299805 C 4.314778 17.433268 4.625651 17.5 4.951172 17.5 Z M 5 14.375 L 5 5.625 C 5 5.455729 5.061849 5.309245 5.185547 5.185547 C 5.309245 5.06185 5.455729 5.000001 5.625 5 C 5.794271 5.000001 5.940755 5.06185 6.064453 5.185547 C 6.188151 5.309245 6.25 5.455729 6.25 5.625 L 6.25 14.375 C 6.25 14.544271 6.188151 14.690756 6.064453 14.814453 C 5.940755 14.938151 5.794271 15 5.625 15 C 5.455729 15 5.309245 14.938151 5.185547 14.814453 C 5.061849 14.690756 5 14.544271 5 14.375 Z M 9.375 14.375 L 9.375 5.625 C 9.375 5.455729 9.436849 5.309245 9.560547 5.185547 C 9.684244 5.06185 9.830729 5.000001 10 5 C 10.169271 5.000001 10.315755 5.06185 10.439453 5.185547 C 10.56315 5.309245 10.625 5.455729 10.625 5.625 L 10.625 14.375 C 10.625 14.544271 10.56315 14.690756 10.439453 14.814453 C 10.315755 14.938151 10.169271 15 10 15 C 9.830729 15 9.684244 14.938151 9.560547 14.814453 C 9.436849 14.690756 9.375 14.544271 9.375 14.375 Z M 13.75 14.375 L 13.75 5.625 C 13.75 5.455729 13.811849 5.309245 13.935547 5.185547 C 14.059244 5.06185 14.205729 5.000001 14.375 5 C 14.544271 5.000001 14.690755 5.06185 14.814453 5.185547 C 14.93815 5.309245 14.999999 5.455729 15 5.625 L 15 14.375 C 14.999999 14.544271 14.93815 14.690756 14.814453 14.814453 C 14.690755 14.938151 14.544271 15 14.375 15 C 14.205729 15 14.059244 14.938151 13.935547 14.814453 C 13.811849 14.690756 13.75 14.544271 13.75 14.375 Z " />
</AppBarToggleButton.Icon>

View File

@@ -10,7 +10,6 @@
<Style TargetType="controls:WinoCalendarView">
<Setter Property="VisibleDateBackground" Value="{ThemeResource WinoCalendarViewVisibleDayBackgroundBrush}" />
<Setter Property="TodayBackgroundBrush" Value="{ThemeResource SystemColorControlAccentBrush}" />
<Setter Property="Template">
<Setter.Value>
@@ -29,7 +28,10 @@
<Setter.Value>
<ControlTemplate TargetType="CalendarViewDayItem">
<Grid>
<Border x:Name="PART_DayViewItemBorder" CornerRadius="5">
<Border
x:Name="PART_DayViewItemBorder"
Margin="0,-1,0,-3"
CornerRadius="5">
<ContentPresenter />
</Border>
</Grid>

View File

@@ -0,0 +1,7 @@
using Wino.Core.UWP;
using Wino.Core.ViewModels;
namespace Wino.Calendar.Views.Abstract
{
public class PersonalizationPageAbstract : BasePage<PersonalizationPageViewModel> { }
}

View File

@@ -169,10 +169,10 @@
<calendarControls:WinoCalendarView
x:Name="CalendarView"
HorizontalAlignment="Center"
DateClickedCommand="{x:Bind ViewModel.DateClickedCommand}"
HighlightedDateRange="{x:Bind ViewModel.HighlightedDateRange, Mode=OneWay}" />
HighlightedDateRange="{x:Bind ViewModel.HighlightedDateRange, Mode=OneWay}"
TodayBackgroundColor="{ThemeResource SystemAccentColor}" />
<ScrollViewer
Grid.Row="1"
@@ -180,6 +180,7 @@
VerticalScrollBarVisibility="Hidden">
<Grid>
<Button
Margin="14,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
Command="{x:Bind ViewModel.SyncCommand}"
@@ -263,64 +264,6 @@
</SplitView.Content>
</SplitView>
<!--<muxc:NavigationView
x:Name="MainNavigationView"
Grid.Row="1"
Grid.ColumnSpan="3"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
AlwaysShowHeader="True"
FooterMenuItemsSource="{x:Bind ViewModel.FooterItems, Mode=OneWay}"
IsBackButtonVisible="Collapsed"
IsPaneOpen="{x:Bind ViewModel.PreferencesService.IsNavigationPaneOpened, Mode=TwoWay}"
IsPaneToggleButtonVisible="False"
IsSettingsVisible="False"
IsTabStop="True"
IsTitleBarAutoPaddingEnabled="False"
MenuItemTemplateSelector="{StaticResource NavigationMenuTemplateSelector}"
MenuItemsSource="{x:Bind ViewModel.MenuItems, Mode=OneWay}"
OpenPaneLength="{x:Bind ViewModel.StatePersistenceService.OpenPaneLength, Mode=TwoWay}"
SelectedItem="{x:Bind ViewModel.SelectedMenuItem, Mode=TwoWay}"
Visibility="Collapsed">
<muxc:NavigationView.ContentTransitions>
<TransitionCollection>
<AddDeleteThemeTransition />
</TransitionCollection>
</muxc:NavigationView.ContentTransitions>
<muxc:NavigationView.PaneHeader>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<calendarControls:WinoCalendarView
x:Name="CalendarView"
HorizontalAlignment="Center"
DateClickedCommand="{x:Bind ViewModel.DateClickedCommand}"
HighlightedDateRange="{x:Bind ViewModel.HighlightedDateRange, Mode=OneWay}" />
<ScrollViewer
Grid.Row="1"
HorizontalScrollMode="Disabled"
VerticalScrollBarVisibility="Hidden">
<StackPanel>
<Button
Margin="0,24"
VerticalAlignment="Bottom"
Command="{x:Bind ViewModel.SyncCommand}"
Content="Sync" />
</StackPanel>
</ScrollViewer>
</Grid>
</muxc:NavigationView.PaneHeader>
<muxc:NavigationView.Content>
</muxc:NavigationView.Content>
</muxc:NavigationView>-->
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LowResolutionStates">
<VisualState x:Name="BigScreen">

View File

@@ -8,15 +8,15 @@
xmlns:local="using:Wino.Calendar.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d">
<!--<Page.Resources>
<x:Double x:Key="TeachingTipMinWidth">500</x:Double>
<x:Double x:Key="TeachingTipMaxWidth">500</x:Double>
</Page.Resources>-->
<Border
Margin="0,0,7,7"
Background="{ThemeResource WinoContentZoneBackgroud}"
BorderBrush="{StaticResource CardStrokeColorDefaultBrush}"
BorderThickness="1"
CornerRadius="7">

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,12 @@
using Wino.Calendar.Views.Abstract;
namespace Wino.Calendar.Views.Settings
{
public sealed partial class PersonalizationPage : PersonalizationPageAbstract
{
public PersonalizationPage()
{
this.InitializeComponent();
}
}
}

View File

@@ -163,6 +163,7 @@
<Compile Include="Views\Abstract\AppShellAbstract.cs" />
<Compile Include="Views\Abstract\CalendarPageAbstract.cs" />
<Compile Include="Views\Abstract\CalendarSettingsPageAbstract.cs" />
<Compile Include="Views\Abstract\PersonalizationPageAbstract.cs" />
<Compile Include="Views\Account\AccountManagementPage.xaml.cs">
<DependentUpon>AccountManagementPage.xaml</DependentUpon>
</Compile>
@@ -175,6 +176,9 @@
<Compile Include="Views\Settings\CalendarSettingsPage.xaml.cs">
<DependentUpon>CalendarSettingsPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Settings\PersonalizationPage.xaml.cs">
<DependentUpon>PersonalizationPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
@@ -297,6 +301,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Settings\PersonalizationPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Uwp.Controls.Primitives">