using System;
using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Input;
using Fitness.Models;
using Fitness.Services;
using Tizen.Applications;
ThumbnailUrl = Application.Current.DirectoryInfo.Resource + "media/video-0002.jpeg",
},
});
+
+ SelectedWorkout = Workouts.First();
+
+ WatchPreview = new Command(() => { NavigationService.Instance.NavigateToLoadingView(); });
+ StartWorkout = new Command(() => { NavigationService.Instance.NavigateToScanningView(); });
}
/// <summary>
/// List of all available workouts
/// </summary>
public IEnumerable<WorkoutViewModel> Workouts { get; private set; }
+
+ /// <summary>
+ /// Selected workout
+ /// </summary>
+ public WorkoutViewModel SelectedWorkout { get; private set; }
+
+ /// <summary>
+ /// watch preview of selected workout
+ /// </summary>
+ public ICommand WatchPreview { get; private set; }
+
+ /// <summary>
+ /// Start selected workout.
+ /// </summary>
+ public ICommand StartWorkout { get; private set; }
}
}
using System;
-using System.Windows.Input;
using Fitness.Models;
using Fitness.Services;
using Fitness.ViewModels;
{
public WorkoutViewModel()
{
- WatchPreview = new Command(() => { NavigationService.Instance.NavigateToLoadingView(); });
- StartWorkout = new Command(() => { NavigationService.Instance.NavigateToScanningView(); });
}
/// <summary>
public bool Favourite { get; set; }
/// <summary>
- /// Stop workout
- /// </summary>
- public ICommand Stop { get; private set; }
-
- /// <summary>
- /// Start/Resume workout
- /// </summary>
- public ICommand Play { get; private set; }
-
- /// <summary>
/// Url to video with workout
/// </summary>
public string ThumbnailUrl { get; set; }
/// Url to workout video
/// </summary>
public string VideoUrl { get; set; }
-
- /// <summary>
- /// Stop workout
- /// </summary>
- public ICommand WatchPreview { get; private set; }
-
- /// <summary>
- /// Start selected workout.
- /// </summary>
- public ICommand StartWorkout { get; private set; }
}
}
<converters:FavouriteToIconConverter x:Key="favouriteToIconConverter"/>
</View.XamlResources>
<View.BindingContext>
- <vm:MainViewModel/>
+ <vm:MainViewModel x:Name="context"/>
</View.BindingContext>
<View.Layout>
<LinearLayout LinearOrientation="Vertical" LinearAlignment="Top"/>
<View.Layout>
<LinearLayout LinearOrientation="Horizontal" LinearAlignment="End"/>
</View.Layout>
- <ImageView BindingContext="{Binding Source={x:Reference scroller}, Path=SelectedItem}" Weight="1.0" HeightResizePolicy="FillToParent" ResourceUrl="{Binding ThumbnailUrl}">
+ <ImageView BindingContext="{Binding Source={x:Reference context}, Path=SelectedWorkout}" Weight="1.0" HeightResizePolicy="FillToParent" ResourceUrl="{Binding ThumbnailUrl}">
<ImageView.Layout>
<LinearLayout LinearOrientation="Vertical" LinearAlignment="Center"/>
</ImageView.Layout>
- <nui:Button BindingContext="{Binding Source={x:Reference scroller}, Path=SelectedItem}" PositionUsesPivotPoint="true" ParentOrigin="0.5,0.5" PivotPoint="0.5,0.5" Text="Let's try!" Command="{Binding StartWorkout}" x:Name="button1" Size="{views:SizeInUnits Width=112,Height=24}"/>
- <nui:Button BindingContext="{Binding Source={x:Reference scroller}, Path=SelectedItem}" PositionUsesPivotPoint="true" ParentOrigin="0.5,0.5" PivotPoint="0.5,0.5" Text="Watch preview" Command="{Binding WatchPreview}" x:Name="button2" Size="{views:SizeInUnits Width=112,Height=24}"/>
+ <nui:Button BindingContext="{Binding Source={x:Reference context}}" PositionUsesPivotPoint="true" ParentOrigin="0.5,0.5" PivotPoint="0.5,0.5" Text="Let's try!" Command="{Binding StartWorkout}" x:Name="button1" Size="{views:SizeInUnits Width=112,Height=24}"/>
+ <nui:Button BindingContext="{Binding Source={x:Reference context}}" PositionUsesPivotPoint="true" ParentOrigin="0.5,0.5" PivotPoint="0.5,0.5" Text="Watch preview" Command="{Binding WatchPreview}" x:Name="button2" Size="{views:SizeInUnits Width=112,Height=24}"/>
</ImageView>
<View Size="{views:SizeInUnits Width=107}" Margin="{views:ExtentsInUnits Start=8}" HeightResizePolicy="FillToParent">
<View HeightResizePolicy="FillToParent" WidthResizePolicy="FillToParent">
<View.Layout>
<LinearLayout LinearOrientation="Horizontal" LinearAlignment="Begin"/>
</View.Layout>
- <TextLabel BindingContext="{Binding Source={x:Reference scroller}, Path=SelectedItem}" Text="{Binding Path=Title}" PointSize="40" VerticalAlignment="Center" TextColor="#000C2B"/>
- <ImageView BindingContext="{Binding Source={x:Reference scroller}, Path=SelectedItem}" Size="36,48" Margin="30,30,0,0" ResourceUrl="{Binding Difficulty, Converter={StaticResource difficultyLevelConverter}}"/>
+ <TextLabel BindingContext="{Binding Source={x:Reference context}, Path=SelectedWorkout}" Text="{Binding Path=Title}" PointSize="40" VerticalAlignment="Center" TextColor="#000C2B"/>
+ <ImageView BindingContext="{Binding Source={x:Reference context}, Path=SelectedWorkout}" Size="36,48" Margin="30,30,0,0" ResourceUrl="{Binding Difficulty, Converter={StaticResource difficultyLevelConverter}}"/>
</View>
<View>
<View.Layout>
<LinearLayout LinearOrientation="Horizontal" LinearAlignment="Begin"/>
</View.Layout>
<ImageView Size="28,28" ResourceUrl="*Resource*/layout/images/icon_time.png"/>
- <TextLabel BindingContext="{Binding Source={x:Reference scroller}, Path=SelectedItem}" Text="{Binding Duration,StringFormat=\{0:h\\:mm\\:ss\}}" PointSize="28" Margin="8,0,0,0" VerticalAlignment="Center" TextColor="#000C2B"/>
+ <TextLabel BindingContext="{Binding Source={x:Reference context}, Path=SelectedWorkout}" Text="{Binding Duration,StringFormat=\{0:h\\:mm\\:ss\}}" PointSize="28" Margin="8,0,0,0" VerticalAlignment="Center" TextColor="#000C2B"/>
</View>
- <TextLabel BindingContext="{Binding Source={x:Reference scroller}, Path=SelectedItem}" Size="{views:SizeInUnits Width=107}" Text="{Binding Description}" PointSize="28" LineWrapMode="Word" Weight="1.0" VerticalAlignment="Bottom" Ellipsis="false" MultiLine="true" TextColor="#000C2B" EnableAutoScroll="true"/>
+ <TextLabel BindingContext="{Binding Source={x:Reference context}, Path=SelectedWorkout}" Size="{views:SizeInUnits Width=107}" Text="{Binding Description}" PointSize="28" LineWrapMode="Word" Weight="1.0" VerticalAlignment="Bottom" Ellipsis="false" MultiLine="true" TextColor="#000C2B" EnableAutoScroll="true"/>
</View>
- <ImageView PositionUsesPivotPoint="true" PivotPoint="1.0,0.0" ParentOrigin="1.0, 0.0" Size="30,30" BindingContext="{Binding Source={x:Reference scroller}, Path=SelectedItem}" ResourceUrl="{Binding Favourite, Converter={StaticResource favouriteToIconConverter}}"/>
+ <ImageView PositionUsesPivotPoint="true" PivotPoint="1.0,0.0" ParentOrigin="1.0, 0.0" Size="30,30" BindingContext="{Binding Source={x:Reference context}, Path=SelectedWorkout}" ResourceUrl="{Binding Favourite, Converter={StaticResource favouriteToIconConverter}}"/>
</View>
</View>
<ctrl:BindableRecyclerView Size="{views:SizeInUnits Height=44}" Margin="{views:ExtentsInUnits Top=10, Bottom=10}" WidthResizePolicy="FillToParent" ItemsSource="{Binding Workouts}" x:Name="scroller" Padding="{views:ExtentsInUnits Start=16, End=16}">