updated designe of aboute diet page

This commit is contained in:
Username1548
2024-11-11 21:10:38 +07:00
parent a9b28c27b9
commit c5e1c5d9b8
46 changed files with 2164 additions and 1012 deletions

View File

@@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
class ComplainingScreen extends StatelessWidget {
const ComplainingScreen({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}

View File

@@ -2,17 +2,28 @@ import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/utils/localization_utils.dart';
import 'package:eatvio_app/core/utils/string_extentions.dart';
import 'package:eatvio_app/core/widgets/custom_divider.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/author_card.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/cpfc_container.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/expandable_text.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/main_background_bouble.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/more_options.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/type_badges.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart';
import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_state.dart';
import 'package:eatvio_app/features/feed/presentation/widgets/comments_widget.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/locator_service.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:go_router/go_router.dart';
import 'package:rive/rive.dart';
import 'package:flutter_portal/flutter_portal.dart';
import 'package:flutter_svg/svg.dart';
import 'package:rive/rive.dart' hide LinearGradient;
class AboutDietScreen extends StatefulWidget {
final Diet diet;
@@ -29,10 +40,25 @@ class AboutDietScreen extends StatefulWidget {
class _AboutDietScreenState extends State<AboutDietScreen> {
final CommentsCubit commentsCubit = sl<CommentsCubit>();
int? replyId;
final ScrollController scrollController = ScrollController();
final textEditingController = TextEditingController();
bool isMoreOptionsVisible = false;
@override
void initState() {
super.initState();
scrollController.addListener(() {
if (isMoreOptionsVisible) {
setState(() {
isMoreOptionsVisible = false;
});
}
});
}
@override
Widget build(BuildContext context) {
final s = S.of(context);
return BlocProvider<CommentsCubit>(
create: (BuildContext context) => commentsCubit
..getComments(
@@ -50,6 +76,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
},
builder: (BuildContext context, CommentsState state) {
return Scaffold(
backgroundColor: appTheme.gray100,
resizeToAvoidBottomInset: true,
bottomSheet: Container(
padding: EdgeInsets.symmetric(vertical: 12) + (Platform.isIOS ? const EdgeInsets.only(bottom: 16) : EdgeInsets.zero),
@@ -61,290 +88,353 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
width: MediaQuery.of(context).size.width - 24,
child: FloatingActionButton.extended(
heroTag: 'nextButtonRegistration',
highlightElevation: 0,
elevation: 0,
focusElevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
backgroundColor: appTheme.greenA700,
onPressed: () {},
label: Text(
'Начать диету',
style: theme.textTheme.titleSmall,
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
Expanded(
child: SizedBox(
child: FloatingActionButton.extended(
heroTag: 'nextButtonRegistration',
highlightElevation: 0,
elevation: 0,
focusElevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
backgroundColor: appTheme.greenA700,
onPressed: () {},
label: Text(
s.startDiet,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: appTheme.whiteA700,
),
),
),
),
),
SizedBox(width: 8),
Container(
width: 52,
height: 52,
decoration: BoxDecoration(color: appTheme.gray50, shape: BoxShape.circle),
child: Icon(
Icons.bookmark_border_rounded,
color: appTheme.blueGray800,
size: 24,
),
)
],
),
),
SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (replyId != null)
SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (replyId != null)
GestureDetector(
onTap: () {
context.read<CommentsCubit>().setReplyId(null);
setState(() {
replyId = null;
textEditingController.clear();
});
FocusManager.instance.primaryFocus?.unfocus();
},
child: Container(
decoration: BoxDecoration(
color: appTheme.blueA400,
shape: BoxShape.circle,
),
height: 32,
width: 32,
child: Icon(
Icons.close_rounded,
size: 18,
color: Colors.white,
),
),
),
if (replyId != null) SizedBox(width: 8),
Expanded(
child: SizedBox(
child: TextFormField(
onChanged: (_) {
setState(() {});
},
controller: textEditingController,
maxLines: 5,
minLines: 1,
keyboardType: TextInputType.multiline,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black,
height: 1,
),
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
hintText: s.comment.capitalize(),
hintStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
height: 1,
color: Color(0xFFAEAEB2),
),
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
),
),
),
),
),
SizedBox(width: 8),
GestureDetector(
onTap: () {
context.read<CommentsCubit>().setReplyId(null);
setState(() {
replyId = null;
textEditingController.clear();
});
FocusManager.instance.primaryFocus?.unfocus();
if (textEditingController.text.length > 2) {
commentsCubit.sendComment(
id: widget.diet.id.toString(),
commentText: textEditingController.text,
parentCommentId: replyId,
commentSourceType: CommentSourceType.diet,
);
context.read<CommentsCubit>().setReplyId(null);
setState(() {
textEditingController.clear();
replyId = null;
});
FocusManager.instance.primaryFocus?.unfocus();
}
},
child: Container(
decoration: BoxDecoration(
color: appTheme.blueA400,
color: textEditingController.text.length > 2 ? appTheme.blueA400 : appTheme.gray50,
shape: BoxShape.circle,
),
height: 32,
width: 32,
child: Icon(
Icons.close_rounded,
Icons.send_rounded,
size: 18,
color: Colors.white,
color: textEditingController.text.length > 2 ? appTheme.whiteA700 : appTheme.blueGray800,
),
),
),
if (replyId != null) SizedBox(width: 8),
SizedBox(
width: MediaQuery.of(context).size.width - (replyId == null ? 64 : 104),
child: TextFormField(
onChanged: (_) {
setState(() {});
},
controller: textEditingController,
maxLines: 5,
minLines: 1,
keyboardType: TextInputType.multiline,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
color: Colors.black,
height: 1,
),
decoration: InputDecoration(
isDense: true,
contentPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
hintText: 'Комментарий',
hintStyle: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w400,
height: 1,
color: Color(0xFFAEAEB2),
),
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(16),
borderSide: BorderSide(
color: Color(0xFFD1D1D6),
width: 1,
),
),
),
),
),
SizedBox(width: 8),
GestureDetector(
onTap: () {
if (textEditingController.text.length > 2) {
commentsCubit.sendComment(
id: widget.diet.id.toString(),
commentText: textEditingController.text,
parentCommentId: replyId,
commentSourceType: CommentSourceType.diet,
);
context.read<CommentsCubit>().setReplyId(null);
setState(() {
textEditingController.clear();
replyId = null;
});
FocusManager.instance.primaryFocus?.unfocus();
}
},
child: Container(
decoration: BoxDecoration(
color: textEditingController.text.length > 2 ? appTheme.blueA400 : Colors.grey,
shape: BoxShape.circle,
),
height: 32,
width: 32,
child: Icon(
Icons.send_rounded,
size: 18,
color: Colors.white,
),
),
),
],
),
],
),
),
appBar: AppBar(
actions: [
InkWell(
borderRadius: BorderRadius.circular(16),
onTap: () => GoRouter.of(context).pushNamed('profileScreen', extra: widget.diet.author),
child: Ink(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircleAvatar(
maxRadius: 16,
minRadius: 16,
backgroundImage: NetworkImage(widget.diet.author.authorProfileIcon),
),
SizedBox(height: 4),
Text(
widget.diet.author.authorName,
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.w400,
height: 1,
),
),
],
),
],
),
),
),
appBar: AppBar(
centerTitle: true,
title: Text(
widget.diet.name,
maxLines: 2,
textAlign: TextAlign.center,
overflow: TextOverflow.ellipsis,
softWrap: true,
style: TextStyle(
color: Colors.black,
fontSize: 24,
fontWeight: FontWeight.w500,
height: 1,
),
),
actions: [
PortalTarget(
visible: isMoreOptionsVisible,
portalFollower: MoreOptions(id: widget.diet.id),
anchor: Aligned(
shiftToWithinBound: AxisFlag(x: true, y: true),
follower: Alignment.topRight,
target: Alignment.bottomRight,
),
child: IconButton(
onPressed: () {
setState(() {
isMoreOptionsVisible = !isMoreOptionsVisible;
});
},
icon: SvgPicture.asset(
'assets/icons/more_button.svg',
width: 20,
height: 20,
)),
),
],
),
body: SingleChildScrollView(
controller: scrollController,
padding: EdgeInsets.only(bottom: 160),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
widget.diet.name,
style: TextStyle(
color: Colors.black,
fontSize: 24,
fontWeight: FontWeight.w500,
height: 1,
),
),
),
SizedBox(height: 12),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
SizedBox(height: 8),
MainBackgroundBouble(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Icon(Icons.timer_outlined),
SizedBox(width: 4),
Text(
widget.diet.duration.toString() + ' дней',
style: TextStyle(
color: Colors.black,
fontSize: 12,
fontWeight: FontWeight.w400,
height: 1,
Stack(children: [
CachedNetworkImage(
imageUrl: baseUrl + '/storage/' + widget.diet.image,
),
Positioned(
child: Row(
children: [
InfoBouble(children: [
], backgroundColor: appTheme.whiteA700,)
],
),
)
]),
SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
s.about_diet,
style: TextStyle(color: appTheme.blueGray800, fontSize: 20, fontWeight: FontWeight.w600),
),
),
SizedBox(height: 12),
SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 16),
scrollDirection: Axis.horizontal,
child: Row(
children: [
InfoBouble(
children: [
SvgPicture.asset(
'assets/icons/time2.svg',
width: 13.3,
height: 13.3,
),
SizedBox(width: 4),
Text(widget.diet.duration.toString() + ' ' + getDayForm(widget.diet.duration, s),
style: TextStyle(color: appTheme.blueGray800, fontSize: 12, fontWeight: FontWeight.w500)),
],
),
SizedBox(width: 12),
InfoBouble(
children: [
SvgPicture.asset(
'assets/icons/people.svg',
width: 13.3,
height: 13.3,
),
SizedBox(width: 4),
Text('80 человек прошли(статика, ещё нет бека)',
style: TextStyle(color: appTheme.blueGray800, fontSize: 12, fontWeight: FontWeight.w500)),
],
),
SizedBox(width: 12),
InfoBouble(
children: [
TypeBadges(type: widget.diet.type),
],
)
],
),
),
ExpandableText(
text: widget.diet.details,
),
SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: AuthorCard(
author: widget.diet.author,
),
),
SizedBox(height: 16),
],
),
),
if (widget.diet.details.isNotEmpty)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Html(
data: widget.diet.details,
style: {
"*": Style(
color: Colors.black87,
),
},
SizedBox(height: 16),
MainBackgroundBouble(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Center(
child: Text(
s.diet_plan + '(${widget.diet.duration.toString()} ' + getDayForm(widget.diet.duration, s) + ')',
style: TextStyle(
color: appTheme.blueGray800,
fontSize: 20,
fontWeight: FontWeight.w600,
),
),
),
SizedBox(height: 12),
CachedNetworkImage(
imageUrl: baseUrl + '/storage/' + widget.diet.image,
),
SizedBox(height: 12),
ListView.separated(
padding: EdgeInsets.all(16),
)),
SizedBox(height: 8),
ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return _dayOfPlan(widget.diet.dailySchedule[index], index);
return _dayOfPlan(widget.diet.dailySchedule[index], index, s);
},
separatorBuilder: (context, index) => Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Container(
height: 0.4,
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(16),
),
),
),
itemCount: widget.diet.dailySchedule.length,
),
SizedBox(height: 32),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Container(
height: 0.4,
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(16),
),
),
),
SizedBox(height: 8),
Container(
padding: EdgeInsets.symmetric(horizontal: 16),
alignment: Alignment.centerLeft,
child: Text(
widget.diet.totalComments.toString() + ' КОММЕНТАРИЕВ',
style: TextStyle(
fontSize: 12,
color: appTheme.gray500,
fontWeight: FontWeight.w400,
),
),
),
SizedBox(height: 16),
if (state is CommentsStateLoading)
Padding(
padding: const EdgeInsets.all(32),
child: SizedBox(
height: 32,
width: 32,
child: RiveAnimation.asset(
'assets/rive_animations/loading.riv',
MainBackgroundBouble(
padding: EdgeInsets.symmetric(vertical: 16),
child: Column(children: [
Container(
padding: EdgeInsets.symmetric(horizontal: 16),
alignment: Alignment.centerLeft,
child: Text(
widget.diet.totalComments.toString() + ' ' + getCommentForm(widget.diet.totalComments, s),
style: TextStyle(
fontSize: 12,
color: appTheme.gray500,
fontWeight: FontWeight.w400,
),
),
),
),
if (state is CommentsStateLoaded)
CommentsWidget(
id: widget.diet.id.toString(),
commentSourceType: CommentSourceType.diet,
comment: state.comment,
replyId: replyId,
),
SizedBox(height: 16),
if (state is CommentsStateLoading)
Padding(
padding: const EdgeInsets.all(32),
child: SizedBox(
height: 32,
width: 32,
child: RiveAnimation.asset(
'assets/rive_animations/loading.riv',
),
),
),
if (state is CommentsStateLoaded)
CommentsWidget(
id: widget.diet.id.toString(),
commentSourceType: CommentSourceType.diet,
comment: state.comment,
replyId: replyId,
),
]),
),
],
),
),
@@ -354,7 +444,7 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
);
}
_dayOfPlan(List<List<DailySchedule>> day, int dayNumber) {
_dayOfPlan(List<List<DailySchedule>> day, int dayNumber, S s) {
_choiceChipWidget(int index) {
return ChoiceChip(
selectedColor: appTheme.blueA400,
@@ -381,73 +471,91 @@ class _AboutDietScreenState extends State<AboutDietScreen> {
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'День ' + (dayNumber + 1).toString(),
style: TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.w500,
height: 1,
),
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: MainBackgroundBouble(
padding: EdgeInsets.only(
top: 16,
),
SizedBox(height: 4),
Text(
'Приём пищи',
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.w400,
height: 1,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
child: Column(
children: [
_choiceChipWidget(0),
_choiceChipWidget(1),
_choiceChipWidget(2),
_choiceChipWidget(3),
_choiceChipWidget(4),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
s.day + ' ' + (dayNumber + 1).toString(),
style: TextStyle(
color: appTheme.blueGray800,
fontSize: 20,
fontWeight: FontWeight.w600,
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12),
child: CustomDivider(),
),
Text(
s.meal,
style: TextStyle(
color: appTheme.blueGray800,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_choiceChipWidget(0),
_choiceChipWidget(1),
_choiceChipWidget(2),
_choiceChipWidget(3),
_choiceChipWidget(4),
],
),
SizedBox(height: 8),
ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => _daily(day[widget.selectedIndexes[dayNumber]][index], s),
itemCount: day[widget.selectedIndexes[dayNumber]].length,
),
SizedBox(height: 8),
],
),
),
CpfcContainer(calories: 0, protein: 0, fat: 0, carbohydrates: 0)
],
),
SizedBox(height: 8),
ListView.separated(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => _daily(day[widget.selectedIndexes[dayNumber]][index]),
separatorBuilder: (context, index) => SizedBox(height: 4),
itemCount: day[widget.selectedIndexes[dayNumber]].length,
),
],
),
);
}
_daily(DailySchedule daily) {
return Row(
children: [
Text(
'• ' + daily.name,
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.w400,
height: 1.2,
_daily(DailySchedule daily, S s) {
return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: Row(
children: [
Text(
daily.name,
style: TextStyle(
color: appTheme.blueGray800,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
),
Spacer(),
Text(
daily.quantity.toString() + ' ' + daily.portion.name,
style: TextStyle(
color: Colors.black,
fontSize: 14,
fontWeight: FontWeight.w400,
height: 1.2,
Spacer(),
Text(
daily.quantity.toString() + ' ' + getLocalizedMeasurementUnits(s, daily.portion),
style: TextStyle(
color: appTheme.blueGray800,
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
),
],
],
),
);
}
}

View File

@@ -0,0 +1,107 @@
import 'package:eatvio_app/features/diets/presentation/widgets/info_bouble.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:go_router/go_router.dart';
class AuthorCard extends StatelessWidget {
const AuthorCard({super.key, required this.author});
final Author author;
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Container(
width: MediaQuery.sizeOf(context).width,
decoration: BoxDecoration(borderRadius: BorderRadius.circular(12), color: appTheme.cardBackground),
child: Stack(
children: [
Padding(
padding: const EdgeInsets.only(left: 16, top: 16, bottom: 24),
child: Column(
children: [
ListTile(
contentPadding: EdgeInsets.zero,
leading: Container(
width: 64,
height: 64,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: NetworkImage(author.authorProfileIcon),
fit: BoxFit.cover,
),
),
),
subtitle: Text(
author.authorName,
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: appTheme.blueGray800,
),
),
title: Text(
s.diet_author,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w600,
color: Color(0xFF6D6F71),
),
),
),
Row(
children: [
Text(
'Конслуьтант',
style: TextStyle(
color: appTheme.blueGray800,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
SizedBox(width: 10),
InfoBouble(radius: 12, backgroundColor: appTheme.whiteA700, children: [
Text(
'128-й в рейтинге',
style: TextStyle(
color: appTheme.blueA400,
fontSize: 16,
fontWeight: FontWeight.w500,
),
)
])
],
)
],
),
),
Positioned(
right: 8,
top: 8,
child: GestureDetector(
onTap: () => GoRouter.of(context).pushNamed('profileScreen', extra: author),
child: Container(
width: 28,
height: 28,
decoration: BoxDecoration(
color: appTheme.whiteA700,
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: SvgPicture.asset(
'assets/icons/arrow.svg',
width: 12,
height: 12,
fit: BoxFit.none,
),
),
),
),
)
],
),
);
}
}

View File

@@ -0,0 +1,46 @@
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
class CpfcContainer extends StatelessWidget {
const CpfcContainer({super.key, required this.calories, required this.protein, required this.fat, required this.carbohydrates});
final double calories;
final double protein;
final double fat;
final double carbohydrates;
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Container(
color: appTheme.cardBackground,
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Column(
children: [
Text('$calories', style: TextStyle(color: appTheme.blueGray800, fontSize: 16, fontWeight: FontWeight.w600)),
Text(s.calories, style: TextStyle(color: appTheme.blueGray800, fontSize: 12, fontWeight: FontWeight.w500)),
],
),
Column(
children: [
Text('$protein', style: TextStyle(color: appTheme.blueGray800, fontSize: 16, fontWeight: FontWeight.w600)),
Text(s.proteins, style: TextStyle(color: appTheme.blueGray800, fontSize: 12, fontWeight: FontWeight.w500)),
],
),
Column(
children: [
Text('$fat', style: TextStyle(color: appTheme.blueGray800, fontSize: 16, fontWeight: FontWeight.w600)),
Text(s.fats, style: TextStyle(color: appTheme.blueGray800, fontSize: 12, fontWeight: FontWeight.w500)),
],
),
Column(
children: [
Text('$carbohydrates', style: TextStyle(color: appTheme.blueGray800, fontSize: 16, fontWeight: FontWeight.w600)),
Text(s.carbohydrates, style: TextStyle(color: appTheme.blueGray800, fontSize: 12, fontWeight: FontWeight.w500)),
],
)
]),
);
}
}

