Set only one button in "time's up" summary view.
authorPiotr Czaja/Advanced Frameworks (PLT) /SRPOL/Engineer/Samsung Electronics <p.czaja@samsung.com>
Thu, 5 Aug 2021 06:03:52 +0000 (08:03 +0200)
committerPiotr Czaja <p.czaja@samsung.com>
Tue, 14 Sep 2021 11:01:34 +0000 (13:01 +0200)
Fitness/ViewModels/ExercisingViewModel.cs
Fitness/Views/SummaryView.xaml.cs
Fitness/res/layout/SummaryView.xaml

index b1bd4d8dfb89e87b116ccc4545631e272f68eb92..c7820b14d4639bf4d901a17fb82e26f5b208e978 100644 (file)
@@ -32,6 +32,7 @@ namespace Fitness.ViewModels
         private int totatCount;
         private TimeSpan totalTime;
         private int avarageScore;
+        private SummaryType summaryType;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="ExercisingViewModel"/> class.
@@ -302,6 +303,22 @@ namespace Fitness.ViewModels
         /// </summary>
         public IExerciseService SquatService { get; private set; }
 
+        /// <summary>
+        /// Gets the <see cref="SummaryType"/> property.
+        /// </summary>
+        public SummaryType SummaryType
+        {
+            get => summaryType;
+            private set
+            {
+                if (value != summaryType)
+                {
+                    summaryType = value;
+                    SummaryTitle = GetSummaryTitle(summaryType);
+                }
+            }
+        }
+
         /// <inheritdoc />
         protected override ICommand GetGoPrevious()
         {
@@ -338,7 +355,7 @@ namespace Fitness.ViewModels
             }
 
             SummaryOkCommand = new Command(() => { ExecuteChangeWorkout(offset); });
-            SummaryTitle = GetSummaryTitle(SummaryType.ChangeWorkout);
+            SummaryType = SummaryType.ChangeWorkout;
             IsSummaryVisible = true;
         }
 
@@ -426,7 +443,7 @@ namespace Fitness.ViewModels
             UpdateStatistics();
             SummaryBackCommand = new Command(ExecuteCloseSummary);
             SummaryOkCommand = new Command(() => { ExecuteChangeWorkout(); });
-            SummaryTitle = GetSummaryTitle(SummaryType.TryAgain);
+            SummaryType = SummaryType.TryAgain;
             IsSummaryVisible = true;
         }
 
@@ -435,7 +452,7 @@ namespace Fitness.ViewModels
             UpdateStatistics();
             SummaryBackCommand = new Command(ExecuteCloseSummary);
             SummaryOkCommand = new Command(Services.NavigationService.Instance.PopToRoot);
-            SummaryTitle = GetSummaryTitle(SummaryType.EndWorkout);
+            SummaryType = SummaryType.EndWorkout;
             IsSummaryVisible = true;
         }
 
@@ -443,7 +460,7 @@ namespace Fitness.ViewModels
         {
             UpdateStatistics();
             SummaryOkCommand = new Command(Services.NavigationService.Instance.PopToRoot);
-            SummaryTitle = GetSummaryTitle(SummaryType.TimeIsUp);
+            SummaryType = SummaryType.TimeIsUp;
             IsSummaryVisible = true;
         }
 
index 657af07aee66979826258e0c61467912d5ec9834..9f7b4d91eb9c122808eb08f90180119d89e4e37c 100644 (file)
@@ -1,12 +1,33 @@
 using Fitness.Controls;
+using Fitness.Models;
+using Tizen.NUI;
 
 namespace Fitness.Views
 {
+    /// <summary>
+    /// Partial <see cref="SummaryView"/> class.
+    /// </summary>
     public partial class SummaryView : Page
     {
+        private const int SingleOkButtonWidth = 98;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="SummaryView"/> class.
+        /// </summary>
         public SummaryView()
         {
             InitializeComponent();
+            SummaryViewTitle.PropertyChanged += OnSummaryTitleChanged;
+        }
+
+        private void OnSummaryTitleChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+            if (BindingContext is ViewModels.ExercisingViewModel viewModel && viewModel.SummaryType == SummaryType.TimeIsUp)
+            {
+                OkButton.Margin = new Extents((ushort)UnitsUtils.UnitsToPixels(SingleOkButtonWidth), 0, 0, 0);
+                BackButton.Size = new Size2D(0, 0);
+                BackButton.Margin = new Extents(0, 0, 0, 0);
+            }
         }
     }
 }
index f583d6f56a4cc7f1f47a1da18b02c0150f0a1b2e..1855e545c0f86c164acd3484563c25da746df6aa 100644 (file)
@@ -28,6 +28,7 @@
                   HeightSpecification="{Static LayoutParamPolicies.MatchParent}"/>
 
             <TextLabel BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"
+                       x:Name="SummaryViewTitle"
                        Text="{Binding SummaryTitle}"
                        PixelSize="40"
                        WidthSpecification="{Static LayoutParamPolicies.MatchParent}"
                     <LinearLayout LinearOrientation="Horizontal"/>
                 </View.Layout>
                 
-                <View Size="{views:SizeInUnits Width=20, Height=26}"/>
-
-                <ctrl:NinePatchButton Text="Back"
-                                      Size="{views:SizeInUnits Width=100, Height=26}"
+                <ctrl:NinePatchButton x:Name="BackButton"
                                       BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"
+                                      Text="Back"
+                                      Margin="{views:ExtentsInUnits Start=20}"
+                                      Size="{views:SizeInUnits Width=100, Height=26}"
                                       Command="{Binding SummaryBackCommand}"
                                       behaviors:StyleSetter.Style="{Binding Source={x:Static styles:Buttons.Outline}}"/>
                 
-                <View Weight="1"
-                      HeightSpecification="{Static LayoutParamPolicies.MatchParent}"
-                      WidthSpecification="{Static LayoutParamPolicies.MatchParent}"/>
 
-                <ctrl:NinePatchButton Text="Ok"
+                <ctrl:NinePatchButton x:Name="OkButton"
+                                      Text="Ok"
+                                      Margin="{views:ExtentsInUnits Start=56}"
                                       Size="{views:SizeInUnits Width=100, Height=26}"
                                       BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"
                                       Command="{Binding SummaryOkCommand}"
                                       behaviors:StyleSetter.Style="{Binding Source={x:Static styles:Buttons.Inverse}}"/>
-                
-                <View Size="{views:SizeInUnits Width=20, Height=24}"/>
             
             </View>