Skip to content

Commit

Permalink
- Removed unsused codes
Browse files Browse the repository at this point in the history
- Refactor the code
  • Loading branch information
Sofiya-kumar committed May 30, 2024
1 parent aed9b85 commit 65ee77b
Show file tree
Hide file tree
Showing 28 changed files with 212 additions and 211 deletions.
2 changes: 1 addition & 1 deletion DemoApp/DemoApp/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static MauiApp CreateMauiApp()
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit()
.UseTrimbleModus(new Resources.Styles.LightThemeColors(), new Resources.Styles.DarkThemeColors())
.UseTrimbleModus()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
Expand Down
29 changes: 28 additions & 1 deletion DemoApp/DemoApp/Resources/Styles/DarkThemeColors.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,32 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="DemoApp.Resources.Styles.DarkThemeColors">

<Color x:Key="Primary">green</Color>
<Color x:Key="Primary">yellow</Color>
<Color x:Key="PrimaryLight">lightyellow</Color>
<Color x:Key="PrimaryDark">#ffeb3b</Color>

<Color x:Key="DefaultTextColor">#FFFFFF</Color>
<Color x:Key="AlternateTextColor">#252A2E</Color>

<Color x:Key="Danger">#d32f2f</Color>
<Color x:Key="DangerLight">#ef5350</Color>
<Color x:Key="DangerDark">#c62828</Color>

<Color x:Key="Tertiary">#3f51b5</Color>
<Color x:Key="TertiaryLight">#c5cae9</Color>
<Color x:Key="TertiaryDark">#1a237e</Color>

<Color x:Key="Warning">#ed6c02</Color>
<Color x:Key="WarningLight">#ff9800</Color>
<Color x:Key="WarningDark">#e65100</Color>

<Color x:Key="Success">#2e7d32</Color>
<Color x:Key="SuccessLight">#4caf50</Color>
<Color x:Key="SuccessDark">#1b5e20</Color>

<Color x:Key="Secondary">#9c27b0</Color>
<Color x:Key="SecondaryLight">#ba68c8</Color>
<Color x:Key="SecondaryDark">#7b1fa2</Color>

<Color x:Key="Transparent">transparent</Color>
</ResourceDictionary>
29 changes: 28 additions & 1 deletion DemoApp/DemoApp/Resources/Styles/LightThemeColors.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,32 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="DemoApp.Resources.Styles.LightThemeColors">
<Color x:Key="Primary">#FFC400</Color>
<Color x:Key="Primary">#019aeb</Color>
<Color x:Key="PrimaryLight">#DCEDF9</Color>
<Color x:Key="PrimaryDark">#004f83</Color>

<Color x:Key="DefaultTextColor">#FFFFFF</Color>
<Color x:Key="AlternateTextColor">#252A2E</Color>

<Color x:Key="Danger">#DA212C</Color>
<Color x:Key="DangerLight">#FBD4D7</Color>
<Color x:Key="DangerDark">#AB1F26</Color>

<Color x:Key="Tertiary">#353A40</Color>
<Color x:Key="TertiaryLight">#E0E1E9</Color>
<Color x:Key="TertiaryDark">#171C1E</Color>

<Color x:Key="Warning">#FBAD26</Color>
<Color x:Key="WarningLight">#fff5e4</Color>
<Color x:Key="WarningDark">#e49325</Color>

<Color x:Key="Success">#1E8A44</Color>
<Color x:Key="SuccessLight">#E0ECCF</Color>
<Color x:Key="SuccessDark">#006638</Color>

<Color x:Key="Secondary">#6A6E79</Color>
<Color x:Key="SecondaryLight">#B7B9C3</Color>
<Color x:Key="SecondaryDark">#585C65</Color>

<Color x:Key="Transparent">transparent</Color>
</ResourceDictionary>
68 changes: 30 additions & 38 deletions Trimble.Modus.Components/Constant/ColorsConstants.cs
Original file line number Diff line number Diff line change
@@ -1,48 +1,40 @@
namespace Trimble.Modus.Components.Constant;

