Skip to content

Commit

Permalink
#282 - Integrate pull-to-refresh in summary and overview.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed Sep 14, 2020
1 parent ddef6ad commit 4a24e70
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
16 changes: 13 additions & 3 deletions src/Money.Blazor.Host/Pages/Overview.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public partial class Overview<T> :
IEventHandler<OutcomeDeleted>,
IEventHandler<OutcomeAmountChanged>,
IEventHandler<OutcomeDescriptionChanged>,
IEventHandler<OutcomeWhenChanged>
IEventHandler<OutcomeWhenChanged>,
IEventHandler<PulledToRefresh>
{
public CurrencyFormatter CurrencyFormatter { get; private set; }

Expand Down Expand Up @@ -158,7 +159,8 @@ private void BindEvents()
.Add<OutcomeDeleted>(this)
.Add<OutcomeAmountChanged>(this)
.Add<OutcomeDescriptionChanged>(this)
.Add<OutcomeWhenChanged>(this);
.Add<OutcomeWhenChanged>(this)
.Add<PulledToRefresh>(this);
}

private void UnBindEvents()
Expand All @@ -168,7 +170,8 @@ private void UnBindEvents()
.Remove<OutcomeDeleted>(this)
.Remove<OutcomeAmountChanged>(this)
.Remove<OutcomeDescriptionChanged>(this)
.Remove<OutcomeWhenChanged>(this);
.Remove<OutcomeWhenChanged>(this)
.Remove<PulledToRefresh>(this);
}

private Task UpdateModel(IEvent payload, Action<OutcomeOverviewModel> handler)
Expand Down Expand Up @@ -237,6 +240,13 @@ Task IEventHandler<OutcomeWhenChanged>.HandleAsync(OutcomeWhenChanged payload)
return Task.CompletedTask;
}

Task IEventHandler<PulledToRefresh>.HandleAsync(PulledToRefresh payload)
{
payload.IsHandled = true;
_ = LoadDataAsync();
return Task.CompletedTask;
}

#endregion

#region OutcomeCard.IContext
Expand Down
16 changes: 13 additions & 3 deletions src/Money.Blazor.Host/Pages/Summary.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public partial class Summary<T> :
IEventHandler<OutcomeCreated>,
IEventHandler<OutcomeDeleted>,
IEventHandler<OutcomeAmountChanged>,
IEventHandler<OutcomeWhenChanged>
IEventHandler<OutcomeWhenChanged>,
IEventHandler<PulledToRefresh>
{
private CurrencyFormatter formatter;

Expand Down Expand Up @@ -189,7 +190,8 @@ private void BindEvents()
.Add<OutcomeCreated>(this)
.Add<OutcomeDeleted>(this)
.Add<OutcomeAmountChanged>(this)
.Add<OutcomeWhenChanged>(this);
.Add<OutcomeWhenChanged>(this)
.Add<PulledToRefresh>(this);
}

private void UnBindEvents()
Expand All @@ -198,7 +200,8 @@ private void UnBindEvents()
.Remove<OutcomeCreated>(this)
.Remove<OutcomeDeleted>(this)
.Remove<OutcomeAmountChanged>(this)
.Remove<OutcomeWhenChanged>(this);
.Remove<OutcomeWhenChanged>(this)
.Remove<PulledToRefresh>(this);
}

Task IEventHandler<OutcomeCreated>.HandleAsync(OutcomeCreated payload)
Expand All @@ -225,6 +228,13 @@ Task IEventHandler<OutcomeWhenChanged>.HandleAsync(OutcomeWhenChanged payload)
return Task.CompletedTask;
}

Task IEventHandler<PulledToRefresh>.HandleAsync(PulledToRefresh payload)
{
payload.IsHandled = true;
_ = LoadSelectedPeriodAsync();
return Task.CompletedTask;
}

private async void OnMonthUpdatedEvent(DateTime changed)
{
if (Periods != null && !IsContained(changed))
Expand Down

0 comments on commit 4a24e70

Please sign in to comment.