View File

@@ -0,0 +1,87 @@
import 'dart:math' as math;
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_svg/svg.dart';
class ExpandableText extends StatefulWidget {
final String text;
final int maxLines;
ExpandableText({required this.text, this.maxLines = 3});
@override
_ExpandableTextState createState() => _ExpandableTextState();
}
class _ExpandableTextState extends State<ExpandableText> {
bool isExpanded = false;
void toggleExpansion() {
setState(() {
isExpanded = !isExpanded;
});
}
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Stack(
children: [
Html(
data: widget.text,
style: {
"*": Style(
color: Colors.black87,
maxLines: isExpanded ? null : widget.maxLines,
textOverflow: TextOverflow.clip,
),
},
),
if (!isExpanded)
Positioned.fill(
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 35,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Colors.white.withOpacity(0.0),
Colors.white.withOpacity(0.6),
Colors.white,
],
),
),
),
),
),
],
),
Align(
alignment: Alignment.bottomCenter,
child: GestureDetector(
onTap: toggleExpansion,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
isExpanded ? s.hide : s.expand,
style: TextStyle(color: appTheme.blueA400, fontSize: 16, fontWeight: FontWeight.w500),
),
Transform.rotate(angle: isExpanded ? math.pi : 0, child: SvgPicture.asset('assets/icons/arrow_down.svg', width: 12, height: 12)),
],
),
),
),
],
);
}
}

