Skip to content

Commit

Permalink
Merge pull request #1 from jfversluis/improve-pedometerdata
Browse files Browse the repository at this point in the history
Add PedometerData.Timestamp & API docs
  • Loading branch information
jfversluis committed Aug 18, 2023
2 parents daa36e6 + f0cf08c commit e50be28
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions samples/Plugin.Maui.Pedometer.Sample/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
<Button x:Name="StartStopMonitoring" Text="Start/Stop" Clicked="Button_Clicked" Margin="20,20,20,0"/>
<Label Text="Steps taken 🥾" HorizontalOptions="Center" FontSize="25" />
<Label x:Name="StepCount" Text="0" HorizontalOptions="Center" FontSize="25" />
<Label x:Name="LastUpdate" HorizontalOptions="Center" />
</VerticalStackLayout>
</ContentPage>
1 change: 1 addition & 0 deletions samples/Plugin.Maui.Pedometer.Sample/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void Pedometer_ReadingChanged(object sender, PedometerData e)
MainThread.InvokeOnMainThreadAsync(() =>
{
StepCount.Text = e.NumberOfSteps.ToString();
LastUpdate.Text = $"Last update: {e.Timestamp}";
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/Plugin.Maui.Pedometer/Pedometer.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public void OnSensorChanged(SensorEvent? e)

ReadingChanged?.Invoke(this, new()
{
NumberOfSteps = count
NumberOfSteps = count,
Timestamp = DateTimeOffset.Now,
});
}

Expand Down
1 change: 1 addition & 0 deletions src/Plugin.Maui.Pedometer/Pedometer.macios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void Start()
ReadingChanged?.Invoke(this, new()
{
NumberOfSteps = (int)data.NumberOfSteps,
Timestamp = DateTimeOffset.Now,
});
});
}
Expand Down
13 changes: 12 additions & 1 deletion src/Plugin.Maui.Pedometer/PedometerData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
namespace Plugin.Maui.Pedometer;

/// <summary>
/// Contains the data measured by the user's device pedometer.
/// </summary>
public class PedometerData
{
public int NumberOfSteps { get; set; }
/// <summary>
/// Gets the timestamp for this sensor reading.
/// </summary>
public DateTimeOffset Timestamp { get; internal set; }

/// <summary>
/// Gets the total number of steps since the current measuring session started.
/// </summary>
public int NumberOfSteps { get; internal set; }
}

0 comments on commit e50be28

Please sign in to comment.