Update counting down view.
authorPiotr Czaja/Advanced Frameworks (PLT) /SRPOL/Engineer/Samsung Electronics <p.czaja@samsung.com>
Tue, 1 Jun 2021 13:29:17 +0000 (15:29 +0200)
committerPiotr Czaja <p.czaja@samsung.com>
Tue, 14 Sep 2021 11:01:34 +0000 (13:01 +0200)
Fitness/ViewModels/ExercisePreviewViewModel.cs
Fitness/ViewModels/LoadingViewModel.cs
Fitness/Views/ExercisePreviewView.cs
Fitness/Views/LoadingView.cs
Fitness/res/layout/ExercisePreviewView.xaml
Fitness/res/layout/ExercisingView.xaml
Fitness/res/layout/LoadingView.xaml

index cb72f9f508553caa9b631140ed94e55f353d8638..cdfc63a45cd129a8734d64f8cc2ac35051915968 100644 (file)
@@ -16,7 +16,8 @@ namespace Fitness.ViewModels
 
         public ExercisePreviewViewModel()
         {
-            Skip = new Command(() => _ = NavigationService.Instance.NavigateToLoadingView());
+            Skip = new Command(() => _ = NavigationService.Instance.NavigateToExercisingView());
+            Back = new Command(NavigationService.Instance.Pop);
             PreviousWorkout = new Command(GoPrevious);
             NextWorkout = new Command(GoNext);
 
@@ -40,9 +41,9 @@ namespace Fitness.ViewModels
         }
 
         /// <summary>
-        /// Review movement
+        /// Gets back command.
         /// </summary>
-        public ICommand ReviewMovement { get; private set; }
+        public ICommand Back { get; private set; }
 
         /// <summary>
         /// Skip review
index a1b25639416e170e5da85c28bb34f73b84e02d14..1b353a5085b5ddfeb1c09d0a97c4d71957e1a502 100644 (file)
@@ -7,20 +7,25 @@ namespace Fitness.ViewModels
     public class LoadingViewModel : BaseViewModel, IDisposable
     {
         private const int TickIntervalInMilliseconds = 1500;
-        private string text;
-        private Timer timer;
-        private bool disposed = false;
+        private const int CountingPixelSizeSmall = 120;
+        private const int CountingPixelSizeMedium = 280;
+        private const int CountingPixelSizeLarge = 400;
 
-        private string[] messages = new string[]
+        private readonly string[] messages = new string[]
         {
             "get ready",
-            "1",
-            "2",
             "3",
+            "2",
+            "1",
             "GO!",
             string.Empty,
         };
 
+        private string text;
+        private int pixelSize;
+        private Timer timer;
+        private bool disposed = false;
+
         public LoadingViewModel()
         {
             StartCounting();
@@ -44,6 +49,19 @@ namespace Fitness.ViewModels
             }
         }
 
