diff options
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/ResourcesProvider.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Tizen/ResourcesProvider.cs | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/ResourcesProvider.cs b/Xamarin.Forms.Platform.Tizen/ResourcesProvider.cs new file mode 100644 index 00000000..15e7485e --- /dev/null +++ b/Xamarin.Forms.Platform.Tizen/ResourcesProvider.cs @@ -0,0 +1,72 @@ +namespace Xamarin.Forms.Platform.Tizen +{ + internal class ResourcesProvider : ISystemResourcesProvider + { + ResourceDictionary _dictionary; + + public IResourceDictionary GetSystemResources() + { + _dictionary = new ResourceDictionary(); + + UpdateStyles(); + + return _dictionary; + } + + void UpdateStyles() + { + _dictionary[Device.Styles.BodyStyleKey] = GetStyleByKey(Device.Styles.BodyStyleKey); + _dictionary[Device.Styles.TitleStyleKey] = GetStyleByKey(Device.Styles.TitleStyleKey); + _dictionary[Device.Styles.SubtitleStyleKey] = GetStyleByKey(Device.Styles.SubtitleStyleKey); + _dictionary[Device.Styles.CaptionStyleKey] = GetStyleByKey(Device.Styles.CaptionStyleKey); + _dictionary[Device.Styles.ListItemTextStyleKey] = GetStyleByKey(Device.Styles.ListItemTextStyleKey); + _dictionary[Device.Styles.ListItemDetailTextStyleKey] = GetStyleByKey(Device.Styles.ListItemDetailTextStyleKey); + } + + //TODO: need Tizen API to get system values + Style GetStyleByKey(string key) + { + Style style = null; + if (key == Device.Styles.TitleStyleKey) + { + style = GetStyle(50, Color.FromRgb(250, 250, 250)); + } + else if (key == Device.Styles.SubtitleStyleKey) + { + style = GetStyle(24, Color.FromRgb(250, 250, 250)); + } + else if (key == Device.Styles.CaptionStyleKey) + { + style = GetStyle(24, Color.FromRgb(115, 115, 115)); + } + else if (key == Device.Styles.ListItemTextStyleKey) + { + style = GetStyle(40, Color.FromRgb(0, 0, 0)); + } + else if (key == Device.Styles.ListItemDetailTextStyleKey) + { + style = GetStyle(24, Color.FromRgb(0, 0, 0)); + } + else + { + style = GetStyle(); + } + + return style; + } + + Style GetStyle(int? fontSize = null, Color? textColor = null) + { + Style style = new Style(typeof(Label)); + if (fontSize.HasValue) + { + style.Setters.Add(new Setter { Property = Label.FontSizeProperty, Value = fontSize }); + } + if (textColor.HasValue) + { + style.Setters.Add(new Setter { Property = Label.TextColorProperty, Value = textColor }); + } + return style; + } + } +} |