diff --git a/lib/app_router.dart b/lib/app_router.dart index 752d0ab5..698cf7c1 100644 --- a/lib/app_router.dart +++ b/lib/app_router.dart @@ -12,6 +12,7 @@ import 'package:eatvio_app/features/diets/presentation/pages/about_diet_screen.d import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/features/feed/models/recipes_model.dart'; import 'package:eatvio_app/features/feed/presentation/pages/feed_screen.dart'; +import 'package:eatvio_app/features/profile/presentation/pages/profile_screen.dart'; import 'package:eatvio_app/features/recipes/presentation/pages/about_recipes_screen.dart'; import 'package:eatvio_app/features/registration/presentation/pages/registration_screen.dart'; import 'package:eatvio_app/presentation/auth/auth_screen/auth_screen.dart'; @@ -94,6 +95,13 @@ class AppRouter { recipes: state.extra as Recipes, ), ), + GoRoute( + path: '/profile-screen', + name: 'profileScreen', + builder: (context, state) => ProfileScreen( + author: state.extra as Author, + ), + ), GoRoute( path: '/about-diet-screen', name: 'aboutDietScreen', diff --git a/lib/features/diets/presentation/pages/about_diet_screen.dart b/lib/features/diets/presentation/pages/about_diet_screen.dart index 916085ce..c7482976 100644 --- a/lib/features/diets/presentation/pages/about_diet_screen.dart +++ b/lib/features/diets/presentation/pages/about_diet_screen.dart @@ -3,12 +3,21 @@ import 'package:eatvio_app/core/constants/constants.dart'; import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; import 'package:eatvio_app/theme/theme_helper.dart'; import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; -class AboutDietScreen extends StatelessWidget { +class AboutDietScreen extends StatefulWidget { final Datum datum; + late final List selectedIndexes; - const AboutDietScreen({super.key, required this.datum}); + AboutDietScreen({super.key, required this.datum}) { + selectedIndexes = List.generate(datum.dailySchedule.length, (_) => 0); + } + @override + State createState() => _AboutDietScreenState(); +} + +class _AboutDietScreenState extends State { @override Widget build(BuildContext context) { return Scaffold( @@ -31,7 +40,37 @@ class AboutDietScreen extends StatelessWidget { ), ), ), - appBar: AppBar(), + appBar: AppBar( + actions: [ + InkWell( + borderRadius: BorderRadius.circular(16), + onTap: () => GoRouter.of(context).pushNamed('profileScreen', extra: widget.datum.author), + child: Ink( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + CircleAvatar( + maxRadius: 16, + minRadius: 16, + backgroundImage: NetworkImage(widget.datum.author.authorProfileIcon), + ), + SizedBox(height: 4), + Text( + widget.datum.author.authorName, + style: TextStyle( + color: Colors.black, + fontSize: 14, + fontWeight: FontWeight.w400, + height: 1, + ), + ), + ], + ), + ), + ), + ], + ), body: SingleChildScrollView( padding: EdgeInsets.only(bottom: 80), child: Column( @@ -40,7 +79,7 @@ class AboutDietScreen extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Text( - datum.name, + widget.datum.name, style: TextStyle( color: Colors.black, fontSize: 24, @@ -57,7 +96,7 @@ class AboutDietScreen extends StatelessWidget { Icon(Icons.timer_outlined), SizedBox(width: 4), Text( - datum.duration.toString() + ' дней', + widget.datum.duration.toString() + ' дней', style: TextStyle( color: Colors.black, fontSize: 12, @@ -72,7 +111,7 @@ class AboutDietScreen extends StatelessWidget { Padding( padding: const EdgeInsets.symmetric(horizontal: 16), child: Text( - datum.details, + widget.datum.details, style: TextStyle( color: Colors.black, fontSize: 14, @@ -83,12 +122,129 @@ class AboutDietScreen extends StatelessWidget { ), SizedBox(height: 12), CachedNetworkImage( - imageUrl: baseUrl + '/storage/' + datum.image, + imageUrl: baseUrl + '/storage/' + widget.datum.image, ), SizedBox(height: 12), + ListView.separated( + padding: EdgeInsets.all(16), + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + itemBuilder: (context, index) { + return _dayOfPlan(widget.datum.dailySchedule[index], index); + }, + 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.datum.dailySchedule.length, + ), + SizedBox(height: 32), ], ), ), ); } + + _dayOfPlan(List> day, int dayNumber) { + _choiceChipWidget(int index) { + return ChoiceChip( + selectedColor: appTheme.blueA400, + pressElevation: 0, + showCheckmark: false, + side: BorderSide.none, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + ), + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + label: Text((index + 1).toString()), + labelStyle: TextStyle( + color: index == widget.selectedIndexes[dayNumber] ? Colors.white : appTheme.gray600, + fontWeight: FontWeight.w500, + fontSize: 12, + ), + selected: widget.selectedIndexes[dayNumber] == index, + backgroundColor: appTheme.gray100, + onSelected: (bool selected) { + setState(() { + widget.selectedIndexes[dayNumber] = index; + }); + }, + ); + } + + return Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'День ' + (dayNumber + 1).toString(), + style: TextStyle( + color: Colors.black, + fontSize: 16, + fontWeight: FontWeight.w500, + height: 1, + ), + ), + SizedBox(height: 4), + Text( + 'Приём пищи', + style: TextStyle( + color: Colors.black, + fontSize: 14, + fontWeight: FontWeight.w400, + height: 1, + ), + ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + _choiceChipWidget(0), + _choiceChipWidget(1), + _choiceChipWidget(2), + _choiceChipWidget(3), + _choiceChipWidget(4), + ], + ), + 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, + ), + ), + Spacer(), + Text( + daily.quantity.toString() + ' ' + daily.portion.name, + style: TextStyle( + color: Colors.black, + fontSize: 14, + fontWeight: FontWeight.w400, + height: 1.2, + ), + ), + ], + ); + } } diff --git a/lib/features/profile/presentation/pages/profile_screen.dart b/lib/features/profile/presentation/pages/profile_screen.dart new file mode 100644 index 00000000..68c2616f --- /dev/null +++ b/lib/features/profile/presentation/pages/profile_screen.dart @@ -0,0 +1,38 @@ +import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart'; +import 'package:flutter/material.dart'; + +class ProfileScreen extends StatelessWidget { + final Author author; + + const ProfileScreen({super.key, required this.author}); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar(), + body: Expanded( + child: Center( + child: Column( + children: [ + CircleAvatar( + maxRadius: 128, + minRadius: 128, + backgroundImage: NetworkImage(author.authorProfileIcon), + ), + SizedBox(height: 32), + Text( + author.authorName, + style: TextStyle( + color: Colors.black, + fontSize: 24, + fontWeight: FontWeight.w400, + height: 1, + ), + ), + ], + ), + ), + ), + ); + } +}