[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void InitializeStyle(ViewStyle style = null)
{
- // First, apply initial style if needs.
var initialStyle = ThemeManager.GetInitialStyleWithoutClone(GetType());
- if (style == null || style.IncludeDefaultStyle)
+ if (style == null)
{
ApplyStyle(initialStyle);
}
-
- // Then, apply given style.
- ApplyStyle(style);
+ else
+ {
+ var refinedStyle = style;
+ if (style.IncludeDefaultStyle)
+ {
+ refinedStyle = initialStyle?.Merge(style);
+ }
+ ApplyStyle(style);
+ }
// Listen theme change event if needs.
if (ThemeManager.PlatformThemeEnabled && initialStyle != null)
public static ViewStyle GetStyle(string styleName)
{
if (styleName == null) throw new ArgumentNullException(nameof(styleName));
- return GetStyleWithoutClone(styleName)?.Clone();
+ return GetInitialStyleWithoutClone(styleName)?.Clone();
}
/// <summary>
public static ViewStyle GetStyle(Type viewType)
{
if (viewType == null) throw new ArgumentNullException(nameof(viewType));
- return GetStyleWithoutClone(viewType)?.Clone();
+ return GetInitialStyleWithoutClone(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>
- internal static ViewStyle GetStyleWithoutClone(Type viewType) => userTheme?.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>
}
else
{
- if (!baseTheme.HasSameIdAndVersion(ExternalThemeManager.CurrentThemeId, ExternalThemeManager.CurrentThemeVersion))
+ if (!string.IsNullOrEmpty(ExternalThemeManager.CurrentThemeId) && !baseTheme.HasSameIdAndVersion(ExternalThemeManager.CurrentThemeId, ExternalThemeManager.CurrentThemeVersion))
{
var loaded = LoadPlatformTheme(ExternalThemeManager.CurrentThemeId);
if (loaded != null)