* Add WorkoutRepository store for all workouts.
Move workouts' collection to WorkoutRepository and access at:
- ExercisePreviewViewModel
- MainViewModel
* Reorder usings (StyleCop check)
--- /dev/null
+using System;
+using System.Collections.Generic;
+using Fitness.Models;
+using Fitness.ViewModels;
+using Tizen.Applications;
+
+namespace Fitness.Services
+{
+ /// <summary>
+ /// WorkoutRepository contains all workouts available for fitness.
+ /// </summary>
+ public class WorkoutRepository
+ {
+ private static readonly Lazy<WorkoutRepository> Lazy = new Lazy<WorkoutRepository>(() => new WorkoutRepository());
+
+ private IList<WorkoutViewModel> workouts = new List<WorkoutViewModel>(new[]
+ {
+ new WorkoutViewModel
+ {
+ 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 = true,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0000.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0000.jpeg",
+ Id = "0",
+ },
+ new WorkoutViewModel
+ {
+ Title = "JOGA Workout 1",
+ Description = "This is a description of JOGA workout 0001",
+ Difficulty = DifficultyLevel.Easy,
+ Duration = new TimeSpan(0, 4, 30),
+ Favourite = false,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0001.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0001.jpeg",
+ Id = "1",
+ },
+ new WorkoutViewModel
+ {
+ Title = "JOGA Workout 2",
+ Description = "This is a description of JOGA workout 0002",
+ Difficulty = DifficultyLevel.Medium,
+ Duration = new TimeSpan(0, 4, 30),
+ Favourite = false,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0002.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0002.jpeg",
+ Id = "2",
+ },
+ new WorkoutViewModel
+ {
+ Title = "JOGA Workout 3",
+ Description = "This is a description of JOGA workout 0003",
+ Difficulty = DifficultyLevel.Medium,
+ Duration = new TimeSpan(0, 4, 30),
+ Favourite = false,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0003.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0003.jpeg",
+ Id = "3",
+ },
+ new WorkoutViewModel
+ {
+ Title = "Sukces Workout 0",
+ Description = "This is a description of Sukces workout 0003",
+ Difficulty = DifficultyLevel.Hard,
+ Duration = new TimeSpan(0, 4, 30),
+ Favourite = false,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0000.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0000.jpeg",
+ Id = "4",
+ },
+ new WorkoutViewModel
+ {
+ Title = "Sukces Workout 1",
+ 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.Medium,
+ Duration = new TimeSpan(0, 4, 30),
+ Favourite = false,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0001.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0001.jpeg",
+ Id = "5",
+ },
+ new WorkoutViewModel
+ {
+ Title = "Sukces Workout 2",
+ Description = "This is a description of Sukces workout 0002",
+ Difficulty = DifficultyLevel.Medium,
+ Duration = new TimeSpan(0, 4, 30),
+ Favourite = false,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0002.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0002.jpeg",
+ Id = "6",
+ },
+ new WorkoutViewModel
+ {
+ Title = "Sukces Workout 3",
+ Description = "This is a description of Sukces workout 0003",
+ Difficulty = DifficultyLevel.Easy,
+ Duration = new TimeSpan(0, 4, 30),
+ Favourite = false,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0003.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0003.jpeg",
+ Id = "7",
+ },
+ new WorkoutViewModel
+ {
+ Title = "Sukces Workout 4",
+ Description = "This is a description of Sukces workout 0004",
+ Difficulty = DifficultyLevel.Easy,
+ Duration = new TimeSpan(0, 4, 30),
+ Favourite = true,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0004.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0004.jpeg",
+ Id = "8",
+ },
+ new WorkoutViewModel
+ {
+ Title = "Video workout 0",
+ Description = "This is a description of workout 0000",
+ Difficulty = DifficultyLevel.Easy,
+ Duration = new TimeSpan(0, 4, 30),
+ Favourite = false,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/video-0000.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0000.jpeg",
+ Id = "9",
+ },
+ new WorkoutViewModel
+ {
+ Title = "Video workout 1",
+ Description = "This is a description of workout 0001",
+ Difficulty = DifficultyLevel.Easy,
+ Duration = new TimeSpan(0, 4, 30),
+ Favourite = false,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/video-0001.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0001.jpeg",
+ Id = "10",
+ },
+ new WorkoutViewModel
+ {
+ Title = "Video workout 2",
+ Description = "This is a description of workout 0002",
+ Difficulty = DifficultyLevel.Medium,
+ Duration = new TimeSpan(0, 4, 30),
+ Favourite = true,
+ VideoUrl = Application.Current.DirectoryInfo.Resource + "media/video-0002.avi",
+ ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0002.jpeg",
+ Id = "11",
+ },
+ });
+
+ private WorkoutRepository()
+ {
+ }
+
+ /// <summary>
+ /// Gets Instance of WorkoutRepository.
+ /// </summary>
+ public static WorkoutRepository Instance => Lazy.Value;
+
+ /// <summary>
+ /// Gets all workouts.
+ /// </summary>
+ /// <returns>List of WorkoutViewModels.</returns>
+ public IList<WorkoutViewModel> GetAll() => workouts;
+ }
+}
PreviousWorkout = new Command(GoPrevious);
NextWorkout = new Command(GoNext);
- Workouts = new List<WorkoutViewModel>(new[]
- {
- new WorkoutViewModel
- {
- 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 = true,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0000.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0000.jpeg",
- Id = "0",
- },
- new WorkoutViewModel
- {
- Title = "JOGA Workout 1",
- Description = "This is a description of JOGA workout 0001",
- Difficulty = DifficultyLevel.Easy,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0001.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0001.jpeg",
- Id = "1",
- },
- new WorkoutViewModel
- {
- Title = "JOGA Workout 2",
- Description = "This is a description of JOGA workout 0002",
- Difficulty = DifficultyLevel.Medium,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0002.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0002.jpeg",
- Id = "2",
- },
- new WorkoutViewModel
- {
- Title = "JOGA Workout 3",
- Description = "This is a description of JOGA workout 0003",
- Difficulty = DifficultyLevel.Medium,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0003.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0003.jpeg",
- Id = "3",
- },
- new WorkoutViewModel
- {
- Title = "Sukces Workout 0",
- Description = "This is a description of Sukces workout 0003",
- Difficulty = DifficultyLevel.Hard,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0000.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0000.jpeg",
- Id = "4",
- },
- new WorkoutViewModel
- {
- Title = "Sukces Workout 1",
- 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.Medium,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0001.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0001.jpeg",
- Id = "5",
- },
- new WorkoutViewModel
- {
- Title = "Sukces Workout 2",
- Description = "This is a description of Sukces workout 0002",
- Difficulty = DifficultyLevel.Medium,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0002.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0002.jpeg",
- Id = "6",
- },
- new WorkoutViewModel
- {
- Title = "Sukces Workout 3",
- Description = "This is a description of Sukces workout 0003",
- Difficulty = DifficultyLevel.Easy,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0003.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0003.jpeg",
- Id = "7",
- },
- new WorkoutViewModel
- {
- Title = "Sukces Workout 4",
- Description = "This is a description of Sukces workout 0004",
- Difficulty = DifficultyLevel.Easy,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = true,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0004.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0004.jpeg",
- Id = "8",
- },
- new WorkoutViewModel
- {
- Title = "Video workout 0",
- Description = "This is a description of workout 0000",
- Difficulty = DifficultyLevel.Easy,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/video-0000.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0000.jpeg",
- Id = "9",
- },
- new WorkoutViewModel
- {
- Title = "Video workout 1",
- Description = "This is a description of workout 0001",
- Difficulty = DifficultyLevel.Easy,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/video-0001.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0001.jpeg",
- Id = "10",
- },
- new WorkoutViewModel
- {
- Title = "Video workout 2",
- Description = "This is a description of workout 0002",
- Difficulty = DifficultyLevel.Medium,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = true,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/video-0002.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0002.jpeg",
- Id = "11",
- },
- });
+ Workouts = WorkoutRepository.Instance.GetAll();
}
/// <summary>
/// <summary>
/// List of all available workouts
/// </summary>
- public List<WorkoutViewModel> Workouts { get; private set; }
+ public IList<WorkoutViewModel> Workouts { get; private set; }
private void GoNext()
{
public MainViewModel()
{
- Workouts = new List<WorkoutViewModel>(new[]
- {
- new WorkoutViewModel
- {
- 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 = true,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0000.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0000.jpeg",
- Id = "0",
- },
- new WorkoutViewModel
- {
- Title = "JOGA Workout 1",
- Description = "This is a description of JOGA workout 0001",
- Difficulty = DifficultyLevel.Easy,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0001.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0001.jpeg",
- Id = "1",
- },
- new WorkoutViewModel
- {
- Title = "JOGA Workout 2",
- Description = "This is a description of JOGA workout 0002",
- Difficulty = DifficultyLevel.Medium,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0002.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0002.jpeg",
- Id = "2",
- },
- new WorkoutViewModel
- {
- Title = "JOGA Workout 3",
- Description = "This is a description of JOGA workout 0003",
- Difficulty = DifficultyLevel.Medium,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0003.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/JOGA-0003.jpeg",
- Id = "3",
- },
- new WorkoutViewModel
- {
- Title = "Sukces Workout 0",
- Description = "This is a description of Sukces workout 0003",
- Difficulty = DifficultyLevel.Hard,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0000.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0000.jpeg",
- Id = "4",
- },
- new WorkoutViewModel
- {
- Title = "Sukces Workout 1",
- 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.Medium,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0001.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0001.jpeg",
- Id = "5",
- },
- new WorkoutViewModel
- {
- Title = "Sukces Workout 2",
- Description = "This is a description of Sukces workout 0002",
- Difficulty = DifficultyLevel.Medium,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0002.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0002.jpeg",
- Id = "6",
- },
- new WorkoutViewModel
- {
- Title = "Sukces Workout 3",
- Description = "This is a description of Sukces workout 0003",
- Difficulty = DifficultyLevel.Easy,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0003.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0003.jpeg",
- Id = "7",
- },
- new WorkoutViewModel
- {
- Title = "Sukces Workout 4",
- Description = "This is a description of Sukces workout 0004",
- Difficulty = DifficultyLevel.Easy,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = true,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0004.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/sukces-0004.jpeg",
- Id = "8",
- },
- new WorkoutViewModel
- {
- Title = "Video workout 0",
- Description = "This is a description of workout 0000",
- Difficulty = DifficultyLevel.Easy,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/video-0000.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0000.jpeg",
- Id = "9",
- },
- new WorkoutViewModel
- {
- Title = "Video workout 1",
- Description = "This is a description of workout 0001",
- Difficulty = DifficultyLevel.Easy,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = false,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/video-0001.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0001.jpeg",
- Id = "10",
- },
- new WorkoutViewModel
- {
- Title = "Video workout 2",
- Description = "This is a description of workout 0002",
- Difficulty = DifficultyLevel.Medium,
- Duration = new TimeSpan(0, 4, 30),
- Favourite = true,
- VideoUrl = Application.Current.DirectoryInfo.Resource + "media/video-0002.avi",
- ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0002.jpeg",
- Id = "11",
- },
- });
-
- SelectedWorkout = Workouts.ElementAt(0);
-
WatchPreview = new Command(() => { NavigationService.Instance.NavigateToExercisePreviewView(SelectedWorkout.Id); });
StartWorkout = new Command(() => { NavigationService.Instance.NavigateToScanningView(); });
Exit = new Command(() => { Tizen.NUI.NUIApplication.Current.Exit(); });
+
+ Workouts = WorkoutRepository.Instance.GetAll();
+ SelectedWorkout = Workouts.FirstOrDefault();
}
/// <summary>