-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restructure main to get initial user if exists
- Loading branch information
1 parent
e4b012f
commit 27b5acf
Showing
14 changed files
with
407 additions
and
182 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
.PHONY: test, seed, assets | ||
.PHONY: test seed assets | ||
|
||
clean: | ||
flutter clean && flutter pub get | ||
|
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 |
---|---|---|
@@ -1,21 +1,97 @@ | ||
//User Model | ||
class UserModel { | ||
import 'package:cloud_firestore/cloud_firestore.dart'; | ||
|
||
class Zone2User { | ||
final String uid; | ||
final String email; | ||
String name; | ||
Map<String, dynamic> fcmTokenMap; | ||
|
||
UserModel( | ||
{required this.uid, required this.email, required this.name, required this.fcmTokenMap}); | ||
final bool onboardingComplete; | ||
ZoneSettings? zoneSettings; | ||
Zone2User( | ||
{required this.uid, | ||
required this.email, | ||
required this.name, | ||
required this.onboardingComplete, | ||
this.zoneSettings}); | ||
|
||
factory UserModel.fromJson(Map data) { | ||
return UserModel( | ||
factory Zone2User.fromJson(Map data) { | ||
return Zone2User( | ||
uid: data['uid'], | ||
email: data['email'] ?? '', | ||
name: data['name'] ?? '', | ||
fcmTokenMap: data['fcmTokenMap'] ?? {}); | ||
onboardingComplete: data['onboardingComplete'] ?? false, | ||
zoneSettings: ZoneSettings.fromJson(data['zoneSettings'] ?? {})); | ||
} | ||
|
||
Map<String, dynamic> toJson() => { | ||
"uid": uid, | ||
"email": email, | ||
"name": name, | ||
"onboardingComplete": onboardingComplete, | ||
"zoneSettings": zoneSettings?.toJson() ?? {} | ||
}; | ||
} | ||
|
||
class ZoneSettings { | ||
final Timestamp journeyStartDate; | ||
final int dailyWaterGoalInOz; | ||
final int dailyZonePointsGoal; | ||
final int dailyCalorieIntakeGoal; | ||
final int dailyCaloriesBurnedGoal; | ||
final int dailyStepsGoal; | ||
final String reasonForStartingJourney; | ||
final double initialWeightInLbs; | ||
final double targetWeightInLbs; | ||
final double heightInInches; | ||
final int heightInFeet; | ||
final String birthDate; | ||
final String gender; | ||
|
||
ZoneSettings( | ||
{required this.journeyStartDate, | ||
required this.dailyWaterGoalInOz, | ||
required this.dailyZonePointsGoal, | ||
required this.dailyCalorieIntakeGoal, | ||
required this.dailyCaloriesBurnedGoal, | ||
required this.dailyStepsGoal, | ||
required this.reasonForStartingJourney, | ||
required this.initialWeightInLbs, | ||
required this.targetWeightInLbs, | ||
required this.heightInInches, | ||
required this.heightInFeet, | ||
required this.birthDate, | ||
required this.gender}); | ||
|
||
factory ZoneSettings.fromJson(Map data) { | ||
return ZoneSettings( | ||
journeyStartDate: data['journeyStartDate'] as Timestamp? ?? Timestamp.now(), | ||
dailyWaterGoalInOz: (data['dailyWaterGoalInOz'] as num?)?.toInt() ?? 100, | ||
dailyZonePointsGoal: (data['dailyZonePointsGoal'] as num?)?.toInt() ?? 100, | ||
dailyCalorieIntakeGoal: (data['dailyCalorieIntakeGoal'] as num?)?.toInt() ?? 0, | ||
dailyCaloriesBurnedGoal: (data['dailyCaloriesBurnedGoal'] as num?)?.toInt() ?? 0, | ||
dailyStepsGoal: (data['dailyStepsGoal'] as num?)?.toInt() ?? 10000, | ||
reasonForStartingJourney: data['reasonForStartingJourney'] as String? ?? '', | ||
initialWeightInLbs: (data['initialWeightInLbs'] as num?)?.toDouble() ?? 0.0, | ||
targetWeightInLbs: (data['targetWeightInLbs'] as num?)?.toDouble() ?? 0.0, | ||
heightInInches: (data['heightInInches'] as num?)?.toDouble() ?? 0.0, | ||
heightInFeet: (data['heightInFeet'] as num?)?.toInt() ?? 0, | ||
birthDate: data['birthDate'] as String? ?? '', | ||
gender: data['gender'] as String? ?? ''); | ||
} | ||
|
||
Map<String, dynamic> toJson() => | ||
{"uid": uid, "email": email, "name": name, "fcmTokenMap": fcmTokenMap}; | ||
Map<String, dynamic> toJson() => { | ||
"journeyStartDate": journeyStartDate, | ||
"dailyWaterGoalInOz": dailyWaterGoalInOz, | ||
"dailyZonePointsGoal": dailyZonePointsGoal, | ||
"dailyCalorieIntakeGoal": dailyCalorieIntakeGoal, | ||
"dailyCaloriesBurnedGoal": dailyCaloriesBurnedGoal, | ||
"dailyStepsGoal": dailyStepsGoal, | ||
"reasonForStartingJourney": reasonForStartingJourney, | ||
"initialWeightInLbs": initialWeightInLbs, | ||
"targetWeightInLbs": targetWeightInLbs, | ||
"heightInInches": heightInInches, | ||
"heightInFeet": heightInFeet, | ||
"birthDate": birthDate, | ||
"gender": gender | ||
}; | ||
} |
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
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
Oops, something went wrong.