* Add platform theme: the theme from tizen-theme-manager using xaml.
* Separate base theme from the user theme: the base theme is not used when update view according to theme change.
* Add new NUIApplication constructor with theme option.
* Compact theme data in View.
* Remove unused dark themes.
* Remove unused xaml theme files.
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual TextLabel CreateText()
{
- return new TextLabel
+ return new TextLabel(new TextLabelStyle())
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual ImageView CreateIcon()
{
- return new ImageView
+ return new ImageView()
{
AccessibilityHighlightable = false
};
}
/// <summary>
- /// Return currently applied style.
+ /// The last applied style object copy.
/// </summary>
/// <remarks>
/// Modifying contents in style may cause unexpected behaviour.
if (buttonStyle.Text != null)
{
+ buttonText.ThemeChangeSensitive = false;
buttonText.ApplyStyle(buttonStyle.Text);
}
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public Control(string styleName) : this(new ControlStyle() /* Apply empty style */)
+ public Control(string styleName) : base(ThemeManager.GetInitialStyleWithoutClone(styleName) ?? throw new InvalidOperationException($"There is no style {styleName}"))
{
- if (ThemeManager.GetStyle(styleName) == null)
- {
- throw new InvalidOperationException($"There is no style {styleName}");
- }
+ this.styleName = styleName;
- StyleName = styleName;
+ SetThemeApplied();
}
/// <summary>
if (gravity == null) throw new ArgumentNullException(nameof(gravity));
- var style = ThemeManager.GetStyle("NotificationToast");
+ var style = ThemeManager.GetInitialStyleWithoutClone("NotificationToast");
if (style != null)
{
textLabel.ApplyStyle(style);
/// <summary>
/// Gets or Sets the Line Style at the top of TabButton.
/// </summary>
- internal ViewStyle TopLine { get; set; } = new ViewStyle();
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ViewStyle TopLine { get; set; } = new ViewStyle();
/// <summary>
/// Gets or Sets the Line Style at the bottom of TabButton.
/// </summary>
- internal ViewStyle BottomLine { get; set; } = new ViewStyle();
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ViewStyle BottomLine { get; set; } = new ViewStyle();
/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
*
*/
-using System.Collections.Generic;
-using Tizen.NUI.BaseComponents;
+#if !PROFILE_TV
+#define ExternalThemeEnabled
+#endif
namespace Tizen.NUI.Components
{
internal partial class DefaultThemeCreator
{
- private HashSet<ExternalThemeKeyList> actionSet;
-
private DefaultThemeCreator() { }
public static IThemeCreator Instance { get; set; } = new DefaultThemeCreator();
- public HashSet<ExternalThemeKeyList> GetExternalThemeKeyListSet()
- {
- if (actionSet != null)
- {
- return actionSet;
- }
-
- actionSet = new HashSet<ExternalThemeKeyList>()
- {
- // Button
- (new ExternalThemeKeyList(typeof(Button), typeof(ButtonStyle)))
- .AddBackgroundSelector("/Background", SetBackgroundColor, SetBackgroundImage)
- .Add<Rectangle>("/BackgroundImageBorder", SetBackgroundBorder)
- .AddSelector<Color>("/Text/TextColor", SetButtonTextColor)
- .AddSelector<float?>("/Text/PixelSize", SetButtonTextPixelSize),
-
- // CheckBox
- (new ExternalThemeKeyList(typeof(CheckBox), typeof(ButtonStyle)))
- .AddSelector<string>("/Icon/ResourceUrl", SetButtonIconResourceUrl, ControlState.Selected, ControlState.DisabledSelected)
- .Add<Rectangle>("/Icon/Border", SetButtonIconBorder)
- .AddSelector<Color>("/Text/TextColor", SetButtonTextColor, ControlState.Selected, ControlState.DisabledSelected)
- .AddSelector<float?>("/Text/PixelSize", SetButtonTextPixelSize, ControlState.Selected, ControlState.DisabledSelected),
-
- // RadioButton
- (new ExternalThemeKeyList(typeof(RadioButton), typeof(ButtonStyle)))
- .AddSelector<string>("/Icon/ResourceUrl", SetButtonIconResourceUrl, ControlState.Selected, ControlState.DisabledSelected)
- .Add<Rectangle>("/Icon/Border", SetButtonIconBorder)
- .AddSelector<Color>("/Text/TextColor", SetButtonTextColor, ControlState.Selected, ControlState.DisabledSelected)
- .AddSelector<float?>("/Text/PixelSize", SetButtonTextPixelSize, ControlState.Selected, ControlState.DisabledSelected),
-
- // Switch
- (new ExternalThemeKeyList(typeof(Switch), typeof(SwitchStyle)))
- .AddSelector<string>("/Track/ResourceUrl", (ViewStyle style, Selector<string> value) => ((SwitchStyle)style).Track.ResourceUrl = value, ControlState.Selected, ControlState.DisabledSelected)
- .AddSelector<string>("/Thumb/ResourceUrl", (ViewStyle style, Selector<string> value) => ((SwitchStyle)style).Thumb.ResourceUrl = value, ControlState.Selected, ControlState.DisabledSelected)
- .Add<Rectangle>("/Track/Border", (ViewStyle style, Rectangle value) => ((SwitchStyle)style).Track.Border = value)
- .Add<Rectangle>("/Thumb/Border", (ViewStyle style, Rectangle value) => ((SwitchStyle)style).Thumb.Border = value)
- .AddSelector<Color>("/Text/TextColor", SetButtonTextColor, ControlState.Selected, ControlState.DisabledSelected)
- .AddSelector<float?>("/Text/PixelSize", SetButtonTextPixelSize, ControlState.Selected, ControlState.DisabledSelected),
-
- // Progress
- (new ExternalThemeKeyList(typeof(Progress), typeof(ProgressStyle)))
- .AddSelector("/Track/Background", (ViewStyle style, Selector<Color> value) => ((ProgressStyle)style).Track.BackgroundColor = value)
- .AddSelector("/Buffer/Background", (ViewStyle style, Selector<Color> value) => ((ProgressStyle)style).Buffer.BackgroundColor = value)
- .AddSelector("/Progress/Background", (ViewStyle style, Selector<Color> value) => ((ProgressStyle)style).Progress.BackgroundColor = value)
- .AddSelector("/Track/ResourceUrl", (ViewStyle style, Selector<string> value) => ((ProgressStyle)style).Track.ResourceUrl = value)
- .AddSelector("/Buffer/ResourceUrl", (ViewStyle style, Selector<string> value) => ((ProgressStyle)style).Buffer.ResourceUrl = value)
- .AddSelector("/Progress/ResourceUrl", (ViewStyle style, Selector<string> value) => ((ProgressStyle)style).Progress.ResourceUrl = value)
- .Add<string>("/IndeterminateImageUrl", (ViewStyle style, string value) => ((ProgressStyle)style).IndeterminateImageUrl = value),
-
- // Slider
- (new ExternalThemeKeyList(typeof(Slider), typeof(SliderStyle)))
- .AddSelector("/Track/Background", (ViewStyle style, Selector<Color> value) => ((SliderStyle)style).Track.BackgroundColor = value)
- .AddSelector("/Progress/Background", (ViewStyle style, Selector<Color> value) => ((SliderStyle)style).Progress.BackgroundColor = value)
- .AddSelector("/Thumb/Background", (ViewStyle style, Selector<Color> value) => ((SliderStyle)style).Thumb.BackgroundColor = value)
- .AddSelector("/Thumb/ResourceUrl", (ViewStyle style, Selector<string> value) => ((SliderStyle)style).Thumb.ResourceUrl = value)
- .AddSelector("/ValueIndicatorImage/ResourceUrl", (ViewStyle style, Selector<string> value) => ((SliderStyle)style).ValueIndicatorImage.ResourceUrl = value),
-
- // Pagination
- (new ExternalThemeKeyList(typeof(Pagination), typeof(PaginationStyle)))
- .AddSelector("/IndicatorImageUrl", (ViewStyle style, Selector<string> value) => ((PaginationStyle)style).IndicatorImageUrl = value),
-
- // Scrollbar
- (new ExternalThemeKeyList(typeof(Scrollbar), typeof(ScrollbarStyle)))
- .Add("/TrackColor", (ViewStyle style, Color value) => ((ScrollbarStyle)style).TrackColor = value)
- .Add("/ThumbColor", (ViewStyle style, Color value) => ((ScrollbarStyle)style).ThumbColor = value),
-
- // RecyclerViewItem
- (new ExternalThemeKeyList(typeof(RecyclerViewItem), typeof(RecyclerViewItemStyle)))
- .AddBackgroundSelector("/Background", SetBackgroundColor, SetBackgroundImage, ControlState.Selected)
- .Add<Rectangle>("/BackgroundImageBorder", SetBackgroundBorder),
-
- // DefaultTitleItem
- (new ExternalThemeKeyList(typeof(DefaultTitleItem), typeof(DefaultTitleItemStyle)))
- .AddBackgroundSelector("/Background", SetBackgroundColor, SetBackgroundImage)
- .Add<Rectangle>("/BackgroundImageBorder", SetBackgroundBorder),
-
- // AppBar
- (new ExternalThemeKeyList(typeof(AppBar), typeof(AppBarStyle))),
-
- // Picker
- (new ExternalThemeKeyList(typeof(Picker), typeof(PickerStyle)))
- .Add<Size>("/Size", (ViewStyle style, Size value) => ((ViewStyle)style).Size = value)
- .AddSelector<float?>("/ItemTextLabel/PixelSize", (ViewStyle style, Selector<float?> value) => ((PickerStyle)style).ItemTextLabel.PixelSize = value, ControlState.Selected)
- .Add<Size>("/ItemTextLabel/Size", (ViewStyle style, Size value) => ((PickerStyle)style).ItemTextLabel.Size = value)
- .AddSelector<Color>("/ItemTextLabel/TextColor", (ViewStyle style, Selector<Color> value) => ((PickerStyle)style).ItemTextLabel.TextColor = value, ControlState.Selected)
- .AddSelector("/ItemTextLabel/BackgroundColor", (ViewStyle style, Selector<Color> value) => ((PickerStyle)style).ItemTextLabel.BackgroundColor = value, ControlState.Selected)
- .Add<float?>("/Divider/SizeHeight", (ViewStyle style, float? value) => ((PickerStyle)style).Divider.SizeHeight = value)
- .Add<Position>("/Divider/Position", (ViewStyle style, Position value) => ((PickerStyle)style).Divider.Position = value)
- .AddSelector("/Divider/BackgroundColor", (ViewStyle style, Selector<Color> value) => ((PickerStyle)style).Divider.BackgroundColor = value, ControlState.Selected)
- .Add<Size>("/StartScrollOffset", (ViewStyle style, Size value) => ((PickerStyle)style).StartScrollOffset = value),
-
- // TabButton
- (new ExternalThemeKeyList(typeof(TabButton), typeof(TabButtonStyle)))
- .Add<Size>("/Size", (ViewStyle style, Size value) => ((ViewStyle)style).Size = value)
- .Add<float?>("/CornerRadius", (ViewStyle style, float? value) => ((ViewStyle)style).CornerRadius = value)
- .AddSelector<Color>("/BackgroundColor", (ViewStyle style, Selector<Color> value) => ((ViewStyle)style).BackgroundColor = value, ControlState.Selected)
- .AddSelector<float?>("/Text/PixelSize", SetButtonTextPixelSize, ControlState.Selected)
- .Add<Size>("/Text/Size", (ViewStyle style, Size value) => ((ButtonStyle)style).Text.Size = value)
- .AddSelector<Color>("/Text/TextColor", SetButtonTextColor, ControlState.Selected)
- .Add<Size>("/Icon/Size", (ViewStyle style, Size value) => ((ButtonStyle)style).Icon.Size = value)
- .AddSelector<Color>("/Icon/Color", (ViewStyle style, Selector<Color> value) => ((ButtonStyle)style).Icon.Color = value, ControlState.Selected)
- .Add<Size>("/TopLine/Size", (ViewStyle style, Size value) => ((TabButtonStyle)style).TopLine.Size = value)
- .AddSelector<Color>("/TopLine/BackgroundColor", (ViewStyle style, Selector<Color> value) => ((TabButtonStyle)style).TopLine.BackgroundColor = value, ControlState.Selected)
- .Add<Size>("/BottomLine/Size", (ViewStyle style, Size value) => ((TabButtonStyle)style).BottomLine.Size = value)
- .Add<Position>("/BottomLine/Position", (ViewStyle style, Position value) => ((TabButtonStyle)style).BottomLine.Position = value)
- .AddSelector<Color>("/BottomLine/BackgroundColor", (ViewStyle style, Selector<Color> value) => ((TabButtonStyle)style).BottomLine.BackgroundColor = value, ControlState.Selected),
-
- // AlertDialog
- (new ExternalThemeKeyList(typeof(AlertDialog), typeof(AlertDialogStyle)))
- .Add<Size>("/Size", (ViewStyle style, Size value) => ((ViewStyle)style).Size = value)
- .Add<Extents>("/Padding", (ViewStyle style, Extents value) => ((ViewStyle)style).Padding = value)
- .Add<string>("/BackgroundImage", (ViewStyle style, string value) => ((ViewStyle)style).BackgroundImage = value)
- .Add<Size>("/TitleTextLabel/Size", (ViewStyle style, Size value) => ((AlertDialogStyle)style).TitleTextLabel.Size = value)
- .Add<Extents>("/TitleTextLabel/Margin", (ViewStyle style, Extents value) => ((AlertDialogStyle)style).TitleTextLabel.Margin = value)
- .Add<float?>("/TitleTextLabel/PixelSize", (ViewStyle style, float? value) => ((AlertDialogStyle)style).TitleTextLabel.PixelSize = value)
- .Add<HorizontalAlignment?>("/TitleTextLabel/HorizontalAlignment", (ViewStyle style, HorizontalAlignment? value) => ((AlertDialogStyle)style).TitleTextLabel.HorizontalAlignment = value)
- .Add<VerticalAlignment?>("/TitleTextLabel/VerticalAlignment", (ViewStyle style, VerticalAlignment? value) => ((AlertDialogStyle)style).TitleTextLabel.VerticalAlignment = value)
- .AddSelector<Color>("/TitleTextLabel/TextColor", (ViewStyle style, Selector<Color> value) => ((AlertDialogStyle)style).TitleTextLabel.TextColor = value)
- .Add<Size>("/MessageTextLabel/Size", (ViewStyle style, Size value) => ((AlertDialogStyle)style).MessageTextLabel.Size = value)
- .Add<Extents>("/MessageTextLabel/Margin", (ViewStyle style, Extents value) => ((AlertDialogStyle)style).MessageTextLabel.Margin = value)
- .Add<float?>("/MessageTextLabel/PixelSize", (ViewStyle style, float? value) => ((AlertDialogStyle)style).MessageTextLabel.PixelSize = value)
- .Add<bool?>("/MessageTextLabel/MultiLine", (ViewStyle style, bool? value) => ((AlertDialogStyle)style).MessageTextLabel.MultiLine = value)
- .Add<HorizontalAlignment?>("/MessageTextLabel/HorizontalAlignment", (ViewStyle style, HorizontalAlignment? value) => ((AlertDialogStyle)style).MessageTextLabel.HorizontalAlignment = value)
- .Add<VerticalAlignment?>("/MessageTextLabel/VerticalAlignment", (ViewStyle style, VerticalAlignment? value) => ((AlertDialogStyle)style).MessageTextLabel.VerticalAlignment = value)
- .AddSelector<Color>("/MessageTextLabel/TextColor", (ViewStyle style, Selector<Color> value) => ((AlertDialogStyle)style).MessageTextLabel.TextColor = value)
- .Add<Size>("/ActionContent/Size", (ViewStyle style, Size value) => ((AlertDialogStyle)style).ActionContent.Size = value),
-
- // TimePicker
- (new ExternalThemeKeyList(typeof(TimePicker), typeof(TimePickerStyle)))
- .Add<Size>("/CellPadding", (ViewStyle style, Size value) => ((TimePickerStyle)style).Size = value)
- .Add<Size>("/Pickers/Size", (ViewStyle style, Size value) => ((TimePickerStyle)style).Pickers.Size = value)
- .AddSelector<float?>("/Pickers/ItemTextLabel/PixelSize", (ViewStyle style, Selector<float?> value) => ((TimePickerStyle)style).Pickers.ItemTextLabel.PixelSize = value, ControlState.Selected)
- .Add<Size>("/Pickers/ItemTextLabel/Size", (ViewStyle style, Size value) => ((TimePickerStyle)style).Pickers.ItemTextLabel.Size = value)
- .AddSelector<Color>("/Pickers/ItemTextLabel/TextColor", (ViewStyle style, Selector<Color> value) => ((TimePickerStyle)style).Pickers.ItemTextLabel.TextColor = value, ControlState.Selected)
- .AddSelector("/Pickers/ItemTextLabel/BackgroundColor", (ViewStyle style, Selector<Color> value) => ((TimePickerStyle)style).Pickers.ItemTextLabel.BackgroundColor = value, ControlState.Selected)
- .Add<float?>("/Pickers/Divider/SizeHeight", (ViewStyle style, float? value) => ((TimePickerStyle)style).Pickers.Divider.SizeHeight = value)
- .Add<Position>("/Pickers/Divider/Position", (ViewStyle style, Position value) => ((TimePickerStyle)style).Pickers.Divider.Position = value)
- .AddSelector("/Pickers/Divider/BackgroundColor", (ViewStyle style, Selector<Color> value) => ((TimePickerStyle)style).Pickers.Divider.BackgroundColor = value, ControlState.Selected)
- .Add<Size>("/Pickers/StartScrollOffset", (ViewStyle style, Size value) => ((TimePickerStyle)style).Pickers.StartScrollOffset = value),
-
- // DatePicker
- (new ExternalThemeKeyList(typeof(DatePicker), typeof(DatePickerStyle)))
- .Add<Size>("/CellPadding", (ViewStyle style, Size value) => ((DatePickerStyle)style).Size = value)
- .Add<Size>("/Pickers/Size", (ViewStyle style, Size value) => ((DatePickerStyle)style).Pickers.Size = value)
- .AddSelector<float?>("/Pickers/ItemTextLabel/PixelSize", (ViewStyle style, Selector<float?> value) => ((DatePickerStyle)style).Pickers.ItemTextLabel.PixelSize = value, ControlState.Selected)
- .Add<Size>("/Pickers/ItemTextLabel/Size", (ViewStyle style, Size value) => ((DatePickerStyle)style).Pickers.ItemTextLabel.Size = value)
- .AddSelector<Color>("/Pickers/ItemTextLabel/TextColor", (ViewStyle style, Selector<Color> value) => ((DatePickerStyle)style).Pickers.ItemTextLabel.TextColor = value, ControlState.Selected)
- .AddSelector("/Pickers/ItemTextLabel/BackgroundColor", (ViewStyle style, Selector<Color> value) => ((DatePickerStyle)style).Pickers.ItemTextLabel.BackgroundColor = value, ControlState.Selected)
- .Add<float?>("/Pickers/Divider/SizeHeight", (ViewStyle style, float? value) => ((DatePickerStyle)style).Pickers.Divider.SizeHeight = value)
- .Add<Position>("/Pickers/Divider/Position", (ViewStyle style, Position value) => ((DatePickerStyle)style).Pickers.Divider.Position = value)
- .AddSelector("/Pickers/Divider/BackgroundColor", (ViewStyle style, Selector<Color> value) => ((DatePickerStyle)style).Pickers.Divider.BackgroundColor = value, ControlState.Selected)
- .Add<Size>("/Pickers/StartScrollOffset", (ViewStyle style, Size value) => ((DatePickerStyle)style).Pickers.StartScrollOffset = value),
-
- // AlertDialog
- (new ExternalThemeKeyList(typeof(AlertDialog), typeof(AlertDialogStyle)))
- .Add<Size>("/Size", (ViewStyle style, Size value) => ((ViewStyle)style).Size = value)
- .Add<Extents>("/Padding", (ViewStyle style, Extents value) => ((ViewStyle)style).Padding = value)
- .Add<string>("/BackgroundImage", (ViewStyle style, string value) => ((ViewStyle)style).BackgroundImage = value)
- .Add<Size>("/TitleTextLabel/Size", (ViewStyle style, Size value) => ((AlertDialogStyle)style).TitleTextLabel.Size = value)
- .Add<Extents>("/TitleTextLabel/Margin", (ViewStyle style, Extents value) => ((AlertDialogStyle)style).TitleTextLabel.Margin = value)
- .Add<float?>("/TitleTextLabel/PixelSize", (ViewStyle style, float? value) => ((AlertDialogStyle)style).TitleTextLabel.PixelSize = value)
- .Add<HorizontalAlignment?>("/TitleTextLabel/HorizontalAlignment", (ViewStyle style, HorizontalAlignment? value) => ((AlertDialogStyle)style).TitleTextLabel.HorizontalAlignment = value)
- .Add<VerticalAlignment?>("/TitleTextLabel/VerticalAlignment", (ViewStyle style, VerticalAlignment? value) => ((AlertDialogStyle)style).TitleTextLabel.VerticalAlignment = value)
- .AddSelector<Color>("/TitleTextLabel/TextColor", (ViewStyle style, Selector<Color> value) => ((AlertDialogStyle)style).TitleTextLabel.TextColor = value)
- .Add<Size>("/MessageTextLabel/Size", (ViewStyle style, Size value) => ((AlertDialogStyle)style).MessageTextLabel.Size = value)
- .Add<Extents>("/MessageTextLabel/Margin", (ViewStyle style, Extents value) => ((AlertDialogStyle)style).MessageTextLabel.Margin = value)
- .Add<float?>("/MessageTextLabel/PixelSize", (ViewStyle style, float? value) => ((AlertDialogStyle)style).MessageTextLabel.PixelSize = value)
- .Add<bool?>("/MessageTextLabel/MultiLine", (ViewStyle style, bool? value) => ((AlertDialogStyle)style).MessageTextLabel.MultiLine = value)
- .Add<HorizontalAlignment?>("/MessageTextLabel/HorizontalAlignment", (ViewStyle style, HorizontalAlignment? value) => ((AlertDialogStyle)style).MessageTextLabel.HorizontalAlignment = value)
- .Add<VerticalAlignment?>("/MessageTextLabel/VerticalAlignment", (ViewStyle style, VerticalAlignment? value) => ((AlertDialogStyle)style).MessageTextLabel.VerticalAlignment = value)
- .AddSelector<Color>("/MessageTextLabel/TextColor", (ViewStyle style, Selector<Color> value) => ((AlertDialogStyle)style).MessageTextLabel.TextColor = value)
- .Add<Size>("/ActionContent/Size", (ViewStyle style, Size value) => ((AlertDialogStyle)style).ActionContent.Size = value),
- };
-
- return actionSet;
- }
-
public static void Preload()
{
ThemeManager.AddPackageTheme(Instance);
- Instance.GetExternalThemeKeyListSet();
- }
-
- private static void SetBackgroundColor(ViewStyle style, Selector<Color> value) => style.BackgroundColor = value;
-
- private static void SetBackgroundImage(ViewStyle style, Selector<string> value) => style.BackgroundImage = value;
- private static void SetBackgroundBorder(ViewStyle style, Rectangle value) => style.BackgroundImageBorder = value;
+#if ExternalThemeEnabled
+ if (string.IsNullOrEmpty(ExternalThemeManager.CurrentThemeId)) return;
- private static void SetButtonTextColor(ViewStyle style, Selector<Color> value) => ((ButtonStyle)style).Text.TextColor = value;
-
- private static void SetButtonTextPixelSize(ViewStyle style, Selector<float?> value) => ((ButtonStyle)style).Text.PixelSize = value;
-
- private static void SetButtonIconResourceUrl(ViewStyle style, Selector<string> value) => ((ButtonStyle)style).Icon.ResourceUrl = value;
-
- private static void SetButtonIconBorder(ViewStyle style, Rectangle value) => ((ButtonStyle)style).Icon.Border = value;
-
- private static void SetButtonIconBackgroundColor(ViewStyle style, Selector<Color> value) => ((ButtonStyle)style).Icon.BackgroundColor = value;
-
- private static void SetButtonIconBackgroundImageUrl(ViewStyle style, Selector<string> value) => ((ButtonStyle)style).Icon.BackgroundImage = value;
-
- private static void SetButtonIconBackgroundBorder(ViewStyle style, Rectangle value) => ((ButtonStyle)style).Icon.BackgroundImageBorder = value;
+ ThemeManager.LoadPlatformTheme(ExternalThemeManager.CurrentThemeId);
+#endif
+ }
}
}
// It is a C# version of res/Tizen.NUI.Components_Tizen.NUI.Theme.Common.xaml
internal partial class DefaultThemeCreator : IThemeCreator
{
+ /// <summary>
+ /// The base theme description.
+ /// </summary>
[SuppressMessage("Microsoft.Reliability", "CA2000: Dispose objects before losing scope", Justification = "The responsibility to dispose the object is transferred to the theme object.")]
public Theme Create()
{
Version = Tizen.NUI.DefaultThemeCreator.DefaultVersion
};
+ // Button base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
{
Size = new Size(339, 96),
},
Text = new TextLabelStyle()
{
- PixelSize = 32,
TextColor = Color.White,
}
});
+ // CheckBox base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.CheckBox", new ButtonStyle()
{
ItemSpacing = new Size2D(32, 32),
},
Text = new TextLabelStyle()
{
- PixelSize = 32,
TextColor = new Color("#001447")
}
});
+ // Popup base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.Popup", new PopupStyle()
{
Size = new Size(500, 280),
Buttons = new ButtonStyle()
{
Size = new Size(0, 80),
+ CornerRadius = 0,
BackgroundColor = new Selector<Color>()
{
Normal = new Color(1, 1, 1, 1),
}
});
+ // Progress base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.Progress", new ProgressStyle()
{
Size = new Size(200, 25),
IndeterminateImageUrl = FrameworkInformation.ResourcePath + "nui_component_default_progress_indeterminate.png",
});
+ // RadioButton base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.RadioButton", new ButtonStyle()
{
ItemSpacing = new Size2D(32, 32),
},
Text = new TextLabelStyle()
{
- PixelSize = 32,
TextColor = new Color("#001447")
}
});
+ // Slider base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.Slider", new SliderStyle()
{
Size = new Size(200, 50),
},
});
+ // Switch base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.Switch", new SwitchStyle()
{
ItemSpacing = new Size2D(32, 32),
},
Text = new TextLabelStyle()
{
- PixelSize = 32,
TextColor = new Color("#001447")
}
});
+ // Loading base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.Loading", new LoadingStyle()
{
LoadingSize = new Size(100, 100),
});
+ // Pagination base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.Pagination", new PaginationStyle()
{
IndicatorImageUrl = new Selector<string>()
IndicatorSize = new Size(10, 10),
});
+ // Scrollbar base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
{
TrackThickness = 12,
ThumbThickness = 12,
TrackColor = new Color(0f, 0f, 0f, 0f),
- ThumbColor = new Color("#0A0E4AFF"),
+ ThumbColor = new Color("#0A0E4A"),
TrackPadding = 4,
ThumbVerticalImageUrl = FrameworkInformation.ResourcePath + "nui_component_default_scroll_vbar.#.png",
ThumbHorizontalImageUrl = FrameworkInformation.ResourcePath + "nui_component_default_scroll_hbar.#.png",
});
+ // LinearLayouter base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.LinearLayouter", new ViewStyle()
{
Padding = new Extents(64, 64, 0, 0)
});
+ // GridLayouter base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.GridLayouter", new ViewStyle()
{
Padding = new Extents(0, 0, 0, 0),
});
+ // ItemsLayouter base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.ItemsLayouter", new ViewStyle()
{
Padding = new Extents(0, 0, 0, 0),
});
+ // RecyclerViewItem base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.RecyclerViewItem", new RecyclerViewItemStyle()
{
BackgroundColor = new Selector<Color>()
},
});
+ // DefaultLinearItem base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultLinearItem", new DefaultLinearItemStyle()
{
SizeHeight = 108,
PixelSize = 32,
Ellipsis = true,
FontFamily = "BreezeSans", //FXIME Font Weight is Light
- TextColor = new Color("#001447FF"),
+ TextColor = new Color("#001447"),
+ ThemeChangeSensitive = false
},
SubLabel = new TextLabelStyle()
{
PixelSize = 28,
Ellipsis = true,
FontFamily = "BreezeSans",
- TextColor = new Color("#001447FF"),
+ TextColor = new Color("#001447"),
+ ThemeChangeSensitive = false
},
Icon = new ViewStyle()
{
{
SizeHeight = 1,
Margin = new Extents(64, 64, 0, 0),
- BackgroundColor = new Color("#C3CAD2FF"),
+ BackgroundColor = new Color("#C3CAD2"),
},
});
+
+ // DefaultGridItem base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultGridItem", new DefaultGridItemStyle()
{
Padding = new Extents(0, 0, 0, 0),
SizeHeight = 60,
PixelSize = 24,
LineWrapMode = LineWrapMode.Character,
+ ThemeChangeSensitive = false
},
Badge = new ViewStyle()
{
},
});
+ // DefaultTitleItem base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultTitleItem", new DefaultTitleItemStyle()
{
SizeHeight = 60,
Margin = new Extents(0, 0, 0, 0),
BackgroundColor = new Selector<Color>()
{
- Normal = new Color("#EEEEF1FF"),
+ Normal = new Color("#EEEEF1"),
},
Label = new TextLabelStyle()
{
PixelSize = 28,
Ellipsis = true,
- TextColor = new Color("#001447FF"),
+ TextColor = new Color("#001447"),
+ ThemeChangeSensitive = false
},
Icon = new ViewStyle()
{
},
});
+ // ContentPage base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.ContentPage", new ViewStyle()
{
- BackgroundColor = new Color("#EEEFF1FF"),
+ BackgroundColor = new Color("#EEEFF1"),
});
+ // AppBar base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.AppBar", new AppBarStyle()
{
Size = new Size(-1, 120),
- BackgroundColor = new Color("#EEEFF1FF"),
+ BackgroundColor = new Color("#EEEFF1"),
BackButton = new ButtonStyle()
{
Size = new Size(48, 48),
ResourceUrl = FrameworkInformation.ResourcePath + "nui_component_default_back_button.png",
Color = new Selector<Color>()
{
- Normal = new Color("#0A0E4AFF"),
- Focused = new Color("#00338BFF"),
- Pressed = new Color("#1B69CAFF"),
- Disabled = new Color("#C3CAD2FF"),
+ Normal = new Color("#0A0E4A"),
+ Focused = new Color("#00338B"),
+ Pressed = new Color("#1B69CA"),
+ Disabled = new Color("#C3CAD2"),
},
},
+ ThemeChangeSensitive = false
},
TitleTextLabel = new TextLabelStyle()
{
VerticalAlignment = VerticalAlignment.Center,
TextColor = new Selector<Color>()
{
- Normal = new Color("#000C2BFF"),
- }
+ Normal = new Color("#000C2B"),
+ },
+ ThemeChangeSensitive = false
},
ActionView = new ViewStyle()
{
PixelSize = 26,
TextColor = new Selector<Color>()
{
- Normal = new Color("#0A0E4AFF"),
- Focused = new Color("#00338BFF"),
- Pressed = new Color("#1B69CAFF"),
- Disabled = new Color("#C3CAD2FF"),
+ Normal = new Color("#0A0E4A"),
+ Focused = new Color("#00338B"),
+ Pressed = new Color("#1B69CA"),
+ Disabled = new Color("#C3CAD2"),
},
},
Icon = new ImageViewStyle()
Size = new Size(-1, 48),
Color = new Selector<Color>()
{
- Normal = new Color("#0A0E4AFF"),
- Focused = new Color("#00338BFF"),
- Pressed = new Color("#1B69CAFF"),
- Disabled = new Color("#C3CAD2FF"),
+ Normal = new Color("#0A0E4A"),
+ Focused = new Color("#00338B"),
+ Pressed = new Color("#1B69CA"),
+ Disabled = new Color("#C3CAD2"),
},
},
+ ThemeChangeSensitive = false,
},
Padding = new Extents(64, 64, 0, 0),
NavigationPadding = new Extents(0, 24, 0, 0),
ActionCellPadding = new Size2D(40, 0),
});
+ // Picker base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.Picker", new PickerStyle()
{
Size = new Size(160, 339),
Size = new Size(0,72),
TextColor = new Selector<Color>()
{
- Normal = new Color("#000C2BFF"),
+ Normal = new Color("#000C2B"),
},
BackgroundColor = Color.White,
},
SizeHeight = 2.0f,
WidthResizePolicy = ResizePolicyType.FillToParent,
Position = new Position(0, 132),
- BackgroundColor = new Color("#0A0E4AFF"),
+ BackgroundColor = new Color("#0A0E4A"),
},
StartScrollOffset = new Size(0, 12),
});
+ // TabButton base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.TabButton", new TabButtonStyle()
{
Size = new Size(-1, 84),
Size = new Size(-2, -2),
TextColor = new Selector<Color>()
{
- Normal = new Color("#000C2BFF"),
- Selected = new Color("#000C2BFF"),
- Pressed = new Color("#1473E6FF"),
- Disabled = new Color("#C3CAD2FF"),
+ Normal = new Color("#000C2B"),
+ Selected = new Color("#000C2B"),
+ Pressed = new Color("#1473E6"),
+ Disabled = new Color("#C3CAD2"),
},
+ ThemeChangeSensitive = false,
},
Icon = new ImageViewStyle()
{
Size = new Size(48, 48),
Color = new Selector<Color>()
{
- Normal = new Color("#000C2BFF"),
- Selected = new Color("#000C2BFF"),
- Pressed = new Color("#1473E6FF"),
- Disabled = new Color("#C3CAD2FF"),
+ Normal = new Color("#000C2B"),
+ Selected = new Color("#000C2B"),
+ Pressed = new Color("#1473E6"),
+ Disabled = new Color("#C3CAD2"),
},
},
TopLine = new ViewStyle()
Size = new Size(-1, 1),
BackgroundColor = new Selector<Color>()
{
- Normal = new Color("#000C2BFF"),
- Selected = new Color("#000C2BFF"),
- Pressed = new Color("#1473E6FF"),
- Disabled = new Color("#C3CAD2FF"),
+ Normal = new Color("#000C2B"),
+ Selected = new Color("#000C2B"),
+ Pressed = new Color("#1473E6"),
+ Disabled = new Color("#C3CAD2"),
},
},
BottomLine = new ViewStyle()
BackgroundColor = new Selector<Color>()
{
Normal = Color.Transparent,
- Selected = new Color("#000C2BFF"),
- Pressed = new Color("#1473E6FF"),
+ Selected = new Color("#000C2B"),
+ Pressed = new Color("#1473E6"),
Disabled = Color.Transparent,
},
},
});
+ // NotificationToast base style
theme.AddStyleWithoutClone("NotificationToast", new TextLabelStyle()
{
- BackgroundImage = FrameworkInformation.ResourcePath + "IoT_Toast_1.png",
- BackgroundImageBorder = new Rectangle(28, 28, 28, 28),
+ BackgroundColor = new Color("#F2F7FF"),
+ CornerRadius = 20.0f,
+ BoxShadow = new Shadow(5.0f, new Color("#00000066"), new Vector2(2.0f, 2.0f)),
TextColor = new Color("#000C2B"),
PixelSize = 32,
WidthResizePolicy = ResizePolicyType.UseNaturalSize,
PositionY = 120,
});
+ // AlertDialog base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.AlertDialog", new AlertDialogStyle()
{
Size = new Size(-2, -2),
Padding = new Extents(80, 80, 0, 0),
- BackgroundImage = FrameworkInformation.ResourcePath + "nui_component_default_dialog_bg.#.png",
+ BackgroundColor = Color.White,
+ CornerRadius = 28.0f,
+ BoxShadow = new Shadow(2.0f, new Color("#00000029"), new Vector2(2.0f, 2.0f)),
TitleTextLabel = new TextLabelStyle()
{
- Size = new Size(1024, -2),
+ Size = new Size(600, -2),
Margin = new Extents(0, 0, 40, 40),
PixelSize = 40,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
- TextColor = new Selector<Color>()
- {
- Normal = new Color("#000C2BFF"),
- },
+ TextColor = new Color("#000C2B"),
+ ThemeChangeSensitive = false,
},
MessageTextLabel = new TextLabelStyle()
{
- Size = new Size(1024, -2),
+ Size = new Size(600, -2),
Margin = new Extents(0, 0, 0, 64),
PixelSize = 32,
MultiLine = true,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
- TextColor = new Selector<Color>()
- {
- Normal = new Color("#000C2BFF"),
- },
+ TextColor = new Color("#000C2B"),
+ ThemeChangeSensitive = false,
},
ActionContent = new ViewStyle()
{
- Size = new Size(1024, -2),
+ Size = new Size(600, -2),
},
});
+ // TimePicker base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.TimePicker", new TimePickerStyle()
{
CellPadding = new Size(50, 339),
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
Size = new Size(0,72),
- TextColor = new Selector<Color>()
- {
- Normal = new Color("#000C2BFF"),
- },
+ TextColor = new Color("#000C2B"),
BackgroundColor = Color.White,
+ ThemeChangeSensitive = false
},
Divider = new ViewStyle()
{
SizeHeight = 2.0f,
WidthResizePolicy = ResizePolicyType.FillToParent,
Position = new Position(0, 132),
- BackgroundColor = new Color("#0A0E4AFF"),
+ BackgroundColor = new Color("#0A0E4A"),
},
StartScrollOffset = new Size2D(0, 12),
}
});
+ // DatePicker base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.DatePicker", new DatePickerStyle()
{
CellPadding = new Size(50, 339),
VerticalAlignment = VerticalAlignment.Center,
HorizontalAlignment = HorizontalAlignment.Center,
Size = new Size(0,72),
- TextColor = new Selector<Color>()
- {
- Normal = new Color("#000C2BFF"),
- },
+ TextColor = new Color("#000C2B"),
BackgroundColor = Color.White,
+ ThemeChangeSensitive = false
},
Divider = new ViewStyle()
{
SizeHeight = 2.0f,
WidthResizePolicy = ResizePolicyType.FillToParent,
Position = new Position(0, 132),
- BackgroundColor = new Color("#0A0E4AFF"),
+ BackgroundColor = new Color("#0A0E4A"),
},
StartScrollOffset = new Size2D(0, 12),
}
});
+ // MenuItem base style
theme.AddStyleWithoutClone("Tizen.NUI.Components.MenuItem", new ButtonStyle()
{
Size = new Size(480, -2),
VerticalAlignment = VerticalAlignment.Center,
TextColor = new Selector<Color>()
{
- Normal = new Color("#001447FF"),
- Focused = new Color("#00338BFF"),
- Pressed = new Color("#1B69CAFF"),
- Disabled = new Color("#C3CAD2FF"),
+ Normal = new Color("#001447"),
+ Focused = new Color("#00338B"),
+ Pressed = new Color("#1B69CA"),
+ Disabled = new Color("#C3CAD2"),
},
+ ThemeChangeSensitive = false
},
Icon = new ImageViewStyle()
{
Size = new Size(-2, 48),
Color = new Selector<Color>()
{
- Normal = new Color("#001447FF"),
- Focused = new Color("#00338BFF"),
- Pressed = new Color("#1B69CAFF"),
- Disabled = new Color("#C3CAD2FF"),
+ Normal = new Color("#001447"),
+ Focused = new Color("#00338B"),
+ Pressed = new Color("#1B69CA"),
+ Disabled = new Color("#C3CAD2"),
},
},
});
}
}
-#endif
+#endif // !PROFILE_WEARABLE
+++ /dev/null
-/*
- * Copyright(c) 2021 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#if false
-
-using System.Diagnostics.CodeAnalysis;
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI.Components
-{
- internal partial class DefaultThemeCreator : IThemeCreator
- {
- [SuppressMessage("Microsoft.Reliability", "CA2000: Dispose objects before losing scope", Justification = "The responsibility to dispose the object is transferred to the theme object.")]
- public Theme Create()
- {
- var theme = new Theme()
- {
- Id = Tizen.NUI.DefaultThemeCreator.DefaultId,
- Version = Tizen.NUI.DefaultThemeCreator.DefaultVersion
- };
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.Button", new ButtonStyle()
- {
- Size = new Size(339, 96),
- CornerRadiusPolicy = VisualTransformPolicyType.Relative,
- CornerRadius = 0.2916f,
- ItemAlignment = LinearLayout.Alignment.Center,
- BackgroundColor = new Selector<Color>()
- {
- Normal = new Color(0.039f, 0.055f, 0.29f, 1),
- Pressed = new Color(0.106f, 0.412f, 0.792f, 1),
- Focused = new Color(0, 0.2f, 0.545f, 1),
- Disabled = new Color(0.765f, 0.792f, 0.824f, 1),
- },
- Text = new TextLabelStyle()
- {
- PixelSize = 32,
- TextColor = Color.White,
- }
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.CheckBox", new ButtonStyle()
- {
- ItemSpacing = new Size2D(32, 32),
- ItemAlignment = LinearLayout.Alignment.Begin,
- Icon = new ImageViewStyle()
- {
- Size = new Size(36, 36),
- ResourceUrl = new Selector<string>()
- {
- Normal = FrameworkInformation.ResourcePath + "IoT_check_off.svg",
- Pressed = FrameworkInformation.ResourcePath + "IoT_check_off_p.svg",
- Disabled = FrameworkInformation.ResourcePath + "IoT_check_off_d.svg",
- Focused = FrameworkInformation.ResourcePath + "IoT_check_off_f.svg",
- Selected = FrameworkInformation.ResourcePath + "IoT_check_on.svg",
- SelectedPressed = FrameworkInformation.ResourcePath + "IoT_check_on_p.svg",
- SelectedFocused = FrameworkInformation.ResourcePath + "IoT_check_on_f.svg",
- DisabledSelected = FrameworkInformation.ResourcePath + "IoT_check_on_d.svg",
- },
- },
- Text = new TextLabelStyle()
- {
- PixelSize = 32,
- TextColor = new Color("#001447")
- }
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.Popup", new PopupStyle()
- {
- Size = new Size(500, 280),
- BackgroundColor = new Color(0.9f, 0.9f, 0.9f, 1),
- ImageShadow = new ImageShadow()
- {
- Url = FrameworkInformation.ResourcePath + "nui_component_default_popup_shadow.png",
- Border = new Rectangle(24, 24, 24, 24),
- Extents = new Vector2(48, 48)
- },
- Title = new TextLabelStyle()
- {
- PointSize = 16,
- Padding = new Extents(20, 20, 20, 20),
- },
- Buttons = new ButtonStyle()
- {
- Size = new Size(0, 80),
- BackgroundColor = new Selector<Color>()
- {
- Normal = new Color(1, 1, 1, 1),
- Pressed = new Color(1, 1, 1, 0.5f),
- },
- Overlay = new ImageViewStyle()
- {
- BackgroundColor = new Selector<Color>()
- {
- Pressed = new Color(0, 0, 0, 0.1f),
- Other = new Color(1, 1, 1, 0.1f),
- },
- },
- Text = new TextLabelStyle()
- {
- TextColor = new Color(0.05f, 0.63f, 0.9f, 1),
- }
- }
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.Progress", new ProgressStyle()
- {
- Size = new Size(200, 25),
- Track = new ImageViewStyle()
- {
- ResourceUrl = FrameworkInformation.ResourcePath + "IoT_progressindicator_empty.png",
- BackgroundColor = new Color(0, 0, 0, 0.1f),
- },
- Buffer = new ImageViewStyle()
- {
- BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 0.3f),
- },
- Progress = new ImageViewStyle()
- {
- ResourceUrl = new Selector<string>()
- {
- Normal = FrameworkInformation.ResourcePath + "IoT_progressindicator_progress_dark.png",
- Disabled = FrameworkInformation.ResourcePath + "IoT_progressindicator_progressdisabled.png",
- },
- BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1),
- },
- IndeterminateImageUrl = FrameworkInformation.ResourcePath + "nui_component_default_progress_indeterminate.png",
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.RadioButton", new ButtonStyle()
- {
- ItemSpacing = new Size2D(32, 32),
- ItemAlignment = LinearLayout.Alignment.Begin,
- Icon = new ImageViewStyle()
- {
- Size = new Size(36, 36),
- ResourceUrl = new Selector<string>()
- {
- Normal = FrameworkInformation.ResourcePath + "IoT_radiobutton_off.svg",
- Pressed = FrameworkInformation.ResourcePath + "IoT_radiobutton_off_p.svg",
- Disabled = FrameworkInformation.ResourcePath + "IoT_radiobutton_off_d.svg",
- Focused = FrameworkInformation.ResourcePath + "IoT_radiobutton_off_f.svg",
- Selected = FrameworkInformation.ResourcePath + "IoT_radiobutton_on.svg",
- SelectedPressed = FrameworkInformation.ResourcePath + "IoT_radiobutton_on_p.svg",
- SelectedFocused = FrameworkInformation.ResourcePath + "IoT_radiobutton_on_f.svg",
- DisabledSelected = FrameworkInformation.ResourcePath + "IoT_radiobutton_on_d.svg",
- },
- },
- Text = new TextLabelStyle()
- {
- PixelSize = 32,
- TextColor = new Color("#001447")
- }
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.Slider", new SliderStyle()
- {
- Size = new Size(200, 50),
- TrackThickness = 8,
- Track = new ImageViewStyle()
- {
- Size = new Size(100, 8),
- ResourceUrl = new Selector<string>()
- {
- Normal = FrameworkInformation.ResourcePath + "IoT_slider_status_empty_track.png",
- Disabled = FrameworkInformation.ResourcePath + "IoT_slider_status_track_disabled.png",
- },
- BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.1f),
- },
- Progress = new ImageViewStyle()
- {
- Size = new Size(100, 8),
- ResourceUrl = FrameworkInformation.ResourcePath + "IoT_slider_status_trackW.png",
- BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 1),
- },
- Thumb = new ImageViewStyle()
- {
- Size = new Size(36, 36),
- ResourceUrl = FrameworkInformation.ResourcePath + "IoT_slider_handler_normalW.png",
- },
- ValueIndicatorImage = new ImageViewStyle()
- {
- Size = new Size(49, 24),
- BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 1.0f),
- },
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.Switch", new SwitchStyle()
- {
- ItemSpacing = new Size2D(32, 32),
- ItemAlignment = LinearLayout.Alignment.Begin,
- Track = new ImageViewStyle()
- {
- Size = new Size(80, 40),
- ResourceUrl = new Selector<string>()
- {
- Normal = FrameworkInformation.ResourcePath + "IoT_switch_track_off.svg",
- Pressed = FrameworkInformation.ResourcePath + "IoT_switch_track_off_p.svg",
- Disabled = FrameworkInformation.ResourcePath + "IoT_switch_track_off_d.svg",
- Focused = FrameworkInformation.ResourcePath + "IoT_switch_track_off_f.svg",
- Selected = FrameworkInformation.ResourcePath + "IoT_switch_track_on.svg",
- SelectedPressed = FrameworkInformation.ResourcePath + "IoT_switch_track_on_p.svg",
- SelectedFocused = FrameworkInformation.ResourcePath + "IoT_switch_track_on_f.svg",
- DisabledSelected = FrameworkInformation.ResourcePath + "IoT_switch_track_on_d.svg",
- },
- },
- Thumb = new ImageViewStyle()
- {
- Size = new Size(40, 40),
- ResourceUrl = new Selector<string>()
- {
- Normal = FrameworkInformation.ResourcePath + "IoT_switch_thumb.svg",
- Disabled = FrameworkInformation.ResourcePath + "IoT_switch_thumb_d.svg",
- Selected = FrameworkInformation.ResourcePath + "IoT_switch_thumb_s.svg",
- SelectedPressed = FrameworkInformation.ResourcePath + "IoT_switch_thumb_sp.svg",
- SelectedFocused = FrameworkInformation.ResourcePath + "IoT_switch_thumb_sf.svg",
- }
- },
- Text = new TextLabelStyle()
- {
- PixelSize = 32,
- TextColor = new Color("#001447")
- }
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.Loading", new LoadingStyle()
- {
- LoadingSize = new Size(100, 100),
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.Pagination", new PaginationStyle()
- {
- IndicatorImageUrl = new Selector<string>()
- {
- Normal = FrameworkInformation.ResourcePath + "nui_component_default_pagination_normal_dot.png",
- Selected = FrameworkInformation.ResourcePath + "nui_component_default_pagination_focus_dot.png",
- },
- IndicatorSize = new Size(10, 10),
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
- {
- TrackThickness = 12,
- ThumbThickness = 12,
- TrackColor = new Color(0f, 0f, 0f, 0f),
- ThumbColor = new Color("#0A0E4AFF"),
- TrackPadding = 4,
- ThumbVerticalImageUrl = FrameworkInformation.ResourcePath + "nui_component_default_scroll_vbar.#.png",
- ThumbHorizontalImageUrl = FrameworkInformation.ResourcePath + "nui_component_default_scroll_hbar.#.png",
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.LinearLayouter", new ViewStyle()
- {
- Padding = new Extents(64, 64, 0, 0)
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.GridLayouter", new ViewStyle()
- {
- Padding = new Extents(0, 0, 0, 0),
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.ItemsLayouter", new ViewStyle()
- {
- Padding = new Extents(0, 0, 0, 0),
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.RecyclerViewItem", new RecyclerViewItemStyle()
- {
- BackgroundColor = new Selector<Color>()
- {
- Normal = new Color(1, 1, 1, 1),
- Pressed = new Color(0.85f, 0.85f, 0.85f, 1),
- Disabled = new Color(0.70f, 0.70f, 0.70f, 1),
- Selected = new Color(0.701f, 0.898f, 0.937f, 1),
- },
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultLinearItem", new DefaultLinearItemStyle()
- {
- SizeHeight = 108,
- Padding = new Extents(64, 64, 18, 17),
- Margin = new Extents(0, 0, 0, 0),
- BackgroundColor = new Selector<Color>()
- {
- Normal = new Color(1, 1, 1, 1),
- Pressed = new Color(0.85f, 0.85f, 0.85f, 1),
- Disabled = new Color(0.70f, 0.70f, 0.70f, 1),
- Selected = new Color(0.85f, 0.85f, 0.85f, 1),
- },
- Label = new TextLabelStyle()
- {
- PixelSize = 32,
- Ellipsis = true,
- FontFamily = "BreezeSans", //FXIME Font Weight is Light
- TextColor = new Color("#001447FF"),
- },
- SubLabel = new TextLabelStyle()
- {
- PixelSize = 28,
- Ellipsis = true,
- FontFamily = "BreezeSans",
- TextColor = new Color("#001447FF"),
- },
- Icon = new ViewStyle()
- {
- Margin = new Extents(0, 32, 0, 0)
- },
- Extra = new ViewStyle()
- {
- Margin = new Extents(32, 0, 0, 0)
- },
- Seperator = new ViewStyle()
- {
- SizeHeight = 1,
- Margin = new Extents(64, 64, 0, 0),
- BackgroundColor = new Color("#C3CAD2FF"),
- },
- });
- theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultGridItem", new DefaultGridItemStyle()
- {
- Padding = new Extents(0, 0, 0, 0),
- Margin = new Extents(5, 5, 5, 5),
- Caption = new TextLabelStyle()
- {
- SizeHeight = 60,
- PixelSize = 24,
- LineWrapMode = LineWrapMode.Character,
- },
- Badge = new ViewStyle()
- {
- Margin = new Extents(5, 5, 5, 5),
- },
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.DefaultTitleItem", new DefaultTitleItemStyle()
- {
- SizeHeight = 60,
- Padding = new Extents(64, 64, 12, 12),
- Margin = new Extents(0, 0, 0, 0),
- BackgroundColor = new Selector<Color>()
- {
- Normal = new Color("#EEEEF1FF"),
- },
- Label = new TextLabelStyle()
- {
- PixelSize = 28,
- Ellipsis = true,
- TextColor = new Color("#001447FF"),
- },
- Icon = new ViewStyle()
- {
- Margin = new Extents(40, 0, 0, 0)
- },
- Seperator = new ViewStyle()
- {
- Margin = new Extents(0, 0, 0, 0),
- BackgroundColor = new Color(0, 0, 0, 0),
- },
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.ContentPage", new ViewStyle()
- {
- BackgroundColor = new Color("#EEEFF1FF"),
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.AppBar", new AppBarStyle()
- {
- Size = new Size(-1, 120),
- BackgroundColor = new Color("#EEEFF1FF"),
- BackButton = new ButtonStyle()
- {
- Size = new Size(48, 48),
- CornerRadius = 0,
- BackgroundColor = new Color(0, 0, 0, 0),
- Icon = new ImageViewStyle()
- {
- Size = new Size(48, 48),
- ResourceUrl = FrameworkInformation.ResourcePath + "nui_component_default_back_button.png",
- Color = new Selector<Color>()
- {
- Normal = new Color("#0A0E4AFF"),
- Focused = new Color("#00338BFF"),
- Pressed = new Color("#1B69CAFF"),
- Disabled = new Color("#C3CAD2FF"),
- },
- },
- },
- TitleTextLabel = new TextLabelStyle()
- {
- PixelSize = 40,
- VerticalAlignment = VerticalAlignment.Center,
- TextColor = new Selector<Color>()
- {
- Normal = new Color("#000C2BFF"),
- }
- },
- ActionView = new ViewStyle()
- {
- Size = new Size(-1, 48),
- CornerRadius = 0,
- BackgroundColor = new Color(0, 0, 0, 0),
- },
- ActionButton = new ButtonStyle()
- {
- Size = new Size(-1, 48),
- CornerRadius = 0,
- BackgroundColor = new Color(0, 0, 0, 0),
- Text = new TextLabelStyle()
- {
- PixelSize = 26,
- TextColor = new Selector<Color>()
- {
- Normal = new Color("#0A0E4AFF"),
- Focused = new Color("#00338BFF"),
- Pressed = new Color("#1B69CAFF"),
- Disabled = new Color("#C3CAD2FF"),
- },
- },
- Icon = new ImageViewStyle()
- {
- Size = new Size(-1, 48),
- Color = new Selector<Color>()
- {
- Normal = new Color("#0A0E4AFF"),
- Focused = new Color("#00338BFF"),
- Pressed = new Color("#1B69CAFF"),
- Disabled = new Color("#C3CAD2FF"),
- },
- },
- },
- Padding = new Extents(64, 64, 0, 0),
- NavigationPadding = new Extents(0, 24, 0, 0),
- ActionPadding = new Extents(40, 0, 0, 0),
- ActionCellPadding = new Size2D(40, 0),
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.Picker", new PickerStyle()
- {
- Size = new Size(160, 339),
- ItemTextLabel = new TextLabelStyle()
- {
- //FIXME: Should be check PointSize. given size from UX is too large.
- PixelSize = 32,
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Center,
- Size = new Size(0,72),
- TextColor = new Selector<Color>()
- {
- Normal = new Color("#000C2BFF"),
- },
- BackgroundColor = Color.White,
- },
- Divider = new ViewStyle()
- {
- SizeHeight = 2.0f,
- WidthResizePolicy = ResizePolicyType.FillToParent,
- Position = new Position(0, 132),
- BackgroundColor = new Color("#0A0E4AFF"),
- },
- StartScrollOffset = new Size(0, 12),
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.TabButton", new TabButtonStyle()
- {
- Size = new Size(-1, 84),
- CornerRadius = 0,
- BackgroundColor = Color.White,
- Text = new TextLabelStyle()
- {
- PixelSize = 28,
- Size = new Size(-2, -2),
- TextColor = new Selector<Color>()
- {
- Normal = new Color("#000C2BFF"),
- Selected = new Color("#000C2BFF"),
- Pressed = new Color("#1473E6FF"),
- Disabled = new Color("#C3CAD2FF"),
- },
- },
- Icon = new ImageViewStyle()
- {
- Size = new Size(48, 48),
- Color = new Selector<Color>()
- {
- Normal = new Color("#000C2BFF"),
- Selected = new Color("#000C2BFF"),
- Pressed = new Color("#1473E6FF"),
- Disabled = new Color("#C3CAD2FF"),
- },
- },
- TopLine = new ViewStyle()
- {
- Size = new Size(-1, 1),
- BackgroundColor = new Selector<Color>()
- {
- Normal = new Color("#000C2BFF"),
- Selected = new Color("#000C2BFF"),
- Pressed = new Color("#1473E6FF"),
- Disabled = new Color("#C3CAD2FF"),
- },
- },
- BottomLine = new ViewStyle()
- {
- Size = new Size(-1, 8),
- Position = new Position(0, 76), // 84 - 8
- BackgroundColor = new Selector<Color>()
- {
- Normal = Color.Transparent,
- Selected = new Color("#000C2BFF"),
- Pressed = new Color("#1473E6FF"),
- Disabled = Color.Transparent,
- },
- },
- });
-
- theme.AddStyleWithoutClone("NotificationToast", new TextLabelStyle()
- {
- BackgroundImage = FrameworkInformation.ResourcePath + "IoT_Toast_1.png",
- BackgroundImageBorder = new Rectangle(28, 28, 28, 28),
- TextColor = new Color("#000C2B"),
- PixelSize = 32,
- WidthResizePolicy = ResizePolicyType.UseNaturalSize,
- HeightResizePolicy = ResizePolicyType.UseNaturalSize,
- PositionUsesPivotPoint = true,
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Center,
- Padding = new Extents(40, 40, 24, 24),
- PositionY = 120,
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.TimePicker", new TimePickerStyle()
- {
- CellPadding = new Size(50, 339),
-
- Pickers = new PickerStyle()
- {
- Size = new Size(160, 339),
- ItemTextLabel = new TextLabelStyle()
- {
- //FIXME: Should be check PointSize. given size from UX is too large.
- PixelSize = 32,
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Center,
- Size = new Size(0,72),
- TextColor = new Selector<Color>()
- {
- Normal = new Color("#000C2BFF"),
- },
- BackgroundColor = Color.White,
- },
- Divider = new ViewStyle()
- {
- SizeHeight = 2.0f,
- WidthResizePolicy = ResizePolicyType.FillToParent,
- Position = new Position(0, 132),
- BackgroundColor = new Color("#0A0E4AFF"),
- },
- StartScrollOffset = new Size2D(0, 12),
- }
- });
-
- theme.AddStyleWithoutClone("Tizen.NUI.Components.DatePicker", new DatePickerStyle()
- {
- CellPadding = new Size(50, 339),
-
- Pickers = new PickerStyle()
- {
- Size = new Size(160, 339),
- ItemTextLabel = new TextLabelStyle()
- {
- //FIXME: Should be check PointSize. given size from UX is too large.
- PixelSize = 32,
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Center,
- Size = new Size(0,72),
- TextColor = new Selector<Color>()
- {
- Normal = new Color("#000C2BFF"),
- },
- BackgroundColor = Color.White,
- },
- Divider = new ViewStyle()
- {
- SizeHeight = 2.0f,
- WidthResizePolicy = ResizePolicyType.FillToParent,
- Position = new Position(0, 132),
- BackgroundColor = new Color("#0A0E4AFF"),
- },
- StartScrollOffset = new Size2D(0, 12),
- }
- });
-
- return theme;
- }
- }
-}
-
-#endif
[EditorBrowsable(EditorBrowsableState.Never)]
public sealed class StyleManager
{
+ private const string defaultName = "DEFAULT";
+
/// <summary>
/// StyleManager construct.
/// </summary>
var key = value.ToUpperInvariant();
+ if (key.Equals(defaultName))
+ {
+ ThemeManager.CurrentTheme = null;
+ return;
+ }
+
// Please note that it does not check "key == Theme" here,
// because of the font size issue of the Tizen.NUI.StyleManager.
// (There are applications to use NUI.Components.StyleManager.ThemeChangedEvent to fix Tizen.NUI.StyleManager font size issue.)
/// <summary>
/// (Theme name, Theme instance)
/// </summary>
- private Dictionary<string, Theme> ThemeMap { get; } = new Dictionary<string, Theme> { ["DEFAULT"] = ThemeManager.DefaultTheme };
+ private Dictionary<string, Theme> ThemeMap { get; } = new Dictionary<string, Theme>();
/// <summary>
/// Register style in StyleManager.
if (Activator.CreateInstance(styleType) is StyleBase styleBase)
{
- var key = "DEFAULT";
-
- if (bDefault && theme != null)
+ if (string.IsNullOrEmpty(theme) || defaultName.Equals(theme, StringComparison.CurrentCultureIgnoreCase))
{
- ThemeMap[key].AddStyleWithoutClone(style, styleBase.GetViewStyle());
+ ThemeManager.BaseTheme.AddStyleWithoutClone(style, styleBase.GetViewStyle());
+ ThemeManager.UpdateThemeForInitialize();
+ return;
}
- if (theme != null)
- {
- key = theme.ToUpperInvariant();
- }
+ var key = theme.ToUpperInvariant();
if (!ThemeMap.ContainsKey(key) || ThemeMap[key] == null)
{
}
ThemeMap[key].AddStyleWithoutClone(style, styleBase.GetViewStyle());
+
+ if (bDefault)
+ {
+ ThemeManager.BaseTheme.AddStyleWithoutClone(style, styleBase.GetViewStyle());
+ ThemeManager.UpdateThemeForInitialize();
+ }
}
}
throw new ArgumentException("The argument targetTheme must be specified");
}
- var key = targetTheme.ToUpperInvariant();
-
- if (!ThemeMap.ContainsKey(key) || ThemeMap[key] == null)
+ if (Activator.CreateInstance(style) is StyleBase styleBase)
{
- Tizen.Log.Error("NUI", "The theme name should be a known one.");
- return;
- }
+ if (defaultName.Equals(targetTheme, StringComparison.CurrentCultureIgnoreCase))
+ {
+ ThemeManager.BaseTheme.AddStyleWithoutClone(component.FullName, styleBase.GetViewStyle());
+ ThemeManager.UpdateThemeForInitialize();
+ return;
+ }
- if (Activator.CreateInstance(style) as StyleBase != null)
- {
- ThemeMap[key].AddStyleWithoutClone(component.FullName, (Activator.CreateInstance(style) as StyleBase).GetViewStyle());
+ var key = targetTheme.ToUpperInvariant();
+
+ if (!ThemeMap.ContainsKey(key) || ThemeMap[key] == null)
+ {
+ Tizen.Log.Error("NUI", "The theme name should be a known one.");
+ return;
+ }
+
+ if (Activator.CreateInstance(style) as StyleBase != null)
+ {
+ ThemeMap[key].AddStyleWithoutClone(component.FullName, styleBase.GetViewStyle());
+ }
}
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<Theme
- xmlns="http://tizen.org/Tizen.NUI/2018/XAML"
- xmlns:c="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components"
- xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- Id="Tizen.NUI.Theme.Common" >
-
- <!--Button-->
- <c:ButtonStyle x:Key="Tizen.NUI.Components.Button" Size="100, 45">
- <c:ButtonStyle.BackgroundColor>
- <Selector x:TypeArguments="Color" Normal="0.88, 0.88, 0.88, 1" Pressed="0.77, 0.77, 0.77, 1" Disabled="0.88, 0.88, 0.88, 1"/>
- </c:ButtonStyle.BackgroundColor>
- <c:ButtonStyle.Text>
- <!--Button Text-->
- <TextLabelStyle PointSize="12">
- <TextLabelStyle.TextColor>
- <Selector x:TypeArguments="Color" Normal="0.22, 0.22, 0.22, 1" Pressed="0.11, 0.11, 0.11, 1" Disabled="0.66, 0.66, 0.66, 1"/>
- </TextLabelStyle.TextColor>
- </TextLabelStyle>
- </c:ButtonStyle.Text>
- </c:ButtonStyle>
-
- <!--CheckBox-->
- <c:ButtonStyle x:Key="Tizen.NUI.Components.CheckBox" Size="30, 30">
- <c:ButtonStyle.Icon>
- <!--CheckBox Icon-->
- <ImageViewStyle>
- <ImageViewStyle.Opacity>
- <Selector x:TypeArguments="x:Single?" Normal="1.0" Selected="1.0" Disabled="0.4" DisabledSelected="0.4"/>
- </ImageViewStyle.Opacity>
- <ImageViewStyle.BackgroundImage>
- <Selector x:TypeArguments="x:String" Pressed="{NUIResourcePath nui_component_default_checkbox_bg_p.png}" Selected="{NUIResourcePath nui_component_default_checkbox_bg_p.png}" Other="{NUIResourcePath nui_component_default_checkbox_bg_n.png}"/>
- </ImageViewStyle.BackgroundImage>
- <ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Selected="{NUIResourcePath nui_component_default_checkbox_s.png}" Other=""/>
- </ImageViewStyle.ResourceUrl>
- </ImageViewStyle>
- </c:ButtonStyle.Icon>
- <c:ButtonStyle.Text>
- <!--CheckBox Text-->
- <TextLabelStyle PointSize="12">
- <TextLabelStyle.TextColor>
- <Selector x:TypeArguments="Color" Normal="0.22, 0.22, 0.22, 1" Pressed="0.11, 0.11, 0.11, 1" Disabled="0.66, 0.66, 0.66, 1"/>
- </TextLabelStyle.TextColor>
- </TextLabelStyle>
- </c:ButtonStyle.Text>
- </c:ButtonStyle>
-
- <!--Popup-->
- <c:PopupStyle x:Key="Tizen.NUI.Components.Popup" Size="500, 280" BackgroundColor="0.9, 0.9, 0.9, 1" ImageShadow="">
- <c:PopupStyle.ImageShadow>
- <ImageShadow>
- <x:Arguments>
- <x:String>{NUIResourcePath nui_component_default_popup_shadow.png}</x:String>
- <Rectangle>24, 24, 24, 24</Rectangle>
- <Vector2>0, 0</Vector2>
- <Vector2>48, 48</Vector2>
- </x:Arguments>
- </ImageShadow>
- </c:PopupStyle.ImageShadow>
- <c:PopupStyle.Title>
- <TextLabelStyle PointSize="16" Padding="20" />
- </c:PopupStyle.Title>
- <c:PopupStyle.Buttons>
- <c:ButtonStyle Size="0, 80">
- <c:ButtonStyle.BackgroundColor>
- <Selector x:TypeArguments="Color" Normal="1, 1, 1, 1" Pressed="1, 1, 1, 0.5"/>
- </c:ButtonStyle.BackgroundColor>
- <c:ButtonStyle.Overlay>
- <ImageViewStyle>
- <ImageViewStyle.BackgroundColor>
- <Selector x:TypeArguments="Color" Normal="1, 1, 1, 1" Pressed="0, 0, 0, 0.1" Selected="1, 1, 1, 1"/>
- </ImageViewStyle.BackgroundColor>
- </ImageViewStyle>
- </c:ButtonStyle.Overlay>
- <c:ButtonStyle.Text>
- <TextLabelStyle TextColor="0.05, 0.63, 0.9, 1" />
- </c:ButtonStyle.Text>
- </c:ButtonStyle>
- </c:PopupStyle.Buttons>
- </c:PopupStyle>
-
- <!--Progress-->
- <c:ProgressStyle x:Key="Tizen.NUI.Components.Progress" Size="200, 5">
- <c:ProgressStyle.Track>
- <ImageViewStyle BackgroundColor="0, 0, 0, 0.1" />
- </c:ProgressStyle.Track>
- <c:ProgressStyle.Buffer>
- <ImageViewStyle BackgroundColor="0.05, 0.63, 0.9, 0.3" />
- </c:ProgressStyle.Buffer>
- <c:ProgressStyle.Progress>
- <ImageViewStyle BackgroundColor="0.05, 0.63, 0.9, 1" />
- </c:ProgressStyle.Progress>
- </c:ProgressStyle>
-
- <!--RadioButton-->
- <c:ButtonStyle x:Key="Tizen.NUI.Components.RadioButton" Size="30, 30">
- <c:ButtonStyle.Icon>
- <ImageViewStyle>
- <ImageViewStyle.Opacity>
- <Selector x:TypeArguments="x:Single?" Normal="1" Selected="1" Disabled="0.4" DisabledSelected="0.4"/>
- </ImageViewStyle.Opacity>
- <ImageViewStyle.BackgroundImage>
- <Selector x:TypeArguments="x:String" Pressed="{NUIResourcePath nui_component_default_radiobutton_p.png}" Selected="{NUIResourcePath nui_component_default_radiobutton_s.png}" Other="{NUIResourcePath nui_component_default_radiobutton_n.png}" />
- </ImageViewStyle.BackgroundImage>
- </ImageViewStyle>
- </c:ButtonStyle.Icon>
- <c:ButtonStyle.Text>
- <TextLabelStyle PointSize="12">
- <TextLabelStyle.TextColor>
- <Selector x:TypeArguments="Color" Normal="0.22, 0.22, 0.22, 1" Pressed="0.11, 0.11, 0.11, 1" Disabled="0.66, 0.66, 0.66, 1" />
- </TextLabelStyle.TextColor>
- </TextLabelStyle>
- </c:ButtonStyle.Text>
- </c:ButtonStyle>
-
- <!--Slider-->
- <c:SliderStyle x:Key="Tizen.NUI.Components.Slider" Size="200, 50" TrackThickness="5">
- <c:SliderStyle.Track>
- <ImageViewStyle BackgroundColor="0, 0, 0, 0.1" />
- </c:SliderStyle.Track>
- <c:SliderStyle.Progress>
- <ImageViewStyle BackgroundColor="0.5, 0.63, 0.9, 1" />
- </c:SliderStyle.Progress>
- <c:SliderStyle.Thumb>
- <ImageViewStyle Size="50, 50" ResourceUrl="{NUIResourcePath nui_component_default_slider_thumb_n.png}">
- <ImageViewStyle.BackgroundImage>
- <Selector x:TypeArguments="x:String" Normal="" Pressed="{NUIResourcePath nui_component_default_slider_thumb_bg_p.png}" />
- </ImageViewStyle.BackgroundImage>
- </ImageViewStyle>
- </c:SliderStyle.Thumb>
- </c:SliderStyle>
-
- <!--Switch-->
- <c:SwitchStyle x:Key="Tizen.NUI.Components.Switch" Size="96, 60">
- <c:Switch.Track>
- <ImageViewStyle Size="96, 60">
- <ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="{NUIResourcePath nui_component_default_switch_track_n.png}" Selected="{NUIResourcePath nui_component_default_switch_track_s.png}" Disabled="{NUIResourcePath nui_component_default_switch_track_d.png}" DisabledSelected="{NUIResourcePath nui_component_default_switch_track_ds.png}" />
- </ImageViewStyle.ResourceUrl>
- </ImageViewStyle>
- </c:Switch.Track>
- <c:Switch.Thumb>
- <ImageViewStyle Size="60, 60">
- <ImageViewStyle.ResourceUrl>
- <Selector x:TypeArguments="x:String" Normal="{NUIResourcePath nui_component_default_switch_thumb_n.png}" Disabled="{NUIResourcePath nui_component_default_switch_thumb_d.png}" Selected="{NUIResourcePath nui_component_default_switch_thumb_n.png}" />
- </ImageViewStyle.ResourceUrl>
- </ImageViewStyle>
- </c:Switch.Thumb>
- <c:Switch.Text>
- <TextLabelStyle PointSize="12">
- <TextLabelStyle.TextColor>
- <Selector x:TypeArguments="Color" Normal="0.22, 0.22, 0.22, 1" Pressed="0.11, 0.11, 0.11, 1" Disabled="0.66, 0.66, 0.66, 1" />
- </TextLabelStyle.TextColor>
- </TextLabelStyle>
- </c:Switch.Text>
- </c:SwitchStyle>
-
- <!--Loading-->
- <c:LoadingStyle x:Key="Tizen.NUI.Components.Loading" LoadingSize="100, 100" />
-
- <!--Pagination-->
- <c:PaginationStyle x:Key="Tizen.NUI.Components.Pagination">
- <c:PaginationStyle.IndicatorImageUrl>
- <Selector x:TypeArguments="x:String" Normal="{NUIResourcePath nui_component_default_pagination_normal_dot.png}" Selected="{NUIResourcePath nui_component_default_pagination_focus_dot.png}" />
- </c:PaginationStyle.IndicatorImageUrl>
- </c:PaginationStyle>
-
- <!--Scrollbar-->
- <c:ScrollbarStyle x:Key="Tizen.NUI.Components.Scrollbar" TrackThickness="8" ThumbThickness="8" TrackColor="0.435, 0.435, 0.435, 0.1" ThumbColor="0, 0, 0, 0.2" TrackPadding="8" />
-
-</Theme>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<Theme
- xmlns="http://tizen.org/Tizen.NUI/2018/XAML"
- xmlns:c="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components"
- xmlns:cx="clr-namespace:Tizen.NUI.Components.Extension;assembly=Tizen.NUI.Components"
- xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- Id="Tizen.NUI.Theme.Wearable">
-
- <!--Button-->
- <c:ButtonStyle x:Key="Tizen.NUI.Components.Button" Size="210, 72" CornerRadius="36">
- <c:ButtonStyle.BackgroundColor>
- <Selector x:TypeArguments="Color" Normal="0, 0.1647, 0.3019, 0.85" Pressed="0, 0.2475, 0.5019, 0.85" Disabled="0.2392, 0.2392, 0.2392, 0.85"/>
- </c:ButtonStyle.BackgroundColor>
- <c:ButtonStyle.Opacity>
- <Selector x:TypeArguments="x:Single?" Other="1.0" Disabled="0.3"/>
- </c:ButtonStyle.Opacity>
- <c:ButtonStyle.Text>
- <!--Button Text-->
- <TextLabelStyle FontFamily="SamsungOne 700" PixelSize="28" Padding="20, 20, 0, 0" HorizontalAlignment="Center" VerticalAlignment="Center">
- <TextLabelStyle.TextColor>
- <Selector x:TypeArguments="Color" Normal="0.2196, 0.6131, 0.9882, 1" Disabled="1, 1, 1, 0.35"/>
- </TextLabelStyle.TextColor>
- </TextLabelStyle>
- </c:ButtonStyle.Text>
- </c:ButtonStyle>
-
- <!--CheckBox-->
- <cx:LottieButtonStyle x:Key="Tizen.NUI.Components.CheckBox" LottieUrl="NUIResourcePath nui_wearable_checkbox_icon.json">
- <cx:LottieButtonStyle.PlayRange>
- <Selector x:TypeArguments="LottieFrameInfo" Selected="19, 36" Normal="0, 18"/>
- </cx:LottieButtonStyle.PlayRange>
- <cx:LottieButtonStyle.Opacity>
- <Selector x:TypeArguments="x:Single?" Other="1" Pressed="0.6" Disabled="0.3"/>
- </cx:LottieButtonStyle.Opacity>
- </cx:LottieButtonStyle>
-
- <!--RadioButton-->
- <cx:LottieButtonStyle x:Key="Tizen.NUI.Components.RadioButton" LottieUrl="NUIResourcePath nui_wearable_radiobutton_icon.json">
- <cx:LottieButtonStyle.PlayRange>
- <Selector x:TypeArguments="LottieFrameInfo" Selected="0, 12" Normal="13, 25"/>
- </cx:LottieButtonStyle.PlayRange>
- <cx:LottieButtonStyle.Opacity>
- <Selector x:TypeArguments="x:Single?" Other="1" Pressed="0.6" Disabled="0.3"/>
- </cx:LottieButtonStyle.Opacity>
- </cx:LottieButtonStyle>
-
- <!--Switch-->
- <cx:LottieSwitchStyle x:Key="Tizen.NUI.Components.Switch" LottieUrl="NUIResourcePath nui_wearable_switch_icon.json">
- <cx:LottieSwitchStyle.PlayRange>
- <Selector x:TypeArguments="LottieFrameInfo" Selected="0, 18" Normal="19, 36"/>
- </cx:LottieSwitchStyle.PlayRange>
- <cx:LottieSwitchStyle.Opacity>
- <Selector x:TypeArguments="x:Single?" Other="1" Pressed="0.6" Disabled="0.3"/>
- </cx:LottieSwitchStyle.Opacity>
- </cx:LottieSwitchStyle>
-
- <!--Loading-->
- <c:LoadingStyle x:Key="Tizen.NUI.Components.Loading" LoadingSize="360, 360" />
-
-</Theme>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<Theme
- xmlns="http://tizen.org/Tizen.NUI/2018/XAML"
- xmlns:c="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components"
- xmlns:w="clr-namespace:Tizen.NUI.Wearable;assembly=Tizen.NUI.Wearable"
- xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- Id="Tizen.NUI.Theme.Common" >
-
- <!--CircularPagination-->
- <w:CircularPaginationStyle x:Key="Tizen.NUI.Wearable.CircularPagination" IndicatorSize="10, 10">
- <w:CircularPaginationStyle.IndicatorImageURL>
- <Selector x:TypeArguments="x:String" Normal="{NUIResourcePath nui_component_default_pagination_normal_dot.png}" Selected="{NUIResourcePath nui_component_default_pagination_focus_dot.png}" />
- </w:CircularPaginationStyle.IndicatorImageURL>
- <w:CircularPaginationStyle.CenterIndicatorImageURL>
- <Selector x:TypeArguments="x:String" Normal="{NUIResourcePath nui_wearable_circular_pagination_center_normal_dot.png}" Selected="{NUIResourcePath nui_wearable_circular_pagination_center_focus_dot.png}" />
- </w:CircularPaginationStyle.CenterIndicatorImageURL>
- </w:CircularPaginationStyle>
-
- <!--CircularProgress-->
- <w:CircularProgressStyle x:Key="Tizen.NUI.Wearable.CircularProgress" Thickness="6" MaxValue="100" MinValue="0" CurrentValue="0" TrackColor="0, 0.16, 0.3, 1" ProgressColor="0, 0.55, 1, 1" />
-
- <!--CircularScrollbar-->
- <w:CircularScrollbarStyle x:Key="Tizen.NUI.Wearable.CircularScrollbar" Thickness="10" TrackSweepAngle="60" TrackColor="1, 1, 1, 0.15" ThumbColor="0.6, 0.6, 0.6, 1" />
-
- <!--CircularSlider-->
- <w:CircularSliderStyle x:Key="Tizen.NUI.Wearable.CircularSlider" Thickness="6" MaxValue="100" MinValue="0" CurrentValue="0" TrackColor="0, 0.16, 0.3, 1" ProgressColor="0, 0.55, 1, 1" ThumbSize="19, 19" ThumbColor="0, 0.55, 1, 1"/>
-
-</Theme>
\ No newline at end of file
return theme;
}
-
- public HashSet<ExternalThemeKeyList> GetExternalThemeKeyListSet() => null;
}
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<Theme xmlns="http://tizen.org/Tizen.NUI/2018/XAML" Id="Tizen.NUI.Theme.Common" >
-</Theme>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<Theme
- xmlns="http://tizen.org/Tizen.NUI/2018/XAML"
- Id="Tizen.NUI.Theme.Wearable"
- BasedOn="Tizen.NUI.Theme.Common">
-</Theme>
\ No newline at end of file
[SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
public NUIApplication() : base(new NUICoreBackend())
{
- ExternalThemeManager.Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public NUIApplication(Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
{
- ExternalThemeManager.Initialize();
}
/// <summary>
[SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
public NUIApplication(string styleSheet) : base(new NUICoreBackend(styleSheet))
{
- ExternalThemeManager.Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public NUIApplication(string styleSheet, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, WindowMode.Opaque, windowSize, windowPosition))
{
- ExternalThemeManager.Initialize();
}
/// <summary>
[SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
public NUIApplication(string styleSheet, WindowMode windowMode) : base(new NUICoreBackend(styleSheet, windowMode))
{
- ExternalThemeManager.Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public NUIApplication(string styleSheet, WindowMode windowMode, Size2D windowSize, Position2D windowPosition) : base(new NUICoreBackend(styleSheet, windowMode, windowSize, windowPosition))
{
- ExternalThemeManager.Initialize();
}
/// <summary>
//windowMode and styleSheet will be added later. currently it's not working as expected.
Graphics.Backend = backend;
Tizen.Log.Error("NUI", "Plaese DO NOT set graphical backend type with this constructor! This will give no effect!");
- ExternalThemeManager.Initialize();
+ }
+
+ /// <summary>
+ /// The constructor with theme option.
+ /// </summary>
+ /// <param name="option">The theme option.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
+ public NUIApplication(ThemeOptions option) : base(new NUICoreBackend())
+ {
+ ApplyThemeOption(option);
+ }
+
+ /// <summary>
+ /// The constructor with window size and position and theme option.
+ /// </summary>
+ /// <param name="windowSize">The window size.</param>
+ /// <param name="windowPosition">The window position.</param>
+ /// <param name="option">The theme option.</param>
+ [SuppressMessage("Microsoft.Design", "CA2000: Dispose objects before losing scope", Justification = "NUICoreBackend is disposed in the base class when the application is terminated")]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public NUIApplication(Size2D windowSize, Position2D windowPosition, ThemeOptions option) : base(new NUICoreBackend("", NUIApplication.WindowMode.Opaque, windowSize, windowPosition))
+ {
+ ApplyThemeOption(option);
}
/// <summary>
}
/// <summary>
+ /// Enumeration for theme options of the NUIApplication.
+ /// </summary>
+ [Flags]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum ThemeOptions : int
+ {
+ /// <summary>
+ /// No option specified.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ None = 0,
+
+ /// <summary>
+ /// Enable platform theme.
+ /// When this option is on, all views in the NUIApplication is affected by platform theme (e.g. light/dark).
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ PlatformThemeEnabled = 1 << 0,
+
+ /// <summary>
+ /// Sets the default value of View.ThemeChangeSensitive.
+ /// when this option is on, all views are made sensitive on theme changing by default.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ ThemeChangeSensitive = 1 << 1,
+ };
+
+ /// <summary>
/// ResourceManager to handle multilingual.
/// </summary>
/// <since_tizen> 4 </since_tizen>
static public void Preload()
{
Interop.Application.PreInitialize();
- ThemeManager.AddPackageTheme(DefaultThemeCreator.Instance);
+ ThemeManager.Preload();
IsPreload = true;
}
/// Check if it is loaded as dotnet-loader-nui.
/// </summary>
static internal bool IsPreload { get; set; }
+
+ private void ApplyThemeOption(ThemeOptions option)
+ {
+ if ((option & ThemeOptions.PlatformThemeEnabled) != 0)
+ {
+ ThemeManager.PlatformThemeEnabled = true;
+ }
+
+ if ((option & ThemeOptions.ThemeChangeSensitive) != 0)
+ {
+ ThemeManager.ApplicationThemeChangeSensitive = true;
+ }
+ }
}
/// <summary>
}
/// <summary>
+ /// The flag that is used when creating a component with this style.
+ /// If the value is true, it will include default component style defined in the default theme.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool IncludeDefaultStyle { get; set; } = false;
+
+ /// <summary>
/// Gets or sets the image resource url of the background of view.
/// The mutually exclusive with "BackgroundColor". Setting it overwrites existing "BackgroundColor".
/// </summary>
SetValue(destinationProperty, sourceValue);
}
}
+
+ IncludeDefaultStyle = source.IncludeDefaultStyle;
}
/// <summary>
private TransitionOptions transitionOptions = null;
private ThemeData themeData;
- internal class ThemeData
- {
- public bool controlStatePropagation = false;
- public ViewStyle viewStyle;
- public bool themeChangeSensitive = false;
- public ControlState controlStates = ControlState.Normal;
- public ViewSelectorData selectorData;
- }
-
static View()
{
RegisterPropertyGroup(PositionProperty, positionPropertyGroup);
public static bool LayoutingDisabled { get; set; } = true;
/// <summary>
+ /// Deprecate. Please do not use this.
/// The style instance applied to this view.
/// Note that please do not modify the ViewStyle.
/// Modifying ViewStyle will affect other views with same ViewStyle.
ControlStateChangeEventInternal?.Invoke(this, changeInfo);
- if (themeData.controlStatePropagation)
+ if (themeData.ControlStatePropagation)
{
foreach (View child in Children)
{
[EditorBrowsable(EditorBrowsableState.Never)]
public bool EnableControlStatePropagation
{
- get => themeData?.controlStatePropagation ?? false;
+ get => themeData?.ControlStatePropagation ?? false;
set
{
if (EnableControlStatePropagation == value) return;
if (themeData == null) themeData = new ThemeData();
- themeData.controlStatePropagation = value;
+ themeData.ControlStatePropagation = value;
foreach (View child in Children)
{
/// <summary>
/// If the value is true, the View will change its style as the theme changes.
- /// It is false by default, but turned to true when setting StyleName (by setting property or using specified constructor).
+ /// The default value is false in normal case but it can be true when the NUIApplication is created with <see cref="NUIApplication.ThemeOptions.ThemeChangeSensitive"/>.
/// </summary>
/// <since_tizen> 9 </since_tizen>
public bool ThemeChangeSensitive
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void OnThemeChanged(object sender, ThemeChangedEventArgs e)
{
- UpdateStyle();
+ if (string.IsNullOrEmpty(styleName)) ApplyStyle(ThemeManager.GetUpdateStyleWithoutClone(GetType()));
+ else ApplyStyle(ThemeManager.GetUpdateStyleWithoutClone(styleName));
}
/// <summary>
Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)view.SwigCPtr, View.Property.StyleName, new Tizen.NUI.PropertyValue(styleName));
view.styleName = styleName;
- view.UpdateStyle();
- view.ThemeChangeSensitive = true;
+
+ if (string.IsNullOrEmpty(styleName)) return;
+
+ var style = ThemeManager.GetUpdateStyleWithoutClone(styleName);
+
+ if (style == null) return;
+
+ view.ApplyStyle(style);
+ view.SetThemeApplied();
}
}),
defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) =>
if (view.themeData == null) view.themeData = new ThemeData();
- view.themeData.themeChangeSensitive = (bool)newValue;
+ view.themeData.ThemeChangeSensitive = (bool)newValue;
+
+ if (!view.themeData.ThemeApplied) return;
- if (view.themeData.themeChangeSensitive)
+ if (view.themeData.ThemeChangeSensitive && !view.themeData.ListeningThemeChangeEvent)
{
+ view.themeData.ListeningThemeChangeEvent = true;
ThemeManager.ThemeChangedInternal.Add(view.OnThemeChanged);
}
- else
+ else if (!view.themeData.ThemeChangeSensitive && view.themeData.ListeningThemeChangeEvent)
{
+ view.themeData.ListeningThemeChangeEvent = false;
ThemeManager.ThemeChangedInternal.Remove(view.OnThemeChanged);
}
},
defaultValueCreator: (bindable) =>
{
- return ((View)bindable).themeData?.themeChangeSensitive ?? false;
+ return ((View)bindable).themeData?.ThemeChangeSensitive ?? ThemeManager.ApplicationThemeChangeSensitive;
});
/// <summary>
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace Tizen.NUI.BaseComponents
{
internal string styleName;
+ internal class ThemeData
+ {
+ [Flags]
+ private enum States : byte
+ {
+ None = 0,
+ ControlStatePropagation = 1 << 0,
+ ThemeChangeSensitive = 1 << 1,
+ ThemeApplied = 1 << 2, // It is true when the view has valid style name or the platform theme has a component style for this view type.
+ // That indicates the view can have different styles by theme.
+ // Hence if the current state has ThemeApplied and ThemeChangeSensitive, the view will change its style by theme changing.
+ ListeningThemeChangeEvent = 1 << 3,
+ };
+
+ private States states = ThemeManager.ApplicationThemeChangeSensitive ? States.ThemeChangeSensitive : States.None;
+ public ViewStyle viewStyle;
+ public ControlState controlStates = ControlState.Normal;
+ public ViewSelectorData selectorData;
+
+ public bool ControlStatePropagation
+ {
+ get => ((states & States.ControlStatePropagation) != 0);
+ set => SetOption(States.ControlStatePropagation, value);
+ }
+
+ public bool ThemeChangeSensitive
+ {
+ get => ((states & States.ThemeChangeSensitive) != 0);
+ set => SetOption(States.ThemeChangeSensitive, value);
+ }
+
+ public bool ThemeApplied
+ {
+ get => ((states & States.ThemeApplied) != 0);
+ set => SetOption(States.ThemeApplied, value);
+ }
+
+ public bool ListeningThemeChangeEvent
+ {
+ get => ((states & States.ListeningThemeChangeEvent) != 0);
+ set => SetOption(States.ListeningThemeChangeEvent, value);
+ }
+
+ private void SetOption(States option, bool value)
+ {
+ if (value) states |= option;
+ else states &= ~option;
+ }
+ }
+
/// <summary>
/// The color mode of View.
/// This specifies whether the View uses its own color, or inherits its parent color.
return value == null ? null : new Selector<T>(value);
}
+ internal void SetThemeApplied()
+ {
+ if (themeData == null) themeData = new ThemeData();
+ themeData.ThemeApplied = true;
+
+ if (ThemeChangeSensitive && !themeData.ListeningThemeChangeEvent)
+ {
+ themeData.ListeningThemeChangeEvent = true;
+ ThemeManager.ThemeChangedInternal.Add(OnThemeChanged);
+ }
+ }
+
/// <summary>
/// you can override it to clean-up your own resources.
/// </summary>
//Called by User
//Release your own managed resources here.
//You should release all of your own disposable objects here.
- themeData?.selectorData?.Reset(this);
- if (ThemeChangeSensitive)
+ if (themeData != null)
{
- ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
+ themeData.selectorData?.Reset(this);
+ if (themeData.ListeningThemeChangeEvent)
+ {
+ ThemeManager.ThemeChangedInternal.Remove(OnThemeChanged);
+ }
}
}
/// Apply initial style to the view.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- protected void InitializeStyle(ViewStyle style = null)
+ protected virtual void InitializeStyle(ViewStyle style = null)
{
- if (style != null) ApplyStyle(style); // Use given style
- else UpdateStyle(); // Use style in the current theme
+ // First, apply initial style if needs.
+ var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
+ if (style == null || style.IncludeDefaultStyle)
+ {
+ ApplyStyle(initialStyle);
+ }
+
+ // Then, apply given style.
+ ApplyStyle(style);
+
+ // Listen theme change event if needs.
+ if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
+ {
+ SetThemeApplied();
+ }
}
private View ConvertIdToView(uint id)
return false;
}
- private void UpdateStyle()
- {
- ViewStyle newStyle;
- if (string.IsNullOrEmpty(styleName)) newStyle = ThemeManager.GetStyleWithoutClone(GetType());
- else newStyle = ThemeManager.GetStyleWithoutClone(styleName);
-
- if (newStyle != null)
- {
- ApplyStyle(newStyle);
- }
- }
-
private ViewSelectorData EnsureSelectorData()
{
if (themeData == null) themeData = new ThemeData();
internal const string DefaultVersion = "1.0.0";
internal static IThemeCreator Instance { get; set; } = new DefaultThemeCreator();
-
- public HashSet<ExternalThemeKeyList> GetExternalThemeKeyListSet() => null;
}
}
{
internal partial class DefaultThemeCreator
{
+ /// <summary>
+ /// The base theme description.
+ /// </summary>
[SuppressMessage("Microsoft.Reliability", "CA2000: Dispose objects before losing scope", Justification = "The responsibility to dispose the object is transferred to the theme object.")]
public Theme Create()
{
}
}
}
-#endif
+
+#endif // !PROFILE_TV
+++ /dev/null
-/*
- * Copyright(c) 2021 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#if DEBUG
-
-using System.Collections.Generic;
-
-namespace Tizen.NUI
-{
- /// <summary>
- /// This is a helper class to test external theme applying.
- /// </summary>
- internal class DictionaryExternalTheme : IExternalTheme
- {
- private readonly Dictionary<string, string> theme;
-
- public DictionaryExternalTheme(string id, string version, Dictionary<string, string> theme)
- {
- Id = id;
- Version = version;
- this.theme = theme;
- }
-
- public string Id { get; }
-
- public string Version { get; }
-
- public string GetValue(string key)
- {
- theme.TryGetValue(key, out string extracted);
-
- return extracted;
- }
- }
-}
-#endif
+++ /dev/null
-/*
- * Copyright(c) 2021 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Reflection;
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Xaml;
-
-namespace Tizen.NUI
-{
- /// <summary>
- /// This class holds a list of string key and corresponding setter function.
- /// <para>
- /// Key
- /// Represents a specific property in a style, for example,
- /// the key "/Text/PixelSize" of styleType "Button" means "ButtonStyle.Text.PixelSize".
- /// </para>
- /// <para>
- /// Action
- /// One action takes two values,
- /// * viewStyle : A style instance in a theme.
- /// * value: A string value that will overwrite a property value in a given viewStyle.
- /// The action parses a given string value into a typed object and set it to the viewStyle.
- /// </para>
- /// </summary>
- internal class ExternalThemeKeyList
- {
- private Type componentType;
- private Type styleType;
- private object selectorData;
- private List<KeyActionPair> list = new List<KeyActionPair>();
-
- /// <summary>
- /// Create a new key list
- /// For example,
- /// <code>
- /// new ExternalThemeKeyList(typeof(Button), typeof(ButtonStyle));
- /// </code>
- /// This means that the keys are related with ButtonStyle and they are defined to decorate Button component.
- /// </summary>
- internal ExternalThemeKeyList(Type componentType, Type styleType)
- {
- this.componentType = componentType;
- this.styleType = styleType;
- }
-
- /// <summary>
- /// Add a key with a corresponding action.
- /// For example,
- /// <code>
- /// var keyList = new ExternalThemeKeyList(typeof(Button), typeof(ButtonStyle));
- /// keyList.Add<Extents>("/Margin", (ViewStyle style, Extents value) => viewStyle.Margin = value);
- /// </code>
- /// </summary>
- internal ExternalThemeKeyList Add<T>(string key, Action<ViewStyle, T> setter)
- {
- list.Add(new KeyActionPair(componentType.Name + key, (ViewStyle viewStyle, string stringInput) =>
- {
- if (ParseXamlStringToObject<T>(stringInput) is T tValue)
- {
- if (tValue != null)
- {
- setter(viewStyle, tValue);
- }
- }
- }));
- return this;
- }
-
- /// <summary>
- /// <para>
- /// The series of actions for a selector.
- /// T is a content type of a selector.
- /// For example, assume that the component type is "Progress",
- /// <code>
- /// AddSelector<Color>("/TrackColor", setter);
- /// </code>
- /// This will produce additional keys and actions for 5 basic ControlStates,
- /// "Progress/TrackColor"
- /// "Progress/TrackColorFocused"
- /// "Progress/TrackColorPressed"
- /// "Progress/TrackColorDisabled"
- /// "Progress/TrackColorOther"
- /// </para>
- /// <para>
- /// Note that if you want to add actions for additional control states, please specify them as parameter.
- /// </para>
- /// </summary>
- /// <code>
- /// AddSelector<Color>("/TrackColor", setter, ControlState.DisabledSelected);
- /// </code>
- internal ExternalThemeKeyList AddSelector<T>(string key, Action<ViewStyle, Selector<T>> setter, params ControlState[] additionalStates)
- {
- list.Add(new KeyActionPair(componentType.Name + key, GenSelectorAction<T>(ControlState.Normal)));
- list.Add(new KeyActionPair(componentType.Name + key + nameof(ControlState.Focused), GenSelectorAction<T>(ControlState.Focused)));
- list.Add(new KeyActionPair(componentType.Name + key + nameof(ControlState.Pressed), GenSelectorAction<T>(ControlState.Pressed)));
- list.Add(new KeyActionPair(componentType.Name + key + nameof(ControlState.Disabled), GenSelectorAction<T>(ControlState.Disabled)));
- list.Add(new KeyActionPair(componentType.Name + key + nameof(ControlState.Other), GenSelectorAction<T>(ControlState.Other)));
-
- foreach (var state in additionalStates)
- {
- list.Add(new KeyActionPair(componentType.Name + key + nameof(state), GenSelectorAction<T>(state)));
- }
-
- list.Add(new KeyActionPair(GenSelectorFinalizer(setter)));
-
- return this;
- }
-
- /// <summary>
- /// Note that, the view's background can be either color or image value.
- /// This method add keys for a selector and each action can handle both color and string (for image url).
- /// </summary>
- internal ExternalThemeKeyList AddBackgroundSelector(string key, Action<ViewStyle, Selector<Color>> colorSetter, Action<ViewStyle, Selector<string>> imageSetter, params ControlState[] additionalStates)
- {
- list.Add(new KeyActionPair(componentType.Name + key, GenBackgroundSelectorAction(ControlState.Normal)));
- list.Add(new KeyActionPair(componentType.Name + key + nameof(ControlState.Focused), GenBackgroundSelectorAction(ControlState.Focused)));
- list.Add(new KeyActionPair(componentType.Name + key + nameof(ControlState.Pressed), GenBackgroundSelectorAction(ControlState.Pressed)));
- list.Add(new KeyActionPair(componentType.Name + key + nameof(ControlState.Disabled), GenBackgroundSelectorAction(ControlState.Disabled)));
- list.Add(new KeyActionPair(componentType.Name + key + nameof(ControlState.Other), GenBackgroundSelectorAction(ControlState.Other)));
-
- foreach (var state in additionalStates)
- {
- list.Add(new KeyActionPair(componentType.Name + key + nameof(state), GenBackgroundSelectorAction(state)));
- }
-
- list.Add(new KeyActionPair(GenColorOrImageSelectorFinalizer(colorSetter, imageSetter)));
-
- return this;
- }
-
- internal void ApplyKeyActions(IExternalTheme externalTheme, Theme theme)
- {
- var style = theme.GetStyle(componentType.FullName);
-
- foreach (var item in list)
- {
- if (item.IsFinalizer)
- {
- item.Action(style, null);
- continue;
- }
-
- string newValue = externalTheme.GetValue(item.Key);
- if (newValue != null)
- {
- if (style == null || style.GetType() != styleType)
- {
- style = Activator.CreateInstance(styleType) as ViewStyle;
- theme.AddStyleWithoutClone(componentType.FullName, style);
- }
-
- // Invoke action with the existing style to overwrite properties of it.
- item.Action(style, newValue);
- }
- }
- }
-
- private Action<ViewStyle, string> GenSelectorAction<T>(ControlState state)
- {
- return (ViewStyle viewStyle, string stringInput) =>
- {
- if (ParseXamlStringToObject<T>(stringInput) is T tValue)
- {
- if (selectorData == null)
- {
- selectorData = new Selector<T>();
- }
- ((Selector<T>)selectorData).AddWithoutDuplicationCheck(state, tValue);
- }
- };
- }
-
- private Action<ViewStyle, string> GenBackgroundSelectorAction(ControlState state)
- {
- return (ViewStyle viewStyle, string stringInput) =>
- {
- var imageUrl = TryConvertToResourcePath(stringInput);
-
- if (imageUrl != null)
- {
- if (selectorData == null || (selectorData as Selector<string> == null))
- {
- selectorData = new Selector<string>();
- }
- ((Selector<string>)selectorData).AddWithoutDuplicationCheck(state, imageUrl);
- }
- else if (ParseXamlStringToObject<Color>(stringInput) is Color color)
- {
- if (selectorData == null || (selectorData as Selector<Color> == null))
- {
- selectorData = new Selector<Color>();
- }
- ((Selector<Color>)selectorData).AddWithoutDuplicationCheck(state, color);
- }
- };
- }
-
- private Action<ViewStyle, string> GenSelectorFinalizer<T>(Action<ViewStyle, Selector<T>> setter)
- {
- return (ViewStyle viewStyle, string value) =>
- {
- if (selectorData == null || viewStyle == null)
- {
- return;
- }
- setter(viewStyle, (Selector<T>)selectorData);
- selectorData = null;
- };
- }
-
- private Action<ViewStyle, string> GenColorOrImageSelectorFinalizer(Action<ViewStyle, Selector<Color>> colorSetter, Action<ViewStyle, Selector<string>> imageSetter)
- {
- return (ViewStyle viewStyle, string value) =>
- {
- if (viewStyle == null)
- {
- return;
- }
- if (selectorData is Selector<Color> colorSelector)
- {
- colorSetter(viewStyle, colorSelector);
- }
- else if (selectorData is Selector<string> imageSelector)
- {
- imageSetter(viewStyle, imageSelector);
- }
- selectorData = null;
- };
- }
-
- private static object ParseXamlStringToObject<T>(string stringInput)
- {
- if (typeof(T) == typeof(string))
- {
- return TryConvertToResourcePath(stringInput) ?? stringInput;
- }
- return stringInput.ConvertTo(typeof(T), () => typeof(T).GetTypeInfo(), null);
- }
-
- private static string TryConvertToResourcePath(string stringInput)
- {
- Debug.Assert(stringInput != null);
- if (stringInput.StartsWith("{") && stringInput.EndsWith("}"))
- {
- // TODO Need to use Tizen.Applications.ThemeManager.Theme.GetPath instead SharedResourcePath after fixing abort problem.
- return ExternalThemeManager.SharedResourcePath + "/" + stringInput.Substring(1, stringInput.Length - 2);
- }
- return null;
- }
-
- internal struct KeyActionPair
- {
- public KeyActionPair(string key, Action<ViewStyle, string> action)
- {
- Key = key;
- Action = action;
- }
-
- public KeyActionPair(Action<ViewStyle, string> action)
- {
- Key = null;
- Action = action;
- }
-
- public bool IsFinalizer => (Key == null);
-
- public string Key { get; }
-
- public Action<ViewStyle, string> Action { get; }
- }
- }
-}
*/
using System;
-using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using System.IO;
using Tizen.Applications;
namespace Tizen.NUI
[SuppressMessage("Microsoft.Design", "CA1031: Do not catch general exception types", Justification = "This method is to handle external resources that may throw an exception but ignorable. This method should not interrupt the main stream.")]
internal static class ExternalThemeManager
{
- private static Tizen.Applications.ThemeManager.ThemeLoader themeLoader = InitializeThemeLoader();
+ private static Tizen.Applications.ThemeManager.ThemeLoader themeLoader;
+ private static string id;
+ private static string version;
- private static string sharedResourcePath;
-#if DEBUG
- private static IExternalTheme theme;
-#endif
static ExternalThemeManager() { }
- public static string SharedResourcePath
+ public static void Initialize()
{
- get
+ if (themeLoader != null)
{
- if (themeLoader == null)
- {
- return string.Empty;
- }
-#if DEBUG
- if (theme != null)
- {
- return string.Empty;
- }
-#endif
- if (sharedResourcePath != null)
- {
- return sharedResourcePath;
- }
-
- var tizenTheme = themeLoader.CurrentTheme;
-
- if (tizenTheme == null || string.IsNullOrEmpty(tizenTheme.Id) || string.IsNullOrEmpty(tizenTheme.Version))
- {
- sharedResourcePath = string.Empty;
- }
- else
- {
- ApplicationInfo themePkgInfo;
- try
- {
- themePkgInfo = ApplicationManager.GetInstalledApplication(tizenTheme.Id);
- }
- catch (ArgumentException e)
- {
- Tizen.Log.Error("NUI", $"{e.GetType().Name} occurred while getting theme application info.");
- throw;
- }
- catch (InvalidOperationException e)
- {
- Tizen.Log.Error("NUI", $"{e.GetType().Name} occurred while getting theme application info.");
- throw;
- }
-
- if (themePkgInfo == null)
- {
- sharedResourcePath = string.Empty;
- }
- else
- {
- sharedResourcePath = themePkgInfo.SharedResourcePath;
- }
- }
+ return;
+ }
- return sharedResourcePath;
+ try
+ {
+ themeLoader = new Tizen.Applications.ThemeManager.ThemeLoader();
+ themeLoader.ThemeChanged += OnExternalPlatformThemeChanged;
+ }
+ catch (Exception e)
+ {
+ Tizen.Log.Info("NUI", $"[Ignorable] {e.GetType().Name} occurred while setting Tizen.Applications.ThemeManager: {e.Message}");
}
}
- public static void Initialize()
+
+ /// <summary> Returns the theme's shared resource path that is currently loading. </summary>
+ public static string SharedResourcePath { get; set; } = String.Empty;
+
+ // FIXME Please remove this API after fix ThemeLoader.CurrentTheme is fixed.
+ public static string CurrentThemeId
{
- if (themeLoader == null)
+ get
{
- return;
+ if (id == null) UpdateCurrentThemeIdAndVersion();
+ return id;
}
-
- themeLoader.ThemeChanged += OnTizenThemeChanged;
}
- public static IExternalTheme GetCurrentTheme()
+ // FIXME Please remove this API after fix ThemeLoader.CurrentTheme is fixed.
+ public static string CurrentThemeVersion
{
- if (themeLoader == null)
+ get
{
- return null;
+ if (version == null) UpdateCurrentThemeIdAndVersion();
+ return version;
}
+ }
-#if DEBUG
- if (theme != null)
+ public static bool SetTheme(string id)
+ {
+ if (themeLoader != null)
{
- return theme;
+ try
+ {
+ themeLoader.CurrentTheme = themeLoader.LoadTheme(id);
+ return true;
+ }
+ catch (Exception e)
+ {
+ Tizen.Log.Info("NUI", $"[Ignorable] {e.GetType().Name} occurred while getting load theme using {themeLoader.GetType().FullName}: {e.Message}");
+ }
}
-#endif
- Tizen.Applications.ThemeManager.Theme tizenTheme = null;
- try
- {
- tizenTheme = themeLoader.CurrentTheme;
- }
- catch (Exception e)
- {
- Tizen.Log.Info("NUI", $"[Ignorable] {e.GetType().Name} occurred while getting current theme using {themeLoader.GetType().FullName}: {e.Message}");
- }
+ return false;
+ }
- if (tizenTheme == null || string.IsNullOrEmpty(tizenTheme.Id) || string.IsNullOrEmpty(tizenTheme.Version))
+ public static string GetSharedResourcePath(string id)
+ {
+ if (!string.IsNullOrEmpty(id))
{
- return null;
+ try
+ {
+ using (var themePkgInfo = ApplicationManager.GetInstalledApplication(id))
+ {
+ return themePkgInfo.SharedResourcePath;
+ }
+ }
+ catch (ArgumentException e)
+ {
+ Tizen.Log.Error("NUI", $"{e.GetType().Name} occurred while getting theme application info.");
+ }
+ catch (InvalidOperationException e)
+ {
+ Tizen.Log.Error("NUI", $"{e.GetType().Name} occurred while getting theme application info.");
+ }
}
- Tizen.Log.Info("NUI", $"TizenTheme: Id({tizenTheme.Id}), Version({tizenTheme.Version}), Title({tizenTheme.Title})");
-
- return new TizenExternalTheme(tizenTheme);
+ return null;
}
- public static IExternalTheme GetTheme(string id)
+ private static void UpdateCurrentThemeIdAndVersion()
{
if (themeLoader == null)
{
- return null;
+ return;
}
Tizen.Applications.ThemeManager.Theme tizenTheme = null;
try
{
- tizenTheme = themeLoader.LoadTheme(id);
+ tizenTheme = themeLoader.CurrentTheme;
}
catch (Exception e)
{
- Tizen.Log.Info("NUI", $"[Ignorable] {e.GetType().Name} occurred while getting load theme using {themeLoader.GetType().FullName}: {e.Message}");
- }
-
- return tizenTheme == null ? null : new TizenExternalTheme(tizenTheme);
- }
-
-#if DEBUG
- public static void SetTestTheme(IExternalTheme testTheme)
- {
- if (testTheme == null)
- {
- throw new ArgumentNullException(nameof(testTheme));
+ Tizen.Log.Info("NUI", $"[Ignorable] {e.GetType().Name} occurred while getting current theme using {themeLoader.GetType().FullName}: {e.Message}");
}
- if (string.IsNullOrEmpty(testTheme.Id) || string.IsNullOrEmpty(testTheme.Version))
+ if (tizenTheme == null || string.IsNullOrEmpty(tizenTheme.Id) || string.IsNullOrEmpty(tizenTheme.Version))
{
- throw new ArgumentException();
+ return;
}
- theme = testTheme;
- ThemeManager.ApplyExternalTheme(theme);
- }
-
- public static void SetTestTheme(string id, string version, Dictionary<string, string> testData)
- {
- if (id == null)
- {
- throw new ArgumentNullException(nameof(id));
- }
- if (version == null)
- {
- throw new ArgumentNullException(nameof(version));
- }
- if (testData == null)
- {
- throw new ArgumentNullException(nameof(testData));
- }
+ Tizen.Log.Info("NUI", $"TizenTheme: Id({tizenTheme.Id}), Version({tizenTheme.Version}), Title({tizenTheme.Title})");
- theme = new DictionaryExternalTheme(id, version, testData);
- ThemeManager.ApplyExternalTheme(theme);
+ id = tizenTheme.Id;
+ version = tizenTheme.Version;
}
-#endif
- private static void OnTizenThemeChanged(object sender, Tizen.Applications.ThemeManager.ThemeEventArgs e)
+ private static void OnExternalPlatformThemeChanged(object sender, Tizen.Applications.ThemeManager.ThemeEventArgs e)
{
-#if DEBUG
- theme = null;
-#endif
Tizen.Log.Info("NUI", $"TizenTheme: Id({e.Theme.Id}), Version({e.Theme.Version}), Title({e.Theme.Title})");
- sharedResourcePath = null;
- ThemeManager.ApplyExternalTheme(new TizenExternalTheme(e.Theme));
- }
- private static Tizen.Applications.ThemeManager.ThemeLoader InitializeThemeLoader()
- {
- try
- {
- return new Tizen.Applications.ThemeManager.ThemeLoader();
- }
- catch (Exception e)
- {
- Tizen.Log.Info("NUI", $"[Ignorable] {e.GetType().Name} occurred while setting Tizen.Applications.ThemeManager: {e.Message}");
- }
+ id = e.Theme.Id;
+ version = e.Theme.Version;
- return null;
+ if (!ThemeManager.PlatformThemeEnabled) return;
+
+ ThemeManager.ApplyExternalPlatformTheme(id, version);
}
}
}
+++ /dev/null
-/*
- * Copyright(c) 2021 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-namespace Tizen.NUI
-{
- /// <summary>
- /// This is a wrapper to express external theme, such as, tizen-theme-manager's theme.
- /// </summary>
- internal interface IExternalTheme
- {
- string Id { get; }
- string Version { get; }
- string GetValue(string key);
- }
-}
*
*/
-using System.Collections.Generic;
-
namespace Tizen.NUI
{
internal interface IThemeCreator
{
Theme Create();
- HashSet<ExternalThemeKeyList> GetExternalThemeKeyListSet();
}
}
if (string.IsNullOrEmpty(baseTheme)) return;
- var baseThemeInstance = (Theme)ThemeManager.GetBuiltinTheme(baseTheme)?.Clone();
+ var baseThemeInstance = (Theme)ThemeManager.LoadPlatformTheme(baseTheme)?.Clone();
if (baseThemeInstance != null)
{
if (Id == null) Id = theme.Id;
+ if (Version == null) Version = theme.Version;
+
foreach (var item in theme)
{
if (item.Value == null)
/// </summary>
internal void AddStyleWithoutClone(string styleName, ViewStyle value) => map[styleName] = value;
- internal void ApplyExternalTheme(IExternalTheme externalTheme, HashSet<ExternalThemeKeyList> keyListSet)
- {
- Id = externalTheme.Id;
- Version = externalTheme.Version;
-
- if (keyListSet == null)
- {
- // Nothing to apply
- return;
- }
-
- foreach (var keyList in keyListSet)
- {
- keyList?.ApplyKeyActions(externalTheme, this);
- }
- }
-
- internal bool HasSameIdAndVersion(IExternalTheme externalTheme)
- {
- if (externalTheme == null)
- {
- return false;
- }
-
- return string.Equals(Id, externalTheme.Id, StringComparison.OrdinalIgnoreCase) && string.Equals(Version, externalTheme.Version, StringComparison.OrdinalIgnoreCase);
- }
+ internal bool HasSameIdAndVersion(string id, string version) => string.Equals(Id, id, StringComparison.OrdinalIgnoreCase) && string.Equals(Version, version, StringComparison.OrdinalIgnoreCase);
internal void SetChangedResources(IEnumerable<KeyValuePair<string, string>> changedResources)
{
/// <summary>
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public ThemeChangedEventArgs(string themeId)
+ public ThemeChangedEventArgs(string themeId, string platformThemeId, bool isPlatformThemeChanged)
{
ThemeId = themeId;
+ PlatformThemeId = platformThemeId;
+ IsPlatformThemeChanged = isPlatformThemeChanged;
}
/// <summary>
- /// The new theme's ID.
+ /// The new theme's Id.
/// </summary>
/// <since_tizen> 9 </since_tizen>
public string ThemeId { get; }
+
+ /// <summary>
+ /// The platform theme's Id.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string PlatformThemeId { get; }
+
+ /// <summary>
+ /// Whether this event is trigger by platform theme change.
+ /// </summary>
+ /// <seealso cref="NUIApplication.ThemeOptions.PlatformThemeEnabled"/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool IsPlatformThemeChanged { get; }
}
}
+++ /dev/null
-/*
- * Copyright(c) 2021 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#if false
-
-using System.Diagnostics.CodeAnalysis;
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI
-{
- internal partial class DefaultThemeCreator
- {
- [SuppressMessage("Microsoft.Reliability", "CA2000: Dispose objects before losing scope", Justification = "The responsibility to dispose the object is transferred to the theme object.")]
- public Theme Create()
- {
- Theme theme = new Theme()
- {
- Id = DefaultId,
- Version = DefaultVersion,
- };
-
- // TextLabel style.
- theme.AddStyleWithoutClone("Tizen.NUI.BaseComponents.TextLabel", new TextLabelStyle()
- {
- FontFamily = "BreezeSans",
- PixelSize = 32,
- TextColor = new Color(1.00f, 1.00f, 1.00f, 1),
- FontStyle = new PropertyMap().Add("weight", new PropertyValue("light")),
- });
-
- // TextField style.
- theme.AddStyleWithoutClone("Tizen.NUI.BaseComponents.TextField", new TextFieldStyle()
- {
- FontFamily = "BreezeSans",
- PixelSize = 32,
- TextColor = new Color(1.00f, 1.00f, 1.00f, 1),
- FontStyle = new PropertyMap().Add("weight", new PropertyValue("regular")),
- PrimaryCursorColor = new Vector4(0.08f, 0.45f, 0.90f, 1),
- SecondaryCursorColor = new Vector4(0.08f, 0.45f, 0.90f, 1),
- CursorWidth = 3,
- SelectionHighlightColor = new Vector4(1.00f, 1.00f, 1.00f, 0.20f),
- GrabHandleColor = new Color(0.08f, 0.45f, 0.90f, 1),
- GrabHandleImage = FrameworkInformation.ResourcePath + "IoT_handler_center_downW.png",
- SelectionHandleImageLeft = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downleftW.png")),
- SelectionHandleImageRight = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downrightW.png")),
- });
-
- // TextEditor style.
- theme.AddStyleWithoutClone("Tizen.NUI.BaseComponents.TextEditor", new TextEditorStyle()
- {
- FontFamily = "BreezeSans",
- PixelSize = 32,
- TextColor = new Color(1.00f, 1.00f, 1.00f, 1),
- FontStyle = new PropertyMap().Add("weight", new PropertyValue("regular")),
- PrimaryCursorColor = new Vector4(0.08f, 0.45f, 0.90f, 1),
- SecondaryCursorColor = new Vector4(0.08f, 0.45f, 0.90f, 1),
- CursorWidth = 3,
- SelectionHighlightColor = new Vector4(1.00f, 1.00f, 1.00f, 0.20f),
- GrabHandleColor = new Color(0.08f, 0.45f, 0.90f, 1),
- GrabHandleImage = FrameworkInformation.ResourcePath + "IoT_handler_center_downW.png",
- SelectionHandleImageLeft = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downleftW.png")),
- SelectionHandleImageRight = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downrightW.png")),
- });
-
- return theme;
- }
- }
-}
-#endif
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using Tizen.NUI.BaseComponents;
namespace Tizen.NUI
/// <since_tizen> 9 </since_tizen>
public static class ThemeManager
{
- private static Theme defaultTheme;
- private static Theme currentTheme;
- private static readonly List<Theme> builtinThemes = new List<Theme>(); // Themes provided by framework.
- private static readonly List<IThemeCreator> packages = new List<IThemeCreator>();// This is to store default theme creators by packages.
+ private static Theme baseTheme; // The base theme. It includes all styles including structures (Size, Position, Policy) of components.
+ private static Theme platformTheme; // The platform theme. This may include color and image information without structure detail.
+ private static Theme userTheme; // The user custom theme.
+ private static Theme themeForUpdate; // platformTheme + userTheme. It is used when the component need to update according to theme change.
+ private static Theme themeForInitialize; // baseTheme + platformTheme + userTheme. It is used when the component is created.
+ private static readonly List<Theme> cachedPlatformThemes = new List<Theme>(); // Themes provided by framework.
+ private static readonly List<IThemeCreator> packages = new List<IThemeCreator>();// This is to store base theme creators by packages.
+ private static bool platformThemeEnabled = false;
static ThemeManager()
{
+ ExternalThemeManager.Initialize();
AddPackageTheme(DefaultThemeCreator.Instance);
}
/// </summary>
internal static WeakEvent<EventHandler<ThemeChangedEventArgs>> ThemeChangedInternal = new WeakEvent<EventHandler<ThemeChangedEventArgs>>();
+ /// <summary>
+ /// The current theme Id.
+ /// It returns null when no theme is applied.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static string ThemeId
+ {
+ get => userTheme?.Id;
+ }
+
+ /// <summary>
+ /// The current platform theme Id.
+ /// Note that it returns null when the platform theme is disabled.
+ /// If the <seealso cref="NUIApplication.ThemeOptions.PlatformThemeEnabled"/> is given, it can be one of followings in tizen 6.5:
+ /// <list type="bullet">
+ /// <item>
+ /// <description>org.tizen.default-light-theme</description>
+ /// </item>
+ /// <item>
+ /// <description>org.tizen.default-dark-theme</description>
+ /// </item>
+ /// </list>
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static string PlatformThemeId
+ {
+ get => platformTheme?.Id;
+ }
+
+ /// <summary>
+ /// To support deprecated StyleManager.
/// NOTE that, please remove this after remove Tizen.NUI.Components.StyleManager
- internal static Theme DefaultTheme
+ /// </summary>
+ internal static Theme BaseTheme
{
- get => defaultTheme;
- set => defaultTheme = value;
+ get => baseTheme;
+ set
+ {
+ baseTheme = value;
+ UpdateThemeForInitialize();
+ }
}
+ /// <summary>
+ /// To support deprecated StyleManager.
+ /// NOTE that, please remove this after remove Tizen.NUI.Components.StyleManager
+ /// </summary>
internal static Theme CurrentTheme
{
- get => currentTheme ?? defaultTheme;
+ get => userTheme ?? baseTheme;
set
{
- currentTheme = value;
+ userTheme = value;
+ UpdateThemeForInitialize();
NotifyThemeChanged();
}
}
- private static bool ThemeApplied => defaultTheme.Count > 0 || (currentTheme != null && currentTheme.Count > 0);
+ internal static bool PlatformThemeEnabled
+ {
+ get => platformThemeEnabled;
+ set
+ {
+ if (platformThemeEnabled == value) return;
+
+ platformThemeEnabled = value;
+
+ if (platformThemeEnabled)
+ {
+ ApplyExternalPlatformTheme(ExternalThemeManager.CurrentThemeId, ExternalThemeManager.CurrentThemeVersion);
+ }
+ }
+ }
+
+ internal static bool ApplicationThemeChangeSensitive { get; set; } = false;
/// <summary>
- /// Apply theme to the NUI.
+ /// Apply custom theme to the NUI.
/// This will change the appearance of the existing components with property <seealso cref="View.ThemeChangeSensitive"/> on.
/// This also affects all components created afterwards.
/// </summary>
newTheme.Id = "NONAME";
}
- CurrentTheme = newTheme;
+ userTheme = newTheme;
+ UpdateThemeForInitialize();
+ UpdateThemeForUpdate();
+ NotifyThemeChanged();
}
/// <summary>
- /// Change base theme.
- /// Originally base theme is a platform profile specific theme.
+ /// Change tizen theme.
/// User may change this to one of platform installed one.
/// </summary>
/// <param name="themeId">The installed theme Id.</param>
/// <returns>true on success, false when it failed to find installed theme with given themeId.</returns>
/// <exception cref="ArgumentNullException">Thrown when the given themeId is null.</exception>
[EditorBrowsable(EditorBrowsableState.Never)]
- public static bool ApplyBaseTheme(string themeId)
+ public static bool ApplyPlatformTheme(string themeId)
{
if (themeId == null) throw new ArgumentNullException(nameof(themeId));
- var theme = GetBuiltinTheme(themeId);
-
- if (theme != null)
- {
- defaultTheme = theme;
- NotifyThemeChanged();
- return true;
- }
-
- Tizen.Log.Info("NUI", $"No Theme found with given id : {themeId}");
-
- return false;
+ return ExternalThemeManager.SetTheme(themeId);
}
/// <summary>
}
/// <summary>
- /// Load a style with style name in the current theme.
+ /// Load a platform style with style name in the current theme.
+ /// It returns null when the platform theme is disabled. <see cref="NUIApplication.ThemeOptions.PlatformThemeEnabled" />.
/// </summary>
/// <param name="styleName">The style name.</param>
+ /// <exception cref="ArgumentNullException">Thrown when the given styleName is null.</exception>
[EditorBrowsable(EditorBrowsableState.Never)]
- internal static ViewStyle GetStyleWithoutClone(string styleName)
+ public static ViewStyle GetPlatformStyle(string styleName)
{
- if (!ThemeApplied) return null;
+ if (styleName == null) throw new ArgumentNullException(nameof(styleName));
+ return platformTheme?.GetStyle(styleName)?.Clone();
+ }
- return currentTheme?.GetStyle(styleName) ?? defaultTheme.GetStyle(styleName);
+ /// <summary>
+ /// Load a platform style with view type in the current theme.
+ /// It returns null when the platform theme is disabled. <see cref="NUIApplication.ThemeOptions.PlatformThemeEnabled" />.
+ /// </summary>
+ /// <param name="viewType"> The type of the view. Full name of the given type will be a key to find a style in the current theme. (e.g. Tizen.NUI.Components.Button) </param>
+ /// <exception cref="ArgumentNullException">Thrown when the given viewType is null.</exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static ViewStyle GetPlatformStyle(Type viewType)
+ {
+ if (viewType == null) throw new ArgumentNullException(nameof(viewType));
+ return platformTheme?.GetStyle(viewType)?.Clone();
}
/// <summary>
+ /// Load a style with style name in the current theme.
+ /// </summary>
+ /// <param name="styleName">The style name.</param>
+ internal static ViewStyle GetStyleWithoutClone(string styleName) => userTheme?.GetStyle(styleName);
+
+ /// <summary>
/// Load a style with View type in the current theme.
/// </summary>
/// <param name="viewType">The type of View.</param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal static ViewStyle GetStyleWithoutClone(Type viewType)
- {
- if (!ThemeApplied) return null;
+ internal static ViewStyle GetStyleWithoutClone(Type viewType) => userTheme?.GetStyle(viewType);
- return currentTheme?.GetStyle(viewType) ?? defaultTheme.GetStyle(viewType);
- }
+ /// <summary>
+ /// Load a style with style name in the current theme.
+ /// </summary>
+ /// <param name="styleName">The style name.</param>
+ internal static ViewStyle GetUpdateStyleWithoutClone(string styleName) => themeForUpdate?.GetStyle(styleName);
/// <summary>
- /// Get a built-in theme.
+ /// Load a style with View type in the current theme.
/// </summary>
- /// <param name="themeId">The built-in theme id.</param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal static Theme GetBuiltinTheme(string themeId)
+ /// <param name="viewType">The type of View.</param>
+ internal static ViewStyle GetUpdateStyleWithoutClone(Type viewType) => themeForUpdate?.GetStyle(viewType);
+
+ /// <summary>
+ /// Load a initial component style.
+ /// </summary>
+ internal static ViewStyle GetInitialStyleWithoutClone(string styleName) => themeForInitialize.GetStyle(styleName);
+
+ /// <summary>
+ /// Load a initial component style.
+ /// </summary>
+ internal static ViewStyle GetInitialStyleWithoutClone(Type viewType) => themeForInitialize.GetStyle(viewType);
+
+ /// <summary>
+ /// Get a platform installed theme.
+ /// </summary>
+ /// <param name="themeId">The theme id.</param>
+ internal static Theme LoadPlatformTheme(string themeId)
{
Debug.Assert(themeId != null);
- Theme result = null;
- int index = builtinThemes.FindIndex(x => string.Equals(x.Id, themeId, StringComparison.OrdinalIgnoreCase));
+ // Check if it is already loaded.
+ int index = cachedPlatformThemes.FindIndex(x => string.Equals(x.Id, themeId, StringComparison.OrdinalIgnoreCase));
if (index >= 0)
{
- result = builtinThemes[index];
+ Tizen.Log.Info("NUI", $"Hit cache.");
+ var found = cachedPlatformThemes[index];
+ // If the cached is not a full set, update it.
+ if (found.PackageCount < packages.Count)
+ {
+ UpdatePlatformTheme(found);
+ Tizen.Log.Info("NUI", $"Update cache.");
+ }
+ return found;
}
- else
+
+ var newTheme = CreatePlatformTheme(themeId);
+ if (newTheme != null)
{
- result = LoadBuiltinTheme(themeId);
+ cachedPlatformThemes.Add(newTheme);
+ Tizen.Log.Info("NUI", $"Platform theme has been loaded successfully.");
}
- return result;
+ return newTheme;
}
/// <summary>
internal static void ApplyFallbackTheme(Theme fallbackTheme)
{
Debug.Assert(fallbackTheme != null);
- defaultTheme = (Theme)fallbackTheme?.Clone();
+ BaseTheme = (Theme)fallbackTheme?.Clone();
}
/// <summary>
- /// Set an external theme as a base theme.
+ /// Apply an external platform theme.
/// </summary>
- /// <param name="externalTheme">The external theme instance to be applied as base.</param>
- internal static void ApplyExternalTheme(IExternalTheme externalTheme)
+ /// <param name="id">The external theme id.</param>
+ /// <param name="version">The external theme version.</param>
+ internal static void ApplyExternalPlatformTheme(string id, string version)
{
#if ExternalThemeEnabled
- Debug.Assert(defaultTheme != null);
+ Debug.Assert(baseTheme != null);
- if (defaultTheme.HasSameIdAndVersion(externalTheme))
+ // If the given theme is invalid, do nothing.
+ if (string.IsNullOrEmpty(id))
{
return;
}
- int index = builtinThemes.FindIndex(x => x.HasSameIdAndVersion(externalTheme));
- if (index >= 0 && builtinThemes[index].PackageCount == packages.Count)
+ // If no platform theme has been applied and the base theme can cover the given one, do nothing.
+ if (platformTheme == null && baseTheme.HasSameIdAndVersion(id, version))
{
- defaultTheme = builtinThemes[index];
- NotifyThemeChanged();
+ Tizen.Log.Info("NUI", "The base theme can cover platform theme: Skip loading.");
return;
}
- var newTheme = new Theme()
+ // If the given theme is already applied, do nothing.
+ if (platformTheme != null && platformTheme.HasSameIdAndVersion(id, version))
{
- Id = externalTheme.Id,
- Version = externalTheme.Version
- };
+ Tizen.Log.Info("NUI", "Platform theme is already applied: Skip loading.");
+ return;
+ }
- AddToBuiltinThemes(newTheme);
+ var loaded = LoadPlatformTheme(id);
- foreach (IThemeCreator themeCreator in packages)
+ if (loaded != null)
{
- var packageTheme = themeCreator.Create();
- Debug.Assert(packageTheme != null);
-
- packageTheme.ApplyExternalTheme(externalTheme, themeCreator.GetExternalThemeKeyListSet());
- newTheme.MergeWithoutClone(packageTheme);
+ Tizen.Log.Info("NUI", $"{loaded.Id} has been applied successfully.");
+ platformTheme = loaded;
+ UpdateThemeForInitialize();
+ UpdateThemeForUpdate();
+ NotifyThemeChanged(true);
}
-
- defaultTheme = newTheme;
- NotifyThemeChanged();
#endif
}
{
return;
}
+
+ Tizen.Log.Info("NUI", $"AddPackageTheme({themeCreator.GetType().Assembly.GetName().Name})");
packages.Add(themeCreator);
- var packageTheme = themeCreator.Create();
- Debug.Assert(packageTheme != null);
+ // Base theme
+ var packageBaseTheme = themeCreator.Create();
+ Debug.Assert(packageBaseTheme != null);
+
+ if (baseTheme == null) baseTheme = packageBaseTheme;
+ else baseTheme.MergeWithoutClone(packageBaseTheme);
+ baseTheme.PackageCount++;
#if ExternalThemeEnabled
- var externalTheme = ExternalThemeManager.GetCurrentTheme();
- if (externalTheme != null && !packageTheme.HasSameIdAndVersion(externalTheme))
+ if (platformThemeEnabled)
{
- packageTheme.ApplyExternalTheme(externalTheme, themeCreator.GetExternalThemeKeyListSet());
+ Tizen.Log.Info("NUI", $"Platform theme is enabled");
+ if (platformTheme != null)
+ {
+ UpdatePlatformTheme(platformTheme);
+ }
+ else
+ {
+ if (!baseTheme.HasSameIdAndVersion(ExternalThemeManager.CurrentThemeId, ExternalThemeManager.CurrentThemeVersion))
+ {
+ var loaded = LoadPlatformTheme(ExternalThemeManager.CurrentThemeId);
+ if (loaded != null)
+ {
+ platformTheme = loaded;
+ }
+ }
+ }
+ UpdateThemeForUpdate();
}
#endif
- if (defaultTheme == null)
+ UpdateThemeForInitialize();
+ }
+
+ internal static void Preload()
+ {
+#if ExternalThemeEnabled
+ Debug.Assert(baseTheme != null);
+
+ if (string.IsNullOrEmpty(ExternalThemeManager.CurrentThemeId)) return;
+
+ LoadPlatformTheme(ExternalThemeManager.CurrentThemeId);
+#endif
+ }
+
+ // TODO Please make it private after removing Tizen.NUI.Components.StyleManager.
+ internal static void UpdateThemeForUpdate()
+ {
+ if (userTheme == null)
{
- defaultTheme = new Theme()
- {
- Id = packageTheme.Id,
- Version = packageTheme.Version
- };
- AddToBuiltinThemes(defaultTheme);
+ themeForUpdate = platformTheme;
+ return;
+ }
+
+ if (platformTheme == null)
+ {
+ themeForUpdate = userTheme;
+ return;
}
- defaultTheme.MergeWithoutClone(packageTheme);
- defaultTheme.PackageCount++;
+ themeForUpdate = new Theme();
+ themeForUpdate.Merge(platformTheme);
+ themeForUpdate.MergeWithoutClone(userTheme);
}
- private static void AddToBuiltinThemes(Theme theme)
+ // TODO Please make it private after removing Tizen.NUI.Components.StyleManager.
+ internal static void UpdateThemeForInitialize()
{
- int index = builtinThemes.FindIndex(x => x.Id.Equals(theme.Id, StringComparison.OrdinalIgnoreCase));
- if (index >= 0)
+ if (platformTheme == null && userTheme == null)
+ {
+ themeForInitialize = baseTheme;
+ return;
+ }
+
+ themeForInitialize = new Theme();
+ themeForInitialize.Merge(baseTheme);
+
+ if (userTheme == null)
{
- builtinThemes[index] = theme;
+ if (platformTheme != null) themeForInitialize.MergeWithoutClone(platformTheme);
}
else
{
- builtinThemes.Add(theme);
+ if (platformTheme != null) themeForInitialize.Merge(platformTheme);
+ themeForInitialize.MergeWithoutClone(userTheme);
+ }
+ }
+
+ private static void UpdatePlatformTheme(Theme theme)
+ {
+ var sharedResourcePath = ExternalThemeManager.GetSharedResourcePath(theme.Id);
+
+ if (sharedResourcePath == null)
+ {
+ return;
+ }
+
+ for (var i = theme.PackageCount; i < packages.Count; i++)
+ {
+ theme.MergeWithoutClone(CreatePlatformTheme(sharedResourcePath, packages[i].GetType().Assembly.GetName().Name));
}
+ theme.PackageCount = packages.Count;
}
- private static Theme LoadBuiltinTheme(string id)
+ private static Theme CreatePlatformTheme(string id)
{
- Debug.Assert(id != null);
- // Load from tizen-theme-manager
- var externalTheme = ExternalThemeManager.GetTheme(id);
+ var sharedResourcePath = ExternalThemeManager.GetSharedResourcePath(id);
- if (externalTheme == null)
+ if (sharedResourcePath == null)
{
return null;
}
var newTheme = new Theme()
{
- Id = externalTheme.Id,
- Version = externalTheme.Version
+ Id = id
};
- AddToBuiltinThemes(newTheme);
-
- foreach (IThemeCreator themeCreator in packages)
+ foreach (var packageCreator in packages)
{
- var packageTheme = themeCreator.Create();
- Debug.Assert(packageTheme != null);
-
- packageTheme.ApplyExternalTheme(externalTheme, themeCreator.GetExternalThemeKeyListSet());
- newTheme.MergeWithoutClone(packageTheme);
+ newTheme.MergeWithoutClone(CreatePlatformTheme(sharedResourcePath, packageCreator.GetType().Assembly.GetName().Name));
}
+ newTheme.PackageCount = packages.Count;
return newTheme;
}
- private static void NotifyThemeChanged()
+ [SuppressMessage("Microsoft.Design", "CA1031: Do not catch general exception types", Justification = "This method is to handle external resources that may throw an exception but ignorable. This method should not interrupt the main stream.")]
+ private static Theme CreatePlatformTheme(string sharedResourcePath, string assemblyName)
+ {
+ ExternalThemeManager.SharedResourcePath = sharedResourcePath;
+ try
+ {
+ return new Theme(sharedResourcePath + assemblyName + ".Theme.xaml");
+ }
+ catch (System.IO.FileNotFoundException)
+ {
+ Tizen.Log.Info("NUI", $"[Ignorable] Current tizen theme does not have NUI theme.");
+ }
+ catch (Exception e)
+ {
+ Tizen.Log.Info("NUI", $"[Ignorable] {e.GetType().Name} occurred while applying tizen theme to {assemblyName}: {e.Message}");
+ }
+
+ return new Theme();
+ }
+
+ private static void AddToPlatformThemes(Theme theme)
+ {
+ int index = cachedPlatformThemes.FindIndex(x => x.Id.Equals(theme.Id, StringComparison.OrdinalIgnoreCase));
+ if (index >= 0)
+ {
+ Tizen.Log.Info("NUI", $"Existing {theme.Id} item is overwritten");
+ cachedPlatformThemes[index] = theme;
+ }
+ else
+ {
+ cachedPlatformThemes.Add(theme);
+ Tizen.Log.Info("NUI", $"New {theme.Id} is saved.");
+ }
+ }
+
+ private static void NotifyThemeChanged(bool platformThemeUpdated = false)
{
- Debug.Assert(defaultTheme != null);
+ Debug.Assert(baseTheme != null);
- var id = currentTheme?.Id ?? defaultTheme.Id;
- ThemeChangedInternal.Invoke(null, new ThemeChangedEventArgs(id));
- ThemeChanged?.Invoke(null, new ThemeChangedEventArgs(id));
+ var platformThemeId = platformTheme?.Id;
+ var userThemeId = userTheme?.Id;
+ ThemeChangedInternal.Invoke(null, new ThemeChangedEventArgs(userThemeId, platformThemeId, platformThemeUpdated));
+ ThemeChanged?.Invoke(null, new ThemeChangedEventArgs(userThemeId, platformThemeId, platformThemeUpdated));
}
}
}
+++ /dev/null
-/*
- * Copyright(c) 2021 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-using System;
-using System.Diagnostics.CodeAnalysis;
-
-namespace Tizen.NUI
-{
- /// <summary>
- /// This is a wrapper to express tizen-theme-manager's theme.
- /// </summary>
- internal class TizenExternalTheme : IExternalTheme
- {
- private const string prefix = "/theme/";
- private readonly Tizen.Applications.ThemeManager.Theme theme;
-
- internal TizenExternalTheme(Tizen.Applications.ThemeManager.Theme theme)
- {
- this.theme = theme;
- }
-
- public string Id
- {
- get => theme.Id;
- }
-
- public string Version
- {
- get => theme.Version;
- }
-
- [SuppressMessage("Microsoft.Design", "CA1031: Do not catch general exception types", Justification = "This method is to handle external resources that may throw an exception but ignorable. This method should not interrupt the main stream.")]
- public string GetValue(string key)
- {
- string themeKey = prefix + key;
- string extracted = null;
-
- try
- {
- if (theme.HasKey(themeKey))
- {
- extracted = theme.GetString(themeKey);
- }
- }
- catch (Exception e)
- {
- Tizen.Log.Error("NUI", $"{e.GetType().Name} occurred while getting value from {theme.GetType().FullName}: {e.Message}");
- }
-
- return extracted;
- }
- }
-}
--- /dev/null
+/*
+ * Copyright(c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+using System;
+using System.ComponentModel;
+using Tizen.NUI.Binding;
+
+namespace Tizen.NUI.Xaml
+{
+ /// <summary> The class to support theme resource path. </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [ContentProperty(nameof(FilePath))]
+ [AcceptEmptyServiceProvider]
+ public class ThemeResourcePathExtension : IMarkupExtension<string>
+ {
+ /// <summary></summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ThemeResourcePathExtension()
+ {
+ }
+
+ /// <summary></summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string FilePath { get; set; }
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string ProvideValue(IServiceProvider serviceProvider) => ExternalThemeManager.SharedResourcePath + FilePath;
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider)
+ {
+ return (this as IMarkupExtension<string>).ProvideValue(serviceProvider);
+ }
+ }
+}