Skip to content

Commit

Permalink
Add TypeScript definition file (#63)
Browse files Browse the repository at this point in the history
* Add Methods_Dietary into RCTAppleHealthKit.xcodeproj

* Add TypeScript definition file
  • Loading branch information
svbutko authored and terrillo committed Nov 12, 2019
1 parent c0e6c74 commit ee0291f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
6 changes: 6 additions & 0 deletions RCTAppleHealthKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */ = {isa = PBXBuildFile; fileRef = 61232F921E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m */; };
64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */ = {isa = PBXBuildFile; fileRef = 64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */; };
64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */ = {isa = PBXBuildFile; fileRef = 64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */; };
846A98EA215244E7000C3E5D /* RCTAppleHealthKit+Methods_Dietary.m in Sources */ = {isa = PBXBuildFile; fileRef = 846A98E9215244E6000C3E5D /* RCTAppleHealthKit+Methods_Dietary.m */; };
C7F88CE6A9E2D530A1CBDFAA /* Pods_RCTAppleHealthKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C84411FDBEEBD8BA9C43C813 /* Pods_RCTAppleHealthKit.framework */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -63,6 +64,8 @@
64C42D491D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Vitals.m"; sourceTree = "<group>"; };
64E0E73D1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Results.h"; sourceTree = "<group>"; };
64E0E73E1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Results.m"; sourceTree = "<group>"; };
846A98E8215244E6000C3E5D /* RCTAppleHealthKit+Methods_Dietary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTAppleHealthKit+Methods_Dietary.h"; sourceTree = "<group>"; };
846A98E9215244E6000C3E5D /* RCTAppleHealthKit+Methods_Dietary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTAppleHealthKit+Methods_Dietary.m"; sourceTree = "<group>"; };
AD8403CE6AF2AAD2D7CEE97E /* Pods-RCTAppleHealthKit.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RCTAppleHealthKit.debug.xcconfig"; path = "Target Support Files/Pods-RCTAppleHealthKit/Pods-RCTAppleHealthKit.debug.xcconfig"; sourceTree = "<group>"; };
C84411FDBEEBD8BA9C43C813 /* Pods_RCTAppleHealthKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RCTAppleHealthKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -100,6 +103,8 @@
3774C88F1D2092F20000B3F3 /* RCTAppleHealthKit */ = {
isa = PBXGroup;
children = (
846A98E8215244E6000C3E5D /* RCTAppleHealthKit+Methods_Dietary.h */,
846A98E9215244E6000C3E5D /* RCTAppleHealthKit+Methods_Dietary.m */,
58C81E6E1F84F6970005DD48 /* RCTAppleHealthKit+Methods_Activity.h */,
58C81E6D1F84F6970005DD48 /* RCTAppleHealthKit+Methods_Activity.m */,
61232F911E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.h */,
Expand Down Expand Up @@ -234,6 +239,7 @@
37837E7D1DCFE270000201A0 /* RCTAppleHealthKit+Methods_Sleep.m in Sources */,
3774C8D41D20C6390000B3F3 /* RCTAppleHealthKit+Methods_Body.m in Sources */,
61232F931E303758000A5026 /* RCTAppleHealthKit+Methods_Mindfulness.m in Sources */,
846A98EA215244E7000C3E5D /* RCTAppleHealthKit+Methods_Dietary.m in Sources */,
64E0E73F1D37947B00EAB905 /* RCTAppleHealthKit+Methods_Results.m in Sources */,
64C42D4A1D351A8800A0A8F7 /* RCTAppleHealthKit+Methods_Vitals.m in Sources */,
3774C8931D2092F20000B3F3 /* RCTAppleHealthKit.m in Sources */,
Expand Down
62 changes: 62 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
declare module "rn-apple-healthkit" {
export interface HealthKitPermissions {
permissions: {
read: string[];
write: string[];
};
}

export interface AppleHealthKit {
initHealthKit(permissions: HealthKitPermissions, callback: (error: string, result: Object) => void): void;

saveFood(options: Object, callback: (error: string, result: Object) => void): void;

isAvailable(callback: (error: Object, results: boolean) => void): void;

getDateOfBirth(options: any, callback: (error: Object, results: HealthDateOfBirth) => void): void;

getLatestHeight(options: HealthUnitOptions, callback: (err: string, results: HealthValue) => void): void;

getLatestWeight(options: HealthUnitOptions, callback: (err: string, results: HealthValue) => void): void;
}

export interface HealthDateOfBirth {
value: string;
age: number;
}

export interface HealthValue {
value: number;
startDate: string;
endDate: string;
}

export interface HealthUnitOptions {
unit: HealthUnit;
}
export enum HealthUnit {
bpm = "bpm",
calorie = "calorie",
celsius = "celsius",
count = "count",
day = "day",
fahrenheit = "fahrenheit",
foot = "foot",
gram = "gram",
hour = "hour",
inch = "inch",
joule = "joule",
meter = "meter",
mgPerdL = "mgPerdL",
mile = "mile",
minute = "minute",
mmhg = "mmhg",
mmolPerL = "mmolPerL",
percent = "percent",
pound = "pound",
second = "second"
}

const appleHealthKit: AppleHealthKit;
export default appleHealthKit;
}

0 comments on commit ee0291f

Please sign in to comment.