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