diff --git a/lib/features/chat/presentation/pages/chat_screen.dart b/lib/features/chat/presentation/pages/chat_screen.dart index 2e96d007..ae20444b 100644 --- a/lib/features/chat/presentation/pages/chat_screen.dart +++ b/lib/features/chat/presentation/pages/chat_screen.dart @@ -27,16 +27,18 @@ class ChatScreen extends StatefulWidget { class _ChatScreenState extends State { final scrollController = ScrollController(); final TextEditingController textEditingController = TextEditingController(); + final ChatRoomCubit chatRoomCubit = sl(); @override void initState() { - scrollController.addListener(_onScroll); super.initState(); + scrollController.addListener(_onScroll); + chatRoomCubit.initChat(widget.chatId); } _onScroll() { if (scrollController.offset >= scrollController.position.maxScrollExtent && !scrollController.position.outOfRange) { - context.read().loadNextPage(widget.chatId); + chatRoomCubit.loadNextPage(widget.chatId); } } @@ -48,8 +50,9 @@ class _ChatScreenState extends State { Widget build(BuildContext context) { return BlocProvider( - create: (BuildContext context) => sl()..initChat(widget.chatId), + create: (BuildContext context) => chatRoomCubit, child: BlocBuilder( + bloc: chatRoomCubit, builder: (context, state) { if (state is ChatRoomStateLoaded) { return _buildChat(context, state); @@ -234,7 +237,7 @@ class _ChatScreenState extends State { if (result != null) { List files = result.paths.map((path) => File(path!)).toList(); - context.read().sendMessage( + chatRoomCubit.sendMessage( chatId: widget.chatId, files: files, ); @@ -305,7 +308,7 @@ class _ChatScreenState extends State { customBorder: CircleBorder(), onTap: () { if (textEditingController.text.isNotEmpty) { - context.read().sendMessage( + chatRoomCubit.sendMessage( chatId: widget.chatId, data: textEditingController.text.trim(), ); diff --git a/lib/features/consultant/become_consultant/pages/stepper_become_consultant_screen.dart b/lib/features/consultant/become_consultant/pages/stepper_become_consultant_screen.dart index 5b010215..c191c402 100644 --- a/lib/features/consultant/become_consultant/pages/stepper_become_consultant_screen.dart +++ b/lib/features/consultant/become_consultant/pages/stepper_become_consultant_screen.dart @@ -1,3 +1,6 @@ +import 'package:eatvio_app/core/utils/image_constant.dart'; +import 'package:eatvio_app/theme/theme_helper.dart'; +import 'package:eatvio_app/widgets/app_bar/appbar_title_image.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; @@ -9,15 +12,127 @@ class StepperBecomeConsultantScreen extends StatefulWidget { } class _StepperBecomeConsultantScreenState extends State { + double progressValue = 1 / 6; + int step = 1; + final pageController = PageController(); + @override Widget build(BuildContext context) { return Scaffold( + floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, + floatingActionButton: Row( + children: [ + Container( + height: 48, + width: MediaQuery.of(context).size.width * 0.2, + padding: EdgeInsets.only(left: 16, right: 4), + child: FloatingActionButton.extended( + heroTag: 'backButtonRegistration', + highlightElevation: 0, + focusElevation: 0, + elevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + backgroundColor: Color(0xFFEAF2FD), + onPressed: () async { + setState(() { + pageController.previousPage( + duration: const Duration(milliseconds: 350), + curve: Curves.easeInOut, + ); + }); + }, + label: Icon( + Icons.arrow_back_ios_new_rounded, + color: appTheme.blueA400, + ), + ), + ), + Container( + height: 48, + width: MediaQuery.of(context).size.width * 0.8, + padding: EdgeInsets.only(left: 4, right: 16), + child: FloatingActionButton.extended( + heroTag: 'nextButtonRegistration', + highlightElevation: 0, + elevation: 0, + focusElevation: 0, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(20), + ), + backgroundColor: appTheme.blueA400, + onPressed: () async { + setState(() { + pageController.nextPage( + duration: const Duration(milliseconds: 350), + curve: Curves.easeInOut, + ); + }); + }, + label: Text( + 'Продолжить', + style: theme.textTheme.titleSmall!.copyWith(color: Colors.white), + ), + ), + ), + ], + ), appBar: AppBar( automaticallyImplyLeading: false, - leading: IconButton( - onPressed: () => GoRouter.of(context).pop(), - icon: Icon(Icons.close), + leading: Builder( + builder: (context) => IconButton( + icon: Icon(Icons.close_rounded), + onPressed: () => GoRouter.of(context).pop(), + ), ), + centerTitle: true, + title: AppbarTitleImage(imagePath: ImageConstant.imgLogoEatvio), + actions: [ + Padding( + padding: const EdgeInsets.only(right: 16), + child: Text('шаг $step из 6'), + ), + ], + bottom: PreferredSize( + preferredSize: Size(MediaQuery.of(context).size.width, 32), + child: Padding( + padding: const EdgeInsets.all(16), + child: TweenAnimationBuilder( + duration: const Duration(milliseconds: 350), + curve: Curves.easeInOut, + tween: Tween( + begin: 0, + end: progressValue, + ), + builder: (context, value, _) => LinearProgressIndicator( + value: value, + borderRadius: BorderRadius.circular(16), + minHeight: 8, + backgroundColor: Colors.grey.shade100, + valueColor: AlwaysStoppedAnimation(appTheme.blueA400), + ), + ), + ), + ), + ), + body: PageView( + physics: NeverScrollableScrollPhysics(), + controller: pageController, + onPageChanged: (index) { + setState(() { + step = index + 1; + progressValue = step / 6; + }); + }, + children: [ + Container(), + Container(), + Container(), + Container(), + Container(), + Container(), + ], ), ); } diff --git a/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart b/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart index 83df5eb0..f387a4eb 100644 --- a/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart +++ b/lib/features/feed/presentation/bloc/feed_cubit/feed_cubit.dart @@ -37,7 +37,9 @@ class FeedCubit extends Cubit { try { if (currentPage < lastPage) { + print('before: $currentPage'); currentPage++; + print('after: $currentPage'); final feedBlogPosts = await feedRepository.getFeedBlogPosts( page: currentPage, query: _query, diff --git a/lib/features/feed/services/feed_service.dart b/lib/features/feed/services/feed_service.dart index 9d0cd1bd..1321fa6b 100644 --- a/lib/features/feed/services/feed_service.dart +++ b/lib/features/feed/services/feed_service.dart @@ -13,20 +13,20 @@ abstract class FeedService { @GET('/api/blogPosts/index') Future getBlogPostList({ - @Path() required int page, + @Query('page') required int page, @Query('query_search') String? query, }); @GET('/api/recipes/index') Future getRecipes({ - @Path() required int page, + @Query('page') required int page, @Query('filters[tags][tags.id][\$in][]') required List? tags, @Query('filters[title][\$contains]') required String? query, }); @GET('/api/diets/index') Future getDiets({ - @Path() required int page, + @Query('page') required int page, @Query('query_search') String? query, }); diff --git a/lib/features/feed/services/feed_service.g.dart b/lib/features/feed/services/feed_service.g.dart index d074b0a2..31b022c4 100644 --- a/lib/features/feed/services/feed_service.g.dart +++ b/lib/features/feed/services/feed_service.g.dart @@ -27,7 +27,10 @@ class _FeedService implements FeedService { String? query, }) async { final _extra = {}; - final queryParameters = {r'query_search': query}; + final queryParameters = { + r'page': page, + r'query_search': query, + }; queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null; @@ -66,6 +69,7 @@ class _FeedService implements FeedService { }) async { final _extra = {}; final queryParameters = { + r'page': page, r'filters[tags][tags.id][$in][]': tags, r'filters[title][$contains]': query, }; @@ -105,7 +109,10 @@ class _FeedService implements FeedService { String? query, }) async { final _extra = {}; - final queryParameters = {r'query_search': query}; + final queryParameters = { + r'page': page, + r'query_search': query, + }; queryParameters.removeWhere((k, v) => v == null); final _headers = {}; const Map? _data = null;