Merge "Add LayoutOptions properties to Dialog" into tizen
authorSeungkeun Lee <sngn.lee@samsung.com>
Thu, 8 Jun 2017 11:11:27 +0000 (11:11 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Thu, 8 Jun 2017 11:11:27 +0000 (11:11 +0000)
Tizen.Xamarin.Forms.Extension.Renderer/DialogImplementation.cs
Tizen.Xamarin.Forms.Extension/Dialog.cs
Tizen.Xamarin.Forms.Extension/IDialog.cs

index b00e25f..7c58fc0 100644 (file)
@@ -21,6 +21,10 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
         string _title;
         string _subtitle;
         StackLayout _contentView;
+        LayoutOptions _horizontalOption = LayoutOptions.Center;
+        LayoutOptions _verticalOption = LayoutOptions.End;
+
+        LayoutOptions _previousHorizontalOption = LayoutOptions.Center;
 
         bool _isDisposed = false;
 
@@ -137,6 +141,32 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
             }
         }
 
+        public LayoutOptions HorizontalOption
+        {
+            get
+            {
+                return _horizontalOption;
+            }
+            set
+            {
+                _horizontalOption = value;
+                OnPropertyChanged();
+            }
+        }
+
+        public LayoutOptions VerticalOption
+        {
+            get
+            {
+                return _verticalOption;
+            }
+            set
+            {
+                _verticalOption = value;
+                OnPropertyChanged();
+            }
+        }
+
         public void Show()
         {
             _control.Show();
@@ -250,6 +280,14 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
             {
                 UpdateSubtitle();
             }
+            else if (e.PropertyName == Dialog.HorizontalOptionProperty.PropertyName)
+            {
+                UpdateHorizontalOption();
+            }
+            else if (e.PropertyName == Dialog.VerticalOptionProperty.PropertyName)
+            {
+                UpdateVerticalOption();
+            }
         }
 
         void OnPropertyChanged([CallerMemberName] string propertyName = null)
@@ -343,5 +381,62 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
         {
             _control.SetPartText("subtitle,text", Subtitle);
         }
+
+        void UpdateHorizontalOption()
+        {
+            switch (HorizontalOption.Alignment)
+            {
+                case LayoutAlignment.Start:
+                    _control.AlignmentX = 0.0;
+                    break;
+
+                case LayoutAlignment.Center:
+                    _control.AlignmentX = 0.5;
+                    break;
+
+                case LayoutAlignment.End:
+                    _control.AlignmentX = 1.0;
+                    break;
+
+                case LayoutAlignment.Fill:
+                    _control.AlignmentX = -1;
+                    break;
+            }
+            if (HorizontalOption.Alignment == LayoutAlignment.Fill)
+            {
+                UpdateContent();
+                _previousHorizontalOption = HorizontalOption;
+            }
+            else
+            {
+                if (_previousHorizontalOption.Alignment == LayoutAlignment.Fill)
+                {
+                    UpdateContent();
+                    _previousHorizontalOption = HorizontalOption;
+                }
+            }
+        }
+
+        void UpdateVerticalOption()
+        {
+            switch (VerticalOption.Alignment)
+            {
+                case LayoutAlignment.Start:
+                    _control.AlignmentY = 0.0;
+                    break;
+
+                case LayoutAlignment.Center:
+                    _control.AlignmentY = 0.5;
+                    break;
+
+                case LayoutAlignment.End:
+                    _control.AlignmentY = 1.0;
+                    break;
+
+                case LayoutAlignment.Fill:
+                    _control.AlignmentY = -1;
+                    break;
+            }
+        }
     }
 }
\ No newline at end of file
index ca76813..78bac3e 100644 (file)
@@ -70,6 +70,16 @@ namespace Tizen.Xamarin.Forms.Extension
         /// </summary>
         public static readonly BindableProperty SubtitleProperty = BindableProperty.Create(nameof(Subtitle), typeof(string), typeof(Dialog), null);
 
+        /// <summary>
+        /// BindableProperty.Identifies the HorizontalOption bindable property.
+        /// </summary>
+        public static readonly BindableProperty HorizontalOptionProperty = BindableProperty.Create(nameof(HorizontalOption), typeof(LayoutOptions), typeof(Dialog), LayoutOptions.Center);
+
+        /// <summary>
+        /// BindableProperty.Identifies the VerticalOption bindable property.
+        /// </summary>
+        public static readonly BindableProperty VerticalOptionProperty = BindableProperty.Create(nameof(VerticalOption), typeof(LayoutOptions), typeof(Dialog), LayoutOptions.End);
+
         IDialog _dialog = null;
 
         /// <summary>
@@ -126,6 +136,8 @@ namespace Tizen.Xamarin.Forms.Extension
             SetBinding(NegativeProperty, new Binding(nameof(Negative), mode: BindingMode.TwoWay, source: _dialog));
             SetBinding(TitleProperty, new Binding(nameof(Title), mode: BindingMode.TwoWay, source: _dialog));
             SetBinding(SubtitleProperty, new Binding(nameof(Subtitle), mode: BindingMode.TwoWay, source: _dialog));
+            SetBinding(HorizontalOptionProperty, new Binding(nameof(HorizontalOption), mode: BindingMode.TwoWay, source: _dialog));
+            SetBinding(VerticalOptionProperty, new Binding(nameof(VerticalOption), mode: BindingMode.TwoWay, source: _dialog));
         }
 
         /// <summary>
@@ -190,6 +202,24 @@ namespace Tizen.Xamarin.Forms.Extension
         }
 
         /// <summary>
+        /// Gets or sets the LayoutOptions that define how the Dialog gets laid in a layout cycle
+        /// </summary>
+        public LayoutOptions HorizontalOption
+        {
+            get { return (LayoutOptions)GetValue(HorizontalOptionProperty); }
+            set { SetValue(HorizontalOptionProperty, value); }
+        }
+
+        /// <summary>
+        /// Gets or sets the LayoutOptions that define how the Dialog gets laid in a layout cycle
+        /// </summary>
+        public LayoutOptions VerticalOption
+        {
+            get { return (LayoutOptions)GetValue(VerticalOptionProperty); }
+            set { SetValue(VerticalOptionProperty, value); }
+        }
+
+        /// <summary>
         /// Shows the Dialog.
         /// </summary>
         public void Show()
index f450550..4deb6d9 100644 (file)
@@ -25,6 +25,10 @@ namespace Tizen.Xamarin.Forms.Extension
 
         string Subtitle { get; set; }
 
+        LayoutOptions HorizontalOption { get; set; }
+
+        LayoutOptions VerticalOption { get; set; }
+
         void Show();
 
         void Hide();