internal class ColorsConstants
{
// Blue
public const string TrimbleBlueDark = "TrimbleBlueDark";
public const string TrimbleBlue = "TrimbleBlue";
public const string Blue = "Blue";
public const string BlueDark = "BlueDark";
public const string BlueLight = "BlueLight";
public const string HighlightBlue = "HighlightBlue";
public const string BluePale = "BluePale";
// Primary
public const string Primary = "Primary";
public const string PrimaryLight = "PrimaryLight";
public const string PrimaryDark = "PrimaryDark";

// Text Colors
public const string DefaultTextColor = "DefaultTextColor";
public const string AlternateTextColor = "AlternateTextColor";

// Black
public const string TrimbleGray = "TrimbleGray";
public const string Gray10 = "Gray10";
public const string Gray9 = "Gray9";
public const string Gray8 = "Gray8";
public const string Gray7 = "Gray7";
public const string Gray6 = "Gray6";
public const string Gray5 = "Gray5";
public const string Gray4 = "Gray4";
public const string Gray3 = "Gray3";
public const string Gray2 = "Gray2";
public const string Gray1 = "Gray1";
public const string Gray0 = "Gray0";
public const string GrayLight = "GrayLight";
public const string White = "White";
// Danger
public const string Danger = "Danger";
public const string DangerLight = "DangerLight";
public const string DangerDark = "DangerDark";

// Tertiary
public const string Tertiary = "Tertiary";
public const string TertiaryLight = "TertiaryLight";
public const string TertiaryDark = "TertiaryDark";

// Orange
public const string YellowDark = "YellowDark";
public const string Yellow = "Yellow";
public const string YellowLight = "YellowLight";
public const string YellowPale = "YellowPale";
// Warning
public const string Warning = "Warning";
public const string WarningLight = "WarningLight";
public const string WarningDark = "WarningDark";

// Red
public const string RedDark = "RedDark";
public const string Red = "Red";
public const string RedLight = "RedLight";
public const string RedPale = "RedPale";
// Success
public const string Success = "Success";
public const string SuccessLight = "SuccessLight";
public const string SuccessDark = "SuccessDark";

// Green
public const string GreenDark = "GreenDark";
public const string Green = "Green";
public const string GreenLight = "GreenLight";
public const string GreenPale = "GreenPale";
// Secondary
public const string Secondary = "Secondary";
public const string SecondaryLight = "SecondaryLight";
public const string SecondaryDark = "SecondaryDark";

// Transparent
public const string Transparent = "Transparent";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
<Border x:Name="border"
VerticalOptions="Start"
HorizontalOptions="Start"
Stroke="{DynamicResource BlueLight}"
Stroke="{DynamicResource PrimaryLight}"
StrokeThickness="4"
Padding="8"
BackgroundColor="White">
<Border.StrokeShape>
<RoundRectangle CornerRadius="4" />
</Border.StrokeShape>
<Border.Shadow>
<Shadow Brush="{DynamicResource Gray9}"
<Shadow Brush="{DynamicResource Secondary}"
Radius="3"
Opacity="0.6">
<Shadow.Offset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public DropDownViewCell()
{
label = new Label
{
TextColor = ResourcesDictionary.ColorsDictionary(ColorsConstants.Gray9),
TextColor = ResourcesDictionary.GetColor(ColorsConstants.Secondary),
FontAttributes = FontAttributes.None,
BackgroundColor = ResourcesDictionary.ColorsDictionary(ColorsConstants.Transparent),
BackgroundColor = ResourcesDictionary.GetColor(ColorsConstants.Transparent),
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Start,
Padding = new Thickness(8, 12)
Expand All @@ -33,7 +33,7 @@ public DropDownViewCell()
{
Children = { label
},
BackgroundColor = ResourcesDictionary.ColorsDictionary(ColorsConstants.Transparent),
BackgroundColor = ResourcesDictionary.GetColor(ColorsConstants.Transparent),
};
}
internal void UpdateBackgroundColor(Color backgroundColor, bool textAttribute)
Expand Down
2 changes: 1 addition & 1 deletion Trimble.Modus.Components/Controls/DropDown/TMDropDown.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
FontSize="16"
HorizontalOptions="Center"
FontFamily="OpenSansSemibold"
TextColor="{DynamicResource White}"
TextColor="{DynamicResource AlternateTextColor}"
VerticalOptions="Center" />
<StackLayout x:Name="indicatorButton"
Orientation="Horizontal"
Expand Down
4 changes: 2 additions & 2 deletions Trimble.Modus.Components/Controls/DropDown/TMDropDown.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ private void UpdateCellColor(ListView list)
{
if (SelectedItem == textCell.BindingContext)
{
textCell.UpdateBackgroundColor(ResourcesDictionary.ColorsDictionary(ColorsConstants.BluePale), true);
textCell.UpdateBackgroundColor(ResourcesDictionary.GetColor(ColorsConstants.PrimaryLight), true);
}
else
{
textCell.UpdateBackgroundColor(ResourcesDictionary.ColorsDictionary(ColorsConstants.White), false);
textCell.UpdateBackgroundColor(ResourcesDictionary.GetColor(ColorsConstants.AlternateTextColor), false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public partial class MessageView : ContentView
nameof(TextAndIconColor),
typeof(Color),
typeof(MessageView),
defaultValue: ResourcesDictionary.ColorsDictionary(ColorsConstants.BlueLight),
defaultValue: ResourcesDictionary.GetColor(ColorsConstants.PrimaryLight),
propertyChanged: OnTextAndIconColorChanged);

public static readonly BindableProperty BorderColorProperty = BindableProperty.Create(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using SkiaSharp;
using SkiaSharp.Views.Maui;
using SkiaSharp.Views.Maui.Controls;
using Trimble.Modus.Components.Enums;
using Trimble.Modus.Components.Constant;
using Trimble.Modus.Components.Enums;
using Trimble.Modus.Components.Helpers;

namespace Trimble.Modus.Components;

Expand All @@ -26,10 +28,10 @@ internal class BaseProgressBar : SKCanvasView
BindableProperty.Create(nameof(Size), typeof(ProgressBarSize), typeof(BaseProgressBar), ProgressBarSize.Default, propertyChanged: OnSizeChangedProperty);

public static readonly BindableProperty ProgressColorProperty =
BindableProperty.Create(nameof(ProgressColor), typeof(Color), typeof(BaseProgressBar), Colors.Blue, propertyChanged: OnProgressColorChangedProperty);
BindableProperty.Create(nameof(ProgressColor), typeof(Color), typeof(BaseProgressBar), ResourcesDictionary.GetColor(ColorsConstants.Primary), propertyChanged: OnProgressColorChangedProperty);

public static readonly BindableProperty BaseColorProperty =
BindableProperty.Create(nameof(BaseColor), typeof(Color), typeof(BaseProgressBar), Colors.DarkGray, propertyChanged: OnBaseColorChangedProperty);
BindableProperty.Create(nameof(BaseColor), typeof(Color), typeof(BaseProgressBar), ResourcesDictionary.GetColor(ColorsConstants.TertiaryDark), propertyChanged: OnBaseColorChangedProperty);

public float Progress
{
Expand Down
6 changes: 4 additions & 2 deletions Trimble.Modus.Components/Controls/TMCard/TMCard.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Windows.Input;
using Trimble.Modus.Components.Constant;
using Trimble.Modus.Components.Helpers;

namespace Trimble.Modus.Components;

Expand Down Expand Up @@ -46,10 +48,10 @@ public object CommandParameter
BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(TMCard), defaultValue: true, propertyChanged: OnSelectedPropertyChanged);

public static new readonly BindableProperty BackgroundColorProperty =
BindableProperty.Create(nameof(BackgroundColor), typeof(Color), typeof(TMCard), defaultValue: Colors.Green, propertyChanged: OnBackgroundColorPropertyChanged);
BindableProperty.Create(nameof(BackgroundColor), typeof(Color), typeof(TMCard), defaultValue: ResourcesDictionary.GetColor(ColorsConstants.TertiaryDark), propertyChanged: OnBackgroundColorPropertyChanged);

public static readonly BindableProperty StrokeColorProperty =
BindableProperty.Create(nameof(StrokeColor), typeof(Color), typeof(TMCard), defaultValue: Colors.Blue, propertyChanged: OnStrokeColorPropertyChanged);
BindableProperty.Create(nameof(StrokeColor), typeof(Color), typeof(TMCard), defaultValue: ResourcesDictionary.GetColor(ColorsConstants.Primary), propertyChanged: OnStrokeColorPropertyChanged);

public static readonly BindableProperty ClickedEventProperty =
BindableProperty.Create(nameof(Clicked), typeof(EventHandler), typeof(TMCard));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial class DataGrid
/// Border color
/// Default Value is Black
/// </summary>
internal Color BorderColor = ResourcesDictionary.ColorsDictionary(ColorsConstants.Gray2);
internal Color BorderColor = ResourcesDictionary.GetColor(ColorsConstants.TertiaryDark);
/// <summary>
/// Border thickness for header &amp; each cell
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal sealed class DataGridRow : Grid
#region Fields

private Color? _bgColor;
private readonly Color? _textColor = ResourcesDictionary.ColorsDictionary(ColorsConstants.TrimbleGray);
private readonly Color? _textColor = ResourcesDictionary.GetColor(ColorsConstants.AlternateTextColor);
private List<int> SelectedIndexes = new List<int>();

#endregion Fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ private void UpdateBorderColors(BaseInput tmInput)
{
tmInput.InputBorder.Opacity = tmInput.InputLabel.Opacity = tmInput.HelperLayout.Opacity = 1;
tmInput.SetDynamicResource(BaseInput.StyleProperty, "Default");
tmInput.GetCoreContent().BackgroundColor = ResourcesDictionary.ColorsDictionary(ColorsConstants.Transparent);
tmInput.GetCoreContent().BackgroundColor = ResourcesDictionary.GetColor(ColorsConstants.Transparent);
SetBorderColor(tmInput);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
VerticalOptions="Center"
HorizontalOptions="Fill"
StrokeShape="RoundRectangle 4"
Stroke="{DynamicResource Gray9}"
Stroke="{DynamicResource Secondary}"
StrokeThickness="0">
<Border.Shadow>
<Shadow Brush="{DynamicResource Gray9}"
<Shadow Brush="{DynamicResource Secondary}"
Offset="0,0"
Opacity="0.2"
Radius="8" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
HorizontalOptions="Start"
IsVisible="{Binding Source={x:Reference ItemContainer}, Path=ShowSeparator}"
Margin="0,8"
Color="{DynamicResource Gray2}"
Color="{DynamicResource TertiaryDark}"
VerticalOptions="FillAndExpand"
WidthRequest="1.4" />
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public partial class TMSegmentedItem

public static readonly BindableProperty IconProperty = BindableProperty.Create(nameof(Icon), typeof(ImageSource), typeof(TMSegmentedItem), null, propertyChanged: OnSegmentedItemPropertyChanged);

public static readonly BindableProperty CurrentBackgroundColorProperty = BindableProperty.Create(nameof(CurrentBackgroundColor), typeof(Color), typeof(TMSegmentedItem), ResourcesDictionary.ColorsDictionary(ColorsConstants.Transparent), propertyChanged: OnCurrentBackgroundColorChanged);
public static readonly BindableProperty CurrentBackgroundColorProperty = BindableProperty.Create(nameof(CurrentBackgroundColor), typeof(Color), typeof(TMSegmentedItem), ResourcesDictionary.GetColor(ColorsConstants.Transparent), propertyChanged: OnCurrentBackgroundColorChanged);

public static readonly BindableProperty SizeProperty = BindableProperty.Create(nameof(Size), typeof(SegmentedControlSize), typeof(TMSegmentedItem), SegmentedControlSize.Small, propertyChanged: OnSizeChanged);

public static readonly BindableProperty TextColorProperty = BindableProperty.Create(nameof(TextColor), typeof(Color), typeof(TMSegmentedItem), ResourcesDictionary.ColorsDictionary(ColorsConstants.Gray9), propertyChanged: OnTextColorChanged);
public static readonly BindableProperty TextColorProperty = BindableProperty.Create(nameof(TextColor), typeof(Color), typeof(TMSegmentedItem), ResourcesDictionary.GetColor(ColorsConstants.Secondary), propertyChanged: OnTextColorChanged);

public static readonly BindableProperty IconTintColorProperty = BindableProperty.Create(nameof(IconTintColor), typeof(Color), typeof(TMSegmentedItem), Colors.Black, propertyChanged: OnIconTintColorChanged);
#endregion
Expand Down
16 changes: 6 additions & 10 deletions Trimble.Modus.Components/Controls/TMSlider/SliderCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,7 @@ protected void OnIsEnabledChanged()
}
else if (child is Border)
{
(child as Border).Stroke = IsEnabled
? ThumbColor
: ResourcesDictionary.ColorsDictionary(
ColorsConstants.Gray1
);
(child as Border).Stroke = IsEnabled ? ThumbColor : ResourcesDictionary.GetColor(ColorsConstants.Tertiary);
}
}
}
Expand All @@ -335,11 +331,11 @@ internal void SetThumbStyle(Border border, double thumbStrokeThickness, double t
border.StrokeThickness = thumbStrokeThickness;
border.Stroke = IsEnabled
? ThumbColor
: ResourcesDictionary.ColorsDictionary(
ColorsConstants.Gray1
: ResourcesDictionary.GetColor(
ColorsConstants.Tertiary
);
border.Margin = new Thickness(0);
border.BackgroundColor = ResourcesDictionary.ColorsDictionary(ColorsConstants.White);
border.BackgroundColor = ResourcesDictionary.GetColor(ColorsConstants.DefaultTextColor);
border.StrokeShape = new Ellipse()
{
WidthRequest = thumbSize,
Expand All @@ -356,8 +352,8 @@ internal void RefreshThumbColor(Border border)
{
border.Stroke = IsEnabled
? ThumbColor
: ResourcesDictionary.ColorsDictionary(
ColorsConstants.Gray1
: ResourcesDictionary.GetColor(
ColorsConstants.Tertiary
);
}
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Trimble.Modus.Components/Controls/TMSlider/SliderHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static Label CreateStepLabel(SliderSize size = SliderSize.Medium)
}
return new Label
{
TextColor = ResourcesDictionary.ColorsDictionary(ColorsConstants.Gray9),
TextColor = ResourcesDictionary.GetColor(ColorsConstants.Secondary),
FontSize = 8,
HorizontalTextAlignment = TextAlignment.Start,
LineBreakMode = LineBreakMode.NoWrap,
Expand Down Expand Up @@ -96,7 +96,7 @@ public static BoxView CreateStepLine(SliderSize size = SliderSize.Medium)
Margin = new Thickness(leftPadding, 0, 0, 0),
WidthRequest = 1,
HeightRequest = 4,
Color = ResourcesDictionary.ColorsDictionary(ColorsConstants.Gray9)
Color = ResourcesDictionary.GetColor(ColorsConstants.Secondary)
};
}
}
Expand Down

0 comments on commit 65ee77b

Please sign in to comment.