Skip to content

Commit

Permalink
UI Improvements: Colors
Browse files Browse the repository at this point in the history
  • Loading branch information
leomotors committed Apr 25, 2022
1 parent 976d4b1 commit 40ab165
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 51 deletions.
5 changes: 3 additions & 2 deletions TestForFailure/UnitTestApp.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
global using System.Threading.Tasks;
global using Microsoft.VisualStudio.TestTools.UnitTesting;

using Microsoft.VisualStudio.TestPlatform.TestExecutor;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.UI.Xaml;
Expand Down Expand Up @@ -56,12 +57,12 @@ protected override void OnLaunched(LaunchActivatedEventArgs e) {
Window.Current.Content = rootFrame;
}

Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();
UnitTestClient.CreateDefaultUI();

// Ensure the current window is active
Window.Current.Activate();

Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments);
UnitTestClient.Run(e.Arguments);
}

/// <summary>
Expand Down
6 changes: 1 addition & 5 deletions YouAreAFailure/Controls/ExternalLink.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
d:DesignWidth="400"
mc:Ignorable="d">

<HyperlinkButton
NavigateUri="{x:Bind Url, Mode=OneWay}"
PointerEntered="OnPointerEntered"
PointerExited="OnPointerExited">
<HyperlinkButton NavigateUri="{x:Bind Url, Mode=OneWay}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{x:Bind Text, Mode=OneWay}" />
<FontIcon
Expand All @@ -21,7 +18,6 @@
VerticalAlignment="Center"
FontFamily="{StaticResource SymbolThemeFontFamily}"
FontSize="16"
Foreground="Blue"
Glyph="&#xE8A7;" />
</StackPanel>
</HyperlinkButton>
Expand Down
31 changes: 1 addition & 30 deletions YouAreAFailure/Controls/ExternalLink.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
using Windows.UI;
using Windows.UI.Xaml.Input;

#nullable enable
#nullable enable

namespace YouAreAFailure.Controls;

public sealed partial class ExternalLink : UserControl {
private static readonly Color lightNormalExtLink =
Color.FromArgb(255, 0, 62, 146);

private static readonly Color ExtLinkColor =
App.Current.IsLightTheme
? lightNormalExtLink
: Color.FromArgb(255, 153, 235, 255);

private static readonly bool isLightTheme = App.Current.IsLightTheme;

public ExternalLink() {
this.InitializeComponent();

ExtIcon.Foreground = new SolidColorBrush(ExtLinkColor);
}

public string Text {
Expand Down Expand Up @@ -47,18 +32,4 @@ public string Url {
typeof(ExternalLink),
new PropertyMetadata(string.Empty)
);

private void OnPointerEntered(object sender, PointerRoutedEventArgs e) {
if (isLightTheme) {
ExtIcon.Foreground =
new SolidColorBrush(Color.FromArgb(255, 0, 26, 104));
}
}

private void OnPointerExited(object sender, PointerRoutedEventArgs e) {
if (isLightTheme) {
ExtIcon.Foreground =
new SolidColorBrush(lightNormalExtLink);
}
}
}
19 changes: 8 additions & 11 deletions YouAreAFailure/Failure/Statistics.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,23 @@ protected override void OnNavigatedTo(NavigationEventArgs e) {
base.OnNavigatedTo(e);
}

// https://blog.mzikmund.com/2020/07/highlighting-dates-in-uwp-calendarview/#comments
private void HighlightDay(CalendarViewDayItem day, Color color) {
day.Background = new SolidColorBrush(color);
}
private readonly SolidColorBrush CalenderColor =
new((Color)Application.Current.Resources[
App.Current.IsLightTheme ? "SystemAccentColorLight2" : "SystemAccentColorDark2"]);

private readonly Color AkiColor =
App.Current.IsLightTheme
? Color.FromArgb(255, 111, 159, 216)
: Color.FromArgb(255, 36, 44, 80);
private readonly SolidColorBrush TransparentBrush = new(Colors.Transparent);

private void FailureCalendar_DayItemChanging(CalendarView sender, CalendarViewDayItemChangingEventArgs args) {
var dateOffset = args.Item.Date;
DateTime date = new(dateOffset.Year, dateOffset.Month, dateOffset.Day);

var color =
App.Current.State.WatchedDate.Contains(date) && date != Today
? AkiColor
: Colors.Transparent;
? CalenderColor
: TransparentBrush;

HighlightDay(args.Item, color);
// https://blog.mzikmund.com/2020/07/highlighting-dates-in-uwp-calendarview/#comments
args.Item.Background = color;
}

private async void ShareButton_Click(object sender, RoutedEventArgs e) {
Expand Down
2 changes: 1 addition & 1 deletion YouAreAFailure/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void UpdateTitleBarLayout(CoreApplicationViewTitleBar coreTitleBar) {
}

// Update the TitleBar based on the inactive/active state of the app
private void Current_Activated(object sender, Windows.UI.Core.WindowActivatedEventArgs e) {
private void Current_Activated(object sender, WindowActivatedEventArgs e) {
var defaultForegroundBrush =
(SolidColorBrush)Application.Current.Resources["TextFillColorPrimaryBrush"];
var inactiveForegroundBrush =
Expand Down
2 changes: 1 addition & 1 deletion YouAreAFailure/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Identity
Name="65313Leomotors.YouareaFailure"
Publisher="CN=E10452D0-AB02-4FD0-8CF3-B1A36A4584AA"
Version="1.0.73.0" />
Version="1.0.76.0" />

<mp:PhoneIdentity PhoneProductId="9b164781-9d5e-4668-89da-851e4bb1ad57" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
2 changes: 1 addition & 1 deletion YouAreAFailure/Package.debug.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Identity
Name="Leomotors.YouAreAFailure.Debug"
Publisher="CN=Leomotors"
Version="1.0.73.0" />
Version="1.0.76.0" />

<mp:PhoneIdentity PhoneProductId="54184a93-8dcf-4a09-9cf4-cee9c428cbf4" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down

0 comments on commit 40ab165

Please sign in to comment.