[NUI] ThemeManager.GetStyle returns integrate style and fix some bugs.
authorJiyun Yang <ji.yang@samsung.com>
Mon, 14 Jun 2021 06:06:27 +0000 (15:06 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 23 Jun 2021 08:25:09 +0000 (17:25 +0900)
* ThemeManager.GetStyle returns integrated style instead user style.
* Fix bug that access null string.

Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
src/Tizen.NUI/src/public/Theme/ThemeManager.cs

index db50bf5..73f571a 100755 (executable)
@@ -1385,15 +1385,20 @@ namespace Tizen.NUI.BaseComponents
         [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)
index ffacf44..44b6cae 100755 (executable)
@@ -192,7 +192,7 @@ namespace Tizen.NUI
         public static ViewStyle GetStyle(string styleName)
         {
             if (styleName == null) throw new ArgumentNullException(nameof(styleName));
-            return GetStyleWithoutClone(styleName)?.Clone();
+            return GetInitialStyleWithoutClone(styleName)?.Clone();
         }
 
         /// <summary>
@@ -205,7 +205,7 @@ namespace Tizen.NUI
         public static ViewStyle GetStyle(Type viewType)
         {
             if (viewType == null) throw new ArgumentNullException(nameof(viewType));
-            return GetStyleWithoutClone(viewType)?.Clone();
+            return GetInitialStyleWithoutClone(viewType)?.Clone();
         }
 
         /// <summary>
@@ -238,18 +238,6 @@ namespace Tizen.NUI
         /// 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>
@@ -384,7 +372,7 @@ namespace Tizen.NUI
                 }
                 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)