Conversation
| /// BindableProperty. Identifies the content bindable property. | ||
| /// </summary> | ||
| /// <since_tizen> 4 </since_tizen> | ||
| public static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(View), typeof(TwoButtonPopup), null); |
There was a problem hiding this comment.
| public static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(View), typeof(TwoButtonPopup), null); | |
| public static readonly BindableProperty ContentProperty = BindableProperty.Create(nameof(Content), typeof(View), typeof(ContentPopup), null); |
|
Currently, I am considering changing to a renderer structure. |
| } | ||
| } | ||
|
|
||
| public void Dispose() |
There was a problem hiding this comment.
Use Dispose pattern
public void Dispose()
{
Dispose(true);
}
protected virtual void Dispose(bool disposing)
{
if (disposing && _renderer != null)
{
_renderer.Dispose();
_renderer = null;
}
}| /// <summary> | ||
| /// Shows the popup. | ||
| /// </summary> | ||
| void Show(); |
| public void Dismiss() | ||
| { | ||
| _popup?.Hide(); | ||
| _popup?.Dismiss(); |
There was a problem hiding this comment.
Should not use Dismiss, because it destroy popup
| /// 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); |
There was a problem hiding this comment.
Need to update parent
void UpdateContent()
{
OnChildAdded(Content);
} // it is method of Element
protected virtual void OnChildAdded(Element child)
{
child.Parent = this;
child.ApplyBindings(skipBindingContext: false, fromBindingContextChanged: true);
ChildAdded?.Invoke(this, new ElementEventArgs(child));
OnDescendantAdded(child);
foreach (Element element in child.Descendants())
OnDescendantAdded(element);
}|
|
||
| public void SetElement(Element element) | ||
| { | ||
| element.Parent = Application.Current.Parent; |
| 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(); |
| (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; |
There was a problem hiding this comment.
Content should be always fullscreen size
|
Please test BindingContext chaining is working on ContentPopup. ContentPopup should use parent's BindingContext, if not set a BindingContext |
| { | ||
| if (IsInitialized) return; | ||
| IsInitialized = true; | ||
| ContentPopup.RendererFunc = () => new ContentPopupRenderer(); |
There was a problem hiding this comment.
where this technique come from?
| ElmSharp.Popup _popup; | ||
| ContentPopup _element; | ||
|
|
||
| public void SetElement(Element element) |
There was a problem hiding this comment.
| public void SetElement(Element element) | |
| public void SetElement(ContentPopup element) |
Because it is ContentPopupRenderer
| void OnDismissed(object sender, EventArgs e) | ||
| { | ||
| _element.SendDismissed(); | ||
| Dispose(); |
| var renderer = Platform.GetOrCreateRenderer(_element.Content); | ||
| (renderer as LayoutRenderer)?.RegisterOnLayoutUpdated(); | ||
| var native = renderer.NativeView; | ||
| native.MinimumHeight = 360; |
There was a problem hiding this comment.
Do not use static value 360
How about use align and weight?
native.AlignmentX= -1;
native.AlignmentY= -1;
native.WeightX = 1;
native.WeightY = 1;| { | ||
| if (IsInitialized) return; | ||
| IsInitialized = true; | ||
| ContentPopup.RendererFunc = () => new ContentPopupRenderer(); |
There was a problem hiding this comment.
| ContentPopup.RendererFunc = () => new ContentPopupRenderer(); | |
| ContentPopup.CreateRenderer = () => new ContentPopupRenderer(); |
|
|
||
| private void OnContentPopupDismissButtonClicked(object sender, EventArgs e) | ||
| { | ||
| ContentPopup _popup = new ContentPopup(); |
There was a problem hiding this comment.
using (ContentPopup _popup = new ContentPopup())
{
var dismiss = new Button
{
Text = "Dismiss",
};
dismiss.Clicked += (s, ee) =>
{
_popup?.Dismiss();
label1.Text = "Test2 Dismissed";
};
var label = new Label
{
Text = "This ContentPopup is dismissed as a below dismiss button.",
HorizontalTextAlignment = TextAlignment.Center,
};
var grid = new Grid();
grid.HeightRequest = 360;
grid.WidthRequest = 360;
grid.RowDefinitions.Add(new RowDefinition());
grid.RowDefinitions.Add(new RowDefinition());
grid.RowDefinitions.Add(new RowDefinition());
grid.RowDefinitions.Add(new RowDefinition());
grid.RowDefinitions.Add(new RowDefinition());
grid.Children.Add(label, 0, 1, 1, 3);
grid.Children.Add(dismiss, 0, 1, 3, 4);
_popup.Content = grid;
_popup.Show();
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
_popup.Dismissed += (s, evt) => tcs.SetResult(true);
_ = await tcs.Task;
}|
|
||
| private void OnContentPopupDismissBackKeyClicked(object sender, EventArgs e) | ||
| { | ||
| ContentPopup _popup = new ContentPopup(); |
There was a problem hiding this comment.
using (ContentPopup _popup = new ContentPopup())
{
_popup.BackButtonPressed += (s, ee) =>
{
_popup?.Dismiss();
label1.Text = "Test1 Dismissed";
};
string _longText = "This ContentPopup is dismissed as a back key.";
var content = new Label { Text = _longText, HorizontalTextAlignment = TextAlignment.Center };
_popup.Content = content;
_popup.Show();
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
_popup.Dismissed += (s, evt) => tcs.SetResult(true);
_ = await tcs.Task;
}| /// Shows the popup. | ||
| /// </summary> | ||
| /// <since_tizen> 4 </since_tizen> | ||
| public void Show() |
There was a problem hiding this comment.
How about rename to Open?
and How about return Task that indicate closing timing
TaskCompletionSource<bool> _tcsForDismiss;
public Task Open()
{
IsShow = true;
_tcsForDismiss = new TaskCompletionSource<bool>();
return _tcsForDismiss.Task;
}
public void SendDismissed()
{
Dismissed?.Invoke(this, EventArgs.Empty);
_tcsForDismiss?.TrySetResult(true);
}If you provide Task we can easily use
using (var popup = new ContentPopup()) {
poup.Content = new StackLayout { ... };
_ = await popup.Open();
}|
Fixed with reference to the above comments. |
| var renderer = Platform.GetOrCreateRenderer(_element.Content); | ||
| (renderer as LayoutRenderer)?.RegisterOnLayoutUpdated(); | ||
| var native = renderer.NativeView; | ||
| native.MinimumHeight = XForms.NativeParent.Geometry.Height; |
There was a problem hiding this comment.
How about use AligementX/Y and WeightX/Y?
There was a problem hiding this comment.
I will set MinimunHeight and MinimumWidth instead of Alignment and Weight.
| /// BindableProperty. Identifies the IsShow bindable property. | ||
| /// </summary> | ||
| /// <since_tizen> 4 </since_tizen> | ||
| public static readonly BindableProperty IsOpenProperty = BindableProperty.Create(nameof(IsOpen), typeof(bool), typeof(ContentPopup), false); |
There was a problem hiding this comment.
TwoWay binding is more proper
defaultBindingMode : BindingMode.TwoWay
| public static async Task ShowPopup(ContentPopup popup) | ||
| { | ||
| if (popup == null) | ||
| await Task.FromResult(false); |
There was a problem hiding this comment.
| await Task.FromResult(false); | |
| return Task.FromResult(false); | |
| using (var renderer = DependencyService.Get<IContentPopupRenderer>(DependencyFetchTarget.NewInstance)) | ||
| { | ||
| if (renderer == null) | ||
| await Task.FromResult(false); |
There was a problem hiding this comment.
| await Task.FromResult(false); | |
| return Task.FromResult(false); | |
|
|
||
| popup.Content = label; | ||
|
|
||
| await ContentPopupManager.ShowPopup(popup); |
There was a problem hiding this comment.
| await ContentPopupManager.ShowPopup(popup); | |
| await Navigation.ShowPopup(popup); | |
| public Task Open() | ||
| { | ||
| _popup.Show(); | ||
| _element.IsOpen = true; |
There was a problem hiding this comment.
| _element.IsOpen = true; | |
| _element.SetValueFromRenderer(ContentPopup.IsOpenProperty, true); | |
rookiejava
left a comment
There was a problem hiding this comment.
We decided to think again about providing ContentPopup on Galaxy Watch, which has a smaller screen size than mobile or TV.
The two main parts we are concerned with are:
- Since the screen is small, the popup always occupies the entire screen, so there is no difference from using the page.
- The complexity of managing the bezel interaction between the content of pop-ups created in a new window and the content of the existing page can be increased.
Description of Change
Add ContentPopup.
It is a popup with only one view, and has less interface restrictions than other popups. (
TwoButtonPopup,InformationPopup)API Changes
Added:
Usage:
Screenshot:
