fix: charts, profile, bottom nav bar

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

View File

@@ -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;
});