refactor: profile model

This commit is contained in:
mso7nueh
2024-09-09 18:18:35 +03:00
parent 3ccf5b6d92
commit 8ea819c5bc
77 changed files with 2735 additions and 2950 deletions

View File

@@ -1,110 +1,57 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'profile_model.freezed.dart';
part 'profile_model.g.dart';
@freezed
class ProfileModel with _$ProfileModel {
const factory ProfileModel({
@JsonKey(name: "user") required User user,
@JsonKey(name: "chartPoints") required List<ChartPointModel> chartPoints,
@JsonKey(name: "userDetails") required UserDetails userDetails,
@JsonKey(name: "circumferences") required List<Circumference> circumferences,
@JsonKey(name: "finishedPlans") required List<dynamic> finishedPlans,
@JsonKey(name: "rejectedPlans") required List<dynamic> rejectedPlans,
@JsonKey(name: "startedPlan") required List<dynamic> startedPlan,
@JsonKey(name: "paidPlan") required List<dynamic> paidPlan,
@JsonKey(name: "requestedPlan") required List<dynamic> requestedPlan,
@JsonKey(name: "initedPlan") required List<dynamic> initedPlan,
@JsonKey(name: "id") required int id,
@JsonKey(name: "name") required String name,
@JsonKey(name: "email") required String email,
@JsonKey(name: "email_verified_at") DateTime? emailVerifiedAt,
@JsonKey(name: "created_at") DateTime? createdAt,
@JsonKey(name: "updated_at") DateTime? updatedAt,
@JsonKey(name: "is_public_profile") required bool isPublicProfile,
@JsonKey(name: "slug") required String slug,
@JsonKey(name: "profile_photo_url") required String profilePhotoUrl,
}) = _ProfileModel;
factory ProfileModel.fromJson(Map<String, dynamic> json) => _$ProfileModelFromJson(json);
}
@freezed
class Circumference with _$Circumference {
const factory Circumference({
@JsonKey(name: "id") required int id,
@JsonKey(name: "user_id") required int userId,
@JsonKey(name: "chest_circumference") required int chestCircumference,
@JsonKey(name: "waist_circumference") required int waistCircumference,
@JsonKey(name: "hip_circumference") required int hipCircumference,
@JsonKey(name: "created_at") required DateTime createdAt,
@JsonKey(name: "updated_at") required DateTime updatedAt,
}) = _Circumference;
factory Circumference.fromJson(Map<String, dynamic> json) => _$CircumferenceFromJson(json);
}
@freezed
class User with _$User {
const factory User({
@JsonKey(name: "id") required int id,
@JsonKey(name: "name") required String name,
@JsonKey(name: "email") required String email,
@JsonKey(name: "email_verified_at") required dynamic emailVerifiedAt,
@JsonKey(name: "two_factor_confirmed_at") required dynamic twoFactorConfirmedAt,
@JsonKey(name: "current_team_id") required dynamic currentTeamId,
@JsonKey(name: "profile_photo_path") String? profilePhotoPath,
@JsonKey(name: "created_at") required DateTime createdAt,
@JsonKey(name: "updated_at") required DateTime updatedAt,
@JsonKey(name: "is_consultant") required int isConsultant,
@JsonKey(name: "is_public_profile") required int isPublicProfile,
@JsonKey(name: "slug") required String slug,
@JsonKey(name: "user_settings_id") required dynamic userSettingsId,
@JsonKey(name: "profile_photo_url") String? profilePhotoUrl,
@JsonKey(name: "detailz") required UserDetails detailz,
}) = _User;
factory User.fromJson(Map<String, dynamic> json) => _$UserFromJson(json);
}
@freezed
class UserDetails with _$UserDetails {
const factory UserDetails({
@JsonKey(name: "id") required int id,
@JsonKey(name: "user_id") required int userId,
class ProfileDetailsModel with _$ProfileDetailsModel {
const factory ProfileDetailsModel({
@JsonKey(name: "first_name") required String firstName,
@JsonKey(name: "last_name") required String lastName,
@JsonKey(name: "birthdate") required DateTime birthdate,
@JsonKey(name: "birthdate") required String birthdate,
@JsonKey(name: "gender") required String gender,
@JsonKey(name: "country") required String country,
@JsonKey(name: "city") required String city,
@JsonKey(name: "lang") required String lang,
@JsonKey(name: "weight") required int weight,
@JsonKey(name: "weight") required double weight,
@JsonKey(name: "height") required int height,
@JsonKey(name: "chest_circumference") required int chestCircumference,
@JsonKey(name: "waist_circumference") required int waistCircumference,
@JsonKey(name: "hip_circumference") required int hipCircumference,
@JsonKey(name: "blood_pressure_up") required int bloodPressureUp,
@JsonKey(name: "blood_pressure_down") required int bloodPressureDown,
@JsonKey(name: "has_hypo") required int hasHypo,
@JsonKey(name: "has_hyper") required int hasHyper,
@JsonKey(name: "has_hypo") required bool hasHypo,
@JsonKey(name: "has_hyper") required bool hasHyper,
@JsonKey(name: "about_alergy") required String aboutAlergy,
@JsonKey(name: "about_taking_pils") required String aboutTakingPils,
@JsonKey(name: "about_sport_hobbies") required String aboutSportHobbies,
@JsonKey(name: "favorite_foods") required String favoriteFoods,
@JsonKey(name: "unfavorite_foods") required String unfavoriteFoods,
@JsonKey(name: "additional_info") required String additionalInfo,
@JsonKey(name: "created_at") required DateTime createdAt,
@JsonKey(name: "updated_at") required DateTime updatedAt,
@JsonKey(name: "is_mood_fillable") required int isMoodFillable,
@JsonKey(name: "is_bedtime_fillable") required int isBedtimeFillable,
@JsonKey(name: "created_at") DateTime? createdAt,
@JsonKey(name: "updated_at") DateTime? updatedAt,
@JsonKey(name: "is_mood_fillable") required bool isMoodFillable,
@JsonKey(name: "is_bedtime_fillable") required bool isBedtimeFillable,
@JsonKey(name: "activity_coefficient") required double activityCoefficient,
}) = _UserDetails;
}) = _ProfileDetailsModel;
factory UserDetails.fromJson(Map<String, dynamic> json) => _$UserDetailsFromJson(json);
}
@freezed
class ChartPointModel with _$ChartPointModel {
const factory ChartPointModel({
@JsonKey(name: "id") required int id,
@JsonKey(name: "user_id") required int userId,
@JsonKey(name: "weight") required double weight,
@JsonKey(name: "bmi") required double bmi,
@JsonKey(name: "created_at") required DateTime createdAt,
@JsonKey(name: "updated_at") required DateTime updatedAt,
}) = _ChartPointModel;
factory ChartPointModel.fromJson(Map<String, dynamic> json) => _$ChartPointModelFromJson(json);
factory ProfileDetailsModel.fromJson(Map<String, dynamic> json) => _$ProfileDetailsModelFromJson(json);
}

File diff suppressed because it is too large Load Diff

View File

@@ -8,136 +8,78 @@ part of 'profile_model.dart';
_$ProfileModelImpl _$$ProfileModelImplFromJson(Map<String, dynamic> json) =>
_$ProfileModelImpl(
user: User.fromJson(json['user'] as Map<String, dynamic>),
chartPoints: (json['chartPoints'] as List<dynamic>)
.map((e) => ChartPointModel.fromJson(e as Map<String, dynamic>))
.toList(),
userDetails:
UserDetails.fromJson(json['userDetails'] as Map<String, dynamic>),
circumferences: (json['circumferences'] as List<dynamic>)
.map((e) => Circumference.fromJson(e as Map<String, dynamic>))
.toList(),
finishedPlans: json['finishedPlans'] as List<dynamic>,
rejectedPlans: json['rejectedPlans'] as List<dynamic>,
startedPlan: json['startedPlan'] as List<dynamic>,
paidPlan: json['paidPlan'] as List<dynamic>,
requestedPlan: json['requestedPlan'] as List<dynamic>,
initedPlan: json['initedPlan'] as List<dynamic>,
id: (json['id'] as num).toInt(),
name: json['name'] as String,
email: json['email'] as String,
emailVerifiedAt: json['email_verified_at'] == null
? null
: DateTime.parse(json['email_verified_at'] as String),
createdAt: json['created_at'] == null
? null
: DateTime.parse(json['created_at'] as String),
updatedAt: json['updated_at'] == null
? null
: DateTime.parse(json['updated_at'] as String),
isPublicProfile: json['is_public_profile'] as bool,
slug: json['slug'] as String,
profilePhotoUrl: json['profile_photo_url'] as String,
);
Map<String, dynamic> _$$ProfileModelImplToJson(_$ProfileModelImpl instance) =>
<String, dynamic>{
'user': instance.user,
'chartPoints': instance.chartPoints,
'userDetails': instance.userDetails,
'circumferences': instance.circumferences,
'finishedPlans': instance.finishedPlans,
'rejectedPlans': instance.rejectedPlans,
'startedPlan': instance.startedPlan,
'paidPlan': instance.paidPlan,
'requestedPlan': instance.requestedPlan,
'initedPlan': instance.initedPlan,
};
_$CircumferenceImpl _$$CircumferenceImplFromJson(Map<String, dynamic> json) =>
_$CircumferenceImpl(
id: (json['id'] as num).toInt(),
userId: (json['user_id'] as num).toInt(),
chestCircumference: (json['chest_circumference'] as num).toInt(),
waistCircumference: (json['waist_circumference'] as num).toInt(),
hipCircumference: (json['hip_circumference'] as num).toInt(),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
);
Map<String, dynamic> _$$CircumferenceImplToJson(_$CircumferenceImpl instance) =>
<String, dynamic>{
'id': instance.id,
'user_id': instance.userId,
'chest_circumference': instance.chestCircumference,
'waist_circumference': instance.waistCircumference,
'hip_circumference': instance.hipCircumference,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
};
_$UserImpl _$$UserImplFromJson(Map<String, dynamic> json) => _$UserImpl(
id: (json['id'] as num).toInt(),
name: json['name'] as String,
email: json['email'] as String,
emailVerifiedAt: json['email_verified_at'],
twoFactorConfirmedAt: json['two_factor_confirmed_at'],
currentTeamId: json['current_team_id'],
profilePhotoPath: json['profile_photo_path'] as String?,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
isConsultant: (json['is_consultant'] as num).toInt(),
isPublicProfile: (json['is_public_profile'] as num).toInt(),
slug: json['slug'] as String,
userSettingsId: json['user_settings_id'],
profilePhotoUrl: json['profile_photo_url'] as String?,
detailz: UserDetails.fromJson(json['detailz'] as Map<String, dynamic>),
);
Map<String, dynamic> _$$UserImplToJson(_$UserImpl instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'email': instance.email,
'email_verified_at': instance.emailVerifiedAt,
'two_factor_confirmed_at': instance.twoFactorConfirmedAt,
'current_team_id': instance.currentTeamId,
'profile_photo_path': instance.profilePhotoPath,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'is_consultant': instance.isConsultant,
'email_verified_at': instance.emailVerifiedAt?.toIso8601String(),
'created_at': instance.createdAt?.toIso8601String(),
'updated_at': instance.updatedAt?.toIso8601String(),
'is_public_profile': instance.isPublicProfile,
'slug': instance.slug,
'user_settings_id': instance.userSettingsId,
'profile_photo_url': instance.profilePhotoUrl,
'detailz': instance.detailz,
};
_$UserDetailsImpl _$$UserDetailsImplFromJson(Map<String, dynamic> json) =>
_$UserDetailsImpl(
id: (json['id'] as num).toInt(),
userId: (json['user_id'] as num).toInt(),
_$ProfileDetailsModelImpl _$$ProfileDetailsModelImplFromJson(
Map<String, dynamic> json) =>
_$ProfileDetailsModelImpl(
firstName: json['first_name'] as String,
lastName: json['last_name'] as String,
birthdate: DateTime.parse(json['birthdate'] as String),
birthdate: json['birthdate'] as String,
gender: json['gender'] as String,
country: json['country'] as String,
city: json['city'] as String,
lang: json['lang'] as String,
weight: (json['weight'] as num).toInt(),
weight: (json['weight'] as num).toDouble(),
height: (json['height'] as num).toInt(),
chestCircumference: (json['chest_circumference'] as num).toInt(),
waistCircumference: (json['waist_circumference'] as num).toInt(),
hipCircumference: (json['hip_circumference'] as num).toInt(),
bloodPressureUp: (json['blood_pressure_up'] as num).toInt(),
bloodPressureDown: (json['blood_pressure_down'] as num).toInt(),
hasHypo: (json['has_hypo'] as num).toInt(),
hasHyper: (json['has_hyper'] as num).toInt(),
hasHypo: json['has_hypo'] as bool,
hasHyper: json['has_hyper'] as bool,
aboutAlergy: json['about_alergy'] as String,
aboutTakingPils: json['about_taking_pils'] as String,
aboutSportHobbies: json['about_sport_hobbies'] as String,
favoriteFoods: json['favorite_foods'] as String,
unfavoriteFoods: json['unfavorite_foods'] as String,
additionalInfo: json['additional_info'] as String,
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
isMoodFillable: (json['is_mood_fillable'] as num).toInt(),
isBedtimeFillable: (json['is_bedtime_fillable'] as num).toInt(),
createdAt: json['created_at'] == null
? null
: DateTime.parse(json['created_at'] as String),
updatedAt: json['updated_at'] == null
? null
: DateTime.parse(json['updated_at'] as String),
isMoodFillable: json['is_mood_fillable'] as bool,
isBedtimeFillable: json['is_bedtime_fillable'] as bool,
activityCoefficient: (json['activity_coefficient'] as num).toDouble(),
);
Map<String, dynamic> _$$UserDetailsImplToJson(_$UserDetailsImpl instance) =>
Map<String, dynamic> _$$ProfileDetailsModelImplToJson(
_$ProfileDetailsModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'user_id': instance.userId,
'first_name': instance.firstName,
'last_name': instance.lastName,
'birthdate': instance.birthdate.toIso8601String(),
'birthdate': instance.birthdate,
'gender': instance.gender,
'country': instance.country,
'city': instance.city,
@@ -157,31 +99,9 @@ Map<String, dynamic> _$$UserDetailsImplToJson(_$UserDetailsImpl instance) =>
'favorite_foods': instance.favoriteFoods,
'unfavorite_foods': instance.unfavoriteFoods,
'additional_info': instance.additionalInfo,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
'created_at': instance.createdAt?.toIso8601String(),
'updated_at': instance.updatedAt?.toIso8601String(),
'is_mood_fillable': instance.isMoodFillable,
'is_bedtime_fillable': instance.isBedtimeFillable,
'activity_coefficient': instance.activityCoefficient,
};
_$ChartPointModelImpl _$$ChartPointModelImplFromJson(
Map<String, dynamic> json) =>
_$ChartPointModelImpl(
id: (json['id'] as num).toInt(),
userId: (json['user_id'] as num).toInt(),
weight: (json['weight'] as num).toDouble(),
bmi: (json['bmi'] as num).toDouble(),
createdAt: DateTime.parse(json['created_at'] as String),
updatedAt: DateTime.parse(json['updated_at'] as String),
);
Map<String, dynamic> _$$ChartPointModelImplToJson(
_$ChartPointModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'user_id': instance.userId,
'weight': instance.weight,
'bmi': instance.bmi,
'created_at': instance.createdAt.toIso8601String(),
'updated_at': instance.updatedAt.toIso8601String(),
};

View File

@@ -13,6 +13,7 @@ class ProfileCubit extends Cubit<ProfileState> {
try {
emit(ProfileState.loaded(
profile: await profileRepository.getProfileBySlug(slug),
profileDetails: await profileRepository.getMyProfileDetails(),
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: slug),
));
} catch (e) {
@@ -23,10 +24,11 @@ class ProfileCubit extends Cubit<ProfileState> {
getMyProfile() async {
try {
final myProfile = await profileRepository.getMyProfile();
final profile = await profileRepository.getMyProfile();
emit(ProfileState.loaded(
profile: myProfile,
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: myProfile.user.slug),
profile: profile,
profileDetails: await profileRepository.getMyProfileDetails(),
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: profile.slug),
));
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
@@ -45,12 +47,7 @@ class ProfileCubit extends Cubit<ProfileState> {
waistCircumference: waistCircumference,
hipCircumference: hipCircumference,
);
emit(
ProfileState.loaded(
profile: await profileRepository.getMyProfile(),
blogPosts: (state as ProfileStateLoaded).blogPosts,
),
);
emit((state as ProfileStateLoaded).copyWith());
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);
@@ -61,15 +58,8 @@ class ProfileCubit extends Cubit<ProfileState> {
required double weight,
}) async {
try {
await profileRepository.addWeight(
weight: weight,
);
emit(
ProfileState.loaded(
profile: await profileRepository.getMyProfile(),
blogPosts: (state as ProfileStateLoaded).blogPosts,
),
);
await profileRepository.addWeight(weight: weight);
emit((state as ProfileStateLoaded).copyWith());
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);

View File

@@ -12,6 +12,7 @@ abstract class ProfileState with _$ProfileState {
const factory ProfileState.loaded({
required ProfileModel profile,
required ProfileDetailsModel profileDetails,
required List<FeedBlogPostModel> blogPosts,
}) = ProfileStateLoaded;

View File

@@ -21,7 +21,9 @@ mixin _$ProfileState {
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(
ProfileModel profile, List<FeedBlogPostModel> blogPosts)
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)
loaded,
required TResult Function(String errorMessage) error,
}) =>
@@ -30,7 +32,8 @@ mixin _$ProfileState {
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ProfileModel profile, List<FeedBlogPostModel> blogPosts)?
TResult? Function(ProfileModel profile, ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)?
loaded,
TResult? Function(String errorMessage)? error,
}) =>
@@ -39,7 +42,8 @@ mixin _$ProfileState {
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ProfileModel profile, List<FeedBlogPostModel> blogPosts)?
TResult Function(ProfileModel profile, ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
@@ -88,6 +92,9 @@ class _$ProfileStateCopyWithImpl<$Res, $Val extends ProfileState>
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
@@ -104,6 +111,9 @@ class __$$ProfileStateImplCopyWithImpl<$Res>
__$$ProfileStateImplCopyWithImpl(
_$ProfileStateImpl _value, $Res Function(_$ProfileStateImpl) _then)
: super(_value, _then);
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
@@ -131,7 +141,9 @@ class _$ProfileStateImpl implements _ProfileState {
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(
ProfileModel profile, List<FeedBlogPostModel> blogPosts)
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)
loaded,
required TResult Function(String errorMessage) error,
}) {
@@ -143,7 +155,8 @@ class _$ProfileStateImpl implements _ProfileState {
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ProfileModel profile, List<FeedBlogPostModel> blogPosts)?
TResult? Function(ProfileModel profile, ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -155,7 +168,8 @@ class _$ProfileStateImpl implements _ProfileState {
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ProfileModel profile, List<FeedBlogPostModel> blogPosts)?
TResult Function(ProfileModel profile, ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
@@ -222,6 +236,9 @@ class __$$ProfileStateLoadingImplCopyWithImpl<$Res>
__$$ProfileStateLoadingImplCopyWithImpl(_$ProfileStateLoadingImpl _value,
$Res Function(_$ProfileStateLoadingImpl) _then)
: super(_value, _then);
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
}
/// @nodoc
@@ -250,7 +267,9 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading {
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(
ProfileModel profile, List<FeedBlogPostModel> blogPosts)
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)
loaded,
required TResult Function(String errorMessage) error,
}) {
@@ -262,7 +281,8 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading {
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ProfileModel profile, List<FeedBlogPostModel> blogPosts)?
TResult? Function(ProfileModel profile, ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -274,7 +294,8 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading {
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ProfileModel profile, List<FeedBlogPostModel> blogPosts)?
TResult Function(ProfileModel profile, ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
@@ -333,9 +354,13 @@ abstract class _$$ProfileStateLoadedImplCopyWith<$Res> {
$Res Function(_$ProfileStateLoadedImpl) then) =
__$$ProfileStateLoadedImplCopyWithImpl<$Res>;
@useResult
$Res call({ProfileModel profile, List<FeedBlogPostModel> blogPosts});
$Res call(
{ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts});
$ProfileModelCopyWith<$Res> get profile;
$ProfileDetailsModelCopyWith<$Res> get profileDetails;
}
/// @nodoc
@@ -346,10 +371,13 @@ class __$$ProfileStateLoadedImplCopyWithImpl<$Res>
$Res Function(_$ProfileStateLoadedImpl) _then)
: super(_value, _then);
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? profile = null,
Object? profileDetails = null,
Object? blogPosts = null,
}) {
return _then(_$ProfileStateLoadedImpl(
@@ -357,6 +385,10 @@ class __$$ProfileStateLoadedImplCopyWithImpl<$Res>
? _value.profile
: profile // ignore: cast_nullable_to_non_nullable
as ProfileModel,
profileDetails: null == profileDetails
? _value.profileDetails
: profileDetails // ignore: cast_nullable_to_non_nullable
as ProfileDetailsModel,
blogPosts: null == blogPosts
? _value._blogPosts
: blogPosts // ignore: cast_nullable_to_non_nullable
@@ -364,6 +396,8 @@ class __$$ProfileStateLoadedImplCopyWithImpl<$Res>
));
}
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ProfileModelCopyWith<$Res> get profile {
@@ -371,17 +405,31 @@ class __$$ProfileStateLoadedImplCopyWithImpl<$Res>
return _then(_value.copyWith(profile: value));
});
}
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
@override
@pragma('vm:prefer-inline')
$ProfileDetailsModelCopyWith<$Res> get profileDetails {
return $ProfileDetailsModelCopyWith<$Res>(_value.profileDetails, (value) {
return _then(_value.copyWith(profileDetails: value));
});
}
}
/// @nodoc
class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
const _$ProfileStateLoadedImpl(
{required this.profile, required final List<FeedBlogPostModel> blogPosts})
{required this.profile,
required this.profileDetails,
required final List<FeedBlogPostModel> blogPosts})
: _blogPosts = blogPosts;
@override
final ProfileModel profile;
@override
final ProfileDetailsModel profileDetails;
final List<FeedBlogPostModel> _blogPosts;
@override
List<FeedBlogPostModel> get blogPosts {
@@ -392,7 +440,7 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
@override
String toString() {
return 'ProfileState.loaded(profile: $profile, blogPosts: $blogPosts)';
return 'ProfileState.loaded(profile: $profile, profileDetails: $profileDetails, blogPosts: $blogPosts)';
}
@override
@@ -401,15 +449,19 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
(other.runtimeType == runtimeType &&
other is _$ProfileStateLoadedImpl &&
(identical(other.profile, profile) || other.profile == profile) &&
(identical(other.profileDetails, profileDetails) ||
other.profileDetails == profileDetails) &&
const DeepCollectionEquality()
.equals(other._blogPosts, _blogPosts));
}
@override
int get hashCode => Object.hash(
runtimeType, profile, const DeepCollectionEquality().hash(_blogPosts));
int get hashCode => Object.hash(runtimeType, profile, profileDetails,
const DeepCollectionEquality().hash(_blogPosts));
@JsonKey(ignore: true)
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ProfileStateLoadedImplCopyWith<_$ProfileStateLoadedImpl> get copyWith =>
@@ -422,11 +474,13 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(
ProfileModel profile, List<FeedBlogPostModel> blogPosts)
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)
loaded,
required TResult Function(String errorMessage) error,
}) {
return loaded(profile, blogPosts);
return loaded(profile, profileDetails, blogPosts);
}
@override
@@ -434,11 +488,12 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ProfileModel profile, List<FeedBlogPostModel> blogPosts)?
TResult? Function(ProfileModel profile, ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
return loaded?.call(profile, blogPosts);
return loaded?.call(profile, profileDetails, blogPosts);
}
@override
@@ -446,13 +501,14 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ProfileModel profile, List<FeedBlogPostModel> blogPosts)?
TResult Function(ProfileModel profile, ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
}) {
if (loaded != null) {
return loaded(profile, blogPosts);
return loaded(profile, profileDetails, blogPosts);
}
return orElse();
}
@@ -498,12 +554,17 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
abstract class ProfileStateLoaded implements ProfileState {
const factory ProfileStateLoaded(
{required final ProfileModel profile,
required final ProfileDetailsModel profileDetails,
required final List<FeedBlogPostModel> blogPosts}) =
_$ProfileStateLoadedImpl;
ProfileModel get profile;
ProfileDetailsModel get profileDetails;
List<FeedBlogPostModel> get blogPosts;
@JsonKey(ignore: true)
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ProfileStateLoadedImplCopyWith<_$ProfileStateLoadedImpl> get copyWith =>
throw _privateConstructorUsedError;
}
@@ -525,6 +586,8 @@ class __$$ProfileStateErrorImplCopyWithImpl<$Res>
$Res Function(_$ProfileStateErrorImpl) _then)
: super(_value, _then);
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
@@ -564,7 +627,9 @@ class _$ProfileStateErrorImpl implements ProfileStateError {
@override
int get hashCode => Object.hash(runtimeType, errorMessage);
@JsonKey(ignore: true)
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ProfileStateErrorImplCopyWith<_$ProfileStateErrorImpl> get copyWith =>
@@ -577,7 +642,9 @@ class _$ProfileStateErrorImpl implements ProfileStateError {
TResult Function() $default, {
required TResult Function() loading,
required TResult Function(
ProfileModel profile, List<FeedBlogPostModel> blogPosts)
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)
loaded,
required TResult Function(String errorMessage) error,
}) {
@@ -589,7 +656,8 @@ class _$ProfileStateErrorImpl implements ProfileStateError {
TResult? whenOrNull<TResult extends Object?>(
TResult? Function()? $default, {
TResult? Function()? loading,
TResult? Function(ProfileModel profile, List<FeedBlogPostModel> blogPosts)?
TResult? Function(ProfileModel profile, ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -601,7 +669,8 @@ class _$ProfileStateErrorImpl implements ProfileStateError {
TResult maybeWhen<TResult extends Object?>(
TResult Function()? $default, {
TResult Function()? loading,
TResult Function(ProfileModel profile, List<FeedBlogPostModel> blogPosts)?
TResult Function(ProfileModel profile, ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
@@ -655,7 +724,10 @@ abstract class ProfileStateError implements ProfileState {
_$ProfileStateErrorImpl;
String get errorMessage;
@JsonKey(ignore: true)
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ProfileStateErrorImplCopyWith<_$ProfileStateErrorImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@@ -1,12 +1,8 @@
import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/feed/presentation/widgets/blog_post_widget.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart';
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_state.dart';
import 'package:eatvio_app/features/profile/presentation/widgets/circumference_chart_widget.dart';
import 'package:eatvio_app/features/profile/presentation/widgets/imt_chart_widget.dart';
import 'package:eatvio_app/features/profile/presentation/widgets/weight_chart_widget.dart';
import 'package:eatvio_app/locator_service.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
@@ -23,8 +19,8 @@ class ProfileScreen extends StatefulWidget {
}
class _ProfileScreenState extends State<ProfileScreen> {
List<Circumference> chartData = [];
List<ChartPointModel> chartPoints = [];
// List<Circumference> chartData = [];
// List<ChartPointModel> chartPoints = [];
final List<String> chipsLabelList = ['Вес', 'Замеры', 'ИМТ'];
final List<String> chipsIntervalLabelList = ['1М', '3М', '6М', '1Г', 'ВСЁ ВРЕМЯ'];
int _selectedChipIndex = 0;
@@ -42,8 +38,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
child: BlocBuilder<ProfileCubit, ProfileState>(
builder: (BuildContext context, ProfileState state) {
if (state is ProfileStateLoaded) {
chartData = state.profile.circumferences;
chartPoints = state.profile.chartPoints;
// chartData = state.profile.circumferences;
// chartPoints = state.profile.chartPoints;
return Scaffold(
backgroundColor: Colors.grey.shade200,
appBar: widget.author == null ? AppBar(toolbarHeight: 0) : AppBar(),
@@ -65,17 +61,13 @@ class _ProfileScreenState extends State<ProfileScreen> {
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
child: Row(
children: [
state.profile.user.profilePhotoUrl != null
? CircleAvatar(
radius: 32,
backgroundImage: NetworkImage(state.profile.user.profilePhotoUrl!),
)
: CircleAvatar(
radius: 32,
),
CircleAvatar(
radius: 32,
backgroundImage: NetworkImage(state.profile.profilePhotoUrl),
),
const SizedBox(width: 12),
Text(
state.profile.user.name,
state.profile.name,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w500,
@@ -123,7 +115,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
GestureDetector(
onTap: () => Share.shareUri(
Uri.parse(
baseUrl + '/ru/profile/' + state.profile.user.slug,
baseUrl + '/ru/profile/' + state.profile.slug,
),
),
child: Container(
@@ -139,12 +131,12 @@ class _ProfileScreenState extends State<ProfileScreen> {
],
),
),
if (state.profile.userDetails.additionalInfo.isNotEmpty)
if (state.profileDetails.additionalInfo.isNotEmpty)
Container(
alignment: Alignment.centerLeft,
padding: const EdgeInsets.all(16),
child: Text(
state.profile.userDetails.additionalInfo,
state.profileDetails.additionalInfo,
style: TextStyle(
color: Colors.black.withOpacity(0.4),
height: 1,
@@ -157,7 +149,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
children: [
SizedBox(width: 16),
GestureDetector(
onTap: () => GoRouter.of(context).pushNamed('chatScreen', ),
onTap: () => GoRouter.of(context).pushNamed(
'chatScreen',
),
child: Container(
alignment: Alignment.center,
padding: EdgeInsets.all(8),
@@ -213,25 +207,25 @@ class _ProfileScreenState extends State<ProfileScreen> {
],
),
),
Builder(
builder: (context) {
switch (_selectedChipIndex) {
case 0:
return WeightChartWidget(
chartPoints: chartPoints,
profileCubit: context.read<ProfileCubit>(),
);
case 1:
return CircumferenceChartWidget(
chartData: chartData,
profileCubit: context.read<ProfileCubit>(),
);
case 2:
return ImtChartWidget(chartPoints: chartPoints);
}
return SizedBox.shrink();
},
),
// Builder(
// builder: (context) {
// switch (_selectedChipIndex) {
// case 0:
// return WeightChartWidget(
// chartPoints: chartPoints,
// profileCubit: context.read<ProfileCubit>(),
// );
// case 1:
// return CircumferenceChartWidget(
// chartData: chartData,
// profileCubit: context.read<ProfileCubit>(),
// );
// case 2:
// return ImtChartWidget(chartPoints: chartPoints);
// }
// return SizedBox.shrink();
// },
// ),
SizedBox(height: 8),
Row(
children: [

View File

@@ -1,374 +1,374 @@
import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
class CircumferenceChartWidget extends StatefulWidget {
final List<Circumference> chartData;
final ProfileCubit profileCubit;
const CircumferenceChartWidget({
super.key,
required this.chartData,
required this.profileCubit,
});
@override
State<CircumferenceChartWidget> createState() => _CircumferenceChartWidgetState();
}
class _CircumferenceChartWidgetState extends State<CircumferenceChartWidget> {
late FixedExtentScrollController chestController;
late FixedExtentScrollController waistController;
late FixedExtentScrollController hipController;
late int chest;
late int waist;
late int hip;
@override
Widget build(BuildContext context) {
return Column(
children: [
if (widget.chartData.isNotEmpty)
Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Row(
children: [
Text(
'${widget.chartData.last.chestCircumference}',
style: TextStyle(
color: Colors.black,
fontSize: 40,
fontWeight: FontWeight.w500,
),
),
if (widget.chartData.length == 1)
Container(
margin: EdgeInsets.symmetric(horizontal: 12),
width: 8,
height: 8,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black12,
),
),
if (widget.chartData.length > 1)
widget.chartData.last.chestCircumference > widget.chartData[widget.chartData.length - 2].chestCircumference
? Icon(
Icons.arrow_drop_up,
size: 40,
color: Colors.grey,
)
: Icon(
Icons.arrow_drop_down,
size: 40,
color: Colors.grey,
),
Text(
'${widget.chartData.last.waistCircumference}',
style: TextStyle(
color: Colors.black,
fontSize: 40,
fontWeight: FontWeight.w500,
),
),
if (widget.chartData.length == 1)
Container(
margin: EdgeInsets.symmetric(horizontal: 12),
width: 8,
height: 8,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black12,
),
),
if (widget.chartData.length > 1)
widget.chartData.last.waistCircumference > widget.chartData[widget.chartData.length - 2].waistCircumference
? Icon(
Icons.arrow_drop_up,
size: 40,
color: Colors.grey,
)
: Icon(
Icons.arrow_drop_down,
size: 40,
color: Colors.grey,
),
Text(
'${widget.chartData.last.hipCircumference}',
style: TextStyle(
color: Colors.black,
fontSize: 40,
fontWeight: FontWeight.w500,
),
),
if (widget.chartData.length == 1)
Container(
margin: EdgeInsets.symmetric(horizontal: 12),
width: 8,
height: 8,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black12,
),
),
if (widget.chartData.length > 1)
widget.chartData.last.hipCircumference > widget.chartData[widget.chartData.length - 2].hipCircumference
? Icon(
Icons.arrow_drop_up,
size: 40,
color: Colors.grey,
)
: Icon(
Icons.arrow_drop_down,
size: 40,
color: Colors.grey,
),
],
),
),
Stack(
alignment: Alignment.bottomRight,
children: [
SfCartesianChart(
margin: EdgeInsets.symmetric(horizontal: 8),
enableAxisAnimation: true,
plotAreaBorderWidth: 0,
trackballBehavior: TrackballBehavior(
enable: true,
activationMode: ActivationMode.singleTap,
tooltipDisplayMode: TrackballDisplayMode.groupAllPoints,
tooltipSettings: InteractiveTooltip(),
lineType: TrackballLineType.vertical,
),
primaryXAxis: DateTimeCategoryAxis(
tickPosition: TickPosition.inside,
majorTickLines: MajorTickLines(
size: 0,
),
edgeLabelPlacement: EdgeLabelPlacement.shift,
dateFormat: DateFormat.MMMd('ru'),
labelStyle: TextStyle(
color: Colors.grey,
),
majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey.withOpacity(0.3)),
axisLine: AxisLine(
color: Colors.grey.withOpacity(0.3),
width: 0.4,
),
),
primaryYAxis: NumericAxis(
isVisible: false,
labelFormat: '{value} см',
axisLine: AxisLine(
width: 1,
),
majorTickLines: MajorTickLines(size: 0),
),
series: _getSplineSeries(),
tooltipBehavior: TooltipBehavior(enable: true),
),
FloatingActionButton.small(
heroTag: 'addCircumference',
onPressed: () {
if (widget.chartData.isNotEmpty) {
chest = widget.chartData.last.chestCircumference;
waist = widget.chartData.last.waistCircumference;
hip = widget.chartData.last.hipCircumference;
chestController = FixedExtentScrollController(initialItem: chest - 20);
waistController = FixedExtentScrollController(initialItem: waist - 20);
hipController = FixedExtentScrollController(initialItem: hip - 20);
} else {
chestController = FixedExtentScrollController();
waistController = FixedExtentScrollController();
hipController = FixedExtentScrollController();
}
showModalBottomSheet(
useRootNavigator: true,
context: context,
builder: (context) {
return Column(
children: [
Expanded(
child: Row(
children: [
Expanded(
child: CupertinoPicker(
magnification: 1.22,
squeeze: 1.2,
useMagnifier: true,
scrollController: chestController,
itemExtent: 24,
onSelectedItemChanged: (int value) {
chest = value;
},
children: [
for (int i = 20; i < 200; i++) Text('$i'),
],
),
),
Expanded(
child: CupertinoPicker(
magnification: 1.22,
squeeze: 1.2,
useMagnifier: true,
scrollController: waistController,
itemExtent: 24,
onSelectedItemChanged: (int value) {
waist = value;
},
children: [
for (int i = 20; i < 200; i++) Text('$i'),
],
),
),
Expanded(
child: CupertinoPicker(
magnification: 1.22,
squeeze: 1.2,
useMagnifier: true,
scrollController: hipController,
itemExtent: 24,
onSelectedItemChanged: (int value) {
hip = value;
},
children: [
for (int i = 20; i < 200; i++) Text('$i'),
],
),
),
],
),
),
InkWell(
onTap: () {
widget.profileCubit.addCircumference(
chestCircumference: chest,
waistCircumference: waist,
hipCircumference: hip,
);
Navigator.of(context).pop();
},
borderRadius: BorderRadius.circular(16),
child: Ink(
width: MediaQuery.of(context).size.width - 32,
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: appTheme.blueA400,
borderRadius: BorderRadius.circular(16),
),
child: Center(
child: Text(
'Сохранить',
style: TextStyle(
color: Colors.white,
),
),
),
),
),
],
);
},
);
},
backgroundColor: Colors.red,
shape: CircleBorder(),
child: Icon(
Icons.add,
color: Colors.white,
),
),
],
),
],
);
}
List<CartesianSeries<Circumference, DateTime>> _getSplineSeries() {
final Color seriesColor1 = Colors.red;
final Color seriesColor2 = appTheme.blueA400;
final Color seriesColor3 = Colors.green;
return <CartesianSeries<Circumference, DateTime>>[
SplineAreaSeries<Circumference, DateTime>(
markerSettings: MarkerSettings(
isVisible: true,
color: seriesColor1,
height: 8,
width: 8,
),
dataLabelSettings: DataLabelSettings(
labelAlignment: ChartDataLabelAlignment.top,
isVisible: true,
),
dataSource: widget.chartData,
borderColor: seriesColor1,
gradient: LinearGradient(
colors: [
seriesColor1.withOpacity(0.14),
Colors.transparent,
],
begin: Alignment.topCenter,
end: Alignment(0, 0.6),
),
name: 'Грудь',
xValueMapper: (Circumference value, int index) => value.createdAt,
yValueMapper: (Circumference value, int index) => value.chestCircumference,
),
SplineAreaSeries<Circumference, DateTime>(
markerSettings: MarkerSettings(
isVisible: true,
color: seriesColor2,
height: 8,
width: 8,
),
dataLabelSettings: DataLabelSettings(
labelAlignment: ChartDataLabelAlignment.top,
isVisible: true,
),
dataSource: widget.chartData,
borderColor: seriesColor2,
gradient: LinearGradient(
colors: [
seriesColor2.withOpacity(0.14),
Colors.transparent,
],
begin: Alignment.topCenter,
end: Alignment(0, 0.6),
),
name: 'Талия',
xValueMapper: (Circumference value, int index) => value.createdAt,
yValueMapper: (Circumference value, int index) => value.waistCircumference,
),
SplineAreaSeries<Circumference, DateTime>(
markerSettings: MarkerSettings(
isVisible: true,
color: seriesColor3,
height: 8,
width: 8,
),
dataLabelSettings: DataLabelSettings(
labelAlignment: ChartDataLabelAlignment.top,
isVisible: true,
),
dataSource: widget.chartData,
borderColor: seriesColor3,
gradient: LinearGradient(
colors: [
seriesColor3.withOpacity(0.14),
Colors.transparent,
],
begin: Alignment.topCenter,
end: Alignment(0, 0.6),
),
name: 'Бёдра',
xValueMapper: (Circumference value, int index) => value.createdAt,
yValueMapper: (Circumference value, int index) => value.hipCircumference,
),
];
}
}
// import 'package:eatvio_app/core/app_export.dart';
// import 'package:eatvio_app/features/profile/models/profile_model.dart';
// import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart';
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart';
// import 'package:intl/intl.dart';
// import 'package:syncfusion_flutter_charts/charts.dart';
//
// class CircumferenceChartWidget extends StatefulWidget {
// final List<Circumference> chartData;
// final ProfileCubit profileCubit;
//
// const CircumferenceChartWidget({
// super.key,
// required this.chartData,
// required this.profileCubit,
// });
//
// @override
// State<CircumferenceChartWidget> createState() => _CircumferenceChartWidgetState();
// }
//
// class _CircumferenceChartWidgetState extends State<CircumferenceChartWidget> {
// late FixedExtentScrollController chestController;
// late FixedExtentScrollController waistController;
// late FixedExtentScrollController hipController;
// late int chest;
// late int waist;
// late int hip;
//
// @override
// Widget build(BuildContext context) {
// return Column(
// children: [
// if (widget.chartData.isNotEmpty)
// Padding(
// padding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
// child: Row(
// children: [
// Text(
// '${widget.chartData.last.chestCircumference}',
// style: TextStyle(
// color: Colors.black,
// fontSize: 40,
// fontWeight: FontWeight.w500,
// ),
// ),
// if (widget.chartData.length == 1)
// Container(
// margin: EdgeInsets.symmetric(horizontal: 12),
// width: 8,
// height: 8,
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// color: Colors.black12,
// ),
// ),
// if (widget.chartData.length > 1)
// widget.chartData.last.chestCircumference > widget.chartData[widget.chartData.length - 2].chestCircumference
// ? Icon(
// Icons.arrow_drop_up,
// size: 40,
// color: Colors.grey,
// )
// : Icon(
// Icons.arrow_drop_down,
// size: 40,
// color: Colors.grey,
// ),
// Text(
// '${widget.chartData.last.waistCircumference}',
// style: TextStyle(
// color: Colors.black,
// fontSize: 40,
// fontWeight: FontWeight.w500,
// ),
// ),
// if (widget.chartData.length == 1)
// Container(
// margin: EdgeInsets.symmetric(horizontal: 12),
// width: 8,
// height: 8,
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// color: Colors.black12,
// ),
// ),
// if (widget.chartData.length > 1)
// widget.chartData.last.waistCircumference > widget.chartData[widget.chartData.length - 2].waistCircumference
// ? Icon(
// Icons.arrow_drop_up,
// size: 40,
// color: Colors.grey,
// )
// : Icon(
// Icons.arrow_drop_down,
// size: 40,
// color: Colors.grey,
// ),
// Text(
// '${widget.chartData.last.hipCircumference}',
// style: TextStyle(
// color: Colors.black,
// fontSize: 40,
// fontWeight: FontWeight.w500,
// ),
// ),
// if (widget.chartData.length == 1)
// Container(
// margin: EdgeInsets.symmetric(horizontal: 12),
// width: 8,
// height: 8,
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// color: Colors.black12,
// ),
// ),
// if (widget.chartData.length > 1)
// widget.chartData.last.hipCircumference > widget.chartData[widget.chartData.length - 2].hipCircumference
// ? Icon(
// Icons.arrow_drop_up,
// size: 40,
// color: Colors.grey,
// )
// : Icon(
// Icons.arrow_drop_down,
// size: 40,
// color: Colors.grey,
// ),
// ],
// ),
// ),
// Stack(
// alignment: Alignment.bottomRight,
// children: [
// SfCartesianChart(
// margin: EdgeInsets.symmetric(horizontal: 8),
// enableAxisAnimation: true,
// plotAreaBorderWidth: 0,
// trackballBehavior: TrackballBehavior(
// enable: true,
// activationMode: ActivationMode.singleTap,
// tooltipDisplayMode: TrackballDisplayMode.groupAllPoints,
// tooltipSettings: InteractiveTooltip(),
// lineType: TrackballLineType.vertical,
// ),
// primaryXAxis: DateTimeCategoryAxis(
// tickPosition: TickPosition.inside,
// majorTickLines: MajorTickLines(
// size: 0,
// ),
// edgeLabelPlacement: EdgeLabelPlacement.shift,
// dateFormat: DateFormat.MMMd('ru'),
// labelStyle: TextStyle(
// color: Colors.grey,
// ),
// majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey.withOpacity(0.3)),
// axisLine: AxisLine(
// color: Colors.grey.withOpacity(0.3),
// width: 0.4,
// ),
// ),
// primaryYAxis: NumericAxis(
// isVisible: false,
// labelFormat: '{value} см',
// axisLine: AxisLine(
// width: 1,
// ),
// majorTickLines: MajorTickLines(size: 0),
// ),
// series: _getSplineSeries(),
// tooltipBehavior: TooltipBehavior(enable: true),
// ),
// FloatingActionButton.small(
// heroTag: 'addCircumference',
// onPressed: () {
// if (widget.chartData.isNotEmpty) {
// chest = widget.chartData.last.chestCircumference;
// waist = widget.chartData.last.waistCircumference;
// hip = widget.chartData.last.hipCircumference;
// chestController = FixedExtentScrollController(initialItem: chest - 20);
// waistController = FixedExtentScrollController(initialItem: waist - 20);
// hipController = FixedExtentScrollController(initialItem: hip - 20);
// } else {
// chestController = FixedExtentScrollController();
// waistController = FixedExtentScrollController();
// hipController = FixedExtentScrollController();
// }
// showModalBottomSheet(
// useRootNavigator: true,
// context: context,
// builder: (context) {
// return Column(
// children: [
// Expanded(
// child: Row(
// children: [
// Expanded(
// child: CupertinoPicker(
// magnification: 1.22,
// squeeze: 1.2,
// useMagnifier: true,
// scrollController: chestController,
// itemExtent: 24,
// onSelectedItemChanged: (int value) {
// chest = value;
// },
// children: [
// for (int i = 20; i < 200; i++) Text('$i'),
// ],
// ),
// ),
// Expanded(
// child: CupertinoPicker(
// magnification: 1.22,
// squeeze: 1.2,
// useMagnifier: true,
// scrollController: waistController,
// itemExtent: 24,
// onSelectedItemChanged: (int value) {
// waist = value;
// },
// children: [
// for (int i = 20; i < 200; i++) Text('$i'),
// ],
// ),
// ),
// Expanded(
// child: CupertinoPicker(
// magnification: 1.22,
// squeeze: 1.2,
// useMagnifier: true,
// scrollController: hipController,
// itemExtent: 24,
// onSelectedItemChanged: (int value) {
// hip = value;
// },
// children: [
// for (int i = 20; i < 200; i++) Text('$i'),
// ],
// ),
// ),
// ],
// ),
// ),
// InkWell(
// onTap: () {
// widget.profileCubit.addCircumference(
// chestCircumference: chest,
// waistCircumference: waist,
// hipCircumference: hip,
// );
// Navigator.of(context).pop();
// },
// borderRadius: BorderRadius.circular(16),
// child: Ink(
// width: MediaQuery.of(context).size.width - 32,
// padding: EdgeInsets.all(16),
// decoration: BoxDecoration(
// color: appTheme.blueA400,
// borderRadius: BorderRadius.circular(16),
// ),
// child: Center(
// child: Text(
// 'Сохранить',
// style: TextStyle(
// color: Colors.white,
// ),
// ),
// ),
// ),
// ),
// ],
// );
// },
// );
// },
// backgroundColor: Colors.red,
// shape: CircleBorder(),
// child: Icon(
// Icons.add,
// color: Colors.white,
// ),
// ),
// ],
// ),
// ],
// );
// }
//
// List<CartesianSeries<Circumference, DateTime>> _getSplineSeries() {
// final Color seriesColor1 = Colors.red;
// final Color seriesColor2 = appTheme.blueA400;
// final Color seriesColor3 = Colors.green;
//
// return <CartesianSeries<Circumference, DateTime>>[
// SplineAreaSeries<Circumference, DateTime>(
// markerSettings: MarkerSettings(
// isVisible: true,
// color: seriesColor1,
// height: 8,
// width: 8,
// ),
// dataLabelSettings: DataLabelSettings(
// labelAlignment: ChartDataLabelAlignment.top,
// isVisible: true,
// ),
// dataSource: widget.chartData,
// borderColor: seriesColor1,
// gradient: LinearGradient(
// colors: [
// seriesColor1.withOpacity(0.14),
// Colors.transparent,
// ],
// begin: Alignment.topCenter,
// end: Alignment(0, 0.6),
// ),
// name: 'Грудь',
// xValueMapper: (Circumference value, int index) => value.createdAt,
// yValueMapper: (Circumference value, int index) => value.chestCircumference,
// ),
// SplineAreaSeries<Circumference, DateTime>(
// markerSettings: MarkerSettings(
// isVisible: true,
// color: seriesColor2,
// height: 8,
// width: 8,
// ),
// dataLabelSettings: DataLabelSettings(
// labelAlignment: ChartDataLabelAlignment.top,
// isVisible: true,
// ),
// dataSource: widget.chartData,
// borderColor: seriesColor2,
// gradient: LinearGradient(
// colors: [
// seriesColor2.withOpacity(0.14),
// Colors.transparent,
// ],
// begin: Alignment.topCenter,
// end: Alignment(0, 0.6),
// ),
// name: 'Талия',
// xValueMapper: (Circumference value, int index) => value.createdAt,
// yValueMapper: (Circumference value, int index) => value.waistCircumference,
// ),
// SplineAreaSeries<Circumference, DateTime>(
// markerSettings: MarkerSettings(
// isVisible: true,
// color: seriesColor3,
// height: 8,
// width: 8,
// ),
// dataLabelSettings: DataLabelSettings(
// labelAlignment: ChartDataLabelAlignment.top,
// isVisible: true,
// ),
// dataSource: widget.chartData,
// borderColor: seriesColor3,
// gradient: LinearGradient(
// colors: [
// seriesColor3.withOpacity(0.14),
// Colors.transparent,
// ],
// begin: Alignment.topCenter,
// end: Alignment(0, 0.6),
// ),
// name: 'Бёдра',
// xValueMapper: (Circumference value, int index) => value.createdAt,
// yValueMapper: (Circumference value, int index) => value.hipCircumference,
// ),
// ];
// }
// }

View File

@@ -1,114 +1,114 @@
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
import 'package:intl/intl.dart';
class ImtChartWidget extends StatelessWidget {
final List<ChartPointModel> chartPoints;
const ImtChartWidget({
super.key,
required this.chartPoints,
});
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Row(
children: [
Text(
'${chartPoints.last.bmi.toStringAsFixed(2)}',
style: TextStyle(
color: Colors.black,
fontSize: 40,
fontWeight: FontWeight.w500,
),
),
chartPoints.last.bmi > chartPoints[chartPoints.length - 2].bmi
? Icon(
Icons.arrow_drop_up,
size: 40,
color: Colors.grey,
)
: Icon(
Icons.arrow_drop_down,
size: 40,
color: Colors.grey,
),
],
),
),
SfCartesianChart(
margin: EdgeInsets.symmetric(horizontal: 8),
enableAxisAnimation: true,
plotAreaBorderWidth: 0,
trackballBehavior: TrackballBehavior(
enable: true,
activationMode: ActivationMode.singleTap,
tooltipDisplayMode: TrackballDisplayMode.groupAllPoints,
tooltipSettings: InteractiveTooltip(),
lineType: TrackballLineType.vertical,
),
primaryXAxis: DateTimeCategoryAxis(
initialVisibleMinimum: chartPoints.first.createdAt,
initialVisibleMaximum: chartPoints.last.createdAt,
tickPosition: TickPosition.inside,
majorTickLines: MajorTickLines(
size: 0,
),
edgeLabelPlacement: EdgeLabelPlacement.shift,
dateFormat: DateFormat.MMMd('ru'),
labelStyle: TextStyle(
color: Colors.grey,
),
majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey.withOpacity(0.3)),
axisLine: AxisLine(
color: Colors.grey.withOpacity(0.3),
width: 0.4,
),
),
primaryYAxis: NumericAxis(
isVisible: false,
),
series: _getSplineSeries(),
tooltipBehavior: TooltipBehavior(enable: true),
),
],
);
}
List<CartesianSeries<ChartPointModel, DateTime>> _getSplineSeries() {
return <CartesianSeries<ChartPointModel, DateTime>>[
SplineAreaSeries<ChartPointModel, DateTime>(
markerSettings: MarkerSettings(
isVisible: true,
color: appTheme.blueA400,
height: 8,
width: 8,
),
dataLabelSettings: DataLabelSettings(
labelAlignment: ChartDataLabelAlignment.top,
isVisible: true,
),
dataSource: chartPoints,
borderColor: appTheme.blueA400,
gradient: LinearGradient(
colors: [
appTheme.blueA400.withOpacity(0.14),
Colors.transparent,
],
begin: Alignment.topCenter,
end: Alignment(0, 0.6),
),
name: 'ИМТ',
xValueMapper: (ChartPointModel value, int index) => value.createdAt,
yValueMapper: (ChartPointModel value, int index) => double.parse(value.bmi.toStringAsFixed(2)),
),
];
}
}
// import 'package:eatvio_app/features/profile/models/profile_model.dart';
// import 'package:eatvio_app/theme/theme_helper.dart';
// import 'package:flutter/material.dart';
// import 'package:syncfusion_flutter_charts/charts.dart';
// import 'package:intl/intl.dart';
//
// class ImtChartWidget extends StatelessWidget {
// final List<ChartPointModel> chartPoints;
//
// const ImtChartWidget({
// super.key,
// required this.chartPoints,
// });
//
// @override
// Widget build(BuildContext context) {
// return Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
// child: Row(
// children: [
// Text(
// '${chartPoints.last.bmi.toStringAsFixed(2)}',
// style: TextStyle(
// color: Colors.black,
// fontSize: 40,
// fontWeight: FontWeight.w500,
// ),
// ),
// chartPoints.last.bmi > chartPoints[chartPoints.length - 2].bmi
// ? Icon(
// Icons.arrow_drop_up,
// size: 40,
// color: Colors.grey,
// )
// : Icon(
// Icons.arrow_drop_down,
// size: 40,
// color: Colors.grey,
// ),
// ],
// ),
// ),
// SfCartesianChart(
// margin: EdgeInsets.symmetric(horizontal: 8),
// enableAxisAnimation: true,
// plotAreaBorderWidth: 0,
// trackballBehavior: TrackballBehavior(
// enable: true,
// activationMode: ActivationMode.singleTap,
// tooltipDisplayMode: TrackballDisplayMode.groupAllPoints,
// tooltipSettings: InteractiveTooltip(),
// lineType: TrackballLineType.vertical,
// ),
// primaryXAxis: DateTimeCategoryAxis(
// initialVisibleMinimum: chartPoints.first.createdAt,
// initialVisibleMaximum: chartPoints.last.createdAt,
// tickPosition: TickPosition.inside,
// majorTickLines: MajorTickLines(
// size: 0,
// ),
// edgeLabelPlacement: EdgeLabelPlacement.shift,
// dateFormat: DateFormat.MMMd('ru'),
// labelStyle: TextStyle(
// color: Colors.grey,
// ),
// majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey.withOpacity(0.3)),
// axisLine: AxisLine(
// color: Colors.grey.withOpacity(0.3),
// width: 0.4,
// ),
// ),
// primaryYAxis: NumericAxis(
// isVisible: false,
// ),
// series: _getSplineSeries(),
// tooltipBehavior: TooltipBehavior(enable: true),
// ),
// ],
// );
// }
//
// List<CartesianSeries<ChartPointModel, DateTime>> _getSplineSeries() {
// return <CartesianSeries<ChartPointModel, DateTime>>[
// SplineAreaSeries<ChartPointModel, DateTime>(
// markerSettings: MarkerSettings(
// isVisible: true,
// color: appTheme.blueA400,
// height: 8,
// width: 8,
// ),
// dataLabelSettings: DataLabelSettings(
// labelAlignment: ChartDataLabelAlignment.top,
// isVisible: true,
// ),
// dataSource: chartPoints,
// borderColor: appTheme.blueA400,
// gradient: LinearGradient(
// colors: [
// appTheme.blueA400.withOpacity(0.14),
// Colors.transparent,
// ],
// begin: Alignment.topCenter,
// end: Alignment(0, 0.6),
// ),
// name: 'ИМТ',
// xValueMapper: (ChartPointModel value, int index) => value.createdAt,
// yValueMapper: (ChartPointModel value, int index) => double.parse(value.bmi.toStringAsFixed(2)),
// ),
// ];
// }
// }

View File

@@ -1,237 +1,237 @@
import 'package:eatvio_app/core/app_export.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
class WeightChartWidget extends StatefulWidget {
final List<ChartPointModel> chartPoints;
final ProfileCubit profileCubit;
const WeightChartWidget({
super.key,
required this.chartPoints,
required this.profileCubit,
});
@override
State<WeightChartWidget> createState() => _WeightChartWidgetState();
}
class _WeightChartWidgetState extends State<WeightChartWidget> {
late FixedExtentScrollController weightKiloController;
late FixedExtentScrollController weightGramsController;
late int weightKilo;
late int weightGrams;
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (widget.chartPoints.isNotEmpty)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: Row(
children: [
Text(
'${widget.chartPoints.last.weight.toStringAsFixed(1)} кг',
style: TextStyle(
color: Colors.black,
fontSize: 40,
fontWeight: FontWeight.w500,
),
),
if (widget.chartPoints.length == 1)
Container(
margin: EdgeInsets.symmetric(horizontal: 12),
width: 8,
height: 8,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.black12,
),
),
if (widget.chartPoints.length > 1) widget.chartPoints.last.weight > widget.chartPoints[widget.chartPoints.length - 2].weight
? Icon(
Icons.arrow_drop_up,
size: 40,
color: Colors.grey.withOpacity(0.4),
)
: Icon(
Icons.arrow_drop_down,
size: 40,
color: Colors.grey.withOpacity(0.4),
),
],
),
),
Stack(
alignment: Alignment.bottomRight,
children: [
SfCartesianChart(
margin: EdgeInsets.symmetric(horizontal: 8),
enableAxisAnimation: true,
plotAreaBorderWidth: 0,
trackballBehavior: TrackballBehavior(
enable: true,
activationMode: ActivationMode.singleTap,
tooltipDisplayMode: TrackballDisplayMode.groupAllPoints,
tooltipSettings: InteractiveTooltip(),
lineType: TrackballLineType.vertical,
),
primaryXAxis: DateTimeCategoryAxis(
tickPosition: TickPosition.inside,
majorTickLines: MajorTickLines(
size: 0,
),
edgeLabelPlacement: EdgeLabelPlacement.shift,
dateFormat: DateFormat.MMMd('ru'),
labelStyle: TextStyle(
color: Colors.grey,
),
majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey.withOpacity(0.3)),
axisLine: AxisLine(
color: Colors.grey.withOpacity(0.3),
width: 0.4,
),
),
primaryYAxis: NumericAxis(
isVisible: false,
labelFormat: '{value} кг',
majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey),
axisLine: AxisLine(
width: 1,
),
majorTickLines: MajorTickLines(size: 0),
),
series: _getSplineSeries(),
tooltipBehavior: TooltipBehavior(enable: true),
),
FloatingActionButton.small(
heroTag: 'addWeight',
onPressed: () {
if (widget.chartPoints.isNotEmpty) {
weightKilo = int.parse(widget.chartPoints.last.weight.toString().split('.')[0]);
weightGrams = int.parse(widget.chartPoints.last.weight.toString().split('.')[1][0]);
weightKiloController = FixedExtentScrollController(initialItem: weightKilo - 20);
weightGramsController = FixedExtentScrollController(initialItem: weightGrams);
} else {
weightKiloController = FixedExtentScrollController();
weightGramsController = FixedExtentScrollController();
}
showModalBottomSheet(
useRootNavigator: true,
context: context,
builder: (context) {
return Column(
children: [
Expanded(
child: Row(
children: [
Expanded(
child: CupertinoPicker(
magnification: 1.22,
squeeze: 1.2,
useMagnifier: true,
scrollController: weightKiloController,
itemExtent: 24,
onSelectedItemChanged: (int value) {
weightKilo = value + 20;
},
children: [
for (int i = 20; i < 300; i++) Text('$i'),
],
),
),
Expanded(
child: CupertinoPicker(
magnification: 1.22,
squeeze: 1.2,
useMagnifier: true,
scrollController: weightGramsController,
itemExtent: 24,
onSelectedItemChanged: (int value) {
weightGrams = value;
},
children: [
for (int i = 0; i < 10; i++) Text('$i'),
],
),
),
],
),
),
InkWell(
onTap: () {
widget.profileCubit.addWeight(weight: double.parse('$weightKilo.$weightGrams'));
Navigator.of(context).pop();
},
borderRadius: BorderRadius.circular(16),
child: Ink(
width: MediaQuery.of(context).size.width - 32,
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: appTheme.blueA400,
borderRadius: BorderRadius.circular(16),
),
child: Center(
child: Text(
'Сохранить',
style: TextStyle(
color: Colors.white,
),
),
),
),
),
],
);
},
);
},
backgroundColor: Colors.red,
shape: CircleBorder(),
child: Icon(
Icons.add,
color: Colors.white,
),
),
],
),
],
);
}
List<CartesianSeries<ChartPointModel, DateTime>> _getSplineSeries() {
return <CartesianSeries<ChartPointModel, DateTime>>[
SplineAreaSeries<ChartPointModel, DateTime>(
markerSettings: MarkerSettings(
isVisible: true,
color: appTheme.blueA400,
height: 8,
width: 8,
),
dataLabelSettings: DataLabelSettings(
labelAlignment: ChartDataLabelAlignment.top,
isVisible: true,
),
dataSource: widget.chartPoints,
borderColor: appTheme.blueA400,
gradient: LinearGradient(
colors: [
appTheme.blueA400.withOpacity(0.14),
Colors.transparent,
],
begin: Alignment.topCenter,
end: Alignment(0, 0.6),
),
name: 'Вес',
xValueMapper: (ChartPointModel value, int index) => value.createdAt,
yValueMapper: (ChartPointModel value, int index) => value.weight,
),
];
}
}
// import 'package:eatvio_app/core/app_export.dart';
// import 'package:eatvio_app/features/profile/models/profile_model.dart';
// import 'package:eatvio_app/features/profile/presentation/bloc/profile_cubit/profile_cubit.dart';
// import 'package:flutter/cupertino.dart';
// import 'package:flutter/material.dart';
// import 'package:intl/intl.dart';
// import 'package:syncfusion_flutter_charts/charts.dart';
//
// class WeightChartWidget extends StatefulWidget {
// final List<ChartPointModel> chartPoints;
// final ProfileCubit profileCubit;
//
// const WeightChartWidget({
// super.key,
// required this.chartPoints,
// required this.profileCubit,
// });
//
// @override
// State<WeightChartWidget> createState() => _WeightChartWidgetState();
// }
//
// class _WeightChartWidgetState extends State<WeightChartWidget> {
// late FixedExtentScrollController weightKiloController;
// late FixedExtentScrollController weightGramsController;
// late int weightKilo;
// late int weightGrams;
//
// @override
// Widget build(BuildContext context) {
// return Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// if (widget.chartPoints.isNotEmpty)
// Padding(
// padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
// child: Row(
// children: [
// Text(
// '${widget.chartPoints.last.weight.toStringAsFixed(1)} кг',
// style: TextStyle(
// color: Colors.black,
// fontSize: 40,
// fontWeight: FontWeight.w500,
// ),
// ),
// if (widget.chartPoints.length == 1)
// Container(
// margin: EdgeInsets.symmetric(horizontal: 12),
// width: 8,
// height: 8,
// decoration: BoxDecoration(
// shape: BoxShape.circle,
// color: Colors.black12,
// ),
// ),
// if (widget.chartPoints.length > 1) widget.chartPoints.last.weight > widget.chartPoints[widget.chartPoints.length - 2].weight
// ? Icon(
// Icons.arrow_drop_up,
// size: 40,
// color: Colors.grey.withOpacity(0.4),
// )
// : Icon(
// Icons.arrow_drop_down,
// size: 40,
// color: Colors.grey.withOpacity(0.4),
// ),
// ],
// ),
// ),
// Stack(
// alignment: Alignment.bottomRight,
// children: [
// SfCartesianChart(
// margin: EdgeInsets.symmetric(horizontal: 8),
// enableAxisAnimation: true,
// plotAreaBorderWidth: 0,
// trackballBehavior: TrackballBehavior(
// enable: true,
// activationMode: ActivationMode.singleTap,
// tooltipDisplayMode: TrackballDisplayMode.groupAllPoints,
// tooltipSettings: InteractiveTooltip(),
// lineType: TrackballLineType.vertical,
// ),
// primaryXAxis: DateTimeCategoryAxis(
// tickPosition: TickPosition.inside,
// majorTickLines: MajorTickLines(
// size: 0,
// ),
// edgeLabelPlacement: EdgeLabelPlacement.shift,
// dateFormat: DateFormat.MMMd('ru'),
// labelStyle: TextStyle(
// color: Colors.grey,
// ),
// majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey.withOpacity(0.3)),
// axisLine: AxisLine(
// color: Colors.grey.withOpacity(0.3),
// width: 0.4,
// ),
// ),
// primaryYAxis: NumericAxis(
// isVisible: false,
// labelFormat: '{value} кг',
// majorGridLines: MajorGridLines(dashArray: [1], color: Colors.grey),
// axisLine: AxisLine(
// width: 1,
// ),
// majorTickLines: MajorTickLines(size: 0),
// ),
// series: _getSplineSeries(),
// tooltipBehavior: TooltipBehavior(enable: true),
// ),
// FloatingActionButton.small(
// heroTag: 'addWeight',
// onPressed: () {
// if (widget.chartPoints.isNotEmpty) {
// weightKilo = int.parse(widget.chartPoints.last.weight.toString().split('.')[0]);
// weightGrams = int.parse(widget.chartPoints.last.weight.toString().split('.')[1][0]);
// weightKiloController = FixedExtentScrollController(initialItem: weightKilo - 20);
// weightGramsController = FixedExtentScrollController(initialItem: weightGrams);
// } else {
// weightKiloController = FixedExtentScrollController();
// weightGramsController = FixedExtentScrollController();
// }
// showModalBottomSheet(
// useRootNavigator: true,
// context: context,
// builder: (context) {
// return Column(
// children: [
// Expanded(
// child: Row(
// children: [
// Expanded(
// child: CupertinoPicker(
// magnification: 1.22,
// squeeze: 1.2,
// useMagnifier: true,
// scrollController: weightKiloController,
// itemExtent: 24,
// onSelectedItemChanged: (int value) {
// weightKilo = value + 20;
// },
// children: [
// for (int i = 20; i < 300; i++) Text('$i'),
// ],
// ),
// ),
// Expanded(
// child: CupertinoPicker(
// magnification: 1.22,
// squeeze: 1.2,
// useMagnifier: true,
// scrollController: weightGramsController,
// itemExtent: 24,
// onSelectedItemChanged: (int value) {
// weightGrams = value;
// },
// children: [
// for (int i = 0; i < 10; i++) Text('$i'),
// ],
// ),
// ),
// ],
// ),
// ),
// InkWell(
// onTap: () {
// widget.profileCubit.addWeight(weight: double.parse('$weightKilo.$weightGrams'));
// Navigator.of(context).pop();
// },
// borderRadius: BorderRadius.circular(16),
// child: Ink(
// width: MediaQuery.of(context).size.width - 32,
// padding: EdgeInsets.all(16),
// decoration: BoxDecoration(
// color: appTheme.blueA400,
// borderRadius: BorderRadius.circular(16),
// ),
// child: Center(
// child: Text(
// 'Сохранить',
// style: TextStyle(
// color: Colors.white,
// ),
// ),
// ),
// ),
// ),
// ],
// );
// },
// );
// },
// backgroundColor: Colors.red,
// shape: CircleBorder(),
// child: Icon(
// Icons.add,
// color: Colors.white,
// ),
// ),
// ],
// ),
// ],
// );
// }
//
// List<CartesianSeries<ChartPointModel, DateTime>> _getSplineSeries() {
// return <CartesianSeries<ChartPointModel, DateTime>>[
// SplineAreaSeries<ChartPointModel, DateTime>(
// markerSettings: MarkerSettings(
// isVisible: true,
// color: appTheme.blueA400,
// height: 8,
// width: 8,
// ),
// dataLabelSettings: DataLabelSettings(
// labelAlignment: ChartDataLabelAlignment.top,
// isVisible: true,
// ),
// dataSource: widget.chartPoints,
// borderColor: appTheme.blueA400,
// gradient: LinearGradient(
// colors: [
// appTheme.blueA400.withOpacity(0.14),
// Colors.transparent,
// ],
// begin: Alignment.topCenter,
// end: Alignment(0, 0.6),
// ),
// name: 'Вес',
// xValueMapper: (ChartPointModel value, int index) => value.createdAt,
// yValueMapper: (ChartPointModel value, int index) => value.weight,
// ),
// ];
// }
// }

View File

@@ -23,6 +23,14 @@ class ProfileRepository {
}
}
Future<ProfileDetailsModel> getMyProfileDetails() async {
try {
return await profileService.getMyProfileDetails();
} catch (e) {
rethrow;
}
}
Future<void> addCircumference({
required int chestCircumference,
required int waistCircumference,

View File

@@ -17,6 +17,9 @@ abstract class ProfileService {
@GET('/api/profile/index')
Future<ProfileModel> getMyProfile();
@GET('/api/profile/detailz')
Future<ProfileDetailsModel> getMyProfileDetails();
@POST('/api/profile/addCircumference')
Future<void> addCircumference({
@Part(name: 'chest_circumference') required int chestCircumference,

View File

@@ -87,6 +87,39 @@ class _ProfileService implements ProfileService {
return _value;
}
@override
Future<ProfileDetailsModel> getMyProfileDetails() async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options = _setStreamType<ProfileDetailsModel>(Options(
method: 'GET',
headers: _headers,
extra: _extra,
)
.compose(
_dio.options,
'/api/profile/detailz',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(
_dio.options.baseUrl,
baseUrl,
)));
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late ProfileDetailsModel _value;
try {
_value = ProfileDetailsModel.fromJson(_result.data!);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
return _value;
}
@override
Future<void> addCircumference({
required int chestCircumference,