This repository has been archived by the owner on Jan 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,083 additions
and
930 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:sample="clr-namespace:Sample" | ||
xmlns:health="clr-namespace:Shiny.Health;assembly=Shiny.Health" | ||
x:DataType="sample:ListViewModel" | ||
x:Class="Sample.ListPage" | ||
Title="{Binding Title}"> | ||
|
||
<StackLayout HorizontalOptions="FillAndExpand" | ||
VerticalOptions="FillAndExpand"> | ||
|
||
<Grid RowDefinitions="Auto, Auto, Auto" | ||
ColumnDefinitions="1*, 2*, 2*"> | ||
|
||
<Label Text="Start Date" | ||
Grid.Column="0" | ||
Grid.Row="0" /> | ||
|
||
<DatePicker Date="{Binding DateStart}" | ||
Grid.Column="1" | ||
Grid.Row="0" /> | ||
|
||
<TimePicker Time="{Binding TimeStart}" | ||
Grid.Column="2" | ||
Grid.Row="0" /> | ||
|
||
<Label Text="End Date" | ||
Grid.Column="0" | ||
Grid.Row="1" /> | ||
|
||
<DatePicker Date="{Binding DateEnd}" | ||
Grid.Column="1" | ||
Grid.Row="1" /> | ||
|
||
<TimePicker Time="{Binding TimeEnd}" | ||
Grid.Column="2" | ||
Grid.Row="1" /> | ||
</Grid> | ||
|
||
<Button Text="Run Query" | ||
Command="{Binding Load}" /> | ||
|
||
<CollectionView ItemsSource="{Binding Data}" | ||
HorizontalOptions="FillAndExpand" | ||
VerticalOptions="FillAndExpand"> | ||
<CollectionView.EmptyView> | ||
<Label Text="No Items" /> | ||
</CollectionView.EmptyView> | ||
|
||
<CollectionView.ItemTemplate> | ||
<DataTemplate x:DataType="health:NumericHealthResult"> | ||
<StackLayout Padding="0,5"> | ||
<StackLayout Orientation="Horizontal" Spacing="5"> | ||
<Label FontAttributes="Bold" Text="{Binding Start, StringFormat='{0:MM/dd/yyyy a\\t h:mm tt}'}" /> | ||
<Label FontAttributes="Bold" Text="to" /> | ||
<Label FontAttributes="Bold" Text="{Binding End, StringFormat='{0:MM/dd/yyyy a\\t h:mm tt}'}" /> | ||
</StackLayout> | ||
<Label Text="{Binding Value, StringFormat='Value: {0}'}" /> | ||
</StackLayout> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
</StackLayout> | ||
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Sample; | ||
|
||
public partial class ListPage : ContentPage | ||
{ | ||
public ListPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using Shiny.Health; | ||
|
||
namespace Sample; | ||
|
||
|
||
public class ListViewModel : ViewModel | ||
{ | ||
DataType type; | ||
|
||
public ListViewModel(BaseServices services, IHealthService health) : base(services) | ||
{ | ||
this.DateStart = DateTime.Now.AddDays(-1); | ||
this.DateEnd = DateTime.Now; | ||
|
||
this.Load = ReactiveCommand.CreateFromTask( | ||
async () => | ||
{ | ||
var start = this.DateStart.Date.Add(this.TimeStart); | ||
var end = this.DateEnd.Date.Add(this.TimeEnd); | ||
|
||
switch (this.type) | ||
{ | ||
case DataType.StepCount: | ||
this.Data = (await health.GetStepCounts(start, end, Interval.Hours)) | ||
.Cast<object>() | ||
.ToList(); | ||
break; | ||
|
||
case DataType.HeartRate: | ||
this.Data = (await health.GetAverageHeartRate(start, end, Interval.Hours)) | ||
.Cast<object>() | ||
.ToList(); | ||
break; | ||
|
||
case DataType.Calories: | ||
this.Data = (await health.GetCalories(start, end, Interval.Hours)) | ||
.Cast<object>() | ||
.ToList(); | ||
break; | ||
|
||
case DataType.Distance: | ||
this.Data = (await health.GetDistances(start, end, Interval.Hours)) | ||
.Cast<object>() | ||
.ToList(); | ||
break; | ||
} | ||
} | ||
); | ||
} | ||
|
||
|
||
public ICommand Load { get; } | ||
|
||
[Reactive] public DateTime DateStart { get; set; } | ||
[Reactive] public TimeSpan TimeStart { get; set; } | ||
[Reactive] public DateTime DateEnd { get; set; } | ||
[Reactive] public TimeSpan TimeEnd { get; set; } | ||
[Reactive] public IList<object> Data { get; private set; } | ||
|
||
public override void OnNavigatedTo(INavigationParameters parameters) | ||
{ | ||
this.type = parameters.GetValue<DataType>("Type"); | ||
switch (this.type) | ||
{ | ||
case DataType.Calories: | ||
this.Title = "Total Calories"; | ||
break; | ||
|
||
case DataType.Distance: | ||
this.Title = "Total Distance"; | ||
break; | ||
|
||
case DataType.HeartRate: | ||
this.Title = "Average Heart Rate"; | ||
break; | ||
|
||
case DataType.StepCount: | ||
this.Title = "Total Steps"; | ||
break; | ||
} | ||
this.Load.Execute(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.