forked from eatvio/eatvio_app
refactor: profile model
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -12,6 +12,7 @@ abstract class ProfileState with _$ProfileState {
|
||||
|
||||
const factory ProfileState.loaded({
|
||||
required ProfileModel profile,
|
||||
required ProfileDetailsModel profileDetails,
|
||||
required List<FeedBlogPostModel> blogPosts,
|
||||
}) = ProfileStateLoaded;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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,
|
||||
// ),
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -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)),
|
||||
// ),
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -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,
|
||||
// ),
|
||||
// ];
|
||||
// }
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user