Skip to content

Commit 079de1b

Browse files
committed
[Health] Add lean mass data type
Closes cph-cachet#1078
1 parent 3784963 commit 079de1b

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

packages/health/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 11.2.0
2+
3+
* Add lean mass data type [#1078](https://github.com/cph-cachet/flutter-plugins/issues/1078)
4+
15
## 11.1.1
26

37
* Fix of [#1059](https://github.com/cph-cachet/flutter-plugins/issues/1059)

packages/health/android/src/main/kotlin/cachet/plugins/health/HealthPlugin.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ const val BLOOD_OXYGEN = "BLOOD_OXYGEN"
4848
const val BLOOD_PRESSURE_DIASTOLIC = "BLOOD_PRESSURE_DIASTOLIC"
4949
const val BLOOD_PRESSURE_SYSTOLIC = "BLOOD_PRESSURE_SYSTOLIC"
5050
const val BODY_FAT_PERCENTAGE = "BODY_FAT_PERCENTAGE"
51+
const val LEAN_BODY_MASS = "LEAN_BODY_MASS"
5152
const val BODY_TEMPERATURE = "BODY_TEMPERATURE"
5253
const val BODY_WATER_MASS = "BODY_WATER_MASS"
5354
const val DISTANCE_DELTA = "DISTANCE_DELTA"
@@ -1596,6 +1597,22 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
15961597
),
15971598
)
15981599

