Skip to content

fix(motion-activity-event): correct field name and update to union type #1624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/declarations/interfaces/Location.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="./GeofenceEvent.d.ts" />
/// <reference path="./MotionActivityEvent.d.ts" />
/// <reference path="./LocationMotionActivityEvent.d.ts" />
/// <reference path="./ProviderChangeEvent.d.ts" />
/// <reference path="../types.d.ts" />
///
Expand Down Expand Up @@ -216,7 +216,7 @@ declare module "react-native-background-geolocation" {
/**
* Device motion-activity when this location was recorded (eg: `still`, `on_foot`, `in_vehicle`).
*/
activity: MotionActivityEvent;
activity: LocationMotionActivityEvent;
/**
* If this location was recorded due to [[ProviderChangeEvent]], this is a reference to the location-provider state.
*/
Expand Down
42 changes: 42 additions & 0 deletions src/declarations/interfaces/LocationMotionActivityEvent.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
declare module "react-native-background-geolocation" {
/**
* Type of activity.
*/
type LocationMotionActivityType =
| "still"
| "walking"
| "on_foot"
| "running"
| "on_bicycle"
| "in_vehicle";

/**
* The `activity` field which is part of the `Location` type that gets passed to [[BackgroundGeolocation.onLocation]].
*
* @example
* ```typescript
* BackgroundGeolocation.onLocatione(location => {
* console.log("[location] ", location.activity.type, location.activity.confidence);
* });
* ```
*/
interface LocationMotionActivityEvent {
/**
* The reported device motion activity.
*
* | Activity Name |
* |----------------|
* | `still` |
* | `walking` |
* | `on_foot` |
* | `running` |
* | `on_bicycle` |
* | `in_vehicle` |
*/
type: LocationMotionActivityType;
/**
* Confidence of the reported device motion activity in %.
*/
confidence: number;
}
}
44 changes: 22 additions & 22 deletions src/declarations/interfaces/MotionActivityEvent.d.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
declare module "react-native-background-geolocation" {
/**
* The event-object provided to [[BackgroundGeolocation.onActivityChange]]. Also attached to each recorded [[Location]].
*
* @example
* ```typescript
* BackgroundGeolocation.onActivityChange(activityChangeEvent => {
* console.log("[activitychange] ", activityChangeEvent.activity, activityChangeEvent.confidence);
* });
* ```
*/
* The event-object provided to [[BackgroundGeolocation.onActivityChange]]. Also attached to each recorded [[Location]].
*
* @example
* ```typescript
* BackgroundGeolocation.onActivityChange(activityChangeEvent => {
* console.log("[activitychange] ", activityChangeEvent.activity, activityChangeEvent.confidence);
* });
* ```
*/
interface MotionActivityEvent {
/**
* The reported device motion activity.
*
* | Activity Name |
* |----------------|
* | `still` |
* | `walking` |
* | `on_foot` |
* | `running` |
* | `on_bicycle` |
* | `in_vehicle` |
*/
* The reported device motion activity.
*
* | Activity Name |
* |----------------|
* | `still` |
* | `walking` |
* | `on_foot` |
* | `running` |
* | `on_bicycle` |
* | `in_vehicle` |
*/
activity: string;
/**
* Confidence of the reported device motion activity in %.
*/
* Confidence of the reported device motion activity in %.
*/
confidence: number;
}
}