Revert "[NUI] Add AlertDialogStyle class with the latest AlertDialog UX"
authorJaehyun Cho <jae_hyun.cho@samsung.com>
Wed, 14 Apr 2021 05:18:11 +0000 (14:18 +0900)
committerhuiyueun <35286162+huiyueun@users.noreply.github.com>
Tue, 20 Apr 2021 06:13:00 +0000 (15:13 +0900)
This reverts commit 5b3358237963183eb17db57b7440cc424b994846.

src/Tizen.NUI.Components/Controls/AlertDialog.cs
src/Tizen.NUI.Components/Style/AlertDialogStyle.cs [deleted file]
src/Tizen.NUI.Components/Theme/DefaultTheme.cs
src/Tizen.NUI.Components/Theme/DefaultThemeCommon.cs

index b1b3ee5..988e95a 100755 (executable)
@@ -39,13 +39,6 @@ namespace Tizen.NUI.Components
         private View defaultTitleContent = null;
         private View defaultContent = null;
         private View defaultActionContent = null;
-        // FIXME: Now AlertDialog.Padding Top and Bottom increases AlertDialog size incorrectly.
-        //        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>
         /// Creates a new instance of AlertDialog.
@@ -84,54 +77,12 @@ namespace Tizen.NUI.Components
                 {
                     Utility.Dispose(actionContent);
                 }
-
-                // FIXME: Now AlertDialog.Padding Top and Bottom increases AlertDialog size incorrectly.
-                //        Until the bug is fixed, padding view is added after action content.
-                if (defaultActionContentPadding != null)
-                {
-                    Utility.Dispose(defaultActionContentPadding);
-                }
             }
 
             base.Dispose(type);
         }
 
         /// <summary>
-        /// Applies style to AlertDialog.
-        /// </summary>
-        /// <param name="viewStyle">The style to apply.</param>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public override void ApplyStyle(ViewStyle viewStyle)
-        {
-            styleApplied = false;
-
-            base.ApplyStyle(viewStyle);
-
-            // Apply Title style.
-            if ((alertDialogStyle?.TitleTextLabel != null) && (DefaultTitleContent is TextLabel))
-            {
-                ((TextLabel)DefaultTitleContent)?.ApplyStyle(alertDialogStyle.TitleTextLabel);
-            }
-
-            // Apply Message style.
-            if ((alertDialogStyle?.MessageTextLabel != null) && (DefaultContent is TextLabel))
-            {
-                ((TextLabel)DefaultContent)?.ApplyStyle(alertDialogStyle.MessageTextLabel);
-            }
-
-            // Apply ActionContent style.
-            if (alertDialogStyle?.ActionContent != null)
-            {
-                DefaultActionContent?.ApplyStyle(alertDialogStyle.ActionContent);
-            }
-
-            styleApplied = true;
-
-            // Calculate dialog position and children's positions based on padding sizes.
-            CalculatePosition();
-        }
-
-        /// <summary>
         /// Title text of AlertDialog.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
@@ -411,13 +362,6 @@ namespace Tizen.NUI.Components
                     defaultActionContent = CreateDefaultActionContent();
                 }
 
-                // FIXME: Now AlertDialog.Padding Top and Bottom increases AlertDialog size incorrectly.
-                //        Until the bug is fixed, padding view is added after action content.
-                if (defaultActionContentPadding == null)
-                {
-                    defaultActionContentPadding = CreateDefaultActionContentPadding();
-                }
-
                 return defaultActionContent;
             }
         }
