fix: charts, profile, bottom nav bar

This commit is contained in:
mso7nueh
2024-09-18 16:14:00 +03:00
parent c800d35663
commit d771feefe3
81 changed files with 1478 additions and 2209 deletions

View File

@@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
class ProfileCubit extends Cubit<ProfileState> {
final ProfileRepository profileRepository;
String _currentPeriod = '1';
ProfileCubit({
required this.profileRepository,
@@ -15,8 +16,6 @@ class ProfileCubit extends Cubit<ProfileState> {
profile: await profileRepository.getProfileBySlug(slug),
profileDetails: await profileRepository.getMyProfileDetails(),
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: slug),
weightPoints: await profileRepository.getWeight(period: '1', slug: slug),
circumferencePoints: await profileRepository.getCircumferences(period: '1', slug: slug),
));
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
@@ -24,15 +23,18 @@ class ProfileCubit extends Cubit<ProfileState> {
}
}
getMyProfile() async {
getMyProfile({
String period = '1',
}) async {
_currentPeriod = period;
try {
final profile = await profileRepository.getMyProfile();
emit(ProfileState.loaded(
profile: profile,
profileDetails: await profileRepository.getMyProfileDetails(),
blogPosts: await profileRepository.getBlogPostsByAuthorSlug(slug: profile.slug),
weightPoints: await profileRepository.getWeight(period: '1'),
circumferencePoints: await profileRepository.getCircumferences(period: '1'),
weightPoints: await profileRepository.getWeight(period: period),
circumferencePoints: await profileRepository.getCircumferences(period: period),
));
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
@@ -51,7 +53,7 @@ class ProfileCubit extends Cubit<ProfileState> {
waistCircumference: waistCircumference,
hipCircumference: hipCircumference,
);
emit((state as ProfileStateLoaded).copyWith());
await getMyProfile(period: _currentPeriod);
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);
@@ -63,7 +65,7 @@ class ProfileCubit extends Cubit<ProfileState> {
}) async {
try {
await profileRepository.addWeight(weight: weight);
emit((state as ProfileStateLoaded).copyWith());
await getMyProfile(period: _currentPeriod);
} catch (e) {
emit(ProfileState.error(errorMessage: e.toString()));
print(e);

View File

@@ -16,8 +16,8 @@ abstract class ProfileState with _$ProfileState {
required ProfileModel profile,
required ProfileDetailsModel profileDetails,
required List<FeedBlogPostModel> blogPosts,
required List<WeightModel> weightPoints,
required List<CircumferenceModel> circumferencePoints,
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints,
}) = ProfileStateLoaded;
const factory ProfileState.error({

View File

@@ -24,8 +24,8 @@ mixin _$ProfileState {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)
loaded,
required TResult Function(String errorMessage) error,
}) =>
@@ -38,8 +38,8 @@ mixin _$ProfileState {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)?
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)?
loaded,
TResult? Function(String errorMessage)? error,
}) =>
@@ -52,8 +52,8 @@ mixin _$ProfileState {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)?
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
@@ -154,8 +154,8 @@ class _$ProfileStateImpl implements _ProfileState {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)
loaded,
required TResult Function(String errorMessage) error,
}) {
@@ -171,8 +171,8 @@ class _$ProfileStateImpl implements _ProfileState {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)?
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -188,8 +188,8 @@ class _$ProfileStateImpl implements _ProfileState {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)?
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
@@ -290,8 +290,8 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)
loaded,
required TResult Function(String errorMessage) error,
}) {
@@ -307,8 +307,8 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)?
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -324,8 +324,8 @@ class _$ProfileStateLoadingImpl implements ProfileStateLoading {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)?
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
@@ -388,8 +388,8 @@ abstract class _$$ProfileStateLoadedImplCopyWith<$Res> {
{ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints});
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints});
$ProfileModelCopyWith<$Res> get profile;
$ProfileDetailsModelCopyWith<$Res> get profileDetails;
@@ -411,8 +411,8 @@ class __$$ProfileStateLoadedImplCopyWithImpl<$Res>
Object? profile = null,
Object? profileDetails = null,
Object? blogPosts = null,
Object? weightPoints = null,
Object? circumferencePoints = null,
Object? weightPoints = freezed,
Object? circumferencePoints = freezed,
}) {
return _then(_$ProfileStateLoadedImpl(
profile: null == profile
@@ -427,14 +427,14 @@ class __$$ProfileStateLoadedImplCopyWithImpl<$Res>
? _value._blogPosts
: blogPosts // ignore: cast_nullable_to_non_nullable
as List<FeedBlogPostModel>,
weightPoints: null == weightPoints
weightPoints: freezed == weightPoints
? _value._weightPoints
: weightPoints // ignore: cast_nullable_to_non_nullable
as List<WeightModel>,
circumferencePoints: null == circumferencePoints
as List<WeightModel>?,
circumferencePoints: freezed == circumferencePoints
? _value._circumferencePoints
: circumferencePoints // ignore: cast_nullable_to_non_nullable
as List<CircumferenceModel>,
as List<CircumferenceModel>?,
));
}
@@ -466,8 +466,8 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
{required this.profile,
required this.profileDetails,
required final List<FeedBlogPostModel> blogPosts,
required final List<WeightModel> weightPoints,
required final List<CircumferenceModel> circumferencePoints})
final List<WeightModel>? weightPoints,
final List<CircumferenceModel>? circumferencePoints})
: _blogPosts = blogPosts,
_weightPoints = weightPoints,
_circumferencePoints = circumferencePoints;
@@ -484,21 +484,25 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
return EqualUnmodifiableListView(_blogPosts);
}
final List<WeightModel> _weightPoints;
final List<WeightModel>? _weightPoints;
@override
List<WeightModel> get weightPoints {
List<WeightModel>? get weightPoints {
final value = _weightPoints;
if (value == null) return null;
if (_weightPoints is EqualUnmodifiableListView) return _weightPoints;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_weightPoints);
return EqualUnmodifiableListView(value);
}
final List<CircumferenceModel> _circumferencePoints;
final List<CircumferenceModel>? _circumferencePoints;
@override
List<CircumferenceModel> get circumferencePoints {
List<CircumferenceModel>? get circumferencePoints {
final value = _circumferencePoints;
if (value == null) return null;
if (_circumferencePoints is EqualUnmodifiableListView)
return _circumferencePoints;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_circumferencePoints);
return EqualUnmodifiableListView(value);
}
@override
@@ -549,8 +553,8 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)
loaded,
required TResult Function(String errorMessage) error,
}) {
@@ -567,8 +571,8 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)?
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -585,8 +589,8 @@ class _$ProfileStateLoadedImpl implements ProfileStateLoaded {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)?
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),
@@ -641,15 +645,15 @@ abstract class ProfileStateLoaded implements ProfileState {
{required final ProfileModel profile,
required final ProfileDetailsModel profileDetails,
required final List<FeedBlogPostModel> blogPosts,
required final List<WeightModel> weightPoints,
required final List<CircumferenceModel> circumferencePoints}) =
final List<WeightModel>? weightPoints,
final List<CircumferenceModel>? circumferencePoints}) =
_$ProfileStateLoadedImpl;
ProfileModel get profile;
ProfileDetailsModel get profileDetails;
List<FeedBlogPostModel> get blogPosts;
List<WeightModel> get weightPoints;
List<CircumferenceModel> get circumferencePoints;
List<WeightModel>? get weightPoints;
List<CircumferenceModel>? get circumferencePoints;
/// Create a copy of ProfileState
/// with the given fields replaced by the non-null parameter values.
@@ -734,8 +738,8 @@ class _$ProfileStateErrorImpl implements ProfileStateError {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)
loaded,
required TResult Function(String errorMessage) error,
}) {
@@ -751,8 +755,8 @@ class _$ProfileStateErrorImpl implements ProfileStateError {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)?
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)?
loaded,
TResult? Function(String errorMessage)? error,
}) {
@@ -768,8 +772,8 @@ class _$ProfileStateErrorImpl implements ProfileStateError {
ProfileModel profile,
ProfileDetailsModel profileDetails,
List<FeedBlogPostModel> blogPosts,
List<WeightModel> weightPoints,
List<CircumferenceModel> circumferencePoints)?
List<WeightModel>? weightPoints,
List<CircumferenceModel>? circumferencePoints)?
loaded,
TResult Function(String errorMessage)? error,
required TResult orElse(),