View File

@@ -0,0 +1,20 @@
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
class InfoBouble extends StatelessWidget {
const InfoBouble({super.key, required this.children, this.backgroundColor, this.radius = 100});
final List<Widget> children;
final Color? backgroundColor;
final double radius;
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 8.5),
decoration: BoxDecoration(
color: backgroundColor ?? appTheme.gray50,
borderRadius: BorderRadius.circular(radius),
),
child: Row(children: children),
);
}
}

View File

@@ -0,0 +1,38 @@
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
class MainBackgroundBouble extends StatelessWidget {
const MainBackgroundBouble(
{super.key, required this.child, this.width, this.padding, this.enableShadow = false});
final double? width;
final Widget child;
final bool enableShadow;
final EdgeInsetsGeometry? padding;
@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
boxShadow: enableShadow
? [
BoxShadow(
color: Color(0x00000000).withOpacity(0.2),
spreadRadius: 0,
blurRadius: 32,
offset: Offset(0, 0),
),
]
: null),
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: Container(
decoration: BoxDecoration(
color: appTheme.whiteA700,
),
width: width ?? MediaQuery.sizeOf(context).width,
padding: padding,
child: child,
),
),
);
}
}

View File

@@ -0,0 +1,96 @@
import 'package:eatvio_app/core/const.dart';
import 'package:eatvio_app/core/utils/toasts.dart';
import 'package:eatvio_app/core/widgets/custom_divider.dart';
import 'package:eatvio_app/features/diets/presentation/widgets/main_background_bouble.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:share_plus/share_plus.dart';
class MoreOptions extends StatelessWidget {
const MoreOptions({super.key, required this.id});
final int id;
@override
Widget build(BuildContext context) {
final s = S.of(context);
return MainBackgroundBouble(
enableShadow: true,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 14),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(text: baseUrl + '/ru/diet/' + id.toString()));
showInfoToast(s.link_was_copied);
},
child: Row(
children: [
Text(
s.copy_link,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: appTheme.blueGray800,
),
),
Spacer(),
SvgPicture.asset('assets/icons/copy2.svg', width: 16, height: 20),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0),
child: CustomDivider(),
),
GestureDetector(
onTap: () => Share.shareUri(
Uri.parse(
baseUrl + '/ru/diet/' + id.toString(),
),
),
child: Row(
children: [
Text(
s.share,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: appTheme.blueGray800,
),
),
Spacer(),
SvgPicture.asset('assets/icons/share2.svg', width: 16, height: 20),
],
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 12.0),
child: CustomDivider(),
),
GestureDetector(
onTap: () {},
child: Row(
children: [
Text(
s.complain,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: appTheme.blueGray800,
),
),
Spacer(),
SvgPicture.asset('assets/icons/complain.svg', width: 16, height: 20),
],
),
)
],
),
),
width: 272);
}
}

