Skip to content

Commit

Permalink
more theme stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Programming-With-Chris committed Aug 18, 2022
1 parent 49aaf6c commit bc2f712
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 74 deletions.
25 changes: 25 additions & 0 deletions ShoppingList/Resources/Styles/Colors.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,31 @@
<Color x:Key="Gray600">#404040</Color>
<Color x:Key="Gray900">#212121</Color>
<Color x:Key="Gray950">#141414</Color>

<!-- My color themes -->

<!-- Nautical -->
<Color x:Key="NauticalPrimary">#0081A7</Color>
<Color x:Key="NauticalSecondary">#00AFB9</Color>
<Color x:Key="NauticalTertiary">#FDFCDC</Color>
<Color x:Key="NauticalAccent">#FED9B7</Color>
<Color x:Key="NauticalDarkAccent">#F07167</Color>

<!-- Neon -->
<Color x:Key="NeonPrimary">#0AFFC2</Color>
<Color x:Key="NeonSecondary">#00CCF5</Color>
<Color x:Key="NeonTertiary">#FF7700</Color>
<Color x:Key="NeonAccent">#F50076</Color>
<Color x:Key="NeonDarkAccent">#FFCF00</Color>

<!-- Striking -->
<Color x:Key="StrikingPrimary">#3D5A80</Color>
<Color x:Key="StrikingSecondary">#98C1D9</Color>
<Color x:Key="StrikingTertiary">#E0FBFC</Color>
<Color x:Key="StrikingAccent">#EE6C4D</Color>
<Color x:Key="StrikingDarkAccent">#293241</Color>


<SolidColorBrush x:Key="PrimaryBrush" Color="{DynamicResource Primary}"/>
<SolidColorBrush x:Key="SecondaryBrush" Color="{DynamicResource Secondary}"/>
<SolidColorBrush x:Key="TertiaryBrush" Color="{StaticResource Tertiary}"/>
Expand Down
31 changes: 10 additions & 21 deletions ShoppingList/View/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,51 +72,40 @@

<HorizontalStackLayout Padding="25"
Margin="25,0,0,0">
<control:CircularButton ButtonColor="CadetBlue"
<control:CircularButton ButtonColor="{StaticResource NauticalPrimary}"
WidthRequest="30"
HeightRequest="30"
IsVisible="True"
Margin="25,0,0,25"
x:Name="CadetBlueButton">
x:Name="Nautical">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
CommandParameter="CadetBlue"/>
CommandParameter="Nautical"/>
</control:CircularButton.GestureRecognizers>

</control:CircularButton>
<control:CircularButton ButtonColor="Pink"
<control:CircularButton ButtonColor="{StaticResource NeonPrimary}"
WidthRequest="30"
HeightRequest="30"
Margin="25,0,0,25"
x:Name="PinkButton">
x:Name="Neon">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
CommandParameter="Pink"/>
CommandParameter="Neon"/>
</control:CircularButton.GestureRecognizers>

</control:CircularButton>
<control:CircularButton ButtonColor="MediumPurple"
<control:CircularButton ButtonColor="{StaticResource StrikingPrimary}"
WidthRequest="30"
HeightRequest="30"
Margin="25,0,0,25"
x:Name="MediumPurpleButton">
x:Name="Striking">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
CommandParameter="MediumPurple"/>
</control:CircularButton.GestureRecognizers>

</control:CircularButton>
<control:CircularButton ButtonColor="WhiteSmoke"
WidthRequest="30"
HeightRequest="30"
Margin="25,0,0,25"
x:Name="WhiteSmokeButton">

<control:CircularButton.GestureRecognizers>
<TapGestureRecognizer Command="{Binding UpdatePrimaryColorPressedCommand}"
CommandParameter="WhiteSmoke"/>
CommandParameter="Striking"/>
</control:CircularButton.GestureRecognizers>

</control:CircularButton>
Expand Down
74 changes: 21 additions & 53 deletions ShoppingList/ViewModel/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,65 +70,33 @@ public async void CancelQuery()
}

[RelayCommand]
public void UpdatePrimaryColorPressed(string colorName)
public void UpdatePrimaryColorPressed(string themeName)
{
Color colorSelected;
Color newPrimary;
Color newSecondary;
Color newTertiary;
Color newBackground;

var wasSuccessfulColor = Color.TryParse(colorName, out colorSelected);
var theme = Application.Current.RequestedTheme;

if (theme == AppTheme.Light)
{

}

switch (colorName)
{
case "CadetBlue":
newPrimary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newSecondary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newTertiary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newBackground = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
break;
case "Pink":
newPrimary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newSecondary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newTertiary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newBackground = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
break;
case "MediumPurple":
newPrimary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newSecondary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newTertiary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newBackground = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
break;
case "WhiteSmoke":
newPrimary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newSecondary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newTertiary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newBackground = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
break;
default:
newPrimary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newSecondary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newTertiary = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
newBackground = theme == AppTheme.Light ? Colors.CadetBlue : Colors.CadetBlue;
break;

}
ICollection<ResourceDictionary> mergedDictionaries = Application.Current.Resources.MergedDictionaries;
if (mergedDictionaries != null)
{
foreach(ResourceDictionary dictionaries in mergedDictionaries)
{
dictionaries["Primary"] = newPrimary;
dictionaries["Secondary"] = newSecondary;
dictionaries["Tertiary"] = newTertiary;
dictionaries["BackgroundLight"] = newBackground;
var primaryFound = dictionaries.TryGetValue(themeName + "Primary", out var primary);
if (primaryFound)
dictionaries["Primary"] = primary;

var secondaryFound = dictionaries.TryGetValue(themeName + "Secondary", out var secondary);
if (secondaryFound)
dictionaries["Secondary"] = secondary;

var tertiaryFound = dictionaries.TryGetValue(themeName + "Tertiary", out var tertiary);
if (tertiaryFound)
dictionaries["Tertiary"] = tertiary;

var accentFound = dictionaries.TryGetValue(themeName + "Accent", out var accent);
if (accentFound)
dictionaries["Accent"] = accent;

var darkAccentFound = dictionaries.TryGetValue(themeName + "DarkAccent", out var darkAccent);
if (darkAccentFound)
dictionaries["DarkAccent"] = darkAccent;


}
}
Expand Down

0 comments on commit bc2f712

Please sign in to comment.