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.
17 #if !PROFILE_WEARABLE && !PROFILE_MOBILE
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 private DefaultThemeCreator() { }
31 public static IThemeCreator Instance { get; set; } = new DefaultThemeCreator();
33 public ResourceDictionary CreateThemeResource() => new ResourceDictionary()
35 ["ButtonBackgroundColorNormal"] = new Color(0.039f, 0.055f, 0.29f, 1),
36 ["ButtonBackgroundColorFocused"] = new Color(0, 0.2f, 0.545f, 1),
37 ["ButtonBackgroundColorPressed"] = new Color(0.106f, 0.412f, 0.792f, 1),
38 ["ButtonBackgroundColorDisabled"] = new Color(0.765f, 0.792f, 0.824f, 1),
39 ["ButtonTextColorNormal"] = Color.White,
40 ["ButtonTextColorPressed"] = Color.White,
41 ["ButtonTextColorDisabled"] = Color.White,
42 ["CheckBoxIconBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
43 ["CheckBoxIconBackgroundImageSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
44 ["CheckBoxIconBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_n.png",
45 ["CheckBoxIconImageResourceUrlPressed"] = "",
46 ["CheckBoxIconImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_s.png",
47 ["CheckBoxIconImageResourceUrlOther"] = "",
48 ["CheckBoxTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
49 ["CheckBoxTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
50 ["CheckBoxTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
51 ["DropDownBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_p.png",
52 ["DropDownBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_checkbox_bg_n.png",
53 ["DropDownIconImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_dropdown_button_icon.png",
54 ["DropDownListBackgroundImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_dropdown_list_bg.png",
55 ["DropDownDataItemBackgroundColorPressed"] = new Color(0.05f, 0.63f, 0.9f, 1),
56 ["DropDownDataItemBackgroundColorSelected"] = new Color(0.8f, 0.8f, 0.8f, 1),
57 ["DropDownDataItemBackgroundColorNormal"] = new Color(1, 1, 1, 1),
58 ["PopupBackgroundColor"] = new Color(0.9f, 0.9f, 0.9f, 1),
59 ["PopupImageShadowUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_popup_shadow.png",
60 ["PopupButtonBackgroundColorNormal"] = new Color(1, 1, 1, 1),
61 ["PopupButtonBackgroundColorPressed"] = new Color(1, 1, 1, 0.5f),
62 ["PopupButtonOverlayBackgroundColorNormal"] = new Color(1, 1, 1, 1),
63 ["PopupButtonOverlayBackgroundColorPressed"] = new Color(0, 0, 0, 0.1f),
64 ["PopupButtonOverlayBackgroundColorSelected"] = new Color(1, 1, 1, 1),
65 ["PopupButtonTextColor"] = new Color(0.05f, 0.63f, 0.9f, 1),
66 ["ProgressTrackBackgroundColor"] = new Color(0, 0, 0, 0.1f),
67 ["ProgressBufferBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 0.3f),
68 ["ProgressProgressBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 1),
69 ["RadioButtonIconBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_p.png",
70 ["RadioButtonIconBackgroundImageSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_s.png",
71 ["RadioButtonIconBackgroundImageOther"] = FrameworkInformation.ResourcePath + "nui_component_default_radiobutton_n.png",
72 ["RadioButtonTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
73 ["RadioButtonTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
74 ["RadioButtonTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
75 ["SliderTrackColor"] = new Color(0, 0, 0, 0.1f),
76 ["SliderProgressColor"] = new Color(0.5f, 0.63f, 0.9f, 1),
77 ["SliderThumbImageResourceUrl"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_n.png",
78 ["SliderThumbBackgroundImageNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_bg_p.png",
79 ["SliderThumbBackgroundImagePressed"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_thumb_bg_p.png",
80 ["SliderValueIndicatorImage"] = FrameworkInformation.ResourcePath + "nui_component_default_slider_value_indicator.png",
81 ["SwitchTrackImageResourceUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_n.png",
82 ["SwitchTrackImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_s.png",
83 ["SwitchTrackImageResourceUrlDisabled"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_d.png",
84 ["SwitchTrackImageResourceUrlDisabledSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_track_ds.png",
85 ["SwitchThumbImageResourceUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
86 ["SwitchThumbImageResourceUrlDisabled"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_d.png",
87 ["SwitchThumbImageResourceUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_switch_thumb_n.png",
88 ["SwitchTextColorNormal"] = new Color(0.22f, 0.22f, 0.22f, 1),
89 ["SwitchTextColorPressed"] = new Color(0.11f, 0.11f, 0.11f, 1),
90 ["SwitchTextColorDisabled"] = new Color(0.66f, 0.66f, 0.66f, 1),
91 ["TabBackgroundColor"] = Color.Yellow,
92 ["TabUnderLineBackgroundColor"] = new Color(0.05f, 0.63f, 0.9f, 1.0f),
93 ["TabTextColorNormal"] = Color.Black,
94 ["TabTextColorSelected"] = new Color(0.05f, 0.63f, 0.9f, 1),
95 ["ToastBackgroundColor"] = new Color(0, 0, 0, 0.8f),
96 ["PaginationIndicatorImageUrlNormal"] = FrameworkInformation.ResourcePath + "nui_component_default_pagination_normal_dot.png",
97 ["PaginationIndicatorImageUrlSelected"] = FrameworkInformation.ResourcePath + "nui_component_default_pagination_focus_dot.png",
98 ["ScrollbarTrackColor"] = new Color(1, 1, 1, 0.15f),
99 ["ScrollbarThumbColor"] = new Color(0.6f, 0.6f, 0.6f, 1.0f),
100 ["RecyclerViewItemBackgroundColorNormal"] = new Color(1, 1, 1, 1),
101 ["RecyclerViewItemBackgroundColorPressed"] = new Color(0.85f, 0.85f, 0.85f, 1),
102 ["RecyclerViewItemBackgroundColorDisabled"] = new Color(0.70f, 0.70f, 0.70f, 1),
103 ["RecyclerViewItemBackgroundColorSelected"] = new Color(0.701f, 0.898f, 0.937f, 1),
104 ["TitleBackgroundColorNormal"] = new Color(0.78f, 0.78f, 0.78f, 1),
107 public Theme Create() => Create(null);
109 [SuppressMessage("Microsoft.Reliability", "CA2000: Dispose objects before losing scope", Justification = "The responsibility to dispose the object is transferred to the theme object.")]
110 public Theme Create(IEnumerable<KeyValuePair<string, string>> changedResources)
112 var theme = new Theme() { Id = "Tizen.NUI.Theme.Common" };
114 theme.SetChangedResources(changedResources);
115 theme.Resources = CreateThemeResource();
116 theme.OnThemeResourcesChanged();
118 theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
120 Size = new Size(339, 96),
122 BackgroundColor = new Selector<Color>()
124 Normal = (Color)theme.Resources["ButtonBackgroundColorNormal"],
125 Pressed = (Color)theme.Resources["ButtonBackgroundColorPressed"],
126 Disabled = (Color)theme.Resources["ButtonBackgroundColorDisabled"],
128 Text = new TextLabelStyle()
131 TextColor = new Selector<Color>()
133 Normal = (Color)theme.Resources["ButtonTextColorNormal"],
134 Pressed = (Color)theme.Resources["ButtonTextColorPressed"],
135 Disabled = (Color)theme.Resources["ButtonTextColorDisabled"],
140 theme.AddStyleWithoutClone("Tizen.NUI.Components.CheckBox", new ButtonStyle()
142 Size = new Size(30, 30),
143 Icon = new ImageViewStyle()
145 Opacity = new Selector<float?>()
151 BackgroundImage = new Selector<string>()
153 Pressed = (string)theme.Resources["CheckBoxIconBackgroundImagePressed"],
154 Selected = (string)theme.Resources["CheckBoxIconBackgroundImageSelected"],
155 Other = (string)theme.Resources["CheckBoxIconBackgroundImageOther"],
157 ResourceUrl = new Selector<string>()
159 Pressed = (string)theme.Resources["CheckBoxIconImageResourceUrlPressed"],
160 Selected = (string)theme.Resources["CheckBoxIconImageResourceUrlSelected"],
161 Other = (string)theme.Resources["CheckBoxIconImageResourceUrlOther"],
164 Text = new TextLabelStyle()
167 TextColor = new Selector<Color>()
169 Normal = (Color)theme.Resources["CheckBoxTextColorNormal"],
170 Pressed = (Color)theme.Resources["CheckBoxTextColorPressed"],
171 Disabled = (Color)theme.Resources["CheckBoxTextColorDisabled"],
176 theme.AddStyleWithoutClone("Tizen.NUI.Components.Popup", new PopupStyle()
178 Size = new Size(500, 280),
179 BackgroundColor = (Color)theme.Resources["PopupBackgroundColor"],
180 ImageShadow = new ImageShadow()
182 Url = (string)theme.Resources["PopupImageShadowUrl"],
183 Border = new Rectangle(24, 24, 24, 24),
184 Extents = new Vector2(48, 48)
186 Title = new TextLabelStyle()
189 Padding = new Extents(20, 20, 20, 20),
191 Buttons = new ButtonStyle()
193 Size = new Size(0, 80),
194 BackgroundColor = new Selector<Color>()
196 Normal = (Color)theme.Resources["PopupButtonBackgroundColorNormal"],
197 Pressed = (Color)theme.Resources["PopupButtonBackgroundColorPressed"],
199 Overlay = new ImageViewStyle()
201 BackgroundColor = new Selector<Color>()
203 Normal = (Color)theme.Resources["PopupButtonOverlayBackgroundColorNormal"],
204 Pressed = (Color)theme.Resources["PopupButtonOverlayBackgroundColorPressed"],
205 Other = (Color)theme.Resources["PopupButtonOverlayBackgroundColorSelected"],
208 Text = new TextLabelStyle()
210 TextColor = (Color)theme.Resources["PopupButtonTextColor"],
215 theme.AddStyleWithoutClone("Tizen.NUI.Components.Progress", new ProgressStyle()
217 Size = new Size(200, 5),
218 Track = new ImageViewStyle()
220 BackgroundColor = (Color)theme.Resources["ProgressTrackBackgroundColor"],
222 Buffer = new ImageViewStyle()
224 BackgroundColor = (Color)theme.Resources["ProgressBufferBackgroundColor"],
226 Progress = new ImageViewStyle()
228 BackgroundColor = (Color)theme.Resources["ProgressProgressBackgroundColor"],
232 theme.AddStyleWithoutClone("Tizen.NUI.Components.RadioButton", new ButtonStyle()
234 Size = new Size(30, 30),
235 Icon = new ImageViewStyle()
237 Opacity = new Selector<float?>()
243 BackgroundImage = new Selector<string>()
245 Pressed = (string)theme.Resources["RadioButtonIconBackgroundImagePressed"],
246 Selected = (string)theme.Resources["RadioButtonIconBackgroundImageSelected"],
247 Other = (string)theme.Resources["RadioButtonIconBackgroundImageOther"],
250 Text = new TextLabelStyle()
253 TextColor = new Selector<Color>()
255 Normal = (Color)theme.Resources["RadioButtonTextColorNormal"],
256 Pressed = (Color)theme.Resources["RadioButtonTextColorPressed"],
257 Disabled = (Color)theme.Resources["RadioButtonTextColorDisabled"],
262 theme.AddStyleWithoutClone("Tizen.NUI.Components.Slider", new SliderStyle()
264 Size = new Size(200, 50),
266 Track = new ImageViewStyle()
268 BackgroundColor = (Color)theme.Resources["SliderTrackColor"],
270 Progress = new ImageViewStyle()
272 BackgroundColor = (Color)theme.Resources["SliderProgressColor"],
274 Thumb = new ImageViewStyle()
276 Size = new Size(50, 50),
277 ResourceUrl = (string)theme.Resources["SliderThumbImageResourceUrl"],
278 BackgroundImage = new Selector<string>()
280 Normal = (string)theme.Resources["SliderThumbBackgroundImageNormal"],
281 Pressed = (string)theme.Resources["SliderThumbBackgroundImagePressed"],
284 ValueIndicatorImage = new ImageViewStyle()
286 Size = new Size(83, 54),
287 ResourceUrl = (string)theme.Resources["SliderValueIndicatorImage"],
291 theme.AddStyleWithoutClone("Tizen.NUI.Components.Switch", new SwitchStyle()
293 Size = new Size(96, 60),
294 Track = new ImageViewStyle()
296 Size = new Size(96, 60),
297 ResourceUrl = new Selector<string>()
299 Normal = (string)theme.Resources["SwitchTrackImageResourceUrlNormal"],
300 Selected = (string)theme.Resources["SwitchTrackImageResourceUrlSelected"],
301 Disabled = (string)theme.Resources["SwitchTrackImageResourceUrlDisabled"],
302 DisabledSelected = (string)theme.Resources["SwitchTrackImageResourceUrlDisabledSelected"],
305 Thumb = new ImageViewStyle()
307 Size = new Size(60, 60),
308 ResourceUrl = new Selector<string>()
310 Normal = (string)theme.Resources["SwitchThumbImageResourceUrlNormal"],
311 Disabled = (string)theme.Resources["SwitchThumbImageResourceUrlDisabled"],
312 Selected = (string)theme.Resources["SwitchThumbImageResourceUrlSelected"],
315 Text = new TextLabelStyle()
318 TextColor = new Selector<Color>()
320 Normal = (Color)theme.Resources["SwitchTextColorNormal"],
321 Pressed = (Color)theme.Resources["SwitchTextColorPressed"],
322 Disabled = (Color)theme.Resources["SwitchTextColorDisabled"],
327 theme.AddStyleWithoutClone("Tizen.NUI.Components.Tab", new TabStyle()
329 Size = new Size(480, 80),
330 BackgroundColor = (Color)theme.Resources["TabBackgroundColor"],
331 UnderLine = new ViewStyle()
333 Size = new Size(0, 6),
334 BackgroundColor = (Color)theme.Resources["TabUnderLineBackgroundColor"],
336 Text = new TextLabelStyle()
339 TextColor = new Selector<Color>()
341 Normal = (Color)theme.Resources["TabTextColorNormal"],
342 Selected = (Color)theme.Resources["TabTextColorSelected"],
347 theme.AddStyleWithoutClone("Tizen.NUI.Components.Toast", new ToastStyle()
349 Size = new Size(480, 80),
350 BackgroundColor = (Color)theme.Resources["ToastBackgroundColor"],
351 Text = new TextLabelStyle()
353 Padding = new Extents(12, 12, 8, 8)
357 theme.AddStyleWithoutClone("Tizen.NUI.Components.Loading", new LoadingStyle()
359 LoadingSize = new Size(100, 100),
362 theme.AddStyleWithoutClone("Tizen.NUI.Components.Pagination", new PaginationStyle()
364 IndicatorImageUrl = new Selector<string>()
366 Normal = (string)theme.Resources["PaginationIndicatorImageUrlNormal"],
367 Selected = (string)theme.Resources["PaginationIndicatorImageUrlSelected"],
371 theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
375 TrackColor = (Color)theme.Resources["ScrollbarTrackColor"],
376 ThumbColor = (Color)theme.Resources["ScrollbarThumbColor"],
380 theme.AddStyleWithoutClone("Tizen.NUI.Components.RecyclerViewItem", new RecyclerViewItemStyle()
382 BackgroundColor = new Selector<Color>()
384 Normal = (Color)theme.Resources["RecyclerViewItemBackgroundColorNormal"],
385 Pressed = (Color)theme.Resources["RecyclerViewItemBackgroundColorPressed"],
386 Disabled = (Color)theme.Resources["RecyclerViewItemBackgroundColorDisabled"],
387 Selected = (Color)theme.Resources["RecyclerViewItemBackgroundColorSelected"],
391 theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultLinearItem", new DefaultLinearItemStyle()
394 Padding = new Extents(20, 20, 5, 5),
395 BackgroundColor = new Selector<Color>()
397 Normal = (Color)theme.Resources["RecyclerViewItemBackgroundColorNormal"],
398 Pressed = (Color)theme.Resources["RecyclerViewItemBackgroundColorPressed"],
399 Disabled = (Color)theme.Resources["RecyclerViewItemBackgroundColorDisabled"],
400 Selected = (Color)theme.Resources["RecyclerViewItemBackgroundColorSelected"],
402 Label = new TextLabelStyle()
407 SubLabel = new TextLabelStyle()
412 Icon = new ViewStyle()
414 Margin = new Extents(0, 20, 0, 0)
416 Extra = new ViewStyle()
418 Margin = new Extents(20, 0, 0, 0)
420 Seperator = new ViewStyle()
422 Margin = new Extents(5, 5, 0, 0),
423 BackgroundColor = new Color(0.78f, 0.78f, 0.78f, 1),
426 theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultGridItem", new DefaultGridItemStyle()
428 Padding = new Extents(5, 5, 5, 5),
429 Caption = new TextLabelStyle()
434 Badge = new ViewStyle()
436 Margin = new Extents(5, 5, 5, 5),
440 theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultTitleItem", new DefaultTitleItemStyle()
443 Padding = new Extents(10, 10, 5, 5),
444 BackgroundColor = new Selector<Color>()
446 Normal = (Color)theme.Resources["TitleBackgroundColorNormal"],
448 Label = new TextLabelStyle()
453 Icon = new ViewStyle()
455 Margin = new Extents(10, 0, 0, 0)
457 Seperator = new ViewStyle()
459 Margin = new Extents(0, 0, 0, 0),
460 BackgroundColor = new Color(0.85f, 0.85f, 0.85f, 1),