/*
- * 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.
using System;
using System.ComponentModel;
+using System.Collections.Generic;
using Tizen.NUI.BaseComponents;
namespace Tizen.NUI.Components
{
/// <summary>
- /// Types of the action button of AlertDialog.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public enum AlertDialogActionButtonType
- {
- /// <summary>
- /// Type of the positive action button.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- Positive,
-
- /// <summary>
- /// Type of the negative action button.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- Negative
- }
-
- /// <summary>
/// AlertDialog class shows a dialog with title, message and action buttons.
/// </summary>
[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<View> 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;
-
- /// <summary>
- /// Creates a new instance of AlertDialog.
- /// </summary>
- /// <param name="title">The title of AlertDialog.</param>
- /// <param name="message">The message of AlertDialog.</param>
- /// <param name="positiveButtonText">The positive button text in the action content of AlertDialog.</param>
- /// <param name="positiveButtonClickedHandler">The clicked callback of the positive button in the action content of AlertDialog.</param>
- /// <param name="negativeButtonText">The negative button text in the action content of AlertDialog.</param>
- /// <param name="negativeButtonClickedHandler">The clicked callback of the negative button in the action content of AlertDialog.</param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public AlertDialog(string title, string message, string positiveButtonText, EventHandler<ClickedEventArgs> positiveButtonClickedHandler, string negativeButtonText = null, EventHandler<ClickedEventArgs> 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;
/// <summary>
/// Creates a new instance of AlertDialog.
/// </summary>
- /// <param name="message">The message of AlertDialog.</param>
- /// <param name="positiveButtonText">The positive button text in the action content of AlertDialog.</param>
- /// <param name="positiveButtonClickedHandler">The clicked callback of the positive button in the action content of AlertDialog.</param>
- /// <param name="negativeButtonText">The negative button text in the action content of AlertDialog.</param>
- /// <param name="negativeButtonClickedHandler">The clicked callback of the negative button in the action content of AlertDialog.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- public AlertDialog(string message, string positiveButtonText, EventHandler<ClickedEventArgs> positiveButtonClickedHandler, string negativeButtonText = null, EventHandler<ClickedEventArgs> negativeButtonClickedHandler = null) : this(null, message, positiveButtonText, positiveButtonClickedHandler, negativeButtonText, negativeButtonClickedHandler)
+ public AlertDialog() : base()
{
+ Initialize();
}
/// <summary>
- /// Creates a new instance of AlertDialog.
+ /// Dispose AlertDialog and all children on it.
/// </summary>
- /// <param name="title">The title of AlertDialog.</param>
- /// <param name="message">The message of AlertDialog.</param>
+ /// <param name="type">Dispose type.</param>
[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;
+ }
- /// <summary>
- /// Creates a new instance of AlertDialog.
- /// </summary>
- /// <param name="message">The message of AlertDialog.</param>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public AlertDialog(string message) : this(null, message)
- {
- }
+ if (type == DisposeTypes.Explicit)
+ {
+ if (titleContent != null)
+ {
+ Utility.Dispose(titleContent);
+ }
- /// <summary>
- /// Creates a new instance of AlertDialog.
- /// </summary>
- /// <param name="titleContent">The title content of AlertDialog.</param>
- /// <param name="bodyContent">The content of AlertDialog.</param>
- /// <param name="actionContent">The action content of AlertDialog.</param>
- [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);
}
/// <summary>
- /// Creates a new instance of AlertDialog.
+ /// Applies style to AlertDialog.
/// </summary>
- /// <param name="bodyContent">The content of AlertDialog.</param>
- /// <param name="actionContent">The action content of AlertDialog.</param>
+ /// <param name="viewStyle">The style to apply.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- public AlertDialog(View bodyContent, View actionContent) : this(null, bodyContent, actionContent)
+ public override void ApplyStyle(ViewStyle viewStyle)
{
- }
+ styleApplied = false;
- /// <summary>
- /// Creates a new instance of AlertDialog.
- /// </summary>
- /// <param name="bodyContent">The content of AlertDialog.</param>
- [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();
}
/// <summary>
- /// Title content of AlertDialog. TitleContent is added to Children automatically.
+ /// Title text of AlertDialog.
/// </summary>
[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();
}
}
/// <summary>
- /// BodyContent of AlertDialog. BodyContent is added to Children automatically.
+ /// Title content of AlertDialog. TitleContent is added to Children automatically.
/// </summary>
[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();
}
}
/// <summary>
- /// Action content of AlertDialog. ActionContent is added to Children automatically.
+ /// Message text of AlertDialog.
/// </summary>
[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()
+ /// <summary>
+ /// Content of AlertDialog. Content is added to Children automatically.
+ /// </summary>
+ [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();
}
}
/// <summary>
- /// Title text of AlertDialog.
+ /// Action views of AlertDialog.
+ /// Action views are added to ActionContent of AlertDialog.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public string Title
+ public IEnumerable<View> 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);
}
}
}
/// <summary>
- /// Message text of AlertDialog.
+ /// Action content of AlertDialog. ActionContent is added to Children automatically.
/// </summary>
[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();
}
}
/// <summary>
- /// Sets action button in the action content of AlertDialog.
+ /// AccessibilityGetName.
/// </summary>
- /// <param name="type">The type of action button.</param>
- /// <param name="text">The text of action button in the action content of AlertDialog.</param>
- /// <param name="clickedHandler">The clicked callback of the action button in the action content of AlertDialog.</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- public void SetActionButton(AlertDialogActionButtonType type, string text, EventHandler<ClickedEventArgs> 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;
+ }
+ }
+
+ /// <summary>
+ /// Default title content of AlertDialog.
+ /// If Title is set, then default title content is automatically displayed.
+ /// </summary>
+ [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;
+ }
+ }
+
+ /// <summary>
+ /// Default content of AlertDialog.
+ /// If Message is set, then default content is automatically displayed.
+ /// </summary>
+ [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);
- }
- }
+ /// <summary>
+ /// Default action content of AlertDialog.
+ /// If Actions are set, then default action content is automatically displayed.
+ /// </summary>
+ [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<ClickedEventArgs> 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<ClickedEventArgs> positiveButtonClickedHandler, string negativeButtonText, EventHandler<ClickedEventArgs> 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);
}
- /// <summary>
- /// Dispose AlertDialog and all children on it.
- /// </summary>
- /// <param name="type">Dispose type.</param>
- [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);
- }
-
- /// <summary>
- /// AccessibilityGetName.
- /// </summary>
- [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);
+ }
}
}
}