This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathResourcesProvider.cs
73 lines (65 loc) · 1.99 KB
/
ResourcesProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using Xamarin.Forms.Internals;
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);
}
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;
}
}
}