Introduce 6-step onboarding screen (Goal → Gender → DOB → Height+Weight → Activity → Calories) with per-step accent colors, hero illustration area (concentric circles + icon), and white card content panel. Backend user entity and service updated to support onboarding fields (goal, activity, height, weight, DOB, dailyCalories). Router guards unauthenticated and onboarding-incomplete users. Profile service and screen updated to expose language and onboarding preferences. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
63 lines
1.5 KiB
Dart
63 lines
1.5 KiB
Dart
import 'package:json_annotation/json_annotation.dart';
|
|
|
|
part 'user.g.dart';
|
|
|
|
@JsonSerializable()
|
|
class User {
|
|
final String id;
|
|
final String email;
|
|
final String name;
|
|
@JsonKey(name: 'avatar_url')
|
|
final String? avatarUrl;
|
|
@JsonKey(name: 'height_cm')
|
|
final int? heightCm;
|
|
@JsonKey(name: 'weight_kg')
|
|
final double? weightKg;
|
|
@JsonKey(name: 'date_of_birth')
|
|
final String? dateOfBirth;
|
|
final String? gender;
|
|
final String? activity;
|
|
final String? goal;
|
|
@JsonKey(name: 'daily_calories')
|
|
final int? dailyCalories;
|
|
final String plan;
|
|
@JsonKey(defaultValue: {})
|
|
final Map<String, dynamic> preferences;
|
|
|
|
const User({
|
|
required this.id,
|
|
required this.email,
|
|
required this.name,
|
|
this.avatarUrl,
|
|
this.heightCm,
|
|
this.weightKg,
|
|
this.dateOfBirth,
|
|
this.gender,
|
|
this.activity,
|
|
this.goal,
|
|
this.dailyCalories,
|
|
required this.plan,
|
|
this.preferences = const {},
|
|
});
|
|
|
|
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
|
|
Map<String, dynamic> toJson() => _$UserToJson(this);
|
|
|
|
int? get age {
|
|
if (dateOfBirth == null) return null;
|
|
final dob = DateTime.tryParse(dateOfBirth!);
|
|
if (dob == null) return null;
|
|
final now = DateTime.now();
|
|
int years = now.year - dob.year;
|
|
if (now.month < dob.month ||
|
|
(now.month == dob.month && now.day < dob.day)) {
|
|
years--;
|
|
}
|
|
return years;
|
|
}
|
|
|
|
bool get hasCompletedOnboarding =>
|
|
heightCm != null && weightKg != null && dateOfBirth != null &&
|
|
gender != null && goal != null && activity != null;
|
|
}
|