View File

@@ -0,0 +1,222 @@
import 'package:eatvio_app/features/diets/presentation/widgets/main_background_bouble.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_portal/flutter_portal.dart';
import 'package:flutter_svg/svg.dart';
class TypeBadges extends StatefulWidget {
const TypeBadges({super.key, required this.type});
final DietType type;
@override
State<TypeBadges> createState() => _TypeBadgesState();
}
class _TypeBadgesState extends State<TypeBadges> {
final List<bool> overlaysVisibilityState = [false, false, false, false];
@override
Widget build(BuildContext context) {
final s = S.of(context);
final List<(String, Widget)> badgeSource = [];
if (widget.type.alko == true) {
badgeSource.add((
'assets/icons/cocktail.svg',
_InfoOverlayEntry(
onClose: closeOverlay,
assetPath: 'assets/icons/cocktail.svg',
title: s.alko_type,
description: s.alko_type_desc,
)
));
}
if (widget.type.veg == true) {
badgeSource.add((
'assets/icons/broccoli.svg',
_InfoOverlayEntry(
onClose: closeOverlay,
assetPath: 'assets/icons/broccoli.svg',
title: s.vegan_type,
description: s.vegan_type_desc,
)
));
}
if (widget.type.corb == true) {
badgeSource.add((
'assets/icons/bread.svg',
_InfoOverlayEntry(
onClose: closeOverlay,
assetPath: 'assets/icons/bread.svg',
title: s.corb_type,
description: s.corb_type_desc,
)
));
}
if (widget.type.meat == true) {
badgeSource.add((
'assets/icons/meat2.svg',
_InfoOverlayEntry(
onClose: closeOverlay,
assetPath: 'assets/icons/meat2.svg',
title: s.meat_type,
description: s.meat_type_desc,
)
));
}
return Row(
children: List.generate(
badgeSource.length,
(index) => _Barrier(
visible: overlaysVisibilityState[index],
onClose: closeOverlay,
child: PortalTarget(
visible: overlaysVisibilityState[index],
anchor: Aligned(
shiftToWithinBound: AxisFlag(x: true, y: true),
follower: Alignment.topRight,
target: Alignment.bottomRight,
),
portalFollower: badgeSource[index].$2,
child: GestureDetector(
onTap: () {
for (int stateIndex = 0; stateIndex < overlaysVisibilityState.length; stateIndex++) {
if (index != stateIndex) {
setState(() {
overlaysVisibilityState[stateIndex] = false;
});
} else {
setState(() {
overlaysVisibilityState[stateIndex] = true;
});
}
}
},
child: Padding(
padding: EdgeInsets.only(right: index != badgeSource.length - 1 ? 8.0 : 0),
child: SvgPicture.asset(
badgeSource[index].$1,
width: 16,
height: 16,
),
),
),
),
),
),
);
}
void closeOverlay() {
for (int stateIndex = 0; stateIndex < overlaysVisibilityState.length; stateIndex++) {
setState(() {
overlaysVisibilityState[stateIndex] = false;
});
}
}
}
class _InfoOverlayEntry extends StatelessWidget {
const _InfoOverlayEntry({super.key, required this.title, required this.description, required this.assetPath, required this.onClose});
final String title;
final String description;
final assetPath;
final void Function() onClose;
@override
Widget build(BuildContext context) {
return MainBackgroundBouble(
padding: EdgeInsets.all(8),
width: 343,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SvgPicture.asset(
assetPath,
width: 20,
height: 20,
),
SizedBox(width: 8),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
title,
style: TextStyle(
decoration: TextDecoration.none,
color: appTheme.blueGray800,
fontSize: 16,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 4),
Text(
description,
softWrap: true,
style: TextStyle(
decoration: TextDecoration.none,
color: appTheme.blueGray800,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
],
),
),
GestureDetector(
onTap: onClose,
child: SvgPicture.asset(
'assets/icons/close_button.svg',
width: 20,
height: 20,
),
),
],
),
);
}
}
class _Barrier extends StatelessWidget {
const _Barrier({
Key? key,
required this.onClose,
required this.visible,
required this.child,
}) : super(key: key);
final Widget child;
final VoidCallback onClose;
final bool visible;
@override
Widget build(BuildContext context) {
return PortalTarget(
visible: visible,
closeDuration: kThemeAnimationDuration,
portalFollower: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: onClose,
child: TweenAnimationBuilder<Color>(
duration: kThemeAnimationDuration,
tween: ColorTween(
begin: Colors.transparent,
end: visible ? Colors.black54 : Colors.transparent,
),
builder: (context, color, child) {
return ColoredBox(color: color);
},
),
),
child: child,
);
}
}
class ColorTween extends Tween<Color> {
ColorTween({required Color begin, required Color end}) : super(begin: begin, end: end);
@override
Color lerp(double t) => Color.lerp(begin, end, t)!;
}