@@ -470,89 +414,57 @@ namespace Tizen.NUI.Components
             if (actionContent != null)
             {
                 Add(actionContent);
-
-                // FIXME: Now AlertDialog.Padding Top and Bottom increases AlertDialog size incorrectly.
-                //        Until the bug is fixed, padding view is added after action content.
-                if (actionContent == defaultActionContent)
-                {
-                    if (defaultActionContentPadding != null)
-                    {
-                        Add(defaultActionContentPadding);
-                    }
-                }
             }
         }
 
         private TextLabel CreateDefaultTitleContent()
         {
-            return new TextLabel();
+            //FIXME: Needs to separate GUI implementation codes to style cs file.
+            return new TextLabel()
+            {
+                HorizontalAlignment = HorizontalAlignment.Center,
+                VerticalAlignment = VerticalAlignment.Center,
+                BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 1.0f),
+                Size = new Size(360, 80),
+            };
         }
 
         private TextLabel CreateDefaultContent()
         {
-            return new TextLabel();
+            //FIXME: Needs to separate GUI implementation codes to style cs file.
+            return new TextLabel()
+            {
+                HorizontalAlignment = HorizontalAlignment.Center,
+                VerticalAlignment = VerticalAlignment.Center,
+                BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 1.0f),
+                Size = new Size(360, 200),
+            };
         }
 
         private View CreateDefaultActionContent()
         {
-            return new View()
+            //FIXME: Needs to separate GUI implementation codes to style cs file.
+            return new Control()
             {
+                BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 1.0f),
+                Size = new Size(360, 80),
                 Layout = new LinearLayout()
                 {
                     LinearOrientation = LinearLayout.Orientation.Horizontal,
+                    LinearAlignment = LinearLayout.Alignment.CenterHorizontal,
+                    CellPadding = new Size2D(10, 0),
                 },
             };
         }
 
-        // FIXME: Now AlertDialog.Padding Top and Bottom increases AlertDialog size incorrectly.
-        //        Until the bug is fixed, padding view is added after action content.
-        private View CreateDefaultActionContentPadding()
-        {
-            var layout = Layout as LinearLayout;
-
-            if ((layout == null) || (defaultActionContent == null))
-            {
-                return null;
-            }
-
-            View paddingView = null;
-
-            using (Size2D size = new Size2D(defaultActionContent.Size2D.Width, defaultActionContent.Size2D.Height))
-            {
-                if (layout.LinearOrientation == LinearLayout.Orientation.Horizontal)
-                {
-                    size.Width = 40;
-                }
-                else
-                {
-                    size.Height = 40;
-                }
-
-                paddingView = new View()
-                {
-                    Size2D = new Size2D(size.Width, size.Height),
-                };
-            }
-
-            return paddingView;
-        }
-
         private void OnRelayout(object sender, EventArgs e)
         {
-            // Calculate dialog position and children's positions based on padding sizes.
+            //FIXME: Needs to separate GUI implementation codes to style cs file.
             CalculatePosition();
         }
 
-        // Calculate dialog position and children's positions based on padding sizes.
         private void CalculatePosition()
         {
-            if (styleApplied == false)
-            {
-                return;
-            }
-
-            CalculateActionsCellPadding();
-
             var size = Size2D;
             var parent = GetParent();
             Size2D parentSize;
@@ -568,58 +480,5 @@ namespace Tizen.NUI.Components
 
             Position2D = new Position2D((parentSize.Width - size.Width) / 2, (parentSize.Height - size.Height) / 2);
         }
-
-        // Calculate CellPadding among Actions if ActionContent is LinearLayout.
-        private void CalculateActionsCellPadding()
-        {
-            if ((ActionContent != DefaultActionContent) || (ActionContent.Layout is LinearLayout == false))
-            {
-                return;
-            }
-
-            if (Actions == null)
-            {
-                return;
-            }
-
-            var size = Size2D;
-            var layout = ActionContent.Layout as LinearLayout;
-            int count = 0;
-
-            if (layout.LinearOrientation == LinearLayout.Orientation.Horizontal)
-            {
-                int actionsWidth = 0;
-
-                foreach (var action in Actions)
-                {
-                    actionsWidth += ((View)action).Size2D.Width + ((((View)action).Margin?.Start + ((View)action).Margin?.End) ?? 0);
-                    count++;
-                }
-
-                if (count > 1)
-                {
-                    actionsWidth += (Padding?.Start + Padding?.End) ?? 0;
-                    var cellPaddingWidth = (size.Width - actionsWidth) / (count - 1);
-                    layout.CellPadding = new Size2D(cellPaddingWidth , 0);
-                }
-            }
-            else
-            {
-                int actionsHeight = 0;
-
-                foreach (var action in Actions)
-                {
-                    actionsHeight += ((View)action).Size2D.Height + ((((View)action).Margin?.Top + ((View)action).Margin?.Bottom) ?? 0);
-                    count++;
-                }
-
-                if (count > 1)
-                {
-                    actionsHeight += (Padding?.Top + Padding?.Bottom) ?? 0;
-                    var cellPaddingHeight = (size.Height - actionsHeight) / (count - 1);
-                    layout.CellPadding = new Size2D(0, cellPaddingHeight);
-                }
-            }
-        }
     }
 }
