Files
food-ai/client/lib/features/profile/profile_service.dart
dbastrikin ddbc8e2bc0 feat: add onboarding flow with visual redesign
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>
2026-03-16 23:13:00 +02:00

63 lines
1.7 KiB
Dart

import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../core/api/api_client.dart';
import '../../core/auth/auth_provider.dart';
import '../../shared/models/user.dart';
final profileServiceProvider = Provider<ProfileService>((ref) {
return ProfileService(ref.read(apiClientProvider));
});
class UpdateProfileRequest {
final String? name;
final int? heightCm;
final double? weightKg;
final String? dateOfBirth;
final String? gender;
final String? activity;
final String? goal;
final String? language;
final int? dailyCalories;
const UpdateProfileRequest({
this.name,
this.heightCm,
this.weightKg,
this.dateOfBirth,
this.gender,
this.activity,
this.goal,
this.language,
this.dailyCalories,
});
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
if (name != null) map['name'] = name;
if (heightCm != null) map['height_cm'] = heightCm;
if (weightKg != null) map['weight_kg'] = weightKg;
if (dateOfBirth != null) map['date_of_birth'] = dateOfBirth;
if (gender != null) map['gender'] = gender;
if (activity != null) map['activity'] = activity;
if (goal != null) map['goal'] = goal;
if (language != null) map['preferences'] = {'language': language};
if (dailyCalories != null) map['daily_calories'] = dailyCalories;
return map;
}
}
class ProfileService {
final ApiClient _client;
ProfileService(this._client);
Future<User> getProfile() async {
final json = await _client.get('/profile');
return User.fromJson(json);
}
Future<User> updateProfile(UpdateProfileRequest req) async {
final json = await _client.put('/profile', data: req.toJson());
return User.fromJson(json);
}
}