Skip to content

Commit

Permalink
Apply review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
myroot committed Oct 15, 2022
1 parent b33e87e commit 90d9000
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ protected override void Dispose(bool disposing)
if (disposing)
{
currentPath.Dispose();
TouchEvent -= OnTouch;
}

base.Dispose(disposing);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static class DrawingViewService
public static ValueTask<Stream> GetImageStream(IList<PointF> points, Size imageSize, float lineWidth, Color strokeColor, Paint? background)
{
var image = GetBitmapForPoints(points, lineWidth, strokeColor, background);
if (image == null)
if (image is null)
{
return ValueTask.FromResult(Stream.Null);
}
Expand All @@ -45,7 +45,7 @@ public static ValueTask<Stream> GetImageStream(IList<PointF> points, Size imageS
public static ValueTask<Stream> GetImageStream(IList<IDrawingLine> lines, Size imageSize, Paint? background)
{
var image = GetBitmapForLines(lines, background);
if (image == null)
if (image is null)
{
return ValueTask.FromResult(Stream.Null);
}
Expand Down
19 changes: 15 additions & 4 deletions src/CommunityToolkit.Maui.Core/Views/Popup/MauiPopup.tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,20 @@ public MauiPopup(IMauiContext mauiContext)
OutsideClicked += OnOutsideClicked;
}

/// <inheritdoc/>
protected override void Dispose(bool isDisposing)
{
if (isDisposing)
{
OutsideClicked -= OnOutsideClicked;
}

base.Dispose(isDisposing);
}

void OnOutsideClicked(object? sender, EventArgs e)
{
if (VirtualView == null || VirtualView.Handler == null)
if (VirtualView is null || VirtualView.Handler is null)
{
return;
}
Expand Down Expand Up @@ -62,15 +73,15 @@ public void ShowPopup()
_ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null");
Content = VirtualView.Content?.ToPlatform(mauiContext) ?? throw new InvalidOperationException($"{nameof(VirtualView.Content)} cannot be null");

if (Content == null)
if (Content is null)
{
return;
}

BackgroundColor = new Tizen.NUI.Color(0.1f, 0.1f, 0.1f, 0.5f);
Content.BackgroundColor = (VirtualView.Color ?? Colors.Transparent).ToNUIColor();

if (VirtualView.Anchor != null)
if (VirtualView.Anchor is not null)
{
var anchorView = VirtualView.Anchor.ToPlatform();
var anchorPosition = anchorView.ScreenPosition;
Expand Down Expand Up @@ -102,7 +113,7 @@ public void ShowPopup()
public void UpdateContentSize()
{
_ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} cannot be null");
if (Content == null)
if (Content is null)
{
return;
}
Expand Down
4 changes: 3 additions & 1 deletion src/CommunityToolkit.Maui/Alerts/Snackbar/Snackbar.tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ protected virtual void Dispose(bool isDisposing)
/// <inheritdoc/>
Task ShowPlatform(CancellationToken token)
{
var dispatcher = Dispatcher.GetForCurrentThread() ?? Application.Current?.Dispatcher ?? throw new InvalidOperationException($"There is no IDispatcher object, application is not initalized");

// close and cleanup the previously opened snackbar
if (PopupStatic != null && PopupStatic.IsOpen)
{
Expand Down Expand Up @@ -138,7 +140,7 @@ Task ShowPlatform(CancellationToken token)
popup.Closed += (s, e) => OnDismissed();
popup.Open();

var timer = (Dispatcher.GetForCurrentThread() ?? Application.Current?.Dispatcher!).CreateTimer();
var timer = dispatcher.CreateTimer();
timer.IsRepeating = false;
timer.Interval = Duration;
timer.Tick += (s, e) => popup.Close();
Expand Down

0 comments on commit 90d9000

Please sign in to comment.