Fixed Dialog to new way layout 96/128796/4
authorSeunghyun Choi <sh4682.choi@samsung.com>
Thu, 11 May 2017 10:48:17 +0000 (19:48 +0900)
committerSeunghyun Choi <sh4682.choi@samsung.com>
Fri, 12 May 2017 06:24:07 +0000 (15:24 +0900)
Change-Id: I3e7d2b801c9f9a6ea2efd256af7fe4484a598692
Signed-off-by: Seunghyun Choi <sh4682.choi@samsung.com>
Tizen.Xamarin.Forms.Extension.Renderer/DialogImplementation.cs

index 06301e4..9ec4a18 100644 (file)
@@ -20,11 +20,12 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
         Button _negative;
         string _title;
         string _subtitle;
+        StackLayout _contentView;
 
         bool _isDisposed = false;
 
-        bool _isNullable = false;
         ElmSharp.Button _nativePositive;
+
         ElmSharp.Button _nativeNeutral;
         ElmSharp.Button _nativeNegative;
         ElmSharp.EvasObject _nativeContent;
@@ -49,6 +50,8 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
             _control.KeyUp += BackButtonPressedHandler;
 
             PropertyChanged += PropertyChangedHandler;
+
+            _contentView = new StackLayout();
         }
 
         ~DialogImplementation()
@@ -146,7 +149,7 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
 
         public void Dismiss()
         {
-            _control.Dismiss();
+            _control.Hide();
         }
 
         public void Dispose()
@@ -202,6 +205,7 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
 
         void ShowAnimationFinishedHandler(object sender, EventArgs e)
         {
+            _nativeContent.MarkChanged();
             Shown?.Invoke(this, EventArgs.Empty);
             GrabBackkey();
         }
@@ -210,8 +214,6 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
         {
             Dismissed?.Invoke(this, EventArgs.Empty);
             UngrabBackKey();
-            //Native control should be freed after dismissed event occurred. (this is EFL's law.)
-            Dispose();
         }
 
         void OutsideClickedHandler(object sender, EventArgs e)
@@ -262,48 +264,32 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
 
         void UpdateContent()
         {
-            _isNullable = _nativeContent != null ? true : false;
-
-            _nativeContent?.Hide();
-
-            View contentView = null;
+            _contentView.Children.Clear();
 
-            if (Content.GetType() == typeof(ScrollView))
-            {
-                contentView = new StackLayout
-                {
-                    Children =
-                    {
-                        Content
-                    }
-                };
-            }
-            else
+            if (Content != null)
             {
-                contentView = Content;
-            }
+                _contentView.Children.Add(Content);
 
-            if (contentView != null)
-            {
-                contentView.Parent = Application.Current.MainPage;
-                _nativeContent = Platform.GetOrCreateRenderer(contentView).NativeView;
+                _contentView.Platform = Application.Current.MainPage.Platform;
 
-                var sizeRequest = contentView.Measure(TForms.Context.MainWindow.ScreenSize.Width, TForms.Context.MainWindow.ScreenSize.Height).Request.ToPixel();
+                var renderer = Platform.GetOrCreateRenderer(_contentView);
+                (renderer as LayoutRenderer)?.RegisterOnLayoutUpdated();
 
+                var sizeRequest = _contentView.Measure(TForms.Context.MainWindow.ScreenSize.Width, TForms.Context.MainWindow.ScreenSize.Height).Request.ToPixel();
+
+                _nativeContent = renderer.NativeView;
                 _nativeContent.MinimumHeight = sizeRequest.Height;
+
+                _control.SetPartContent("default", _nativeContent, true);
             }
             else
             {
-                _nativeContent = null;
+                _control.SetPartContent("default", null, true);
             }
-
-            _control.SetPartContent("default", _nativeContent, _isNullable);
         }
 
         void UpdatePositive()
         {
-            _isNullable = _nativePositive != null ? true : false;
-
             _nativePositive?.Hide();
 
             if (Positive != null)
@@ -316,13 +302,11 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
                 _nativePositive = null;
             }
 
-            _control.SetPartContent("button1", _nativePositive, _isNullable);
+            _control.SetPartContent("button1", _nativePositive, true);
         }
 
         void UpdateNeutral()
         {
-            _isNullable = _nativeNeutral != null ? true : false;
-
             _nativeNeutral?.Hide();
 
             if (Neutral != null)
@@ -335,13 +319,11 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
                 _nativeNeutral = null;
             }
 
-            _control.SetPartContent("button2", _nativeNeutral, _isNullable);
+            _control.SetPartContent("button2", _nativeNeutral, true);
         }
 
         void UpdateNegative()
         {
-            _isNullable = _nativeNegative != null ? true : false;
-
             _nativeNegative?.Hide();
 
             if (Negative != null)
@@ -354,7 +336,7 @@ namespace Tizen.Xamarin.Forms.Extension.Renderer
                 _nativeNegative = null;
             }
 
-            _control.SetPartContent("button3", _nativeNegative, _isNullable);
+            _control.SetPartContent("button3", _nativeNegative, true);
         }
 
         void UpdateTitle()