2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.Collections.Generic;
20 using System.Diagnostics.CodeAnalysis;
21 using Tizen.NUI.BaseComponents;
22 using Tizen.NUI.Binding;
24 namespace Tizen.NUI.Components
26 // It is a C# version of res/Tizen.NUI.Components_Tizen.NUI.Theme.Common.xaml
27 internal class DefaultThemeCreator : IThemeCreator
29 public ResourceDictionary CreateThemeResource() => new ResourceDictionary()
31 ["ButtonBackgroundColorNormal"] = new Color(0.88f, 0.88f, 0.88f, 1),
32 ["ButtonBackgroundColorPressed"] = new Color(0.77f, 0.77f, 0.77f, 1),
33 ["ButtonBackgroundColorDisabled"] = new Color(0.88f, 0.88f, 0.88f, 1),
34 ["ButtonTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
35 ["ButtonTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
36 ["ButtonTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
37 ["CheckBoxIconBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
38 ["CheckBoxIconBackgroundImageSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
39 ["CheckBoxIconBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_n.png",
40 ["CheckBoxIconImageResourceUrlPressed"] = "",
41 ["CheckBoxIconImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_s.png",
42 ["CheckBoxIconImageResourceUrlOther"] = "",
43 ["CheckBoxTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
44 ["CheckBoxTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
45 ["CheckBoxTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
46 ["DropDownBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
47 ["DropDownBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_n.png",
48 ["DropDownIconImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_dropdown_button_icon.png",
49 ["DropDownListBackgroundImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_dropdown_list_bg.png",
50 ["DropDownDataItemBackgroundColorPressed"] = new Color(0.05f, 0.63f, 0.9f, 1),
51 ["DropDownDataItemBackgroundColorSelected"] = new Color(0.8f, 0.8f, 0.8f, 1),
52 ["DropDownDataItemBackgroundColorNormal"] = new Color(1, 1, 1, 1),
53 ["PopupBackgroundColor"] = new Color(0.9f, 0.9f, 0.9f, 1),
54 ["PopupImageShadowUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_popup_shadow.png",
55 ["PopupButtonBackgroundColorNormal"] = new Color(1, 1, 1, 1),
56 ["PopupButtonBackgroundColorPressed"] = new Color(1, 1, 1, 0.5f),
57 ["PopupButtonOverlayBackgroundColorNormal"] = new Color(1, 1, 1, 1),
58 ["PopupButtonOverlayBackgroundColorPressed"] = new Color(0, 0, 0, 0.1f),
59 ["PopupButtonOverlayBackgroundColorSelected"] = new Color(1, 1, 1, 1),
60 ["PopupButtonTextColor"] = new Color(0.05f, 0.63f, 0.9f, 1),
61 ["ProgressTrackBackgroundColor"] = new Color(0, 0, 0, 0.1f),
62 ["ProgressBufferBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 0.3f),
63 ["ProgressProgressBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 1),
64 ["RadioButtonIconBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_p.png",
65 ["RadioButtonIconBackgroundImageSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_s.png",
66 ["RadioButtonIconBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_n.png",
67 ["RadioButtonTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
68 ["RadioButtonTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
69 ["RadioButtonTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
70 ["SliderTrackColor"] = new Color(0, 0, 0, 0.1f),
71 ["SliderProgressColor"] = new Color(0.5f, 0.63f, 0.9f, 1),
72 ["SliderThumbImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_n.png",
73 ["SliderThumbBackgroundImageNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_bg_p.png",
74 ["SliderThumbBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_bg_p.png",
75 ["SliderValueIndicatorImage"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_value_indicator.png",
76 ["SwitchTrackImageResourceUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_n.png",
77 ["SwitchTrackImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_s.png",
78 ["SwitchTrackImageResourceUrlDisabled"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_d.png",
79 ["SwitchTrackImageResourceUrlDisabledSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_ds.png",
80 ["SwitchThumbImageResourceUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
81 ["SwitchThumbImageResourceUrlDisabled"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_d.png",
82 ["SwitchThumbImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
83 ["SwitchTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
84 ["SwitchTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
85 ["SwitchTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
86 ["TabBackgroundColor"] = Color.Yellow,
87 ["TabUnderLineBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 1.0f),
88 ["TabTextColorNormal"] = Color.Black,
89 ["TabTextColorSelected"] = new Color(0.05f, 0.63f, 0.9f, 1),
90 ["ToastBackgroundColor"] = new Color(0, 0, 0, 0.8f),
91 ["PaginationIndicatorImageUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_pagination_normal_dot.png",
92 ["PaginationIndicatorImageUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_pagination_focus_dot.png",
93 ["ScrollbarTrackColor"] = new Color(1, 1, 1, 0.15f),
94 ["ScrollbarThumbColor"] = new Color(0.6f, 0.6f, 0.6f, 1.0f),
95 ["RecyclerViewItemBackgroundColorNormal"] = new Color(1, 1, 1, 1),
96 ["RecyclerViewItemBackgroundColorPressed"] = new Color(0.85f, 0.85f, 0.85f, 1),
97 ["RecyclerViewItemBackgroundColorDisabled"] = new Color(0.70f, 0.70f, 0.70f, 1),
98 ["RecyclerViewItemBackgroundColorSelected"] = new Color(0.701f, 0.898f, 0.937f, 1),
99 ["TitleBackgroundColorNormal"] = new Color(0.78f, 0.78f, 0.78f, 1),
102 public Theme Create() => Create(null);
104 [SuppressMessage("Microsoft.Reliability", "CA2000: Dispose objects before losing scope", Justification = "The responsibility to dispose the object is transferred to the theme object.")]
105 public Theme Create(IEnumerable<KeyValuePair<string, string>> changedResources)
107 var theme = new Theme() { Id = "Tizen.NUI.Theme.Common" };
109 theme.SetChangedResources(changedResources);
110 theme.Resources = CreateThemeResource();
111 theme.OnThemeResourcesChanged();
113 theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
115 Size = new Size(100, 45),
116 BackgroundColor = new Selector<Color>()
118 Normal = (Color)theme.Resources["ButtonBackgroundColorNormal"],
119 Pressed = (Color)theme.Resources["ButtonBackgroundColorPressed"],
120 Disabled = (Color)theme.Resources["ButtonBackgroundColorDisabled"],
122 Text = new TextLabelStyle()
125 TextColor = new Selector<Color>()
127 Normal = (Color)theme.Resources["ButtonTextColorNormal"],
128 Pressed = (Color)theme.Resources["ButtonTextColorPressed"],
129 Disabled = (Color)theme.Resources["ButtonTextColorDisabled"],
134 theme.AddStyleWithoutClone("Tizen.NUI.Components.CheckBox", new ButtonStyle()
136 Size = new Size(30, 30),
137 Icon = new ImageViewStyle()
139 Opacity = new Selector<float?>()
145 BackgroundImage = new Selector<string>()
147 Pressed = (string)theme.Resources["CheckBoxIconBackgroundImagePressed"],
148 Selected = (string)theme.Resources["CheckBoxIconBackgroundImageSelected"],
149 Other = (string)theme.Resources["CheckBoxIconBackgroundImageOther"],
151 ResourceUrl = new Selector<string>()
153 Pressed = (string)theme.Resources["CheckBoxIconImageResourceUrlPressed"],
154 Selected = (string)theme.Resources["CheckBoxIconImageResourceUrlSelected"],
155 Other = (string)theme.Resources["CheckBoxIconImageResourceUrlOther"],
158 Text = new TextLabelStyle()
161 TextColor = new Selector<Color>()
163 Normal = (Color)theme.Resources["CheckBoxTextColorNormal"],
164 Pressed = (Color)theme.Resources["CheckBoxTextColorPressed"],
165 Disabled = (Color)theme.Resources["CheckBoxTextColorDisabled"],
170 theme.AddStyleWithoutClone("Tizen.NUI.Components.Popup", new PopupStyle()
172 Size = new Size(500, 280),
173 BackgroundColor = (Color)theme.Resources["PopupBackgroundColor"],
174 ImageShadow = new ImageShadow()
176 Url = (string)theme.Resources["PopupImageShadowUrl"],
177 Border = new Rectangle(24, 24, 24, 24),
178 Extents = new Vector2(48, 48)
180 Title = new TextLabelStyle()
183 Padding = new Extents(20, 20, 20, 20),
185 Buttons = new ButtonStyle()
187 Size = new Size(0, 80),
188 BackgroundColor = new Selector<Color>()
190 Normal = (Color)theme.Resources["PopupButtonBackgroundColorNormal"],
191 Pressed = (Color)theme.Resources["PopupButtonBackgroundColorPressed"],
193 Overlay = new ImageViewStyle()
195 BackgroundColor = new Selector<Color>()
197 Normal = (Color)theme.Resources["PopupButtonOverlayBackgroundColorNormal"],
198 Pressed = (Color)theme.Resources["PopupButtonOverlayBackgroundColorPressed"],
199 Other = (Color)theme.Resources["PopupButtonOverlayBackgroundColorSelected"],
202 Text = new TextLabelStyle()
204 TextColor = (Color)theme.Resources["PopupButtonTextColor"],
209 theme.AddStyleWithoutClone("Tizen.NUI.Components.Progress", new ProgressStyle()
211 Size = new Size(200, 5),
212 Track = new ImageViewStyle()
214 BackgroundColor = (Color)theme.Resources["ProgressTrackBackgroundColor"],
216 Buffer = new ImageViewStyle()
218 BackgroundColor = (Color)theme.Resources["ProgressBufferBackgroundColor"],
220 Progress = new ImageViewStyle()
222 BackgroundColor = (Color)theme.Resources["ProgressProgressBackgroundColor"],
226 theme.AddStyleWithoutClone("Tizen.NUI.Components.RadioButton", new ButtonStyle()
228 Size = new Size(30, 30),
229 Icon = new ImageViewStyle()
231 Opacity = new Selector<float?>()
237 BackgroundImage = new Selector<string>()
239 Pressed = (string)theme.Resources["RadioButtonIconBackgroundImagePressed"],
240 Selected = (string)theme.Resources["RadioButtonIconBackgroundImageSelected"],
241 Other = (string)theme.Resources["RadioButtonIconBackgroundImageOther"],
244 Text = new TextLabelStyle()
247 TextColor = new Selector<Color>()
249 Normal = (Color)theme.Resources["RadioButtonTextColorNormal"],
250 Pressed = (Color)theme.Resources["RadioButtonTextColorPressed"],
251 Disabled = (Color)theme.Resources["RadioButtonTextColorDisabled"],
256 theme.AddStyleWithoutClone("Tizen.NUI.Components.Slider", new SliderStyle()
258 Size = new Size(200, 50),
260 Track = new ImageViewStyle()
262 BackgroundColor = (Color)theme.Resources["SliderTrackColor"],
264 Progress = new ImageViewStyle()
266 BackgroundColor = (Color)theme.Resources["SliderProgressColor"],
268 Thumb = new ImageViewStyle()
270 Size = new Size(50, 50),
271 ResourceUrl = (string)theme.Resources["SliderThumbImageResourceUrl"],
272 BackgroundImage = new Selector<string>()
274 Normal = (string)theme.Resources["SliderThumbBackgroundImageNormal"],
275 Pressed = (string)theme.Resources["SliderThumbBackgroundImagePressed"],
278 ValueIndicatorImage = new ImageViewStyle()
280 Size = new Size(83, 54),
281 ResourceUrl = (string)theme.Resources["SliderValueIndicatorImage"],
285 theme.AddStyleWithoutClone("Tizen.NUI.Components.Switch", new SwitchStyle()
287 Size = new Size(96, 60),
288 Track = new ImageViewStyle()
290 Size = new Size(96, 60),
291 ResourceUrl = new Selector<string>()
293 Normal = (string)theme.Resources["SwitchTrackImageResourceUrlNormal"],
294 Selected = (string)theme.Resources["SwitchTrackImageResourceUrlSelected"],
295 Disabled = (string)theme.Resources["SwitchTrackImageResourceUrlDisabled"],
296 DisabledSelected = (string)theme.Resources["SwitchTrackImageResourceUrlDisabledSelected"],
299 Thumb = new ImageViewStyle()
301 Size = new Size(60, 60),
302 ResourceUrl = new Selector<string>()
304 Normal = (string)theme.Resources["SwitchThumbImageResourceUrlNormal"],
305 Disabled = (string)theme.Resources["SwitchThumbImageResourceUrlDisabled"],
306 Selected = (string)theme.Resources["SwitchThumbImageResourceUrlSelected"],
309 Text = new TextLabelStyle()
312 TextColor = new Selector<Color>()
314 Normal = (Color)theme.Resources["SwitchTextColorNormal"],
315 Pressed = (Color)theme.Resources["SwitchTextColorPressed"],
316 Disabled = (Color)theme.Resources["SwitchTextColorDisabled"],
321 theme.AddStyleWithoutClone("Tizen.NUI.Components.Tab", new TabStyle()
323 Size = new Size(480, 80),
324 BackgroundColor = (Color)theme.Resources["TabBackgroundColor"],
325 UnderLine = new ViewStyle()
327 Size = new Size(0, 6),
328 BackgroundColor = (Color)theme.Resources["TabUnderLineBackgroundColor"],
330 Text = new TextLabelStyle()
333 TextColor = new Selector<Color>()
335 Normal = (Color)theme.Resources["TabTextColorNormal"],
336 Selected = (Color)theme.Resources["TabTextColorSelected"],
341 theme.AddStyleWithoutClone("Tizen.NUI.Components.Toast", new ToastStyle()
343 Size = new Size(480, 80),
344 BackgroundColor = (Color)theme.Resources["ToastBackgroundColor"],
345 Text = new TextLabelStyle()
347 Padding = new Extents(12, 12, 8, 8)
351 theme.AddStyleWithoutClone("Tizen.NUI.Components.Loading", new LoadingStyle()
353 LoadingSize = new Size(100, 100),
356 theme.AddStyleWithoutClone("Tizen.NUI.Components.Pagination", new PaginationStyle()
358 IndicatorImageUrl = new Selector<string>()
360 Normal = (string)theme.Resources["PaginationIndicatorImageUrlNormal"],
361 Selected = (string)theme.Resources["PaginationIndicatorImageUrlSelected"],
365 theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
369 TrackColor = (Color)theme.Resources["ScrollbarTrackColor"],
370 ThumbColor = (Color)theme.Resources["ScrollbarThumbColor"],
374 theme.AddStyleWithoutClone("Tizen.NUI.Components.RecyclerViewItem", new RecyclerViewItemStyle()
376 BackgroundColor = new Selector<Color>()
378 Normal = (Color)theme.Resources["RecyclerViewItemBackgroundColorNormal"],
379 Pressed = (Color)theme.Resources["RecyclerViewItemBackgroundColorPressed"],
380 Disabled = (Color)theme.Resources["RecyclerViewItemBackgroundColorDisabled"],
381 Selected = (Color)theme.Resources["RecyclerViewItemBackgroundColorSelected"],
385 theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultLinearItem", new DefaultLinearItemStyle()
388 Padding = new Extents(10, 10, 20, 20),
389 BackgroundColor = new Selector<Color>()
391 Normal = (Color)theme.Resources["RecyclerViewItemBackgroundColorNormal"],
392 Pressed = (Color)theme.Resources["RecyclerViewItemBackgroundColorPressed"],
393 Disabled = (Color)theme.Resources["RecyclerViewItemBackgroundColorDisabled"],
394 Selected = (Color)theme.Resources["RecyclerViewItemBackgroundColorSelected"],
396 Label = new TextLabelStyle()
401 SubLabel = new TextLabelStyle()
406 Icon = new ViewStyle()
408 Margin = new Extents(0, 10, 0, 0)
410 Extra = new ViewStyle()
412 Margin = new Extents(10, 0, 0, 0)
414 Seperator = new ViewStyle()
416 Margin = new Extents(5, 5, 0, 0),
417 BackgroundColor = new Color(0.78f, 0.78f, 0.78f, 1),
420 theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultGridItem", new DefaultGridItemStyle()
422 Padding = new Extents(5, 5, 5, 5),
423 Caption = new TextLabelStyle()
428 Badge = new ViewStyle()
430 Margin = new Extents(5, 5, 5, 5),
434 theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultTitleItem", new DefaultTitleItemStyle()
437 Padding = new Extents(10, 10, 5, 5),
438 BackgroundColor = new Selector<Color>()
440 Normal = (Color)theme.Resources["TitleBackgroundColorNormal"],
442 Label = new TextLabelStyle()
447 Icon = new ViewStyle()
449 Margin = new Extents(10, 0, 0, 0)
451 Seperator = new ViewStyle()
453 Margin = new Extents(0, 0, 0, 0),
454 BackgroundColor = new Color(0.85f, 0.85f, 0.85f, 1),