[NUI] Introduce CollectionView and related classes. (#2525)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Theme / DefaultTheme.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 #if !PROFILE_WEARABLE && !PROFILE_MOBILE
18
19 using System.Collections.Generic;
20 using System.Diagnostics.CodeAnalysis;
21 using Tizen.NUI.BaseComponents;
22 using Tizen.NUI.Binding;
23
24 namespace Tizen.NUI.Components
25 {
26     // It is a C# version of res/Tizen.NUI.Components_Tizen.NUI.Theme.Common.xaml
27     internal class DefaultThemeCreator : IThemeCreator
28     {
29         private DefaultThemeCreator() { }
30
31         public static IThemeCreator Instance { get; set; } = new DefaultThemeCreator();
32
33         public ResourceDictionary CreateThemeResource() => new ResourceDictionary()
34         {
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),
105         };
106
107         public Theme Create() => Create(null);
108
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)
111         {
112             var theme = new Theme() { Id = "Tizen.NUI.Theme.Common" };
113
114             theme.SetChangedResources(changedResources);
115             theme.Resources = CreateThemeResource();
116             theme.OnThemeResourcesChanged();
117
118             theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
119             {
120                 Size = new Size(339, 96),
121                 CornerRadius = 28,
122                 BackgroundColor = new Selector<Color>()
123                 {
124                     Normal = (Color)theme.Resources["ButtonBackgroundColorNormal"],
125                     Pressed = (Color)theme.Resources["ButtonBackgroundColorPressed"],
126                     Disabled = (Color)theme.Resources["ButtonBackgroundColorDisabled"],
127                 },
128                 Text = new TextLabelStyle()
129                 {
130                     PixelSize = 32,
131                     TextColor = new Selector<Color>()
132                     {
133                         Normal = (Color)theme.Resources["ButtonTextColorNormal"],
134                         Pressed = (Color)theme.Resources["ButtonTextColorPressed"],
135                         Disabled = (Color)theme.Resources["ButtonTextColorDisabled"],
136                     }
137                 }
138             });
139
140             theme.AddStyleWithoutClone("Tizen.NUI.Components.CheckBox", new ButtonStyle()
141             {
142                 Size = new Size(30, 30),
143                 Icon = new ImageViewStyle()
144                 {
145                     Opacity = new Selector<float?>()
146                     {
147                         Normal = 1.0f,
148                         Disabled = 0.4f,
149                         Selected = 1.0f,
150                     },
151                     BackgroundImage = new Selector<string>()
152                     {
153                         Pressed = (string)theme.Resources["CheckBoxIconBackgroundImagePressed"],
154                         Selected = (string)theme.Resources["CheckBoxIconBackgroundImageSelected"],
155                         Other = (string)theme.Resources["CheckBoxIconBackgroundImageOther"],
156                     },
157                     ResourceUrl = new Selector<string>()
158                     {
159                         Pressed = (string)theme.Resources["CheckBoxIconImageResourceUrlPressed"],
160                         Selected = (string)theme.Resources["CheckBoxIconImageResourceUrlSelected"],
161                         Other = (string)theme.Resources["CheckBoxIconImageResourceUrlOther"],
162                     },
163                 },
164                 Text = new TextLabelStyle()
165                 {
166                     PointSize = 12,
167                     TextColor = new Selector<Color>()
168                     {
169                         Normal = (Color)theme.Resources["CheckBoxTextColorNormal"],
170                         Pressed = (Color)theme.Resources["CheckBoxTextColorPressed"],
171                         Disabled = (Color)theme.Resources["CheckBoxTextColorDisabled"],
172                     }
173                 }
174             });
175
176             theme.AddStyleWithoutClone("Tizen.NUI.Components.Popup", new PopupStyle()
177             {
178                 Size = new Size(500, 280),
179                 BackgroundColor = (Color)theme.Resources["PopupBackgroundColor"],
180                 ImageShadow = new ImageShadow()
181                 {
182                     Url = (string)theme.Resources["PopupImageShadowUrl"],
183                     Border = new Rectangle(24, 24, 24, 24),
184                     Extents = new Vector2(48, 48)
185                 },
186                 Title = new TextLabelStyle()
187                 {
188                     PointSize = 16,
189                     Padding = new Extents(20, 20, 20, 20),
190                 },
191                 Buttons = new ButtonStyle()
192                 {
193                     Size = new Size(0, 80),
194                     BackgroundColor = new Selector<Color>()
195                     {
196                         Normal = (Color)theme.Resources["PopupButtonBackgroundColorNormal"],
197                         Pressed = (Color)theme.Resources["PopupButtonBackgroundColorPressed"],
198                     },
199                     Overlay = new ImageViewStyle()
200                     {
201                         BackgroundColor = new Selector<Color>()
202                         {
203                             Normal = (Color)theme.Resources["PopupButtonOverlayBackgroundColorNormal"],
204                             Pressed = (Color)theme.Resources["PopupButtonOverlayBackgroundColorPressed"],
205                             Other = (Color)theme.Resources["PopupButtonOverlayBackgroundColorSelected"],
206                         },
207                     },
208                     Text = new TextLabelStyle()
209                     {
210                         TextColor = (Color)theme.Resources["PopupButtonTextColor"],
211                     }
212                 }
213             });
214
215             theme.AddStyleWithoutClone("Tizen.NUI.Components.Progress", new ProgressStyle()
216             {
217                 Size = new Size(200, 5),
218                 Track = new ImageViewStyle()
219                 {
220                     BackgroundColor = (Color)theme.Resources["ProgressTrackBackgroundColor"],
221                 },
222                 Buffer = new ImageViewStyle()
223                 {
224                     BackgroundColor = (Color)theme.Resources["ProgressBufferBackgroundColor"],
225                 },
226                 Progress = new ImageViewStyle()
227                 {
228                     BackgroundColor = (Color)theme.Resources["ProgressProgressBackgroundColor"],
229                 },
230             });
231
232             theme.AddStyleWithoutClone("Tizen.NUI.Components.RadioButton", new ButtonStyle()
233             {
234                 Size = new Size(30, 30),
235                 Icon = new ImageViewStyle()
236                 {
237                     Opacity = new Selector<float?>()
238                     {
239                         Normal = 1.0f,
240                         Disabled = 0.4f,
241                         Selected = 1.0f,
242                     },
243                     BackgroundImage = new Selector<string>()
244                     {
245                         Pressed = (string)theme.Resources["RadioButtonIconBackgroundImagePressed"],
246                         Selected = (string)theme.Resources["RadioButtonIconBackgroundImageSelected"],
247                         Other = (string)theme.Resources["RadioButtonIconBackgroundImageOther"],
248                     }
249                 },
250                 Text = new TextLabelStyle()
251                 {
252                     PointSize = 12,
253                     TextColor = new Selector<Color>()
254                     {
255                         Normal = (Color)theme.Resources["RadioButtonTextColorNormal"],
256                         Pressed = (Color)theme.Resources["RadioButtonTextColorPressed"],
257                         Disabled = (Color)theme.Resources["RadioButtonTextColorDisabled"],
258                     }
259                 }
260             });
261
262             theme.AddStyleWithoutClone("Tizen.NUI.Components.Slider", new SliderStyle()
263             {
264                 Size = new Size(200, 50),
265                 TrackThickness = 5,
266                 Track = new ImageViewStyle()
267                 {
268                     BackgroundColor = (Color)theme.Resources["SliderTrackColor"],
269                 },
270                 Progress = new ImageViewStyle()
271                 {
272                     BackgroundColor = (Color)theme.Resources["SliderProgressColor"],
273                 },
274                 Thumb = new ImageViewStyle()
275                 {
276                     Size = new Size(50, 50),
277                     ResourceUrl = (string)theme.Resources["SliderThumbImageResourceUrl"],
278                     BackgroundImage = new Selector<string>()
279                     {
280                         Normal = (string)theme.Resources["SliderThumbBackgroundImageNormal"],
281                         Pressed = (string)theme.Resources["SliderThumbBackgroundImagePressed"],
282                     }
283                 },
284                 ValueIndicatorImage = new ImageViewStyle()
285                 {
286                     Size = new Size(83, 54),
287                     ResourceUrl = (string)theme.Resources["SliderValueIndicatorImage"],
288                 },
289             });
290
291             theme.AddStyleWithoutClone("Tizen.NUI.Components.Switch", new SwitchStyle()
292             {
293                 Size = new Size(96, 60),
294                 Track = new ImageViewStyle()
295                 {
296                     Size = new Size(96, 60),
297                     ResourceUrl = new Selector<string>()
298                     {
299                         Normal = (string)theme.Resources["SwitchTrackImageResourceUrlNormal"],
300                         Selected = (string)theme.Resources["SwitchTrackImageResourceUrlSelected"],
301                         Disabled = (string)theme.Resources["SwitchTrackImageResourceUrlDisabled"],
302                         DisabledSelected = (string)theme.Resources["SwitchTrackImageResourceUrlDisabledSelected"],
303                     }
304                 },
305                 Thumb = new ImageViewStyle()
306                 {
307                     Size = new Size(60, 60),
308                     ResourceUrl = new Selector<string>()
309                     {
310                         Normal = (string)theme.Resources["SwitchThumbImageResourceUrlNormal"],
311                         Disabled = (string)theme.Resources["SwitchThumbImageResourceUrlDisabled"],
312                         Selected = (string)theme.Resources["SwitchThumbImageResourceUrlSelected"],
313                     }
314                 },
315                 Text = new TextLabelStyle()
316                 {
317                     PointSize = 12,
318                     TextColor = new Selector<Color>()
319                     {
320                         Normal = (Color)theme.Resources["SwitchTextColorNormal"],
321                         Pressed = (Color)theme.Resources["SwitchTextColorPressed"],
322                         Disabled = (Color)theme.Resources["SwitchTextColorDisabled"],
323                     }
324                 }
325             });
326
327             theme.AddStyleWithoutClone("Tizen.NUI.Components.Tab", new TabStyle()
328             {
329                 Size = new Size(480, 80),
330                 BackgroundColor = (Color)theme.Resources["TabBackgroundColor"],
331                 UnderLine = new ViewStyle()
332                 {
333                     Size = new Size(0, 6),
334                     BackgroundColor = (Color)theme.Resources["TabUnderLineBackgroundColor"],
335                 },
336                 Text = new TextLabelStyle()
337                 {
338                     PointSize = 16,
339                     TextColor = new Selector<Color>()
340                     {
341                         Normal = (Color)theme.Resources["TabTextColorNormal"],
342                         Selected = (Color)theme.Resources["TabTextColorSelected"],
343                     }
344                 }
345             });
346
347             theme.AddStyleWithoutClone("Tizen.NUI.Components.Toast", new ToastStyle()
348             {
349                 Size = new Size(480, 80),
350                 BackgroundColor = (Color)theme.Resources["ToastBackgroundColor"],
351                 Text = new TextLabelStyle()
352                 {
353                     Padding = new Extents(12, 12, 8, 8)
354                 }
355             });
356
357             theme.AddStyleWithoutClone("Tizen.NUI.Components.Loading", new LoadingStyle()
358             {
359                 LoadingSize = new Size(100, 100),
360             });
361
362             theme.AddStyleWithoutClone("Tizen.NUI.Components.Pagination", new PaginationStyle()
363             {
364                 IndicatorImageUrl = new Selector<string>()
365                 {
366                     Normal = (string)theme.Resources["PaginationIndicatorImageUrlNormal"],
367                     Selected = (string)theme.Resources["PaginationIndicatorImageUrlSelected"],
368                 }
369             });
370
371             theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
372             {
373                 TrackThickness = 6,
374                 ThumbThickness = 6,
375                 TrackColor = (Color)theme.Resources["ScrollbarTrackColor"],
376                 ThumbColor = (Color)theme.Resources["ScrollbarThumbColor"],
377                 TrackPadding = 4
378             });
379
380             theme.AddStyleWithoutClone("Tizen.NUI.Components.RecyclerViewItem", new RecyclerViewItemStyle()
381             {
382                 BackgroundColor = new Selector<Color>()
383                 {
384                     Normal = (Color)theme.Resources["RecyclerViewItemBackgroundColorNormal"],
385                     Pressed = (Color)theme.Resources["RecyclerViewItemBackgroundColorPressed"],
386                     Disabled = (Color)theme.Resources["RecyclerViewItemBackgroundColorDisabled"],
387                     Selected = (Color)theme.Resources["RecyclerViewItemBackgroundColorSelected"],
388                 },
389             });
390             
391             theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultLinearItem", new DefaultLinearItemStyle()
392             {
393                 SizeHeight = 130,
394                 Padding = new Extents(20, 20, 5, 5),
395                 BackgroundColor = new Selector<Color>()
396                 {
397                     Normal = (Color)theme.Resources["RecyclerViewItemBackgroundColorNormal"],
398                     Pressed = (Color)theme.Resources["RecyclerViewItemBackgroundColorPressed"],
399                     Disabled = (Color)theme.Resources["RecyclerViewItemBackgroundColorDisabled"],
400                     Selected = (Color)theme.Resources["RecyclerViewItemBackgroundColorSelected"],
401                 },
402                 Label = new TextLabelStyle()
403                 {
404                     PointSize = 10,
405                     Ellipsis = true,
406                 },
407                 SubLabel = new TextLabelStyle()
408                 {
409                     PointSize = 6,
410                     Ellipsis = true,
411                 },
412                 Icon = new ViewStyle()
413                 {
414                     Margin = new Extents(0, 20, 0, 0)
415                 },
416                 Extra = new ViewStyle()
417                 {
418                     Margin = new Extents(20, 0, 0, 0)
419                 },
420                 Seperator = new ViewStyle()
421                 {
422                     Margin = new Extents(5, 5, 0, 0),
423                     BackgroundColor = new Color(0.78f, 0.78f, 0.78f, 1),
424                 },
425             });
426             theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultGridItem", new DefaultGridItemStyle()
427             {
428                 Padding = new Extents(5, 5, 5, 5),
429                 Caption = new TextLabelStyle()
430                 {
431                     PointSize = 9,
432                     Ellipsis = true,
433                 },
434                 Badge = new ViewStyle()
435                 {
436                     Margin = new Extents(5, 5, 5, 5),
437                 },
438             });
439
440             theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultTitleItem", new DefaultTitleItemStyle()
441             {
442                 SizeHeight = 90,
443                 Padding = new Extents(10, 10, 5, 5),
444                 BackgroundColor = new Selector<Color>()
445                 {
446                     Normal = (Color)theme.Resources["TitleBackgroundColorNormal"],
447                 },
448                 Label = new TextLabelStyle()
449                 {
450                     PointSize = 10,
451                     Ellipsis = true,
452                 },
453                 Icon = new ViewStyle()
454                 {
455                     Margin = new Extents(10, 0, 0, 0)
456                 },
457                 Seperator = new ViewStyle()
458                 {
459                     Margin = new Extents(0, 0, 0, 0),
460                     BackgroundColor = new Color(0.85f, 0.85f, 0.85f, 1),
461                 },
462             });
463
464             return theme;
465         }
466     }
467 }
468
469 #endif