From b60730aabd7b066177f05d341a0a9d7beb73dd73 Mon Sep 17 00:00:00 2001 From: "huiyu.eun" Date: Tue, 20 Apr 2021 15:01:52 +0900 Subject: [PATCH] Revert "Revert "[NUI] Add AlertDialogStyle class with the latest AlertDialog UX"" This reverts commit 18a2050cf2890d02668449571e5950ef3c3faf42. Signed-off-by: huiyu.eun --- src/Tizen.NUI.Components/Controls/AlertDialog.cs | 722 +++++++++++---------- src/Tizen.NUI.Components/Style/AlertDialogStyle.cs | 86 +++ src/Tizen.NUI.Components/Theme/DefaultTheme.cs | 20 + .../Theme/DefaultThemeCommon.cs | 36 + 4 files changed, 516 insertions(+), 348 deletions(-) create mode 100755 src/Tizen.NUI.Components/Style/AlertDialogStyle.cs diff --git a/src/Tizen.NUI.Components/Controls/AlertDialog.cs b/src/Tizen.NUI.Components/Controls/AlertDialog.cs index 6e42b4c..b1b3ee5 100755 --- a/src/Tizen.NUI.Components/Controls/AlertDialog.cs +++ b/src/Tizen.NUI.Components/Controls/AlertDialog.cs @@ -1,5 +1,5 @@ /* - * Copyright(c) 2020 Samsung Electronics Co., Ltd. + * 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. @@ -17,582 +17,608 @@ using System; using System.ComponentModel; +using System.Collections.Generic; using Tizen.NUI.BaseComponents; namespace Tizen.NUI.Components { /// - /// Types of the action button of AlertDialog. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public enum AlertDialogActionButtonType - { - /// - /// Type of the positive action button. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - Positive, - - /// - /// Type of the negative action button. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - Negative - } - - /// /// AlertDialog class shows a dialog with title, message and action buttons. /// [EditorBrowsable(EditorBrowsableState.Never)] - public class AlertDialog : Dialog + public class AlertDialog : Control { private string title = null; private string message = null; - private View popupTitle = null; - private View popupContent = null; - private View popupAction = null; + private View titleContent = null; + private View content = null; + private View actionContent = null; + private IEnumerable actionContentViews = null; 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 Button positiveButton = null; - private Button negativeButton = null; - - /// - /// Creates a new instance of AlertDialog. - /// - /// The title of AlertDialog. - /// The message of AlertDialog. - /// The positive button text in the action content of AlertDialog. - /// The clicked callback of the positive button in the action content of AlertDialog. - /// The negative button text in the action content of AlertDialog. - /// The clicked callback of the negative button in the action content of AlertDialog. - [EditorBrowsable(EditorBrowsableState.Never)] - public AlertDialog(string title, string message, string positiveButtonText, EventHandler positiveButtonClickedHandler, string negativeButtonText = null, EventHandler negativeButtonClickedHandler = null) : base() - { - //Content is initialized to add TitleContent, BodyContent and ActionContent. - //FIXME: Needs to separate GUI implementation codes to style cs file. - InitContent(); - - //Title setter calls TitleContent setter if TitleContent is null. - Title = title; + private AlertDialogStyle alertDialogStyle => ViewStyle as AlertDialogStyle; - //Message setter calls BodyContent setter if BodyContent is null. - Message = message; - - ActionContent = CreateActionContent(positiveButtonText, positiveButtonClickedHandler, negativeButtonText, negativeButtonClickedHandler); - } + private bool styleApplied = false; /// /// Creates a new instance of AlertDialog. /// - /// The message of AlertDialog. - /// The positive button text in the action content of AlertDialog. - /// The clicked callback of the positive button in the action content of AlertDialog. - /// The negative button text in the action content of AlertDialog. - /// The clicked callback of the negative button in the action content of AlertDialog. [EditorBrowsable(EditorBrowsableState.Never)] - public AlertDialog(string message, string positiveButtonText, EventHandler positiveButtonClickedHandler, string negativeButtonText = null, EventHandler negativeButtonClickedHandler = null) : this(null, message, positiveButtonText, positiveButtonClickedHandler, negativeButtonText, negativeButtonClickedHandler) + public AlertDialog() : base() { + Initialize(); } /// - /// Creates a new instance of AlertDialog. + /// Dispose AlertDialog and all children on it. /// - /// The title of AlertDialog. - /// The message of AlertDialog. + /// Dispose type. [EditorBrowsable(EditorBrowsableState.Never)] - public AlertDialog(string title, string message) : this(title, message, null, null, null, null) + protected override void Dispose(DisposeTypes type) { - } + if (disposed) + { + return; + } - /// - /// Creates a new instance of AlertDialog. - /// - /// The message of AlertDialog. - [EditorBrowsable(EditorBrowsableState.Never)] - public AlertDialog(string message) : this(null, message) - { - } + if (type == DisposeTypes.Explicit) + { + if (titleContent != null) + { + Utility.Dispose(titleContent); + } - /// - /// Creates a new instance of AlertDialog. - /// - /// The title content of AlertDialog. - /// The content of AlertDialog. - /// The action content of AlertDialog. - [EditorBrowsable(EditorBrowsableState.Never)] - public AlertDialog(View titleContent, View bodyContent, View actionContent) : base() - { - //Content is initialized to add TitleContent, BodyContent and ActionContent. - //FIXME: Needs to separate GUI implementation codes to style cs file. - InitContent(); + if (content != null) + { + Utility.Dispose(content); + } - TitleContent = titleContent; + if (actionContent != null) + { + Utility.Dispose(actionContent); + } - BodyContent = bodyContent; + // 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); + } + } - ActionContent = actionContent; + base.Dispose(type); } /// - /// Creates a new instance of AlertDialog. + /// Applies style to AlertDialog. /// - /// The content of AlertDialog. - /// The action content of AlertDialog. + /// The style to apply. [EditorBrowsable(EditorBrowsableState.Never)] - public AlertDialog(View bodyContent, View actionContent) : this(null, bodyContent, actionContent) + public override void ApplyStyle(ViewStyle viewStyle) { - } + styleApplied = false; - /// - /// Creates a new instance of AlertDialog. - /// - /// The content of AlertDialog. - [EditorBrowsable(EditorBrowsableState.Never)] - public AlertDialog(View bodyContent = null) : this(bodyContent, null) - { - } + base.ApplyStyle(viewStyle); - private void InitContent() - { - var content = new Control(); + // 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); + } - var linearLayout = new LinearLayout(); - linearLayout.LinearOrientation = LinearLayout.Orientation.Vertical; - content.Layout = linearLayout; + styleApplied = true; - Content = content; + // Calculate dialog position and children's positions based on padding sizes. + CalculatePosition(); } /// - /// Title content of AlertDialog. TitleContent is added to Children automatically. + /// Title text of AlertDialog. /// [EditorBrowsable(EditorBrowsableState.Never)] - public View TitleContent + public string Title { get { - return popupTitle; + return title; } set { - if (popupTitle == value) + if (title == value) { return; } - if (popupTitle != null) - { - Remove(popupTitle); - } + title = value; - popupTitle = value; - if (popupTitle == null) + if (TitleContent is TextLabel textLabel) { - return; + textLabel.Text = title; } - - ResetContent(); } } /// - /// BodyContent of AlertDialog. BodyContent is added to Children automatically. + /// Title content of AlertDialog. TitleContent is added to Children automatically. /// [EditorBrowsable(EditorBrowsableState.Never)] - public View BodyContent + public View TitleContent { get { - return popupContent; + return titleContent; } set { - if (popupContent == value) + if (titleContent == value) { return; } - if (popupContent != null) + if (titleContent != null) { - Remove(popupContent); + Remove(titleContent); } - popupContent = value; - if (popupContent == null) + titleContent = value; + if (titleContent == null) { return; } + if (titleContent is TextLabel textLabel) + { + textLabel.Text = Title; + } + ResetContent(); } } /// - /// Action content of AlertDialog. ActionContent is added to Children automatically. + /// Message text of AlertDialog. /// [EditorBrowsable(EditorBrowsableState.Never)] - public View ActionContent + public string Message { get { - return popupAction; + return message; } set { - if (popupAction == value) + if (message == value) { return; } - if (popupAction != null) - { - Remove(popupAction); - } + message = value; - popupAction = value; - if (popupAction == null) + if (Content is TextLabel textLabel) { - return; + textLabel.Text = message; } - - ResetContent(); } } - private void ResetContent() + /// + /// Content of AlertDialog. Content is added to Children automatically. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public View Content { - if (Content == null) - { - return; - } - - //To keep the order of TitleContent, BodyContent and ActionContent, - //the existing contents are removed and added again. - if (popupTitle != null) + get { - Content.Remove(popupTitle); + return content; } - - if (popupContent != null) + set { - Content.Remove(popupContent); - } + if (content == value) + { + return; + } - if (popupAction != null) - { - Content.Remove(popupAction); - } + if (content != null) + { + Remove(content); + } - if (popupTitle != null) - { - Content.Add(popupTitle); - } + content = value; + if (content == null) + { + return; + } - if (popupContent != null) - { - Content.Add(popupContent); - } + if (content is TextLabel textLabel) + { + textLabel.Text = message; + } - if (popupAction != null) - { - Content.Add(popupAction); + ResetContent(); } } /// - /// Title text of AlertDialog. + /// Action views of AlertDialog. + /// Action views are added to ActionContent of AlertDialog. /// [EditorBrowsable(EditorBrowsableState.Never)] - public string Title + public IEnumerable Actions { get { - return title; + return actionContentViews; } set { - if (title == value) + if (ActionContent == null) { + actionContentViews = value; return; } - title = value; - if (title == null) + if (actionContentViews != null) { - if (TitleContent != null) + foreach (var oldAction in actionContentViews) { - //TitleContent setter calls Remove(popupTitle). - TitleContent = null; + if (ActionContent.Children?.Contains(oldAction) == true) + { + ActionContent.Children.Remove(oldAction); + } } } - else + + actionContentViews = value; + + if (actionContentViews == null) { - if (TitleContent == null) - { - TitleContent = CreateTitleContent(title); - } - else if (TitleContent == defaultTitleContent) - { - //Sets text if TitleContent is not set by user. - ((TextLabel)TitleContent).Text = title; - } + return; + } + + foreach (var action in actionContentViews) + { + ActionContent.Add(action); } } } /// - /// Message text of AlertDialog. + /// Action content of AlertDialog. ActionContent is added to Children automatically. /// [EditorBrowsable(EditorBrowsableState.Never)] - public string Message + public View ActionContent { - get - { - return message; - } - set - { - if (message == value) + get + { + return actionContent; + } + set + { + if (actionContent == value) + { + return; + } + + var oldActionContent = actionContent; + actionContent = value; + + // Add views first before remove previous action content + // not to cause Garbage Collector collects views. + if ((actionContent != null) && (Actions != null)) { - return; + foreach (var action in Actions) + { + actionContent.Add(action); + } } - message = value; - if (message == null) + if (oldActionContent != null) { - if (BodyContent != null) - { - //BodyContent setter calls Remove(popupContent). - BodyContent = null; - } + Remove(oldActionContent); } - else + + if (actionContent == null) { - if (BodyContent == null) - { - BodyContent = CreateContent(message); - } - else if (BodyContent == defaultContent) - { - //Sets text if BodyContent is not set by user. - ((TextLabel)BodyContent).Text = message; - } + return; } + + ResetContent(); } } /// - /// Sets action button in the action content of AlertDialog. + /// AccessibilityGetName. /// - /// The type of action button. - /// The text of action button in the action content of AlertDialog. - /// The clicked callback of the action button in the action content of AlertDialog. [EditorBrowsable(EditorBrowsableState.Never)] - public void SetActionButton(AlertDialogActionButtonType type, string text, EventHandler clickedHandler) + protected override string AccessibilityGetName() { - if (ActionContent == null) + if (!String.IsNullOrEmpty(Title)) { - if (type == AlertDialogActionButtonType.Positive) - { - ActionContent = CreateActionContent(text, clickedHandler, null, null); - } - else - { - ActionContent = CreateActionContent(null, null, text, clickedHandler); - } + return Title; } - else if (ActionContent == defaultActionContent) + else + { + return Message; + } + } + + /// + /// Default title content of AlertDialog. + /// If Title is set, then default title content is automatically displayed. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected View DefaultTitleContent + { + get { - //To keep the order of negativeButton and positiveButton, - //positiveButton is always removed. - if (positiveButton != null) + if (defaultTitleContent == null) { - ActionContent.Remove(positiveButton); + defaultTitleContent = CreateDefaultTitleContent(); } - if (type == AlertDialogActionButtonType.Negative) + return defaultTitleContent; + } + } + + /// + /// Default content of AlertDialog. + /// If Message is set, then default content is automatically displayed. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected View DefaultContent + { + get + { + if (defaultContent == null) { - if (negativeButton != null) - { - ActionContent.Remove(negativeButton); - } + defaultContent = CreateDefaultContent(); + } - negativeButton = CreateActionButton(text, clickedHandler); - if (negativeButton != null) - { - ActionContent.Add(negativeButton); + return defaultContent; + } + } - if (positiveButton != null) - { - ActionContent.Add(positiveButton); - } - } + /// + /// Default action content of AlertDialog. + /// If Actions are set, then default action content is automatically displayed. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected View DefaultActionContent + { + get + { + if (defaultActionContent == null) + { + defaultActionContent = CreateDefaultActionContent(); } - else + + // 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) { - positiveButton = CreateActionButton(text, clickedHandler); - if (positiveButton != null) - { - ActionContent.Add(positiveButton); - } + defaultActionContentPadding = CreateDefaultActionContentPadding(); } + + return defaultActionContent; } } - private TextLabel CreateTitleContent(string text) + private void Initialize() { - if (text == null) + Layout = new LinearLayout() { - return null; - } + LinearOrientation = LinearLayout.Orientation.Vertical, + }; - //FIXME: Needs to separate GUI implementation codes to style cs file. - var titleContent = new TextLabel(text); - titleContent.HorizontalAlignment = HorizontalAlignment.Center; - titleContent.VerticalAlignment = VerticalAlignment.Center; - titleContent.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 1.0f); - titleContent.Size = new Size(360, 80); + this.Relayout += OnRelayout; - defaultTitleContent = titleContent; + TitleContent = DefaultTitleContent; - return titleContent; + Content = DefaultContent; + + ActionContent = DefaultActionContent; } - private TextLabel CreateContent(string message) + private void ResetContent() { - if (message == null) + //To keep the order of TitleContent, Content and ActionContent, + //the existing contents are removed and added again. + if (titleContent != null) { - return null; + Remove(titleContent); + } + + if (content != null) + { + Remove(content); + } + + if (actionContent != null) + { + Remove(actionContent); + } + + if (titleContent != null) + { + Add(titleContent); + } + + if (content != null) + { + Add(content); + } + + 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); + } + } } + } - //FIXME: Needs to separate GUI implementation codes to style cs file. - var messageContent = new TextLabel(message); - messageContent.HorizontalAlignment = HorizontalAlignment.Center; - messageContent.VerticalAlignment = VerticalAlignment.Center; - messageContent.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 1.0f); - messageContent.Size = new Size(360, 200); + private TextLabel CreateDefaultTitleContent() + { + return new TextLabel(); + } - defaultContent = messageContent; + private TextLabel CreateDefaultContent() + { + return new TextLabel(); + } - return messageContent; + private View CreateDefaultActionContent() + { + return new View() + { + Layout = new LinearLayout() + { + LinearOrientation = LinearLayout.Orientation.Horizontal, + }, + }; } - private Button CreateActionButton(string text, EventHandler clickedHandler) + // 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() { - if (text == null) + var layout = Layout as LinearLayout; + + if ((layout == null) || (defaultActionContent == null)) { return null; } - //FIXME: Needs to separate GUI implementation codes to style cs file. - var actionButton = new Button(); - actionButton.Text = text; - actionButton.Size = new Size(120, 80); + View paddingView = null; - if (clickedHandler != null) + using (Size2D size = new Size2D(defaultActionContent.Size2D.Width, defaultActionContent.Size2D.Height)) { - actionButton.Clicked += clickedHandler; + if (layout.LinearOrientation == LinearLayout.Orientation.Horizontal) + { + size.Width = 40; + } + else + { + size.Height = 40; + } + + paddingView = new View() + { + Size2D = new Size2D(size.Width, size.Height), + }; } - return actionButton; + return paddingView; + } + + private void OnRelayout(object sender, EventArgs e) + { + // Calculate dialog position and children's positions based on padding sizes. + CalculatePosition(); } - private View CreateActionContent(string positiveButtonText, EventHandler positiveButtonClickedHandler, string negativeButtonText, EventHandler negativeButtonClickedHandler) + // Calculate dialog position and children's positions based on padding sizes. + private void CalculatePosition() { - if ((negativeButtonText == null) && (positiveButtonText == null)) + if (styleApplied == false) { - return null; + return; } - //FIXME: Needs to separate GUI implementation codes to style cs file. - var actionContent = new Control(); - actionContent.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 1.0f); - actionContent.Size = new Size(360, 80); + CalculateActionsCellPadding(); - //FIXME: Needs to separate GUI implementation codes to style cs file. - var actionLayout = new LinearLayout(); - actionLayout.LinearOrientation = LinearLayout.Orientation.Horizontal; - actionLayout.LinearAlignment = LinearLayout.Alignment.CenterHorizontal; - actionLayout.CellPadding = new Size2D(10, 0); - actionContent.Layout = actionLayout; + var size = Size2D; + var parent = GetParent(); + Size2D parentSize; - negativeButton = CreateActionButton(negativeButtonText, negativeButtonClickedHandler); - if (negativeButton != null) + if ((parent != null) && (parent is View)) { - actionContent.Add(negativeButton); + parentSize = ((View)parent).Size; } - - positiveButton = CreateActionButton(positiveButtonText, positiveButtonClickedHandler); - if (positiveButton != null) + else { - actionContent.Add(positiveButton); + parentSize = NUIApplication.GetDefaultWindow().Size; } - defaultActionContent = actionContent; - - return actionContent; + Position2D = new Position2D((parentSize.Width - size.Width) / 2, (parentSize.Height - size.Height) / 2); } - /// - /// Dispose AlertDialog and all children on it. - /// - /// Dispose type. - [EditorBrowsable(EditorBrowsableState.Never)] - protected override void Dispose(DisposeTypes type) + // Calculate CellPadding among Actions if ActionContent is LinearLayout. + private void CalculateActionsCellPadding() { - if (disposed) + if ((ActionContent != DefaultActionContent) || (ActionContent.Layout is LinearLayout == false)) { return; } - if (type == DisposeTypes.Explicit) + if (Actions == null) { - if (popupTitle != null) - { - Utility.Dispose(popupTitle); - } + return; + } + + var size = Size2D; + var layout = ActionContent.Layout as LinearLayout; + int count = 0; - if (popupContent != null) + if (layout.LinearOrientation == LinearLayout.Orientation.Horizontal) + { + int actionsWidth = 0; + + foreach (var action in Actions) { - Utility.Dispose(popupContent); + actionsWidth += ((View)action).Size2D.Width + ((((View)action).Margin?.Start + ((View)action).Margin?.End) ?? 0); + count++; } - if (popupAction != null) + if (count > 1) { - if (positiveButton != null) - { - Utility.Dispose(positiveButton); - } - - if (negativeButton != null) - { - Utility.Dispose(negativeButton); - } - - Utility.Dispose(popupAction); + actionsWidth += (Padding?.Start + Padding?.End) ?? 0; + var cellPaddingWidth = (size.Width - actionsWidth) / (count - 1); + layout.CellPadding = new Size2D(cellPaddingWidth , 0); } } - - base.Dispose(type); - } - - /// - /// AccessibilityGetName. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - protected override string AccessibilityGetName() - { - if (!String.IsNullOrEmpty(Title)) - { - return Title; - } else { - return Message; + 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 new file mode 100755 index 0000000..0cc8ed8 --- /dev/null +++ b/src/Tizen.NUI.Components/Style/AlertDialogStyle.cs @@ -0,0 +1,86 @@ +/* + * 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 +{ + /// + /// AlertDialogStyle is a class which saves AlertDialog's ux data. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class AlertDialogStyle : ButtonStyle + { + [EditorBrowsable(EditorBrowsableState.Never)] + static AlertDialogStyle() { } + + /// + /// Creates a new instance of a AlertDialogStyle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public AlertDialogStyle() : base() + { + } + + /// + /// Creates a new instance of a AlertDialogStyle with style. + /// + /// Create AlertDialogStyle by style customized by user. + [EditorBrowsable(EditorBrowsableState.Never)] + public AlertDialogStyle(AlertDialogStyle style) : base(style) + { + } + + /// + /// Gets or sets the AlertDialog Title TextLabel style. + /// This style is applied if AlertDialog TitleContent is a TextLabel. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public TextLabelStyle TitleTextLabel { get; set; } = new TextLabelStyle(); + + /// + /// Gets or sets the AlertDialog Message TextLabel style. + /// This style is applied if AlertDialog Content is a TextLabel. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public TextLabelStyle MessageTextLabel { get; set; } = new TextLabelStyle(); + + /// + /// Gets or sets the AlertDialog ActionContent style. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ViewStyle ActionContent { get; set; } = new ViewStyle(); + + /// + /// Style's clone function. + /// + /// The style that need to copy. + [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); + } + } + } +} diff --git a/src/Tizen.NUI.Components/Theme/DefaultTheme.cs b/src/Tizen.NUI.Components/Theme/DefaultTheme.cs index 84323f2..cdfd732 100755 --- a/src/Tizen.NUI.Components/Theme/DefaultTheme.cs +++ b/src/Tizen.NUI.Components/Theme/DefaultTheme.cs @@ -180,6 +180,26 @@ namespace Tizen.NUI.Components .Add("/Pickers/Divider/Position", (ViewStyle style, Position value) => ((DatePickerStyle)style).Pickers.Divider.Position = value) .AddSelector("/Pickers/Divider/BackgroundColor", (ViewStyle style, Selector value) => ((DatePickerStyle)style).Pickers.Divider.BackgroundColor = value, ControlState.Selected) .Add("/Pickers/StartScrollOffset", (ViewStyle style, Size value) => ((DatePickerStyle)style).Pickers.StartScrollOffset = value), + + // AlertDialog + (new ExternalThemeKeyList(typeof(AlertDialog), typeof(AlertDialogStyle))) + .Add("/Size", (ViewStyle style, Size value) => ((ViewStyle)style).Size = value) + .Add("/Padding", (ViewStyle style, Extents value) => ((ViewStyle)style).Padding = value) + .Add("/BackgroundImage", (ViewStyle style, string value) => ((ViewStyle)style).BackgroundImage = value) + .Add("/TitleTextLabel/Size", (ViewStyle style, Size value) => ((AlertDialogStyle)style).TitleTextLabel.Size = value) + .Add("/TitleTextLabel/Margin", (ViewStyle style, Extents value) => ((AlertDialogStyle)style).TitleTextLabel.Margin = value) + .Add("/TitleTextLabel/PixelSize", (ViewStyle style, float? value) => ((AlertDialogStyle)style).TitleTextLabel.PixelSize = value) + .Add("/TitleTextLabel/HorizontalAlignment", (ViewStyle style, HorizontalAlignment? value) => ((AlertDialogStyle)style).TitleTextLabel.HorizontalAlignment = value) + .Add("/TitleTextLabel/VerticalAlignment", (ViewStyle style, VerticalAlignment? value) => ((AlertDialogStyle)style).TitleTextLabel.VerticalAlignment = value) + .AddSelector("/TitleTextLabel/TextColor", (ViewStyle style, Selector value) => ((AlertDialogStyle)style).TitleTextLabel.TextColor = value) + .Add("/MessageTextLabel/Size", (ViewStyle style, Size value) => ((AlertDialogStyle)style).MessageTextLabel.Size = value) + .Add("/MessageTextLabel/Margin", (ViewStyle style, Extents value) => ((AlertDialogStyle)style).MessageTextLabel.Margin = value) + .Add("/MessageTextLabel/PixelSize", (ViewStyle style, float? value) => ((AlertDialogStyle)style).MessageTextLabel.PixelSize = value) + .Add("/MessageTextLabel/MultiLine", (ViewStyle style, bool? value) => ((AlertDialogStyle)style).MessageTextLabel.MultiLine = value) + .Add("/MessageTextLabel/HorizontalAlignment", (ViewStyle style, HorizontalAlignment? value) => ((AlertDialogStyle)style).MessageTextLabel.HorizontalAlignment = value) + .Add("/MessageTextLabel/VerticalAlignment", (ViewStyle style, VerticalAlignment? value) => ((AlertDialogStyle)style).MessageTextLabel.VerticalAlignment = value) + .AddSelector("/MessageTextLabel/TextColor", (ViewStyle style, Selector value) => ((AlertDialogStyle)style).MessageTextLabel.TextColor = value) + .Add("/ActionContent/Size", (ViewStyle style, Size value) => ((AlertDialogStyle)style).ActionContent.Size = value), }; return actionSet; diff --git a/src/Tizen.NUI.Components/Theme/DefaultThemeCommon.cs b/src/Tizen.NUI.Components/Theme/DefaultThemeCommon.cs index d9ebcc7..0e79362 100755 --- a/src/Tizen.NUI.Components/Theme/DefaultThemeCommon.cs +++ b/src/Tizen.NUI.Components/Theme/DefaultThemeCommon.cs @@ -626,6 +626,42 @@ 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() + { + 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() + { + Normal = new Color("#000C2BFF"), + }, + }, + ActionContent = new ViewStyle() + { + Size = new Size(1024, -2), + }, + }); + return theme; } } -- 2.7.4