Skip to content

Commit

Permalink
Task/hmo common colors (#59)
Browse files Browse the repository at this point in the history
* Added Colors

* Added more colors and added sample page

* Updated statics and added sample app with reflection to show all colors

* Fixed xaml error

* No comments for colors yet, this should be included when we have use case scenarios for the different colors

* Added colors to XmlnsDefinition

* Added documentation for the different colors

* Formatted code

* Updated samples colors
  • Loading branch information
haavamoa authored Nov 29, 2019
1 parent 8ca8c47 commit a5177db
Show file tree
Hide file tree
Showing 13 changed files with 8,909 additions and 8,641 deletions.
17,272 changes: 8,636 additions & 8,636 deletions src/DIPS.Xamarin.UI.Android/Resources/Resource.designer.cs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/DIPS.Xamarin.UI/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
[assembly: XmlnsDefinition("http://dips.xamarin.ui.com", "DIPS.Xamarin.UI.Controls.DatePicker")]
[assembly: XmlnsDefinition("http://dips.xamarin.ui.com", "DIPS.Xamarin.UI.Controls.RadioButtonGroup")]
[assembly: XmlnsDefinition("http://dips.xamarin.ui.com", "DIPS.Xamarin.UI.Controls.Popup")]
[assembly: XmlnsDefinition("http://dips.xamarin.ui.com", "DIPS.Xamarin.UI.Controls.TrendGraph")]
[assembly: XmlnsDefinition("http://dips.xamarin.ui.com", "DIPS.Xamarin.UI.Controls.TrendGraph")]
[assembly: XmlnsDefinition("http://dips.xamarin.ui.com", "DIPS.Xamarin.UI.Resources.Colors")]
36 changes: 36 additions & 0 deletions src/DIPS.Xamarin.UI/Resources/Colors/ColorPalette.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Xamarin.Forms;

namespace DIPS.Xamarin.UI.Resources.Colors
{
/// <summary>
/// Color palette colors should be used for backgrounds, borders, buttons, checkbox or other controls that the app uses
/// </summary>
public static class ColorPalette
{
#pragma warning disable 1591
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");
#pragma warning restore 1591
}
}
37 changes: 37 additions & 0 deletions src/DIPS.Xamarin.UI/Resources/Colors/StatusColorPalette.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Xamarin.Forms;

namespace DIPS.Xamarin.UI.Resources.Colors
{
/// <summary>
/// Status colors palette colors should be used to indicate different statuses.
/// </summary>
public static class StatusColorPalette
{
#pragma warning disable 1591
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");
#pragma warning restore 1591
}
}
20 changes: 20 additions & 0 deletions src/DIPS.Xamarin.UI/Resources/Colors/Theme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Xamarin.Forms;

namespace DIPS.Xamarin.UI.Resources.Colors
{
/// <summary>
/// Theme colors should be used as an overall color for an app. The colors are suitable for navigation bars, splash
/// screen, action bars etc..
/// </summary>
public static class Theme
{
#pragma warning disable 1591
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");
#pragma warning restore 1591
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
<EmbeddedResource Update="Converters\ValueConverters\InvertedBoolConverterPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Resources\Colors\ColorsPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Resources\ResourcesPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
Expand Down
15 changes: 12 additions & 3 deletions src/Samples/DIPS.Xamarin.UI.Samples/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,18 @@
Title="DIPS.Xamarin.UI">

<StackLayout>
<Button Text="Controls" Command="{Binding NavigateToCommand}" CommandParameter="Controls"/>
<Button Text="Converters" Command="{Binding NavigateToCommand}" CommandParameter="Converters"/>
<Button Text="Async command" Command="{Binding NavigateToCommand}" CommandParameter="Async command"/>
<Button Text="Controls"
Command="{Binding NavigateToCommand}"
CommandParameter="Controls" />
<Button Text="Resources"
Command="{Binding NavigateToCommand}"
CommandParameter="Resources" />
<Button Text="Converters"
Command="{Binding NavigateToCommand}"
CommandParameter="Converters" />
<Button Text="Async command"
Command="{Binding NavigateToCommand}"
CommandParameter="Async command" />
</StackLayout>

</ContentPage>
6 changes: 5 additions & 1 deletion src/Samples/DIPS.Xamarin.UI.Samples/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using System.Windows.Input;
using DIPS.Xamarin.UI.Samples.Commands;
using DIPS.Xamarin.UI.Samples.Commands;
using DIPS.Xamarin.UI.Samples.Controls;
using DIPS.Xamarin.UI.Samples.Controls.DatePicker;
using DIPS.Xamarin.UI.Samples.Converters;
using DIPS.Xamarin.UI.Samples.Resources;
using Xamarin.Forms;

namespace DIPS.Xamarin.UI.Samples
Expand All @@ -26,6 +27,9 @@ private void NavigateTo(string parameter)
case "Controls":
m_navigation.PushAsync(new ControlsPage());
break;
case "Resources":
m_navigation.PushAsync(new ResourcesPage());
break;
case "Converters":
m_navigation.PushAsync(new ConvertersPage());
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
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"
>

<ScrollView>
<StackLayout x:Name="colorCategories"/>
</ScrollView>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using DIPS.Xamarin.UI.Resources.Colors;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace DIPS.Xamarin.UI.Samples.Resources.Colors
{
[XamlCompilation(XamlCompilationOptions.Compile)]
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)),
Margin = new Thickness(5,0,0,0)
});
foreach (var colorInfo in colorCategory.ColorInfos)
{
var colorStackLayout = new StackLayout();
colorStackLayout.Children.Add(new Label() { Text = $"{colorInfo.Name} ({colorInfo.Color.ToHex()})", Margin = new Thickness(5,0,0,0)});
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 Color Color { get; }
public string Name { get; }
}

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

public IEnumerable<ColorInfo> ColorInfos { get; }
public string Name { get; }
}
}
}
13 changes: 13 additions & 0 deletions src/Samples/DIPS.Xamarin.UI.Samples/Resources/ResourcesPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
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"
mc:Ignorable="d"
x:Class="DIPS.Xamarin.UI.Samples.Resources.ResourcesPage">
<StackLayout>
<Button Text="Colors"
Command="{Binding NavigateToCommand}"
CommandParameter="Colors" />
</StackLayout>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace DIPS.Xamarin.UI.Samples.Resources
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class ResourcesPage : ContentPage
{
public ResourcesPage()
{
InitializeComponent();
BindingContext = new ResourcesPageViewModel(Application.Current.MainPage.Navigation);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Windows.Input;
using DIPS.Xamarin.UI.Samples.Resources.Colors;
using Xamarin.Forms;

namespace DIPS.Xamarin.UI.Samples.Resources
{
public class ResourcesPageViewModel
{
private readonly INavigation m_navigation;

public ResourcesPageViewModel(INavigation navigation)
{
m_navigation = navigation;
NavigateToCommand = new Command<string>(NavigateTo);
}

public ICommand NavigateToCommand { get; }

private void NavigateTo(string parameter)
{
if (parameter.Equals("Colors"))
m_navigation.PushAsync(new ColorsPage());

}
}
}

0 comments on commit a5177db

Please sign in to comment.