From cc5af3c08044642cdab357590d10da9ab8a59c5d Mon Sep 17 00:00:00 2001 From: Andrzej Krawczyk Date: Thu, 29 Jul 2021 15:21:20 +0200 Subject: [PATCH] Fixed back button command. --- Fitness/ViewModels/ExercisingViewModel.cs | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Fitness/ViewModels/ExercisingViewModel.cs b/Fitness/ViewModels/ExercisingViewModel.cs index c8f4952..bd137d3 100644 --- a/Fitness/ViewModels/ExercisingViewModel.cs +++ b/Fitness/ViewModels/ExercisingViewModel.cs @@ -25,6 +25,7 @@ namespace Fitness.ViewModels private int repetitions; private Landmark[,] poseLandmarks; private bool isSummaryVisible; + private ICommand summaryBackCommand; private ICommand summaryOkCommand; private string summaryTitle; private bool isLoading; @@ -45,13 +46,23 @@ namespace Fitness.ViewModels HoldTimeThreshold = 1200, }; SquatService.ExerciseStateUpdated += SquatService_ExerciseStateUpdated; - SummaryBackCommand = new Command(ExecuteCloseSummary); } /// /// Gets a of SummaryView back button. /// - public ICommand SummaryBackCommand { get; private set; } + public ICommand SummaryBackCommand + { + get => summaryBackCommand; + private set + { + if (value != summaryBackCommand) + { + summaryBackCommand = value; + RaisePropertyChanged(); + } + } + } /// /// Gets a of SummaryView ok button. @@ -268,6 +279,11 @@ namespace Fitness.ViewModels if (State == WorkoutState.Playing) { State = WorkoutState.Paused; + SummaryBackCommand = new Command(ExecuteCloseSummaryAndPlay); + } + else + { + SummaryBackCommand = new Command(ExecuteCloseSummary); } SummaryOkCommand = new Command(() => { ExecuteChangeWorkout(offset); }); @@ -275,9 +291,14 @@ namespace Fitness.ViewModels IsSummaryVisible = true; } - private void ExecuteCloseSummary() + private void ExecuteCloseSummaryAndPlay() { State = WorkoutState.Playing; + ExecuteCloseSummary(); + } + + private void ExecuteCloseSummary() + { IsSummaryVisible = false; } @@ -339,6 +360,7 @@ namespace Fitness.ViewModels private void ConfirmTryAgain() { + SummaryBackCommand = new Command(ExecuteCloseSummary); SummaryOkCommand = new Command(() => { ExecuteChangeWorkout(); }); SummaryTitle = GetSummaryTitle(SummaryType.TryAgain); IsSummaryVisible = true; @@ -346,6 +368,7 @@ namespace Fitness.ViewModels private void ConfirmEndWorkout() { + SummaryBackCommand = new Command(ExecuteCloseSummary); SummaryOkCommand = new Command(Services.NavigationService.Instance.PopToRoot); SummaryTitle = GetSummaryTitle(SummaryType.EndWorkout); IsSummaryVisible = true; -- 2.7.4