forked from eatvio/eatvio_app
fix: charts, profile, bottom nav bar
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -30,265 +30,268 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
List<WeightModel> weightPoints = [];
|
||||
final List<String> chipsLabelList = ['Вес', 'Замеры', 'ИМТ'];
|
||||
final List<String> chipsIntervalLabelList = ['1М', '3М', '6М', '1Г', 'ВСЁ ВРЕМЯ'];
|
||||
final List<String> chipsIntervalList = ['1', '3', '6', '12', 'all'];
|
||||
int _selectedChipIndex = 0;
|
||||
int _selectedIntervalChipIndex = 0;
|
||||
final ProfileCubit profileCubit = sl<ProfileCubit>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
widget.author == null ? profileCubit.getMyProfile() : profileCubit.getProfileBySlug(widget.author!.authorSlug);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<ProfileCubit>(
|
||||
create: (BuildContext context) {
|
||||
if (widget.author == null)
|
||||
return sl<ProfileCubit>()..getMyProfile();
|
||||
else
|
||||
return sl<ProfileCubit>()..getProfileBySlug(widget.author!.authorSlug);
|
||||
},
|
||||
child: BlocBuilder<ProfileCubit, ProfileState>(
|
||||
builder: (BuildContext context, ProfileState state) {
|
||||
if (state is ProfileStateLoaded) {
|
||||
circumferencePoints = state.circumferencePoints;
|
||||
weightPoints = state.weightPoints;
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
appBar: widget.author == null ? AppBar(toolbarHeight: 0) : AppBar(),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.vertical(
|
||||
bottom: Radius.circular(16),
|
||||
),
|
||||
return BlocBuilder<ProfileCubit, ProfileState>(
|
||||
bloc: profileCubit,
|
||||
builder: (BuildContext context, ProfileState state) {
|
||||
if (state is ProfileStateLoaded) {
|
||||
if (state.circumferencePoints != null) {
|
||||
circumferencePoints = state.circumferencePoints!;
|
||||
weightPoints = state.weightPoints!;
|
||||
}
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.grey.shade200,
|
||||
appBar: widget.author == null ? AppBar(toolbarHeight: 0) : AppBar(),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.vertical(
|
||||
bottom: Radius.circular(16),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 32,
|
||||
backgroundImage: NetworkImage(state.profile.profilePhotoUrl),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
state.profile.name,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
child: SvgPicture.asset(
|
||||
height: 28,
|
||||
width: 28,
|
||||
'assets/icons/subscribers.svg',
|
||||
colorFilter: ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
'123',
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Подписчика',
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.black38,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () => Share.shareUri(
|
||||
Uri.parse(
|
||||
baseUrl + '/ru/profile/' + state.profile.slug,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: 16),
|
||||
child: SvgPicture.asset(
|
||||
height: 24,
|
||||
width: 24,
|
||||
'assets/icons/share.svg',
|
||||
colorFilter: ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (state.profileDetails.additionalInfo.isNotEmpty)
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
state.profileDetails.additionalInfo,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(
|
||||
radius: 32,
|
||||
backgroundImage: NetworkImage(state.profile.profilePhotoUrl),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
state.profile.name,
|
||||
style: TextStyle(
|
||||
color: Colors.black.withOpacity(0.4),
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.author != null) const SizedBox(height: 8),
|
||||
if (widget.author != null)
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(width: 16),
|
||||
GestureDetector(
|
||||
onTap: () => GoRouter.of(context).pushNamed(
|
||||
'chatScreen',
|
||||
const Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
child: SvgPicture.asset(
|
||||
height: 28,
|
||||
width: 28,
|
||||
'assets/icons/subscribers.svg',
|
||||
colorFilter: ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.all(8),
|
||||
width: (MediaQuery.of(context).size.width - 40) / 2,
|
||||
decoration: BoxDecoration(
|
||||
color: appTheme.blueA400.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Text(
|
||||
'Сообщение',
|
||||
style: TextStyle(
|
||||
color: appTheme.blueA400,
|
||||
SizedBox(width: 8),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
'123',
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'Подписчика',
|
||||
style: TextStyle(
|
||||
height: 1,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: Colors.black38,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () => Share.shareUri(
|
||||
Uri.parse(
|
||||
baseUrl + '/ru/profile/' + state.profile.slug,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Container(
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(left: 16),
|
||||
child: SvgPicture.asset(
|
||||
height: 24,
|
||||
width: 24,
|
||||
'assets/icons/share.svg',
|
||||
colorFilter: ColorFilter.mode(appTheme.blueA400, BlendMode.srcIn),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (state.profileDetails.additionalInfo.isNotEmpty)
|
||||
Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(
|
||||
state.profileDetails.additionalInfo,
|
||||
style: TextStyle(
|
||||
color: Colors.black.withOpacity(0.4),
|
||||
height: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.author != null) const SizedBox(height: 8),
|
||||
if (widget.author != null)
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(width: 16),
|
||||
GestureDetector(
|
||||
onTap: () => GoRouter.of(context).pushNamed(
|
||||
'chatScreen',
|
||||
),
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.all(8),
|
||||
width: (MediaQuery.of(context).size.width - 40) / 2,
|
||||
decoration: BoxDecoration(
|
||||
color: appTheme.blueA400,
|
||||
color: appTheme.blueA400.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Text(
|
||||
'Подписаться',
|
||||
'Сообщение',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
color: appTheme.blueA400,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 16),
|
||||
],
|
||||
),
|
||||
if (widget.author != null) SizedBox(height: 16),
|
||||
if (widget.author == null) _divider(context),
|
||||
if (widget.author == null)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
_choiceChipWidget(0),
|
||||
SizedBox(width: 8),
|
||||
_choiceChipWidget(1),
|
||||
SizedBox(width: 8),
|
||||
_choiceChipWidget(2),
|
||||
],
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.all(8),
|
||||
width: (MediaQuery.of(context).size.width - 40) / 2,
|
||||
decoration: BoxDecoration(
|
||||
color: appTheme.blueA400,
|
||||
borderRadius: BorderRadius.circular(16),
|
||||
),
|
||||
child: Text(
|
||||
'Подписаться',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
switch (_selectedChipIndex) {
|
||||
case 0:
|
||||
return WeightChartWidget(
|
||||
weightPoints: weightPoints,
|
||||
profileCubit: context.read<ProfileCubit>(),
|
||||
);
|
||||
case 1:
|
||||
return CircumferenceChartWidget(
|
||||
circumferencePoints: circumferencePoints,
|
||||
profileCubit: context.read<ProfileCubit>(),
|
||||
);
|
||||
case 2:
|
||||
return ImtChartWidget(
|
||||
weightPoints: weightPoints,
|
||||
);
|
||||
}
|
||||
return SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Row(
|
||||
),
|
||||
SizedBox(width: 16),
|
||||
],
|
||||
),
|
||||
if (widget.author != null) SizedBox(height: 16),
|
||||
if (widget.author == null) _divider(context),
|
||||
if (widget.author == null)
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
SingleChildScrollView(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 16),
|
||||
_choiceIntervalChipWidget(0),
|
||||
_choiceChipWidget(0),
|
||||
SizedBox(width: 8),
|
||||
_choiceIntervalChipWidget(1),
|
||||
_choiceChipWidget(1),
|
||||
SizedBox(width: 8),
|
||||
_choiceIntervalChipWidget(2),
|
||||
SizedBox(width: 8),
|
||||
_choiceIntervalChipWidget(3),
|
||||
SizedBox(width: 8),
|
||||
_choiceIntervalChipWidget(4),
|
||||
_choiceChipWidget(2),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) {
|
||||
switch (_selectedChipIndex) {
|
||||
case 0:
|
||||
return WeightChartWidget(
|
||||
weightPoints: weightPoints,
|
||||
profileCubit: profileCubit,
|
||||
);
|
||||
case 1:
|
||||
return CircumferenceChartWidget(
|
||||
circumferencePoints: circumferencePoints,
|
||||
profileCubit: profileCubit,
|
||||
);
|
||||
case 2:
|
||||
return ImtChartWidget(
|
||||
weightPoints: weightPoints,
|
||||
);
|
||||
}
|
||||
return SizedBox.shrink();
|
||||
},
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(width: 16),
|
||||
_choiceIntervalChipWidget(0),
|
||||
SizedBox(width: 8),
|
||||
_choiceIntervalChipWidget(1),
|
||||
SizedBox(width: 8),
|
||||
_choiceIntervalChipWidget(2),
|
||||
SizedBox(width: 8),
|
||||
_choiceIntervalChipWidget(3),
|
||||
SizedBox(width: 8),
|
||||
_choiceIntervalChipWidget(4),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) => BlogPostWidget(feedBlogPostModel: state.blogPosts[index]),
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||
itemCount: state.blogPosts.length,
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
itemBuilder: (context, index) => BlogPostWidget(feedBlogPostModel: state.blogPosts[index]),
|
||||
separatorBuilder: (context, index) => SizedBox(height: 8),
|
||||
itemCount: state.blogPosts.length,
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
);
|
||||
} else if (state is ProfileStateError) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(state.errorMessage),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (state is ProfileStateError) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(state.errorMessage),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -321,6 +324,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
),
|
||||
selected: _selectedIntervalChipIndex == index,
|
||||
onSelected: (bool selected) {
|
||||
profileCubit.getMyProfile(period: chipsIntervalList[index]);
|
||||
setState(() {
|
||||
_selectedIntervalChipIndex = index;
|
||||
});
|
||||
|
||||
@@ -54,68 +54,73 @@ class _WeightChartWidgetState extends State<WeightChartWidget> {
|
||||
color: Colors.black12,
|
||||
),
|
||||
),
|
||||
if (widget.weightPoints.length > 1) widget.weightPoints.last.weight > widget.weightPoints[widget.weightPoints.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),
|
||||
),
|
||||
if (widget.weightPoints.length > 1)
|
||||
widget.weightPoints.last.weight > widget.weightPoints[widget.weightPoints.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),
|
||||
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.weightPoints.isNotEmpty) {
|
||||
weightKilo = int.parse(widget.weightPoints.last.weight.toString().split('.')[0]);
|
||||
weightGrams = int.parse(widget.weightPoints.last.weight.toString().split('.')[1][0]);
|
||||
try {
|
||||
weightKilo = int.parse(widget.weightPoints.last.weight.toString().split('.')[0]);
|
||||
weightGrams = int.parse(widget.weightPoints.last.weight.toString().split('.')[1][0]);
|
||||
} catch (e) {
|
||||
weightGrams = 0;
|
||||
}
|
||||
weightKiloController = FixedExtentScrollController(initialItem: weightKilo - 20);
|
||||
weightGramsController = FixedExtentScrollController(initialItem: weightGrams);
|
||||
} else {
|
||||
@@ -192,7 +197,7 @@ class _WeightChartWidgetState extends State<WeightChartWidget> {
|
||||
},
|
||||
);
|
||||
},
|
||||
backgroundColor: Colors.red,
|
||||
backgroundColor: appTheme.blueA400,
|
||||
shape: CircleBorder(),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
|
||||
Reference in New Issue
Block a user