diff --git a/src/Tizen.NUI.Components/Style/AlertDialogStyle.cs b/src/Tizen.NUI.Components/Style/AlertDialogStyle.cs
deleted file mode 100755 (executable)
index 0cc8ed8..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.ComponentModel;
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Binding;
-
-namespace Tizen.NUI.Components
-{
-    /// <summary>
-    /// AlertDialogStyle is a class which saves AlertDialog's ux data.
-    /// </summary>
-    [EditorBrowsable(EditorBrowsableState.Never)]
-    public class AlertDialogStyle : ButtonStyle
-    {
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        static AlertDialogStyle() { }
-
-        /// <summary>
-        /// Creates a new instance of a AlertDialogStyle.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public AlertDialogStyle() : base()
-        {
-        }
-
-        /// <summary>
-        /// Creates a new instance of a AlertDialogStyle with style.
-        /// </summary>
-        /// <param name="style">Create AlertDialogStyle by style customized by user.</param>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public AlertDialogStyle(AlertDialogStyle style) : base(style)
-        {
-        }
-
-        /// <summary>
-        /// Gets or sets the AlertDialog Title TextLabel style.
-        /// This style is applied if AlertDialog TitleContent is a TextLabel.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public TextLabelStyle TitleTextLabel { get; set; } = new TextLabelStyle();
-
-        /// <summary>
-        /// Gets or sets the AlertDialog Message TextLabel style.
-        /// This style is applied if AlertDialog Content is a TextLabel.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public TextLabelStyle MessageTextLabel { get; set; } = new TextLabelStyle();
-
-        /// <summary>
-        /// Gets or sets the AlertDialog ActionContent style.
-        /// </summary>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public ViewStyle ActionContent { get; set; } = new ViewStyle();
-
-        /// <summary>
-        /// Style's clone function.
-        /// </summary>
-        /// <param name="bindableObject">The style that need to copy.</param>
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public override void CopyFrom(BindableObject bindableObject)
-        {
-            base.CopyFrom(bindableObject);
-
-            if (bindableObject is AlertDialogStyle alertDialogStyle)
-            {
-                TitleTextLabel.CopyFrom(alertDialogStyle.TitleTextLabel);
-                MessageTextLabel.CopyFrom(alertDialogStyle.MessageTextLabel);
-                ActionContent.CopyFrom(alertDialogStyle.ActionContent);
-            }
-        }
-    }
-}
index cdfd732..84323f2 100755 (executable)
@@ -180,26 +180,6 @@ namespace Tizen.NUI.Components
                     .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;
index 0e79362..d9ebcc7 100755 (executable)
@@ -626,42 +626,6 @@ namespace Tizen.NUI.Components
                 }
             });
 
-            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",
-                TitleTextLabel = new TextLabelStyle()
-                {
-                    Size = new Size(1024, -2),
-                    Margin = new Extents(0, 0, 40, 40),
-                    PixelSize = 40,
-                    HorizontalAlignment = HorizontalAlignment.Center,
-                    VerticalAlignment = VerticalAlignment.Center,
-                    TextColor = new Selector<Color>()
-                    {
-                        Normal = new Color("#000C2BFF"),
-                    },
-                },
-                MessageTextLabel = new TextLabelStyle()
-                {
-                    Size = new Size(1024, -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"),
-                    },
-                },
-                ActionContent = new ViewStyle()
-                {
-                    Size = new Size(1024, -2),
-                },
-            });
-
             return theme;
         }
     }