[NUI] Fix AlertDialog not to use ViewStyle. (#3268)
authorJiyun Yang <ji.yang@samsung.com>
Wed, 7 Jul 2021 04:41:52 +0000 (13:41 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 9 Jul 2021 10:39:50 +0000 (19:39 +0900)
ViewStyle is the last applied style which is not the same as the current style.
Hence it is not recommanded to use ViewStyle inside components code.
(Please note that View.ViewStyle is deprecated and better not to use.)

Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI.Components/Controls/AlertDialog.cs

index c325eeb..68212cf 100755 (executable)
@@ -43,8 +43,6 @@ namespace Tizen.NUI.Components
         //        Until the bug is fixed, padding view is added after action content.
         private View defaultActionContentPadding = null;
 
-        private AlertDialogStyle alertDialogStyle => ViewStyle as AlertDialogStyle;
-
         private bool styleApplied = false;
 
         /// <summary>
@@ -124,20 +122,27 @@ namespace Tizen.NUI.Components
 
             base.ApplyStyle(viewStyle);
 
+            var alertDialogStyle = viewStyle as AlertDialogStyle;
+
+            if (alertDialogStyle == null)
+            {
+                return;
+            }
+
             // Apply Title style.
-            if ((alertDialogStyle?.TitleTextLabel != null) && (DefaultTitleContent is TextLabel))
+            if ((alertDialogStyle.TitleTextLabel != null) && (DefaultTitleContent is TextLabel))
             {
                 ((TextLabel)DefaultTitleContent)?.ApplyStyle(alertDialogStyle.TitleTextLabel);
             }
 
             // Apply Message style.
-            if ((alertDialogStyle?.MessageTextLabel != null) && (DefaultContent is TextLabel))
+            if ((alertDialogStyle.MessageTextLabel != null) && (DefaultContent is TextLabel))
             {
                 ((TextLabel)DefaultContent)?.ApplyStyle(alertDialogStyle.MessageTextLabel);
             }
 
             // Apply ActionContent style.
-            if (alertDialogStyle?.ActionContent != null)
+            if (alertDialogStyle.ActionContent != null)
             {
                 DefaultActionContent?.ApplyStyle(alertDialogStyle.ActionContent);
             }