Last active
February 19, 2018 11:52
-
-
Save reniris/d4274fb7d85b3690e8c20c1aef8c0669 to your computer and use it in GitHub Desktop.
Xamarin Theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// テーマ変更 | |
/// </summary> | |
/// <param name="theme">theme</param> | |
/// <exception cref="NotImplementedException"></exception> | |
public void ChangeTheme(ThemeType theme) | |
{ | |
if (MainPage == null) return; | |
MainPage.Parent = null; | |
ResourceDictionary t = null; | |
switch (theme) | |
{ | |
case ThemeType.Dark: | |
t = new DarkTheme(); | |
break; | |
case ThemeType.Light: | |
t = new LightTheme(); | |
break; | |
default: | |
throw new NotImplementedException(); | |
} | |
Application.Current.Resources.MergedDictionaries.Add(t); | |
MainPage.Parent = this; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
x:Class="TaxPon.View.Themes.DarkTheme"> | |
<Color x:Key="BackgroundColor">Black</Color> | |
<Color x:Key="ForegroundColor">#bdc3c7</Color> | |
<Color x:Key="HeaderBackgroundColor">#20202a</Color> | |
<Color x:Key="HeaderForegroundColor">#bdc3c7</Color> | |
<Color x:Key="HeaderLogoColor">#1abc9c</Color> | |
<Color x:Key="ListItemBackgroundColor">#1c1c1c</Color> | |
<Color x:Key="ListItemTitleColor">#2980b9</Color> | |
</ResourceDictionary> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[XamlCompilation(XamlCompilationOptions.Compile)] | |
public partial class DarkTheme : ResourceDictionary | |
{ | |
public DarkTheme () | |
{ | |
InitializeComponent (); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
x:Class="TaxPon.View.Themes.LightTheme"> | |
<Color x:Key="BackgroundColor">#ecf0f1</Color> | |
<Color x:Key="ForegroundColor">#33333c</Color> | |
<Color x:Key="HeaderBackgroundColor">#2c3e50</Color> | |
<Color x:Key="HeaderForegroundColor">#bdc3c7</Color> | |
<Color x:Key="HeaderLogoColor">#1abc9c</Color> | |
<Color x:Key="ListItemBackgroundColor">#bdc3c7</Color> | |
<Color x:Key="ListItemTitleColor">#2980b9</Color> | |
</ResourceDictionary> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[XamlCompilation(XamlCompilationOptions.Compile)] | |
public partial class LightTheme : ResourceDictionary | |
{ | |
public LightTheme () | |
{ | |
InitializeComponent (); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum ThemeType | |
{ | |
Dark, | |
Light, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment