Skip to content

Commit

Permalink
Updated statics and added sample app with reflection to show all colors
Browse files Browse the repository at this point in the history
  • Loading branch information
haavamoa committed Nov 28, 2019
1 parent fc7ed64 commit e0dfe21
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 110 deletions.
3 changes: 0 additions & 3 deletions src/DIPS.Xamarin.UI/DIPS.Xamarin.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
<EmbeddedResource Update="Controls\RadioButtonGroup\RadioButtonGroup.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Resources\Colors.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
Expand Down
72 changes: 0 additions & 72 deletions src/DIPS.Xamarin.UI/Resources/Colors.xaml

This file was deleted.

29 changes: 0 additions & 29 deletions src/DIPS.Xamarin.UI/Resources/Colors.xaml.cs

This file was deleted.

34 changes: 34 additions & 0 deletions src/DIPS.Xamarin.UI/Resources/Colors/ColorPalette.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;

namespace DIPS.Xamarin.UI.Resources.Colors
{
public static class ColorPalette
{
public static Color Dark = Color.FromHex("#000000");
public static Color DarkLight = Color.FromHex("#111111");
public static Color DarkAir = Color.FromHex("#3B3D3D");

public static Color Tertiary = Color.FromHex("#404040");
public static Color TertiaryLight = Color.FromHex("#4A4A4A");
public static Color TertiaryAir = Color.FromHex("#646464");

public static Color Quaternary = Color.FromHex("#76797A");
public static Color QuaternaryLight = Color.FromHex("#7F7F7F");
public static Color QuaternaryAir = Color.FromHex("#8C8C8C");

public static Color Quinary = Color.FromHex("#ACACAC");
public static Color QuinaryLight = Color.FromHex("#B2B2B2");
public static Color QuinaryAir = Color.FromHex("#D9D9D9");

public static Color Light = Color.FromHex("#EBEBEB");
public static Color LightLight = Color.FromHex("#F9F9F9");
public static Color LightAir = Color.FromHex("#FFFFFF");

public static Color Accent = Color.FromHex("#AB69BF");
public static Color AccentLight = Color.FromHex("#D297E3");
public static Color AccentAir = Color.FromHex("#F4DDFA");
}
}
35 changes: 35 additions & 0 deletions src/DIPS.Xamarin.UI/Resources/Colors/StatusColorPalette.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;

namespace DIPS.Xamarin.UI.Resources.Colors
{
public static class StatusColorPalette
{
public static Color DangerDark = Color.FromHex("#C9524D");
public static Color Danger = Color.FromHex("#F76D6D");
public static Color DangerLight = Color.FromHex("#E19D9A");
public static Color DangerAir = Color.FromHex("#FFDEDE");

public static Color WarningDark = Color.FromHex("#D29F0F");
public static Color Warning = Color.FromHex("#FFDC52");
public static Color WarningLight = Color.FromHex("#EDD5A6");
public static Color WarningAir = Color.FromHex("#F3E9BC");

public static Color SuccessDark = Color.FromHex("#006700");
public static Color Success = Color.FromHex("#5CB85C");
public static Color SuccessLight = Color.FromHex("#9FD99F");
public static Color SuccessAir = Color.FromHex("#CCEBCC");

public static Color InfoDark = Color.FromHex("#266B89");
public static Color Info = Color.FromHex("#337AB7");
public static Color InfoLight = Color.FromHex("#7FAFD8");
public static Color InfoAir = Color.FromHex("#C4DBEF");

public static Color IdleDark = Color.FromHex("#697577");
public static Color Idle = Color.FromHex("#92A1A3");
public static Color IdleLight = Color.FromHex("#B1BEBF");
public static Color IdleAir = Color.FromHex("#D3DDDE");
}
}
14 changes: 14 additions & 0 deletions src/DIPS.Xamarin.UI/Resources/Colors/Theme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Xamarin.Forms;

namespace DIPS.Xamarin.UI.Resources.Colors
{
public static class Theme
{
public static Color TealPrimary = Color.FromHex("#047F89");
public static Color TealPrimaryLight = Color.FromHex("#65868F");
public static Color TealPrimaryAir = Color.FromHex("#98B2AE");
public static Color TealSecondary = Color.FromHex("#97C8CD");
public static Color TealSecondaryLight = Color.FromHex("#ECF3F4");
public static Color TealSecondaryAir = Color.FromHex("#F0F5F7");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Resources="http://dips.xamarin.ui.com"
xmlns:Colors="clr-namespace:DIPS.Xamarin.UI.Resources.Colors;assembly=DIPS.Xamarin.UI"
mc:Ignorable="d"
x:Class="DIPS.Xamarin.UI.Samples.Resources.Colors.ColorsPage"
xmlns:dxui="http://dips.xamarin.ui.com">
<ContentPage.Resources>
<dxui:Colors />
</ContentPage.Resources>
>

<BoxView BackgroundColor="{StaticResource ColorPalette.Accent}"/>
<ScrollView>
<StackLayout x:Name="colorCategories"/>
<Label FontSize=""
</ScrollView>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using Xamarin.Forms;
using System;
using System.Collections.Generic;
using System.Reflection;
using DIPS.Xamarin.UI.Resources;
using DIPS.Xamarin.UI.Resources.Colors;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace DIPS.Xamarin.UI.Samples.Resources.Colors
Expand All @@ -9,6 +14,61 @@ public partial class ColorsPage : ContentPage
public ColorsPage()
{
InitializeComponent();
var allColorsCategories = new List<ColorCategory>()
{
GetColorCategory(typeof(Theme)), GetColorCategory(typeof(ColorPalette)), GetColorCategory(typeof(StatusColorPalette)),
};


foreach (var colorCategory in allColorsCategories)
{
colorCategories.Children.Add(new Label(){Text = colorCategory.Name, FontAttributes = FontAttributes.Bold, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))});
foreach (var colorInfo in colorCategory.ColorInfos)
{
var colorStackLayout = new StackLayout();
colorStackLayout.Children.Add(new Label(){Text = colorInfo.Name});
colorStackLayout.Children.Add(new BoxView(){Color = colorInfo.Color});
colorCategories.Children.Add(colorStackLayout);
}
}

}

private ColorCategory GetColorCategory(Type type)
{
var listOfColorInfos = new List<ColorInfo>();
var fields = type.GetFields(BindingFlags.Static | BindingFlags.Public);
var categoryName = type.Name;
foreach (var fieldInfo in fields)
{
var colorInfo = new ColorInfo(fieldInfo.Name, (Color)fieldInfo.GetValue(null));

listOfColorInfos.Add(colorInfo);
}
return new ColorCategory(categoryName, listOfColorInfos);
}

public class ColorInfo
{
public ColorInfo(string name, Color color)
{
Name = name;
Color = color;
}
public string Name { get; }
public Color Color { get; }
}

public class ColorCategory
{
public string Name { get; }
public IEnumerable<ColorInfo> ColorInfos { get; }

public ColorCategory(string name, IEnumerable<ColorInfo> colorInfos)
{
Name = name;
ColorInfos = colorInfos;
}
}
}
}

0 comments on commit e0dfe21

Please sign in to comment.