View File

@@ -0,0 +1,12 @@
import 'package:dio/dio.dart';
import 'package:retrofit/retrofit.dart';
part 'diets_service.g.dart';
@RestApi()
abstract class DietsService {
factory DietsService(Dio dio, {String baseUrl}) = _DietsService;
}

View File

@@ -0,0 +1,53 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'diets_service.dart';
// **************************************************************************
// RetrofitGenerator
// **************************************************************************
// ignore_for_file: unnecessary_brace_in_string_interps,no_leading_underscores_for_local_identifiers,unused_element,unnecessary_string_interpolations
class _DietsService implements DietsService {
_DietsService(
this._dio, {
this.baseUrl,
this.errorLogger,
});
final Dio _dio;
String? baseUrl;
final ParseErrorLogger? errorLogger;
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
if (T != dynamic &&
!(requestOptions.responseType == ResponseType.bytes ||
requestOptions.responseType == ResponseType.stream)) {
if (T == String) {
requestOptions.responseType = ResponseType.plain;
} else {
requestOptions.responseType = ResponseType.json;
}
}
return requestOptions;
}
String _combineBaseUrls(
String dioBaseUrl,
String? baseUrl,
) {
if (baseUrl == null || baseUrl.trim().isEmpty) {
return dioBaseUrl;
}
final url = Uri.parse(baseUrl);
if (url.isAbsolute) {
return url.toString();
}
return Uri.parse(dioBaseUrl).resolveUri(url).toString();
}
}

