From 0527f1441bec0ce6e5c5be9cdfd338dc515c3194 Mon Sep 17 00:00:00 2001 From: "sung-su.kim" Date: Thu, 23 Apr 2020 16:59:34 +0900 Subject: [PATCH] Fix ContentPopup --- .../ContentPopupRenderer.cs | 8 ++-- .../ContentPopup.cs | 46 +++++++++++++++---- .../IContentPopupRenderer.cs | 10 ---- .../ITwoButtonPopup.cs | 4 +- 4 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/Tizen.Wearable.CircularUI.Forms.Renderer/ContentPopupRenderer.cs b/src/Tizen.Wearable.CircularUI.Forms.Renderer/ContentPopupRenderer.cs index 5dc88ff4..c4959a36 100644 --- a/src/Tizen.Wearable.CircularUI.Forms.Renderer/ContentPopupRenderer.cs +++ b/src/Tizen.Wearable.CircularUI.Forms.Renderer/ContentPopupRenderer.cs @@ -33,9 +33,9 @@ public class ContentPopupRenderer : IContentPopupRenderer public void SetElement(Element element) { - element.Parent = Application.Current.Parent; + if (element.Parent == null) + element.Parent = Application.Current; element.PropertyChanged += OnElementPropertyChanged; - _element = element as ContentPopup; UpdateContent(); @@ -65,7 +65,6 @@ public void Dispose() public void Dismiss() { _popup?.Hide(); - _popup?.Dismiss(); } public void Show() @@ -122,8 +121,7 @@ void UpdateContent() var renderer = Platform.GetOrCreateRenderer(_element.Content); (renderer as LayoutRenderer)?.RegisterOnLayoutUpdated(); var native = renderer.NativeView; - var sizeRequest = _element.Content.Measure(XForms.NativeParent.Geometry.Width, XForms.NativeParent.Geometry.Height).Request.ToPixel(); - native.MinimumHeight = sizeRequest.Height; + native.MinimumHeight = 360; _popup.SetContent(native, false); } else diff --git a/src/Tizen.Wearable.CircularUI.Forms/ContentPopup.cs b/src/Tizen.Wearable.CircularUI.Forms/ContentPopup.cs index 73aafc56..fb7b3b40 100644 --- a/src/Tizen.Wearable.CircularUI.Forms/ContentPopup.cs +++ b/src/Tizen.Wearable.CircularUI.Forms/ContentPopup.cs @@ -38,7 +38,7 @@ public class ContentPopup : Element, IDisposable /// BindableProperty. Identifies the Content bindable property. /// /// 4 - public static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(View), typeof(ContentPopup), null); + public static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(View), typeof(ContentPopup), null, propertyChanged: (b, o, n) => ((ContentPopup)b).UpdateContent()); /// /// BindableProperty. Identifies the IsShow bindable property. @@ -114,22 +114,50 @@ public void SendBackButtonPressed() BackButtonPressed?.Invoke(this, EventArgs.Empty); } - void UpdateRenderer() + /// + /// Dispose the popup. + /// + /// 4 + public void Dispose() { - if (_renderer == null) - { - _renderer = RendererFunc(); - _renderer.SetElement(this); - } + Dispose(true); } - public void Dispose() + protected virtual void Dispose(bool disposing) { - if (_renderer != null) + if (disposing && _renderer != null) { _renderer.Dispose(); _renderer = null; } } + + protected override void OnBindingContextChanged() + { + base.OnBindingContextChanged(); + if (Content != null) + { + if (Content.BindingContext == null) + { + SetInheritedBindingContext(Content, BindingContext); + } + } + } + + void UpdateContent() + { + if (Content != null) + OnChildAdded(Content); + } + + void UpdateRenderer() + { + if (_renderer == null) + { + _renderer = RendererFunc(); + _renderer.SetElement(this); + } + } + } } diff --git a/src/Tizen.Wearable.CircularUI.Forms/IContentPopupRenderer.cs b/src/Tizen.Wearable.CircularUI.Forms/IContentPopupRenderer.cs index 9c9b576c..dab7be9e 100644 --- a/src/Tizen.Wearable.CircularUI.Forms/IContentPopupRenderer.cs +++ b/src/Tizen.Wearable.CircularUI.Forms/IContentPopupRenderer.cs @@ -25,16 +25,6 @@ namespace Tizen.Wearable.CircularUI.Forms /// 4 public interface IContentPopupRenderer : IDisposable { - /// - /// Shows the popup. - /// - void Show(); - - /// - /// Dismisses the popup. - /// - void Dismiss(); - /// /// Sets the Element associated with this renderer. /// diff --git a/src/Tizen.Wearable.CircularUI.Forms/ITwoButtonPopup.cs b/src/Tizen.Wearable.CircularUI.Forms/ITwoButtonPopup.cs index b4e1adc7..79473668 100644 --- a/src/Tizen.Wearable.CircularUI.Forms/ITwoButtonPopup.cs +++ b/src/Tizen.Wearable.CircularUI.Forms/ITwoButtonPopup.cs @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Flora License, Version 1.1 (the "License"); * you may not use this file except in compliance with the License. @@ -72,4 +72,4 @@ internal interface ITwoButtonPopup /// 4 void Dismiss(); } -} \ No newline at end of file +}