1600+
LEAN_BODY_MASS ->
1601+
LeanBodyMassRecord(
1602+
time =
1603+
Instant.ofEpochMilli(
1604+
startTime
1605+
),
1606+
mass =
1607+
Mass.kilograms(
1608+
value
1609+
),
1610+
zoneOffset = null,
1611+
metadata = Metadata(
1612+
recordingMethod = recordingMethod,
1613+
),
1614+
)
1615+
15991616
HEIGHT ->
16001617
HeightRecord(
16011618
time =
@@ -2398,6 +2415,7 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
23982415
private val mapToType =
23992416
hashMapOf(
24002417
BODY_FAT_PERCENTAGE to BodyFatRecord::class,
2418+
LEAN_BODY_MASS to LeanBodyMassRecord::class,
24012419
HEIGHT to HeightRecord::class,
24022420
WEIGHT to WeightRecord::class,
24032421
STEPS to StepsRecord::class,
@@ -2451,7 +2469,6 @@ class HealthPlugin(private var channel: MethodChannel? = null) :
24512469
// "HeartRate" to HeartRateRecord::class,
24522470
// "Height" to HeightRecord::class,
24532471
// "Hydration" to HydrationRecord::class,
2454-
// "LeanBodyMass" to LeanBodyMassRecord::class,
24552472
// "MenstruationPeriod" to MenstruationPeriodRecord::class,
24562473
// "Nutrition" to NutritionRecord::class,
24572474
// "OvulationTest" to OvulationTestRecord::class,

packages/health/ios/Classes/SwiftHealthPlugin.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin {
3535
let BLOOD_PRESSURE_DIASTOLIC = "BLOOD_PRESSURE_DIASTOLIC"
3636
let BLOOD_PRESSURE_SYSTOLIC = "BLOOD_PRESSURE_SYSTOLIC"
3737
let BODY_FAT_PERCENTAGE = "BODY_FAT_PERCENTAGE"
38+
let LEAN_BODY_MASS = "LEAN_BODY_MASS"
3839
let BODY_MASS_INDEX = "BODY_MASS_INDEX"
3940
let BODY_TEMPERATURE = "BODY_TEMPERATURE"
4041
// Nutrition
@@ -1409,6 +1410,7 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin {
14091410
forIdentifier: .bloodPressureSystolic)!
14101411
dataTypesDict[BODY_FAT_PERCENTAGE] = HKSampleType.quantityType(
14111412
forIdentifier: .bodyFatPercentage)!
1413+
dataTypesDict[LEAN_BODY_MASS] = HKSampleType.quantityType(forIdentifier: .bodyMass)!
14121414
dataTypesDict[BODY_MASS_INDEX] = HKSampleType.quantityType(forIdentifier: .bodyMassIndex)!
14131415
dataTypesDict[BODY_TEMPERATURE] = HKSampleType.quantityType(forIdentifier: .bodyTemperature)!
14141416

@@ -1507,6 +1509,7 @@ public class SwiftHealthPlugin: NSObject, FlutterPlugin {
15071509
dataQuantityTypesDict[BLOOD_PRESSURE_DIASTOLIC] = HKQuantityType.quantityType(forIdentifier: .bloodPressureDiastolic)!
15081510
dataQuantityTypesDict[BLOOD_PRESSURE_SYSTOLIC] = HKQuantityType.quantityType(forIdentifier: .bloodPressureSystolic)!
15091511
dataQuantityTypesDict[BODY_FAT_PERCENTAGE] = HKQuantityType.quantityType(forIdentifier: .bodyFatPercentage)!
1512+
dataQuantityTypesDict[LEAN_BODY_MASS] = HKSampleType.quantityType(forIdentifier: .bodyMass)!
15101513
dataQuantityTypesDict[BODY_MASS_INDEX] = HKQuantityType.quantityType(forIdentifier: .bodyMassIndex)!
15111514
dataQuantityTypesDict[BODY_TEMPERATURE] = HKQuantityType.quantityType(forIdentifier: .bodyTemperature)!
15121515

packages/health/lib/src/heath_data_types.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ enum HealthDataType {
1111
BLOOD_PRESSURE_DIASTOLIC,
1212
BLOOD_PRESSURE_SYSTOLIC,
1313
BODY_FAT_PERCENTAGE,
14+
LEAN_BODY_MASS,
1415
BODY_MASS_INDEX,
1516
BODY_TEMPERATURE,
1617
BODY_WATER_MASS,
@@ -125,6 +126,7 @@ const List<HealthDataType> dataTypeKeysIOS = [
125126
HealthDataType.BLOOD_PRESSURE_DIASTOLIC,
126127
HealthDataType.BLOOD_PRESSURE_SYSTOLIC,
127128
HealthDataType.BODY_FAT_PERCENTAGE,
129+
HealthDataType.LEAN_BODY_MASS,
128130
HealthDataType.BODY_MASS_INDEX,
129131
HealthDataType.BODY_TEMPERATURE,
130132
HealthDataType.DIETARY_CARBS_CONSUMED,
@@ -216,6 +218,7 @@ const List<HealthDataType> dataTypeKeysAndroid = [
216218
HealthDataType.BLOOD_PRESSURE_DIASTOLIC,
217219
HealthDataType.BLOOD_PRESSURE_SYSTOLIC,
218220
HealthDataType.BODY_FAT_PERCENTAGE,
221+
HealthDataType.LEAN_BODY_MASS,
219222
HealthDataType.BODY_MASS_INDEX,
220223
HealthDataType.BODY_TEMPERATURE,
221224
HealthDataType.BODY_WATER_MASS,
@@ -256,6 +259,7 @@ const Map<HealthDataType, HealthDataUnit> dataTypeToUnit = {
256259
HealthDataType.BLOOD_PRESSURE_DIASTOLIC: HealthDataUnit.MILLIMETER_OF_MERCURY,
257260
HealthDataType.BLOOD_PRESSURE_SYSTOLIC: HealthDataUnit.MILLIMETER_OF_MERCURY,
258261
HealthDataType.BODY_FAT_PERCENTAGE: HealthDataUnit.PERCENT,
262+
HealthDataType.LEAN_BODY_MASS: HealthDataUnit.KILOGRAM,
259263
HealthDataType.BODY_MASS_INDEX: HealthDataUnit.NO_UNIT,
260264
HealthDataType.BODY_TEMPERATURE: HealthDataUnit.DEGREE_CELSIUS,
261265
HealthDataType.BODY_WATER_MASS: HealthDataUnit.KILOGRAM,

0 commit comments

Comments
 (0)