+        public int PixelSize
+        {
+            get => pixelSize;
+            set
+            {
+                if (pixelSize != value)
+                {
+                    pixelSize = value;
+                    RaisePropertyChanged();
+                }
+            }
+        }
+
         public void Dispose()
         {
             Dispose(true);
@@ -68,23 +86,20 @@ namespace Fitness.ViewModels
             int count = 0;
             timer = new Timer(TickIntervalInMilliseconds);
             Text = messages[count++];
+            PixelSize = CountingPixelSizeSmall;
 
             timer.Tick += (sender, args) =>
             {
                 Text = messages[count++];
+                PixelSize = CountingPixelSizeLarge;
 
-                // If next string to display is 'String.Empty'
                 if (count == messages.Length - 1)
                 {
-                    // Workaround.
-                    // After setting Text to 'GO!', we don't need to wait 1.5 sec before starting preview.
-                    // But if we move to ExersingView here, the string 'GO!' is not displayed.
-                    timer.Interval = 0;
+                    PixelSize = CountingPixelSizeMedium;
                 }
 
                 if (count == messages.Length)
                 {
-                    Services.NavigationService.Instance.NavigateToExercisingView();
                     return false;
                 }
 
index 9cdd297f62ab9b5b7bf77cf3b4487f75f8109f7a..3aa1a024cbd40895a77894e09407ccaa4c5d7af1 100644 (file)
@@ -34,7 +34,6 @@ namespace Fitness.Views
 
         private void InitializeCallbacks()
         {
-            this.reviewButton.Clicked += ReplyVideo;
             this.nextButton.Clicked += ReplyVideo;
             this.previousButton.Clicked += ReplyVideo;
             this.player.Hide();
index 50d6faeb4647342f6cde3e1c8271426cc33e1ca8..2b19715fdc07d7a3c310bd53eb7194c81fcc378f 100644 (file)
@@ -1,7 +1,5 @@
-using System.Threading.Tasks;
 using Fitness.Controls;
-using Fitness.Services;
-using Tizen.Security;
+using Tizen.NUI;
 
 namespace Fitness.Views
 {
@@ -10,6 +8,20 @@ namespace Fitness.Views
         public LoadingView()
         {
             InitializeComponent();
+            CountingLabel.PropertyChanged += CountingLabel_PropertyChanged;
+            PropertyMap fontStyle = new PropertyMap();
+            fontStyle.Add("weight", new PropertyValue("medium"));
+            CountingLabel.FontStyle = fontStyle;
+
+        }
+
+        private void CountingLabel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+        {
+            Services.Logger.Debug($"CountingLabel_PropertyChanged called for {e.PropertyName}. Text: {CountingLabel.Text}");
+            if (e.PropertyName == nameof(CountingLabel.Text) && CountingLabel.Text == string.Empty)
+            {
+                Hide();
+            }
         }
     }
 }
index 5484ce18a01df7993ceeacc8e04fbcd908cbdf36..1324855ea7069f3c20fa6650fd8892665919806a 100644 (file)
@@ -42,8 +42,8 @@
             <View.Layout>
                 <LinearLayout LinearOrientation="Horizontal" LinearAlignment="CenterVertical" CellPadding="40,40"/>
             </View.Layout>
-            <ctrl:NinePatchButton BindingContext="{Binding Source={x:Reference context}}" Text="Review Movement" Size="{views:SizeInUnits Width=219,Height=26}" Command="{Binding ReviewMovement}" x:Name="reviewButton" behaviors:StyleSetter.Style="{x:Static styles:Buttons.RegularRepeat}"/>
-            <ctrl:NinePatchButton BindingContext="{Binding Source={x:Reference context}}" Text="Skip" Size="{views:SizeInUnits Width=219,Height=26}" Command="{Binding Skip}" behaviors:StyleSetter.Style="{x:Static styles:Buttons.Regular}"/>
+            <ctrl:NinePatchButton BindingContext="{Binding Source={x:Reference context}}" Text="Back" Size="{views:SizeInUnits Width=219,Height=26}" Command="{Binding Back}" behaviors:StyleSetter.Style="{x:Static styles:Buttons.Regular}"/>
+            <ctrl:NinePatchButton BindingContext="{Binding Source={x:Reference context}}" Text="Let's try!" Size="{views:SizeInUnits Width=219,Height=26}" Command="{Binding Skip}" behaviors:StyleSetter.Style="{x:Static styles:Buttons.Regular}"/>
         </View>
     </View>
 </View>
index 20f2bdd564e0ebbe1173710c50cffc916d138edc..67086acff90d8cd635ce2f470ed9f756ac3e7399 100644 (file)
@@ -28,4 +28,5 @@
     <views:BarView BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"
                 PrevCommand="{Binding Prev}"
                 NextCommand="{Binding Next}"/>
+    <views:LoadingView x:Name="LoadingView"/>
 </ctrl:Page>
index 9190a00d86c770aa5019e48bc3b124315d10aaca..9b34dc0fff45a739b44f5c7b1be6da2a25525222 100644 (file)
@@ -4,7 +4,7 @@
   xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
   xmlns:ctrl="clr-namespace:Fitness.Controls"
   xmlns:vm="clr-namespace:Fitness.ViewModels"
-  BackgroundColor="#EEEFF1"
+  BackgroundColor="Transparent"
   >
   <ctrl:Page.BindingContext>
       <vm:LoadingViewModel x:Name="context"/>
@@ -12,6 +12,7 @@
   <ctrl:Page.Layout>
       <AbsoluteLayout/>
   </ctrl:Page.Layout>
+  <ImageView HeightResizePolicy="FillToParent" WidthResizePolicy="FillToParent" ResourceUrl="*Resource*/layout/images/0_BG_dim.png"/>
   <ImageView PositionUsesPivotPoint="true" ParentOrigin="Center" PivotPoint="Center" HeightResizePolicy="SizeRelativeToParent" WidthForHeight="true" SizeModeFactor="0.0,0.8,1.0" ResourceUrl="*Resource*/layout/images/circle.svg" x:Name="image" Opacity="0.48"/>
-  <TextLabel Text="{Binding Text}" PixelSize="420" WidthResizePolicy="FillToParent" HeightResizePolicy="FillToParent" PositionUsesPivotPoint="true" PivotPoint="Center" ParentOrigin="Center" VerticalAlignment="Center" HorizontalAlignment="Center" TextColor="#000C2B"/>
+  <TextLabel x:Name="CountingLabel" Text="{Binding Text}" PixelSize="{Binding PixelSize}" WidthResizePolicy="FillToParent" HeightResizePolicy="FillToParent" PositionUsesPivotPoint="true" PivotPoint="Center" ParentOrigin="Center" VerticalAlignment="Center" HorizontalAlignment="Center" TextColor="#000C2B"/>
 </ctrl:Page>