Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Fix ContentPopup
Browse files Browse the repository at this point in the history
  • Loading branch information
sung-su committed Apr 23, 2020
1 parent 61915f4 commit 008c361
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -65,7 +65,6 @@ public void Dispose()
public void Dismiss()
{
_popup?.Hide();
_popup?.Dismiss();
}

public void Show()
Expand Down Expand Up @@ -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
Expand Down
41 changes: 32 additions & 9 deletions src/Tizen.Wearable.CircularUI.Forms/ContentPopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ContentPopup : Element, IDisposable
/// BindableProperty. Identifies the Content bindable property.
/// </summary>
/// <since_tizen> 4 </since_tizen>
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());

/// <summary>
/// BindableProperty. Identifies the IsShow bindable property.
Expand Down Expand Up @@ -114,22 +114,45 @@ public void SendBackButtonPressed()
BackButtonPressed?.Invoke(this, EventArgs.Empty);
}

void UpdateRenderer()
/// <summary>
/// Dispose the popup.
/// </summary>
/// <since_tizen> 4 </since_tizen>
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)
SetInheritedBindingContext(Content, BindingContext);
}

void UpdateContent()
{
if (Content != null)
OnChildAdded(Content);
}

void UpdateRenderer()
{
if (_renderer == null)
{
_renderer = RendererFunc();
_renderer.SetElement(this);
}
}

}
}
10 changes: 0 additions & 10 deletions src/Tizen.Wearable.CircularUI.Forms/IContentPopupRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ namespace Tizen.Wearable.CircularUI.Forms
/// <since_tizen> 4 </since_tizen>
public interface IContentPopupRenderer : IDisposable
{
/// <summary>
/// Shows the popup.
/// </summary>
void Show();

/// <summary>
/// Dismisses the popup.
/// </summary>
void Dismiss();

/// <summary>
/// Sets the Element associated with this renderer.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Tizen.Wearable.CircularUI.Forms/ITwoButtonPopup.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -72,4 +72,4 @@ internal interface ITwoButtonPopup
/// <since_tizen> 4 </since_tizen>
void Dismiss();
}
}
}

0 comments on commit 008c361

Please sign in to comment.