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

Commit

Permalink
[Information/TwoButtonPopup] fix issue that button event handler is n…
Browse files Browse the repository at this point in the history
…ot invoked (#200)
  • Loading branch information
jkpu committed Jul 5, 2019
1 parent f97b5b0 commit e9d529e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ protected virtual void Dispose(bool disposing)
{
_layout.Unrealize();
_layout = null;
_popUp.BackButtonPressed -= BackButtonPressedHandler;
_popUp.Unrealize();
_popUp = null;
}
Expand Down Expand Up @@ -260,14 +261,15 @@ void UpdateButton()
((IMenuItemController)BottomButton).Activate();
};

if(_buttonBgColor != Color.Default)
if (_buttonBgColor != Color.Default)
{
Log.Debug(FormsCircularUI.Tag, $"InformationPopup set button background color:{_buttonBgColor.ToNative()}");
_bottomButton.BackgroundColor = _buttonBgColor.ToNative();
}
}
else
{
_bottomButton.Unrealize();
_bottomButton = null;
}

Expand Down Expand Up @@ -329,14 +331,46 @@ public void Show()

public void Dismiss()
{
_popUp.Hide();

if (_bottomButton != null)
{
_bottomButton.Unrealize();
_bottomButton = null;
_popUp.SetPartContent("button1", null);
}

if (_box != null)
{
_box.Unrealize();
_box = null;
}

if (_progress != null)
{
_progress.Unrealize();
_progress = null;
}

if (_progressLabel != null)
{
_progressLabel.Unrealize();
_progressLabel = null;
}

if (_popUp != null)
{
_popUp.Dismiss();
_layout.Unrealize();
_layout = null;
_popUp.BackButtonPressed -= BackButtonPressedHandler;
_popUp.Unrealize();
_popUp = null;
}
}

void OnDismissed(object sender, EventArgs e)
{
Log.Debug(FormsCircularUI.Tag, $"OnDismissed called");
Dispose();
}
}
Expand Down
27 changes: 26 additions & 1 deletion src/Tizen.Wearable.CircularUI.Forms.Renderer/TwoButtonPopupImplementation.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ protected virtual void Dispose(bool disposing)
_secondButton.Unrealize();
_secondButton = null;
}

if (_nativeContent != null)
{
_nativeContent.Unrealize();
Expand Down Expand Up @@ -355,14 +356,38 @@ public void Show()

public void Dismiss()
{
if (_firstButton != null)
{
_firstButton.Unrealize();
_firstButton = null;
_popUp.SetPartContent("button1", null);
}

if (_secondButton != null)
{
_secondButton.Unrealize();
_secondButton = null;
_popUp.SetPartContent("button2", null);
}

if (_nativeContent != null)
{
_nativeContent.Unrealize();
_nativeContent = null;
}

if (_popUp != null)
{
_popUp.Dismiss();
_layout.Unrealize();
_layout = null;
_popUp.Unrealize();
_popUp = null;
}
}

void OnDismissed(object sender, EventArgs e)
{
Log.Debug(FormsCircularUI.Tag, $"OnDismissed called");
Dispose();
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/Tizen.Wearable.CircularUI.Forms/InformationPopup.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
using System;
using Xamarin.Forms;
using Tizen.Wearable.CircularUI.Forms;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Tizen.Wearable.CircularUI.Forms
{
Expand Down Expand Up @@ -48,6 +50,8 @@ public class InformationPopup : BindableObject

IInformationPopup _popUp;

static IList<IInformationPopup> _popUpList = new ObservableCollection<IInformationPopup>();

/// <summary>
/// Occurs when the device's back button is pressed.
/// </summary>
Expand Down Expand Up @@ -117,6 +121,7 @@ public MenuItem BottomButton
public void Show()
{
_popUp.Show();
_popUpList.Add(_popUp);
}

/// <summary>
Expand All @@ -126,6 +131,7 @@ public void Show()
public void Dismiss()
{
_popUp.Dismiss();
_popUpList.Remove(_popUp);
}
}
}
6 changes: 6 additions & 0 deletions src/Tizen.Wearable.CircularUI.Forms/TwoButtonPopup.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
using Xamarin.Forms;

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Tizen.Wearable.CircularUI.Forms
{
Expand Down Expand Up @@ -96,6 +98,8 @@ public class TwoButtonPopup : BindableObject

ITwoButtonPopup _popUp;

static IList<ITwoButtonPopup> _popUpList = new ObservableCollection<ITwoButtonPopup>();

/// <summary>
/// Occurs when the device's back button is pressed.
/// </summary>
Expand Down Expand Up @@ -185,6 +189,7 @@ public MenuItem SecondButton
public void Show()
{
_popUp.Show();
_popUpList.Add(_popUp);
}

/// <summary>
Expand All @@ -194,6 +199,7 @@ public void Show()
public void Dismiss()
{
_popUp.Dismiss();
_popUpList.Remove(_popUp);
}
}
}

0 comments on commit e9d529e

Please sign in to comment.