From 3dd2f58f5df0f5bc10344699b648dd3fee8b6dd3 Mon Sep 17 00:00:00 2001 From: Lukasz Stanislawski Date: Wed, 28 Oct 2020 15:29:41 +0100 Subject: [PATCH] MainView UI partial implementation --- Fitness/Models/Workout.cs | 45 ------------ Fitness/ViewModels/ExercisingViewModel.cs | 54 ++++++++++++++ Fitness/ViewModels/MainViewModel.cs | 79 +++++++++++++-------- Fitness/ViewModels/WorkoutViewModel.cs | 32 +++++---- .../Converters/DifficultyLevelToIconConverter.cs | 30 ++++++++ .../Views/Converters/FavouriteToIconConverter.cs | 26 +++++++ Fitness/res/layout/MainView.xaml | 52 ++++++++++---- Fitness/res/layout/images/icon_fav_empty.png | Bin 0 -> 699 bytes Fitness/res/layout/images/icon_fav_full.png | Bin 0 -> 483 bytes Fitness/res/layout/images/icon_time.png | Bin 0 -> 1277 bytes Fitness/res/layout/images/lvl_easy.png | Bin 0 -> 200 bytes Fitness/res/layout/images/lvl_hard.png | Bin 0 -> 185 bytes Fitness/res/layout/images/lvl_medium.png | Bin 0 -> 192 bytes 13 files changed, 216 insertions(+), 102 deletions(-) delete mode 100644 Fitness/Models/Workout.cs create mode 100644 Fitness/ViewModels/ExercisingViewModel.cs create mode 100644 Fitness/Views/Converters/DifficultyLevelToIconConverter.cs create mode 100644 Fitness/Views/Converters/FavouriteToIconConverter.cs create mode 100644 Fitness/res/layout/images/icon_fav_empty.png create mode 100644 Fitness/res/layout/images/icon_fav_full.png create mode 100644 Fitness/res/layout/images/icon_time.png create mode 100644 Fitness/res/layout/images/lvl_easy.png create mode 100644 Fitness/res/layout/images/lvl_hard.png create mode 100644 Fitness/res/layout/images/lvl_medium.png diff --git a/Fitness/Models/Workout.cs b/Fitness/Models/Workout.cs deleted file mode 100644 index 4cfa015..0000000 --- a/Fitness/Models/Workout.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; - -namespace Fitness.Models -{ - /// - /// Workout's information. - /// - public class Workout - { - /// - /// Workout title - /// - public string Title { get; set; } - - /// - /// Full workout description - /// - public string Description { get; set; } - - /// - /// Duration of the workout - /// - public TimeSpan Duration { get; set; } - - /// - /// Predefined difficulty level of workout - /// - public DifficultyLevel Difficulty { get; set; } - - /// - /// True if workout is added is user's favourite - /// - public bool Favourite { get; set; } - - /// - /// Url to thumbnail of the workout - /// - public string ThumbnailUrl { get; set; } - - /// - /// Url to workout video - /// - public string VideoUrl { get; set; } - } -} diff --git a/Fitness/ViewModels/ExercisingViewModel.cs b/Fitness/ViewModels/ExercisingViewModel.cs new file mode 100644 index 0000000..68a5507 --- /dev/null +++ b/Fitness/ViewModels/ExercisingViewModel.cs @@ -0,0 +1,54 @@ +using System; +using System.Windows.Input; +using Fitness.Models; +using Fitness.Services; + +namespace Fitness.ViewModels +{ + public class ExercisingViewModel : BaseViewModel + { + public ExercisingViewModel() + { + } + + /// + /// Current score + /// + public int Score { get; private set; } + + /// + /// Repetitions made in current Workout + /// + public int Repetitions { get; private set; } + + /// + /// Time left in current body pose to accept repetition. + /// + public TimeSpan Hold { get; private set; } + + /// + /// TimeLeft in workout + /// + public TimeSpan TimeLeft { get; private set; } + + /// + /// Current workout state + /// + public WorkoutState State { get; private set; } + + /// + /// Pause workout + /// + public ICommand Pause { get; private set; } + + /// + /// Url to video with workout + /// + public string WorkoutVideoUrl { get; private set; } + + /// + /// Url to preview from device camera + /// + public string PreviewVideoUrl { get; private set; } + } +} diff --git a/Fitness/ViewModels/MainViewModel.cs b/Fitness/ViewModels/MainViewModel.cs index 6fc03c7..a0c9ff5 100644 --- a/Fitness/ViewModels/MainViewModel.cs +++ b/Fitness/ViewModels/MainViewModel.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.ObjectModel; +using System.Collections.Generic; using System.Windows.Input; using Fitness.Models; using Fitness.Services; @@ -10,23 +10,25 @@ namespace Fitness.ViewModels { public class MainViewModel : BaseViewModel { + private WorkoutViewModel selectedWorkout; + public MainViewModel() { - Workouts = new ObservableCollection(new[] + Workouts = new List(new[] { - new Workout + new WorkoutViewModel { - Title = "JOGA Workout 0000", - Description = "This is a description of JOGA workout 0000", + Title = "JOGA Workout 0", + Description = "1. Lie down on your back, keep your knees bent and your back and feet flat on the mat.\n2. Slowly lift your torso and situp.\n3. Return to the starting position by rolling down one vertebrae at a time.\n4. Repeat the exercise until set is complete.", Difficulty = DifficultyLevel.Easy, Duration = new TimeSpan(0, 4, 30), - Favourite = false, + Favourite = true, VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0000.avi", ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0000.jpeg", }, - new Workout + new WorkoutViewModel { - Title = "JOGA Workout 0001", + Title = "JOGA Workout 1", Description = "This is a description of JOGA workout 0001", Difficulty = DifficultyLevel.Easy, Duration = new TimeSpan(0, 4, 30), @@ -34,9 +36,9 @@ namespace Fitness.ViewModels VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0001.avi", ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0001.jpeg", }, - new Workout + new WorkoutViewModel { - Title = "JOGA Workout 0002", + Title = "JOGA Workout 2", Description = "This is a description of JOGA workout 0002", Difficulty = DifficultyLevel.Medium, Duration = new TimeSpan(0, 4, 30), @@ -44,9 +46,9 @@ namespace Fitness.ViewModels VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0002.avi", ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0002.jpeg", }, - new Workout + new WorkoutViewModel { - Title = "JOGA Workout 0003", + Title = "JOGA Workout 3", Description = "This is a description of JOGA workout 0003", Difficulty = DifficultyLevel.Medium, Duration = new TimeSpan(0, 4, 30), @@ -54,9 +56,9 @@ namespace Fitness.ViewModels VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0003.avi", ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0003.jpeg", }, - new Workout + new WorkoutViewModel { - Title = "Sukces Workout 0003", + Title = "Sukces Workout 0", Description = "This is a description of Sukces workout 0003", Difficulty = DifficultyLevel.Hard, Duration = new TimeSpan(0, 4, 30), @@ -64,9 +66,9 @@ namespace Fitness.ViewModels VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0000.avi", ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0000.jpeg", }, - new Workout + new WorkoutViewModel { - Title = "Sukces Workout 0001", + Title = "Sukces Workout 1", Description = "This is a description of Sukces workout 0001", Difficulty = DifficultyLevel.Medium, Duration = new TimeSpan(0, 4, 30), @@ -74,9 +76,9 @@ namespace Fitness.ViewModels VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0001.avi", ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0001.jpeg", }, - new Workout + new WorkoutViewModel { - Title = "Sukces Workout 0002", + Title = "Sukces Workout 2", Description = "This is a description of Sukces workout 0002", Difficulty = DifficultyLevel.Medium, Duration = new TimeSpan(0, 4, 30), @@ -84,9 +86,9 @@ namespace Fitness.ViewModels VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0002.avi", ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0002.jpeg", }, - new Workout + new WorkoutViewModel { - Title = "Sukces Workout 0003", + Title = "Sukces Workout 3", Description = "This is a description of Sukces workout 0003", Difficulty = DifficultyLevel.Easy, Duration = new TimeSpan(0, 4, 30), @@ -94,9 +96,9 @@ namespace Fitness.ViewModels VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0003.avi", ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0003.jpeg", }, - new Workout + new WorkoutViewModel { - Title = "Sukces Workout 0004", + Title = "Sukces Workout 4", Description = "This is a description of Sukces workout 0004", Difficulty = DifficultyLevel.Easy, Duration = new TimeSpan(0, 4, 30), @@ -104,9 +106,9 @@ namespace Fitness.ViewModels VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0004.avi", ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0004.jpeg", }, - new Workout + new WorkoutViewModel { - Title = "Video workout 0000", + Title = "Video workout 0", Description = "This is a description of workout 0000", Difficulty = DifficultyLevel.Easy, Duration = new TimeSpan(0, 4, 30), @@ -114,9 +116,9 @@ namespace Fitness.ViewModels VideoUrl = Application.Current.DirectoryInfo.Resource + "media/video-0000.avi", ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0000.jpeg", }, - new Workout + new WorkoutViewModel { - Title = "Video workout 0001", + Title = "Video workout 1", Description = "This is a description of workout 0001", Difficulty = DifficultyLevel.Easy, Duration = new TimeSpan(0, 4, 30), @@ -124,9 +126,9 @@ namespace Fitness.ViewModels VideoUrl = Application.Current.DirectoryInfo.Resource + "media/video-0001.avi", ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0001.jpeg", }, - new Workout + new WorkoutViewModel { - Title = "Video workout 0002", + Title = "Video workout 2", Description = "This is a description of workout 0002", Difficulty = DifficultyLevel.Medium, Duration = new TimeSpan(0, 4, 30), @@ -138,15 +140,32 @@ namespace Fitness.ViewModels WatchPreview = new Command(() => { NavigationService.Instance.NavigateToExercisePreviewView(); }); StartWorkout = new Command(() => { NavigationService.Instance.NavigateToExercisingView(); }); + SelectedWorkout = Workouts[0] as WorkoutViewModel; } /// /// List of all available workouts /// - public ObservableCollection Workouts { get; private set; } + public List Workouts { get; private set; } + + /// + /// Currently selected workout + /// + public WorkoutViewModel SelectedWorkout + { + get => selectedWorkout; + set + { + if (value != selectedWorkout) + { + selectedWorkout = value; + RaisePropertyChanged(); + } + } + } /// - /// Watch selected workout preview + /// Stop workout /// public ICommand WatchPreview { get; private set; } diff --git a/Fitness/ViewModels/WorkoutViewModel.cs b/Fitness/ViewModels/WorkoutViewModel.cs index 42f3f32..5b8c9c9 100644 --- a/Fitness/ViewModels/WorkoutViewModel.cs +++ b/Fitness/ViewModels/WorkoutViewModel.cs @@ -1,9 +1,13 @@ using System; using System.Windows.Input; using Fitness.Models; +using Fitness.ViewModels; -namespace Fitness.ViewModels +namespace Fitness.Models { + /// + /// WorkoutViewModel's information. + /// public class WorkoutViewModel : BaseViewModel { /// @@ -12,29 +16,29 @@ namespace Fitness.ViewModels public int Score { get; private set; } /// - /// Repetitions made in current Workout + /// WorkoutViewModel title /// - public int Repetitions { get; private set; } + public string Title { get; set; } /// - /// Time left in current body pose to accept repetition. + /// Full workout description /// - public TimeSpan Hold { get; private set; } + public string Description { get; set; } /// - /// TimeLeft in workout + /// Duration of the workout /// - public TimeSpan TimeLeft { get; private set; } + public TimeSpan Duration { get; set; } /// - /// Current workout state + /// Predefined difficulty level of workout /// - public WorkoutState State { get; private set; } + public DifficultyLevel Difficulty { get; set; } /// - /// Pause workout + /// True if workout is added is user's favourite /// - public ICommand Pause { get; private set; } + public bool Favourite { get; set; } /// /// Stop workout @@ -49,11 +53,11 @@ namespace Fitness.ViewModels /// /// Url to video with workout /// - public string WorkoutVideoUrl { get; private set; } + public string ThumbnailUrl { get; set; } /// - /// Url to preview from device camera + /// Url to workout video /// - public string PreviewVideoUrl { get; private set; } + public string VideoUrl { get; set; } } } diff --git a/Fitness/Views/Converters/DifficultyLevelToIconConverter.cs b/Fitness/Views/Converters/DifficultyLevelToIconConverter.cs new file mode 100644 index 0000000..4d7dad8 --- /dev/null +++ b/Fitness/Views/Converters/DifficultyLevelToIconConverter.cs @@ -0,0 +1,30 @@ +using System; +using Fitness.Models; +using Tizen.NUI; +using Tizen.NUI.Binding; + +namespace Fitness.Views.Converters +{ + public class DifficultyLevelToIconConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + switch ((DifficultyLevel)value) + { + case DifficultyLevel.Easy: + return NUIApplication.Current.DirectoryInfo.Resource + "/layout/images/lvl_easy.png"; + case DifficultyLevel.Medium: + return NUIApplication.Current.DirectoryInfo.Resource + "/layout/images/lvl_medium.png"; + case DifficultyLevel.Hard: + return NUIApplication.Current.DirectoryInfo.Resource + "/layout/images/lvl_hard.png"; + default: + return null; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotSupportedException(); + } + } +} diff --git a/Fitness/Views/Converters/FavouriteToIconConverter.cs b/Fitness/Views/Converters/FavouriteToIconConverter.cs new file mode 100644 index 0000000..0707078 --- /dev/null +++ b/Fitness/Views/Converters/FavouriteToIconConverter.cs @@ -0,0 +1,26 @@ +using System; +using Tizen.NUI; +using Tizen.NUI.Binding; + +namespace Fitness.Views.Converters +{ + public class FavouriteToIconConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + if ((bool)value) + { + return NUIApplication.Current.DirectoryInfo.Resource + "/layout/images/icon_fav_full.png"; + } + else + { + return NUIApplication.Current.DirectoryInfo.Resource + "/layout/images/icon_fav_empty.png"; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotSupportedException(); + } + } +} diff --git a/Fitness/res/layout/MainView.xaml b/Fitness/res/layout/MainView.xaml index 6018a36..db1db0b 100644 --- a/Fitness/res/layout/MainView.xaml +++ b/Fitness/res/layout/MainView.xaml @@ -5,29 +5,55 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:views="clr-namespace:Fitness.Views" xmlns:ctrl="clr-namespace:Fitness.Controls" - xmlns:c="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components" + xmlns:nui="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components" + xmlns:converters="clr-namespace:Fitness.Views.Converters" HeightResizePolicy="FillToParent" WidthResizePolicy="FillToParent" BackgroundColor="#EEEFF1" ParentOrigin="Center" PivotPoint="Center" PositionUsesPivotPoint="true" Padding="{views:ExtentsInUnits Top=26}"> + + + + + + + + - - - - + - - - + + + + + + + + + - + - - + + + + + + + + + + + + + + + + - - + + diff --git a/Fitness/res/layout/images/icon_fav_empty.png b/Fitness/res/layout/images/icon_fav_empty.png new file mode 100644 index 0000000000000000000000000000000000000000..b2fefa84fcea29a1e5e50c307525960cf7cfbe5f GIT binary patch literal 699 zcmV;s0!00ZP)ZrCeTfbAeX_I7>Hu6L|h21lpxxbk_|#DS3==R zAxt8LHX?qk+?Xv=GjbJ#iy)^j8cjtvXW(#oZ{Ekervtq|T(~pu{Qu`a^Ul5R+y^mY z#P~l@3#5QmAPr=IE#MW<4iwvPN`MYvN@6p@T?L*3HDMS#0}KMYz)_B|2Ha4*CScu# zvkMGJj=<(7U6SbW54Z!|mAO~mWKffXhR{5a1QI|w&?vVmtzr&jWIv~YCqRR6&I8TB zqM`jbNX_Zn`V6ofVrzg6n}22_N1a)snT^f(t;v)kFXS+nMK$n4aem5oxnKcHiZkTL z;Cn?(dgQbM!!mAr?-hAiOo7~2Od!hyfq$i4f+1!9^)B1 zExn#!lmIh^R(Du6V|F&LeXi^x;H9DQD9jaS0nd#D$Z!Av0dPq~ zK~z}7?U+4F13?gmpNL{?^cSd|HiDIfprv3didu?A#8wcy$Q6oUWhE%-{lH%$u`!s! zR#FJjLh(*fwAtVmiI>^C+dXh!7`Wo*=DGctomuem^7eE(s$z>MZM3)EtKB4Ag=Forvi38LEvumY^A=WhMZ zOd$h7kd}QallqlS)?8!|$kak$xYIPY(+1FQaT6ASlEmT0;^?*PS_1gw0I(^U;-Z6G zJ0JmUH~@T*0M;D<)+K;f4gf_lhb(WDCNL=dqiu_TTc*kL&H`L5$)PX-yk&gEO(tEu z>lp&BrM1I?4B*OXrho!)k|Nx37I~_mKAaS;lBA06rpm4)fIH0+P9Mob1Gpm_aJqH` za0jm1(M{khrbj8^SPLEcmv>+}FOB^?@T$SR0CRb}eV76sRb?`r*DI27V9ehXd3kyL Z>IXXaqeSEv>;eD)002ovPDHLkV1o2e%lZHS literal 0 HcmV?d00001 diff --git a/Fitness/res/layout/images/icon_time.png b/Fitness/res/layout/images/icon_time.png new file mode 100644 index 0000000000000000000000000000000000000000..7d95648a02b905e381b432d2911a8d9b91b005be GIT binary patch literal 1277 zcmVc zIqx~|dkza8K+`m3`6sYw)G%H=tkWl%&DLiojSu|*U|V?T5|0=BC?-nWD;5b_n>4C# zJo#g-MKnG`wB46)lnv|je((a4Xz@~(Jhep_0wqn;cCQJQwOaZ43)egQ?hLZA0m!8B z);&49@-*~;Upx|ic;M5DGvEKzY%*IYM#kd?qaZ&MdvoPTh?hV=ZUl?Pf+#|O{(&KM zc3nmLxl1saEe<~+d@gzCt-R_JU#Od&8kyqo=T*ME7YNvi1nfi-5SBt}=w@P`vl3?n z3SK1a@RwXiH}ODNmegSJrAXpJP*&}CiT10nJMhP!w>OmO zk%RleAzl<6tOQ>O;LCOg7-`MS95GRR(>fi@hS+PT1*Ni=HmSSppc3q@wwzr)GR97K`PTp)f*#?#?#UsmtKwL%Gy?EjZVmq9|+$ z3*|4*FFf)Cfboeb#K%QH)!4^}0$o#veR&z6D9S6s@rl(N5rpxVDL$XGzzFW%8}iCY zvMd2IX}nju&OZ4(&H^RbF79Ilon2S4+34uH>^R3ni+U)rNYKg%+Rt5rdCt0NWG1r( zon2Q}8z@3>isA$;o{>b0mly?2p z7r))?b(xLDm9)k&ErcOZ%B1mD09ahKp`fS|dV_JpnduEi6cj43xM+LaWJw7YAs=ej zkCr~3?#%%9gui<3x(r}`WSU)BtChQrti1Y|!gw%tCYV z%8kmQ;W4ik;nc literal 0 HcmV?d00001 diff --git a/Fitness/res/layout/images/lvl_easy.png b/Fitness/res/layout/images/lvl_easy.png new file mode 100644 index 0000000000000000000000000000000000000000..c019e0acf9e6710570a64a268d39da22594e039f GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^DnP8s!3HE_=XJXQDYhhUcNd2LAh=-f^2tCE&H|6f zVxW%eAk65bF}ngN$X?><>&pIwOO{VUM|l3;bf8eEr;B4q#NoH+E^;;~Ft`ThHg1Sz znx1JjUGUD*45ny@KQFXj+&RzA@28{t-QeYoY?-&uOa1GkqvHQg`>?SA8>nNgVh|GK Vk>?7T><+Ym!PC{xWt~$(698XrLLLAB literal 0 HcmV?d00001 diff --git a/Fitness/res/layout/images/lvl_hard.png b/Fitness/res/layout/images/lvl_hard.png new file mode 100644 index 0000000000000000000000000000000000000000..ad89b252647a92aaa6f018d5893268b4bce75c23 GIT binary patch literal 185 zcmeAS@N?(olHy`uVBq!ia0vp^DnP8s!3HE_=XJXQDYhhUcNd2LAh=-f^2tCE&H|6f zVxW%eAk65bF}ngN$X?><>&pIwOO{Vkc+aDS(m)|MPZ!6Kh{JEs1#&Vd2)G=)ETU$- z<>&pIwOPZfq@xey>)j%O%PZ!6Kh{JEs9ppTqAmDQG?vx32 zYwZ4NtaOm(sQw`G;qT)E2TuRIW8Agr>z`ZY^|gDRzVDjP%7O)yh-5JSXyTDi$@^Ok PG?>BD)z4*}Q$iB}o>4q# literal 0 HcmV?d00001 -- 2.7.4