Skip to content

Commit

Permalink
use reference color
Browse files Browse the repository at this point in the history
  • Loading branch information
rthanga1 committed May 9, 2024
1 parent 5661c4d commit 266e12f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 18 deletions.
3 changes: 2 additions & 1 deletion DemoApp/DemoApp/Resources/Styles/LightTheme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="DemoApp.Resources.Styles.LightTheme">
<Color x:Key="PrimaryFillButtonBackgroundColor">brown</Color>
<!--<Color x:Key="PrimaryFillButtonBackgroundColor">brown</Color>-->
<Color x:Key="PrimaryFillButtonBackgroundColor">#FFC400</Color>
</ResourceDictionary>
34 changes: 20 additions & 14 deletions Trimble.Modus.Components/Helpers/ThemeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@ public static void Initialize(ResourceDictionary lightTheme = null, ResourceDict
var defaultDarkTheme = new Styles.DarkTheme();
if (lightTheme != null && lightTheme.Count > 0)
{
LightThemeResourceDictionary = lightTheme;
var notExistsInDictionary = defaultLightTheme.Where(x => !lightTheme.ContainsKey(x.Key)).ToDictionary(x => x.Key, x => x.Value);
foreach (var item in notExistsInDictionary)
{
var keyExists = LightThemeResourceDictionary.ContainsKey(item.Key);
if (keyExists)
{
LightThemeResourceDictionary[item.Key] = item.Value;
}
else
{
LightThemeResourceDictionary.Add(item.Key, item.Value);
}
}

LightThemeResourceDictionary = new ResourceDictionary();
// Add lightTheme and LightThemeResourceDictionary to the MergedDictionaries of the new ResourceDictionary
LightThemeResourceDictionary.MergedDictionaries.Add(defaultLightTheme);
LightThemeResourceDictionary.MergedDictionaries.Add(lightTheme);

// LightThemeResourceDictionary = lightTheme;
// var notExistsInDictionary = defaultLightTheme.Where(x => !lightTheme.ContainsKey(x.Key)).ToDictionary(x => x.Key, x => x.Value);
// foreach (var item in notExistsInDictionary)
// {
// var keyExists = LightThemeResourceDictionary.ContainsKey(item.Key);
// if (keyExists)
// {
// LightThemeResourceDictionary[item.Key] = item.Value;
// }
// else
// {
// LightThemeResourceDictionary.Add(item.Key, item.Value);
// }
// }
}
else
{
Expand Down
7 changes: 4 additions & 3 deletions Trimble.Modus.Components/Styles/LightTheme.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:styles="clr-namespace:Trimble.Modus.Components.Styles"
x:Class="Trimble.Modus.Components.Styles.LightTheme">

<Color x:Key="Blue">#0063a3</Color>
<Color x:Key="PrimaryColor">#0063a3</Color>
<Color x:Key="DarkBlue">#004f83</Color>
<Color x:Key="LightBlue">#DCEDF9</Color>

Expand All @@ -22,7 +22,8 @@

<!--Button-->
<!--Fill Button-->
<Color x:Key="PrimaryFillButtonBackgroundColor">#0063A3</Color>
<styles:ReferenceColor x:Key="PrimaryFillButtonBackgroundColor" Color="{StaticResource PrimaryColor}"/>
<!--<Color x:Key="PrimaryFillButtonBackgroundColor">#0063a3</Color>-->
<Color x:Key="PrimaryFillButtonSelectedBackgroundColor">#0E416C</Color>
<Color x:Key="PrimaryFillButtonTextColor">#FFFFFF</Color>
<Color x:Key="PrimaryFillIconTintColor">#FFFFFF</Color>
Expand Down
16 changes: 16 additions & 0 deletions Trimble.Modus.Components/Styles/ReferenceColor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
namespace Trimble.Modus.Components.Styles
{
public class ReferenceColor
{
public Color Color { get; set; }

public ReferenceColor()
{

}

public static implicit operator Color(ReferenceColor referenceColor) => referenceColor.Color;
}
}

0 comments on commit 266e12f

Please sign in to comment.