View File

@@ -14,7 +14,7 @@ class CommentsCubit extends Cubit<CommentsState> {
emit((state as CommentsStateLoaded).copyWith(replyId: replyId));
}
getComments(String id, CommentSourceType commentSourceType, [bool isFirstFetch = false]) async {
getComments(String id, CommentSourceType commentSourceType, [bool isFirstFetch = false]) async {
if (isFirstFetch) emit(CommentsState.loading());
try {
switch (commentSourceType) {

View File

@@ -1,6 +1,7 @@
import 'package:eatvio_app/core/utils/date_time_utils.dart';
import 'package:eatvio_app/features/feed/models/comment_model.dart';
import 'package:eatvio_app/features/feed/presentation/bloc/comments_cubit/comments_cubit.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:eatvio_app/theme/theme_helper.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -28,15 +29,16 @@ class CommentsWidget extends StatefulWidget {
class _CommentsWidgetState extends State<CommentsWidget> {
@override
Widget build(BuildContext context) {
final s = S.of(context);
return Column(
children: [
for (int i = 0; i < widget.comment.data.length; i++) ...[
_comment(widget.comment.data[i]),
_comment(s, widget.comment.data[i]),
if (widget.comment.data[i].childrenComments.isNotEmpty) SizedBox(height: 8),
for (int j = 0; j < widget.comment.data[i].childrenComments.length; j++)
Padding(
padding: EdgeInsets.only(left: 40),
child: _comment(widget.comment.data[i].childrenComments[j], 12, true),
child: _comment(s, widget.comment.data[i].childrenComments[j], 16, true),
),
SizedBox(height: 8),
],
@@ -44,7 +46,7 @@ class _CommentsWidgetState extends State<CommentsWidget> {
);
}
_comment(Comment comment, [double radius = 16, bool isChild = false]) {
_comment(S s, Comment comment, [double radius = 18, bool isChild = false]) {
return Container(
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
@@ -69,16 +71,19 @@ class _CommentsWidgetState extends State<CommentsWidget> {
comment.authorName,
style: TextStyle(
height: 1,
color: Colors.grey.shade600,
color: appTheme.grey,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
SizedBox(width: 4),
SizedBox(height: 4),
Text(
comment.body,
style: TextStyle(
height: 1,
color: Colors.black,
color: appTheme.blueGray800,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 4),
@@ -87,10 +92,10 @@ class _CommentsWidgetState extends State<CommentsWidget> {
Text(
comment.createdAt.format('dd MMMM', 'ru'),
style: TextStyle(
color: Colors.grey.shade600,
fontSize: 12,
fontWeight: FontWeight.w400,
height: 1,
color: appTheme.grey,
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
SizedBox(width: 16),
@@ -100,11 +105,11 @@ class _CommentsWidgetState extends State<CommentsWidget> {
context.read<CommentsCubit>().setReplyId(comment.id);
},
child: Text(
'Ответить',
s.answer,
style: TextStyle(
height: 1,
color: appTheme.grey,
fontSize: 12,
color: Colors.grey.shade800,
fontWeight: FontWeight.w500,
),
),

View File

@@ -111,7 +111,8 @@ class _CityOfLivingScreenState extends State<CityOfLivingScreen> {
suggestionsCallback: (query) async {
if (query.length >= 3) {
final registrationCubit = context.read<RegistrationCubit>();
return (await registrationCubit.getLocationsByQuery(query));
final qwe = (await registrationCubit.getLocationsByQuery(query));
return qwe;
}
return null;
},
@@ -129,9 +130,11 @@ class _CityOfLivingScreenState extends State<CityOfLivingScreen> {
if (locationData != null) {
final List<String> locations = await context
.read<RegistrationCubit>()
.getLocationsByCoordinates(locationData.latitude.toString(), locationData.longitude.toString());
.getLocationsByCoordinates(
locationData.latitude.toString(), locationData.longitude.toString());
final registrationCubit = context.read<RegistrationCubit>();
registrationCubit.updateSheet(registrationCubit.state.sheet.copyWith(location: locations.first));
registrationCubit
.updateSheet(registrationCubit.state.sheet.copyWith(location: locations.first));
setState(() {
cityController.text = locations.first;
suggestionsController.suggestions = locations;