public void Initialize()
{
- //NavigationService.Instance.NavigateToMainView();
- NavigationService.Instance.NavigateToExercisingView();
+ NavigationService.Instance.NavigateToMainView();
}
protected override void OnCreate()
{
navigation.Push(new SummaryView());
}
+
+ public void Pop()
+ {
+ navigation.Pop();
+ }
}
}
-using Fitness.Models;
using System;
using System.Windows.Input;
using Tizen.NUI.Binding;
+using Fitness.Models;
namespace Fitness.ViewModels
{
{
PauseResumeWorkout = new Command(TriggerPauseResumeWorkout);
EndWorkout = new Command(ExecuteEndWorkout);
+ Prev = new Command(ExecutePrev);
+ Next = new Command(ExecuteNext);
State = WorkoutState.Playing;
}
public string PreviewVideoUrl { get; private set; }
/// <summary>
+ /// Gets Prev Command.
+ /// </summary>
+ public ICommand Prev { get; private set; }
+
+ /// <summary>
+ /// Gets Next Command.
+ /// </summary>
+ public ICommand Next { get; private set; }
+
+ /// <summary>
/// Gets PauseWorkout Command.
/// </summary>
public ICommand PauseResumeWorkout { get; private set; }
private void ExecuteEndWorkout()
{
- //NavigationService.Instance.Pop();
+ Services.NavigationService.Instance.Pop();
+ }
+
+ private void ExecutePrev()
+ {
+ }
+
+ private void ExecuteNext()
+ {
}
}
}
-namespace Fitness.Views
+using Tizen.NUI.Binding;
+
+namespace Fitness.Views
{
public partial class BarView
{
+ public static readonly BindableProperty PrevCommandProperty = BindableProperty.Create(
+ "PrevCommand",
+ typeof(Command),
+ typeof(BarView),
+ null,
+ propertyChanged: OnPrevCommandChanged);
+
+ public static readonly BindableProperty NextCommandProperty = BindableProperty.Create(
+ "NextCommand",
+ typeof(Command),
+ typeof(BarView),
+ null,
+ propertyChanged: OnNextCommandChanged);
+
public BarView()
{
InitializeComponent();
}
+
+ private static void OnPrevCommandChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ if (bindable is BarView view && newValue is Command command)
+ {
+ view.prev.Command = command;
+ }
+ }
+
+ private static void OnNextCommandChanged(BindableObject bindable, object oldValue, object newValue)
+ {
+ if (bindable is BarView view && newValue is Command command)
+ {
+ view.next.Command = command;
+ }
+ }
}
}
{
public partial class ExercisingView : Fitness.Controls.Page
{
- struct Coordinates
- {
- public Position Position;
- public Size Size;
- }
-
+ public static readonly BindableProperty IsPlayingProperty = BindableProperty.Create(
+ "IsPlaying",
+ typeof(bool),
+ typeof(ExercisingView),
+ true,
+ propertyChanged: OnIsPlayingChanged);
+
+ private const int TransitionTime = 500;
private CancellationTokenSource source;
private bool isInitialized = false;
- private const int TransitionTime = 1_000;
private (Coordinates Preview, Coordinates Camera) playing;
private (Coordinates Preview, Coordinates Camera) pause =
(
- Preview: new Coordinates() //fixed for now
+ Preview: new Coordinates() // fixed for now
{
Position = new Position(0, 0),
Size = new Size(1920, 1080),
},
- Camera: new Coordinates() //fixed for now
+ Camera: new Coordinates() // fixed for now
{
Position = new Position(1464, 138),
Size = new Size(392, 220),
- }
- );
-
- public static readonly BindableProperty IsPlayingProperty =
- BindableProperty.Create(
- "IsPlaying",
- typeof(bool),
- typeof(ExercisingView),
- true,
- propertyChanged: OnIsPlayingChanged);
+ });
public ExercisingView()
{
PlayingView.PreviewStub.Relayout += OnPlayingViewRelayout;
}
- public static void OnIsPlayingChanged(BindableObject bindable, object oldValue, object newValue)
+ private static void OnIsPlayingChanged(BindableObject bindable, object oldValue, object newValue)
{
if (newValue is bool isPlaying && bindable is ExercisingView view)
{
}
}
+ private static Task Animate(View view, Coordinates from, Coordinates to, CancellationToken token)
+ {
+ Task Scale()
+ {
+ view.PivotPoint = new Position(0, 0);
+ float scale = view.ScaleX * (to.Size.Width / from.Size.Width);
+ var animation = new Animation(TransitionTime);
+ animation.AnimateTo(view, "ScaleX", scale, new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear));
+ animation.AnimateTo(view, "ScaleY", scale, new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear));
+ return animation.PlayAndDispose(token);
+ }
+
+ Task Move()
+ {
+ var frames = new KeyFrames();
+ frames.Add(0.0f, from.Position);
+ frames.Add(1.0f, to.Position);
+
+ var animation = new Animation(TransitionTime);
+ animation.AnimateBetween(view, nameof(from.Position), frames);
+ return animation.PlayAndDispose(token);
+ }
+
+ return Task.WhenAll(Scale(), Move());
+ }
+
+ private static Position GetPosition(View view)
+ {
+ Position position = view.Position;
+ if (view.GetParent() is View parent)
+ {
+ position += GetPosition(parent);
+ }
+
+ return position;
+ }
+
private async Task TriggerStates(bool isPlaying)
{
if (isInitialized)
}
}
- private static Task Animate(View view, Coordinates from, Coordinates to, CancellationToken token)
- {
- Task Scale()
- {
- view.PivotPoint = new Position(0, 0);
- float scale = view.ScaleX * (to.Size.Width / from.Size.Width);
- var animation = new Animation(TransitionTime);
- animation.AnimateTo(view, "ScaleX", scale, new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear));
- animation.AnimateTo(view, "ScaleY", scale, new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear));
- return animation.PlayAndDispose(token);
- }
-
- Task Move()
- {
- var frames = new KeyFrames();
- frames.Add(0.0f, from.Position);
- frames.Add(1.0f, to.Position);
-
- var animation = new Animation(TransitionTime);
- animation.AnimateBetween(view, nameof(from.Position), frames);
- return animation.PlayAndDispose(token);
- }
-
- return Task.WhenAll(Scale(), Move());
- }
-
- private static Position GetPosition(View view)
+ private struct Coordinates
{
- Position position = view.Position;
- if (view.GetParent() is View parent)
- {
- position += GetPosition(parent);
- }
-
- return position;
+ public Position Position;
+ public Size Size;
}
}
}
public static ButtonStyle Previous => new ButtonStyle
{
- BackgroundColor = Color.Transparent,
+ BackgroundImage = new Selector<string>
+ {
+ Normal = NUIApplication.Current.DirectoryInfo.Resource + "styles/button/button_regular.png",
+ Pressed = NUIApplication.Current.DirectoryInfo.Resource + "styles/button/button_pressed.png",
+ Disabled = NUIApplication.Current.DirectoryInfo.Resource + "styles/button/button_disabled.png",
+ },
Text = new TextLabelStyle
{
PixelSize = 24.0f,
TextColor = Color.Black,
FontFamily = GetNavigationFont(),
+ HorizontalAlignment = HorizontalAlignment.Begin,
},
Icon = new ImageViewStyle
{
Disabled = NUIApplication.Current.DirectoryInfo.Resource + "styles/button/12_icon_back_arrow_active.png",
},
},
+ TextPadding = new Extents(20, 0, 0, 0),
IconRelativeOrientation = Button.IconOrientation.Left,
};
public static ButtonStyle Next => new ButtonStyle
{
- BackgroundColor = Color.Transparent,
+ BackgroundImage = new Selector<string>
+ {
+ Normal = NUIApplication.Current.DirectoryInfo.Resource + "styles/button/button_regular.png",
+ Pressed = NUIApplication.Current.DirectoryInfo.Resource + "styles/button/button_pressed.png",
+ Disabled = NUIApplication.Current.DirectoryInfo.Resource + "styles/button/button_disabled.png",
+ },
Text = new TextLabelStyle
{
PixelSize = 24.0f,
TextColor = Color.Black,
FontFamily = GetNavigationFont(),
+ HorizontalAlignment = HorizontalAlignment.End,
},
Icon = new ImageViewStyle
{
Disabled = NUIApplication.Current.DirectoryInfo.Resource + "styles/button/12_icon_back_arrow_active_reverse.png",
},
},
+ IconPadding = new Extents(20, 0, 0, 0),
IconRelativeOrientation = Button.IconOrientation.Right,
};
IconRelativeOrientation = Button.IconOrientation.Left,
};
+ public static ButtonStyle ReviewMovement => new ButtonStyle
+ {
+ BackgroundColor = Color.Transparent,
+ Text = new TextLabelStyle
+ {
+ PixelSize = 32.0f,
+ EnableMarkup = true,
+ TextColor = new Selector<Color>
+ {
+ Normal = new Color(0.0f, 20.0f / 255.0f, 71 / 255.0f, 1.0f),
+ Pressed = new Color(41.0f / 255.0f, 91.0f / 255.0f, 178 / 255.0f, 1.0f),
+ },
+ FontFamily = GetNavigationFont(),
+ HorizontalAlignment = HorizontalAlignment.Begin,
+ },
+ Icon = new ImageViewStyle
+ {
+ ResourceUrl = new Selector<string>
+ {
+ Normal = NUIApplication.Current.DirectoryInfo.Resource + "styles/button/icon-feather-repeat.png",
+ Pressed = NUIApplication.Current.DirectoryInfo.Resource + "styles/button/icon-feather-repeat.png",
+ Disabled = NUIApplication.Current.DirectoryInfo.Resource + "styles/button/icon-feather-repeat.png",
+ },
+ },
+ IconPadding = new Extents(76, 0, 0, 0),
+ TextPadding = new Extents(24, 0, 0, 0),
+ IconRelativeOrientation = Button.IconOrientation.Left,
+ };
+
+ public static ButtonStyle Transparent => new ButtonStyle
+ {
+ BackgroundColor = Color.Transparent,
+ Text = new TextLabelStyle
+ {
+ PixelSize = 32.0f,
+ EnableMarkup = true,
+ TextColor = new Selector<Color>
+ {
+ Normal = new Color(0.0f, 20.0f / 255.0f, 71 / 255.0f, 1.0f),
+ Pressed = new Color(41.0f / 255.0f, 91.0f / 255.0f, 178 / 255.0f, 1.0f),
+ },
+ FontFamily = GetNavigationFont(),
+ HorizontalAlignment = HorizontalAlignment.Center,
+ },
+ };
+
private static Selector<string> GetNavigationFont()
{
return new Selector<string>
xmlns:ctrl="clr-namespace:Fitness.Controls"
xmlns:views="clr-namespace:Fitness.Views"
xmlns:nui="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components"
- xmlns:style="clr-namespace:Fitness.Views.Styles"
+ xmlns:styles="clr-namespace:Fitness.Views.Styles"
+ xmlns:behaviors="clr-namespace:Fitness.Views.Behaviors"
WidthResizePolicy="FillToParent"
Size="{views:SizeInUnits Height=30}"
x:Name="Root">
- <ImageView Position="{views:PositionInUnits X=17, Y=5}"
- Size="{views:SizeInUnits Width=20, Height=20}"
- ResourceUrl="*Resource*/layout/images/left_arrow.png"/>
- <TextLabel Text="previous"
- TextColor="#000C2B"
- PixelSize="24"
- HorizontalAlignment="Begin"
- Position="{views:PositionInUnits X=40, Y=11}"
- Margin="{views:ExtentsInUnits Start=40, Top=11}"
- Size="{views:SizeInUnits Width=28, Height=9}"/>
+ <nui:Button Text="previous"
+ x:Name="prev"
+ Position="{views:PositionInUnits X=17, Y=10}"
+ Size="{views:SizeInUnits Width=64, Height=20}"
+ behaviors:StyleSetter.Style="{x:Static styles:Buttons.Previous}"/>
<TextLabel BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"
Text="{Binding Title}"
TextColor="#000C2B"
PixelSize="32"
HorizontalAlignment="Center"
- Position="{views:PositionInUnits X=220, Y=10}"
+ Position="{views:PositionInUnits X=220, Y=15}"
Size="{views:SizeInUnits Width=40, Height=10}"/>
- <TextLabel Text="next"
- TextColor="#000C2B"
- PixelSize="24"
- HorizontalAlignment="End"
- Position="{views:PositionInUnits X=400, Y=11}"
- Size="{views:SizeInUnits Width=40, Height=9}"/>
- <ImageView Position="{views:PositionInUnits X=443, Y=5}"
- Size="{views:SizeInUnits Width=20, Height=20}"
- ResourceUrl="*Resource*/layout/images/right_arrow.png"/>
+ <nui:Button Text="next"
+ x:Name="next"
+ Position="{views:PositionInUnits X=400, Y=10}"
+ Size="{views:SizeInUnits Width=64, Height=20}"
+ behaviors:StyleSetter.Style="{x:Static styles:Buttons.Next}"/>
</View>
\ No newline at end of file
<!--Layer-->
<views:PauseView x:Name="PauseView"
BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"/>
+ <!--Layer-->
+ <views:BarView BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"
+ PrevCommand="{Binding Prev}"
+ NextCommand="{Binding Next}"/>
</ctrl:Page>
xmlns:ctrl="clr-namespace:Fitness.Controls"
xmlns:views="clr-namespace:Fitness.Views"
xmlns:nui="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components"
- xmlns:style="clr-namespace:Fitness.Views.Styles"
+ xmlns:styles="clr-namespace:Fitness.Views.Styles"
+ xmlns:behaviors="clr-namespace:Fitness.Views.Behaviors"
HeightResizePolicy="FillToParent"
WidthResizePolicy="FillToParent"
x:Name="Root">
<View.Layout>
<LinearLayout LinearOrientation="Vertical"/>
</View.Layout>
- <!--Bar-->
- <views:BarView BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"/>
+ <!--Bar stub-->
+ <View Size="{views:SizeInUnits Height=30}"
+ WidthResizePolicy="FillToParent"/>
<!--Margin-->
<View BackgroundColor="Transparent"
WidthResizePolicy="FillToParent"
HeightResizePolicy="FillToParent"
Weight="1"/>
<!--Bar-->
- <View Size="{views:SizeInUnits Height=30}"
- Margin="{views:ExtentsInUnits Start=16, End=16}"
- WidthResizePolicy="FillToParent"
- BackgroundColor="Green">
+ <ImageView Size="{views:SizeInUnits Height=30}"
+ Margin="{views:ExtentsInUnits Start=16, End=16}"
+ WidthResizePolicy="FillToParent"
+ ResourceUrl="*Resource*/styles/button/ButtonFrame.png">
<!--Left button-->
<View Size="{views:SizeInUnits Height=30}"
WidthResizePolicy="FillToParent">
HeightResizePolicy="FillToParent"
Text="Review movement"
Weight="1"
- Command="{Binding ReviewMovement}"/>
+ Command="{Binding ReviewMovement}"
+ behaviors:StyleSetter.Style="{Binding Source={x:Static styles:Buttons.ReviewMovement}}"/>
<View HeightResizePolicy="FillToParent"
BackgroundColor="Transparent"
Weight="2"/>
HeightResizePolicy="FillToParent"
Text="End workout"
Weight="1"
- Command="{Binding EndWorkout}"/>
+ Command="{Binding EndWorkout}"
+ behaviors:StyleSetter.Style="{Binding Source={x:Static styles:Buttons.Transparent}}"/>
</View>
<!--Center button-->
<View Size="{views:SizeInUnits Height=30}"
HeightResizePolicy="FillToParent"
Text="Continue exercise"
Weight="1"
- Command="{Binding PauseResumeWorkout}"/>
+ Command="{Binding PauseResumeWorkout}"
+ behaviors:StyleSetter.Style="{Binding Source={x:Static styles:Buttons.Regular}}"/>
<View HeightResizePolicy="FillToParent"
BackgroundColor="Transparent"
Weight="1"/>
</View>
- </View>
+ </ImageView>
<View Size="{views:SizeInUnits Height=5}"
WidthResizePolicy="FillToParent"/>
</View>
xmlns:ctrl="clr-namespace:Fitness.Controls"
xmlns:views="clr-namespace:Fitness.Views"
xmlns:nui="clr-namespace:Tizen.NUI.Components;assembly=Tizen.NUI.Components"
- xmlns:style="clr-namespace:Fitness.Views.Styles"
+ xmlns:styles="clr-namespace:Fitness.Views.Styles"
+ xmlns:behaviors="clr-namespace:Fitness.Views.Behaviors"
HeightResizePolicy="FillToParent"
WidthResizePolicy="FillToParent"
x:Name="Root">
<View.Layout>
<LinearLayout LinearOrientation="Vertical"/>
</View.Layout>
- <views:BarView BindingContext="{Binding Source={x:Reference Root}, Path=BindingContext}"/>
+ <!--Bar stub-->
+ <View Size="{views:SizeInUnits Height=30}"
+ WidthResizePolicy="FillToParent"/>
<!--Margin-->
<View BackgroundColor="Transparent"
WidthResizePolicy="FillToParent"
PivotPoint="Center"
Text="Pause"
Command="{Binding PauseResumeWorkout}"
- Size="{views:SizeInUnits Width=448, Height=30}">
+ Size="{views:SizeInUnits Width=448, Height=30}"
+ behaviors:StyleSetter.Style="{Binding Source={x:Static styles:Buttons.Regular}}">
</nui:Button>
</View>
<View Size="{views:SizeInUnits Height=5}"