diff --git a/lib/views/detail/pages/detail_tablet_page.dart b/lib/views/detail/pages/detail_tablet_page.dart index 540b561..e8eef3e 100644 --- a/lib/views/detail/pages/detail_tablet_page.dart +++ b/lib/views/detail/pages/detail_tablet_page.dart @@ -84,6 +84,7 @@ class _TenderDetailTabletPageState extends State { appBar: tabletAppBar( title: TenderDetailsStrings.tenderDetailTitle, key: key, + context: context, ), drawer: const TabletNavigationWidget( diff --git a/lib/views/home/pages/t_home_page.dart b/lib/views/home/pages/t_home_page.dart index 7428020..ea3dcee 100644 --- a/lib/views/home/pages/t_home_page.dart +++ b/lib/views/home/pages/t_home_page.dart @@ -22,7 +22,7 @@ class TabletHomePage extends StatelessWidget { return Scaffold( key: key, - appBar: tabletAppBar(title: HomeStrings.home, key: key), + appBar: tabletAppBar(title: HomeStrings.home, key: key, context: context), drawer: const TabletNavigationWidget( currentIndex: 0, // Home is index 0 diff --git a/lib/views/liked_tenders/pages/liked_tenders_desktop_page.dart b/lib/views/liked_tenders/pages/liked_tenders_desktop_page.dart index 91cbbe8..25ae91a 100644 --- a/lib/views/liked_tenders/pages/liked_tenders_desktop_page.dart +++ b/lib/views/liked_tenders/pages/liked_tenders_desktop_page.dart @@ -88,35 +88,35 @@ class _LikedTendersDesktopPageState extends State { ), ); } - + if (viewModel.errorMessage != null) { return Center(child: Text(viewModel.errorMessage!)); } - + final feedback = viewModel.data?.data?.feedback ?? []; - + if (feedback.isEmpty) { return const Center( child: Text(LikedTendersStrings.noLikedTenders), ); } - + final currentPage = viewModel.currentPage; final totalPages = viewModel.data?.data?.meta?.pages ?? 1; - + return Column( children: [ _likedTendersList(feedback, viewModel), - + SizedBox(height: 10.0.h()), - + _likedTenersListPageControll( context, totalPages, viewModel, currentPage, ), - + SizedBox(height: 30.0.h()), ], ); @@ -154,7 +154,11 @@ class _LikedTendersDesktopPageState extends State { onTap: () async { final selectedPage = await showDialog( context: context, - builder: (context) => PageSelectionDialog(totalPages: totalPages), + builder: + (context) => PageSelectionDialog( + totalPages: totalPages, + currentPage: currentPage, + ), ); if (selectedPage != null) { diff --git a/lib/views/liked_tenders/pages/liked_tenders_tablet_page.dart b/lib/views/liked_tenders/pages/liked_tenders_tablet_page.dart index 180797c..8d932cd 100644 --- a/lib/views/liked_tenders/pages/liked_tenders_tablet_page.dart +++ b/lib/views/liked_tenders/pages/liked_tenders_tablet_page.dart @@ -61,7 +61,11 @@ class _LikedTendersTabletPageState extends State { child: Scaffold( key: key, backgroundColor: AppColors.backgroundColor, - appBar: tabletAppBar(title: LikedTendersStrings.likedTenders, key: key), + appBar: tabletAppBar( + title: LikedTendersStrings.likedTenders, + key: key, + context: context, + ), drawer: const TabletNavigationWidget(currentIndex: 1), body: SafeArea( child: Center( @@ -101,35 +105,36 @@ class _LikedTendersTabletPageState extends State { ), ); } - + if (viewModel.errorMessage != null) { return Center(child: Text(viewModel.errorMessage!)); } - + final feedback = viewModel.data?.data?.feedback ?? []; - + if (feedback.isEmpty) { return const Center( child: Text(LikedTendersStrings.noLikedTenders), ); } - + final currentPage = viewModel.currentPage; - final totalPages = viewModel.data?.data?.meta?.pages ?? 1; - + final totalPages = + viewModel.data?.data?.meta?.pages ?? 1; + return Column( children: [ _likedTendersList(feedback, viewModel), - + SizedBox(height: 10.0.h()), - + _likeTendersListPagesControll( context, totalPages, viewModel, currentPage, ), - + SizedBox(height: 30.0.h()), ], ); @@ -168,7 +173,11 @@ class _LikedTendersTabletPageState extends State { onTap: () async { final selectedPage = await showDialog( context: context, - builder: (context) => PageSelectionDialog(totalPages: totalPages), + builder: + (context) => PageSelectionDialog( + totalPages: totalPages, + currentPage: currentPage, + ), ); if (selectedPage != null) { diff --git a/lib/views/notification/pages/d_notification_page.dart b/lib/views/notification/pages/d_notification_page.dart index 820b0be..17c180e 100644 --- a/lib/views/notification/pages/d_notification_page.dart +++ b/lib/views/notification/pages/d_notification_page.dart @@ -153,6 +153,7 @@ class _DesktopNotificationPageState extends State builder: (context) => PageSelectionDialog( totalPages: totalPages, + currentPage: currentPage, ), ); diff --git a/lib/views/notification/pages/t_notification_page.dart b/lib/views/notification/pages/t_notification_page.dart index 9913608..f02f58f 100644 --- a/lib/views/notification/pages/t_notification_page.dart +++ b/lib/views/notification/pages/t_notification_page.dart @@ -68,6 +68,7 @@ class _TabletNotificationPageState extends State appBar: tabletAppBar( title: NotificationStrings.notificationTitle, key: key, + context: context, ), drawer: const TabletNavigationWidget(currentIndex: 3), body: Center( @@ -151,8 +152,10 @@ class _TabletNotificationPageState extends State final selectedPage = await showDialog( context: context, builder: - (context) => - PageSelectionDialog(totalPages: totalPages), + (context) => PageSelectionDialog( + totalPages: totalPages, + currentPage: currentPage, + ), ); if (selectedPage != null) { diff --git a/lib/views/notification/strings/notification_strings.dart b/lib/views/notification/strings/notification_strings.dart index 93c0329..727e90f 100644 --- a/lib/views/notification/strings/notification_strings.dart +++ b/lib/views/notification/strings/notification_strings.dart @@ -7,7 +7,7 @@ class NotificationStrings { static const String important = 'Important'; static const String markAllAsReadButton = 'Mark all as read'; static const String page = 'page'; - static const String selectPage = 'selectPage'; + static const String selectPage = 'Select Page'; static const String currentPage = 'currentPage'; static const String of = 'of'; static const String totalPages = 'totalPages'; diff --git a/lib/views/profile/pages/t_profile_page.dart b/lib/views/profile/pages/t_profile_page.dart index c393c24..7ac20b3 100644 --- a/lib/views/profile/pages/t_profile_page.dart +++ b/lib/views/profile/pages/t_profile_page.dart @@ -67,8 +67,12 @@ class _TabletProfilePageState extends State { return Scaffold( key: key, backgroundColor: AppColors.backgroundColor, - appBar: tabletAppBar(title: ProfileStrings.profileTitle, key: key), - + appBar: tabletAppBar( + title: ProfileStrings.profileTitle, + key: key, + context: context, + ), + drawer: const TabletNavigationWidget(currentIndex: 4), body: SafeArea( child: Padding( diff --git a/lib/views/shared/desktop_navigation_widget.dart b/lib/views/shared/desktop_navigation_widget.dart index 3bb459b..7b57ebf 100644 --- a/lib/views/shared/desktop_navigation_widget.dart +++ b/lib/views/shared/desktop_navigation_widget.dart @@ -75,9 +75,10 @@ class DesktopNavigationWidget extends StatelessWidget { text: TendersStrings.tendersTitle, isActive: currentIndex == 1, onTap: () { - if (currentIndex == 1) { - return; - } else { + // if (currentIndex == 1) { + // return; + // } else + { Router.neglect( context, () => const TendersRouteData().go(context), diff --git a/lib/views/shared/page_selection_dialog.dart b/lib/views/shared/page_selection_dialog.dart index cc194bf..54006d1 100644 --- a/lib/views/shared/page_selection_dialog.dart +++ b/lib/views/shared/page_selection_dialog.dart @@ -1,29 +1,82 @@ import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; import 'package:tm_app/core/theme/colors.dart'; +import 'package:tm_app/core/utils/size_config.dart'; import 'package:tm_app/views/notification/strings/notification_strings.dart'; -class PageSelectionDialog extends StatelessWidget { +class PageSelectionDialog extends StatefulWidget { final int totalPages; + final int currentPage; const PageSelectionDialog({ - required this.totalPages, super.key, + required this.totalPages, + required this.currentPage, + super.key, }); + @override + State createState() => _PageSelectionDialogState(); +} + +class _PageSelectionDialogState extends State { + late int selectedPage; + + @override + void initState() { + super.initState(); + selectedPage = widget.currentPage; + } + @override Widget build(BuildContext context) { return AlertDialog( backgroundColor: AppColors.backgroundColor, - title: const Text(NotificationStrings.selectPage), + insetPadding: EdgeInsets.symmetric( + horizontal: 16.0.w(), + vertical: 16.0.h(), + ), + title: Text( + '${NotificationStrings.selectPage} (Current: ${widget.currentPage})', + style: TextStyle( + fontSize: 16.0.sp(), + fontWeight: FontWeight.w500, + color: AppColors.grey80, + ), + ), content: SizedBox( width: 200, height: 300, child: ListView.builder( - itemCount: totalPages, + itemCount: widget.totalPages, itemBuilder: (context, index) { final pageNumber = index + 1; + return ListTile( - title: Text('$pageNumber'), - onTap: () => Navigator.pop(context, pageNumber), + leading: Radio( + value: pageNumber, + groupValue: selectedPage, + activeColor: AppColors.mainBlue, + onChanged: (value) { + setState(() { + selectedPage = value!; + }); + context.pop(value); + }, + ), + title: Text( + '$pageNumber', + style: TextStyle( + fontSize: 16.0.sp(), + fontWeight: FontWeight.w500, + color: AppColors.grey80, + ), + ), + onTap: () { + setState(() { + selectedPage = pageNumber; + }); + context.pop(pageNumber); + }, ); }, ), diff --git a/lib/views/shared/tender_app_bar.dart b/lib/views/shared/tender_app_bar.dart index 13893c7..03ecaa4 100644 --- a/lib/views/shared/tender_app_bar.dart +++ b/lib/views/shared/tender_app_bar.dart @@ -1,9 +1,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; +import 'package:provider/provider.dart'; import 'package:tm_app/core/constants/assets.dart'; import 'package:tm_app/core/theme/colors.dart'; import 'package:tm_app/core/utils/size_config.dart'; +import '../../core/routes/app_routes.dart'; +import '../../view_models/home_view_model.dart'; + PreferredSizeWidget tenderMobileAppBar({required String title}) { return PreferredSize( preferredSize: const Size.fromHeight(56), @@ -65,6 +69,7 @@ PreferredSizeWidget appBar({ PreferredSizeWidget tabletAppBar({ required String title, required GlobalKey key, + required BuildContext context, }) { return PreferredSize( preferredSize: const Size.fromHeight(64), @@ -75,7 +80,17 @@ PreferredSizeWidget tabletAppBar({ titleSpacing: 0, leading: Padding( padding: EdgeInsetsDirectional.only(start: 24.0.w()), - child: SvgPicture.asset(AssetsManager.logoSmall), + child: InkWell( + splashColor: Colors.transparent, + + highlightColor: AppColors.green0, + borderRadius: BorderRadius.circular(50), + onTap: () { + Router.neglect(context, () => const HomeRouteData().go(context)); + context.read().init(); + }, + child: SvgPicture.asset(AssetsManager.logoSmall), + ), ), actions: [ IconButton( diff --git a/lib/views/tenders/pages/d_tenders_page.dart b/lib/views/tenders/pages/d_tenders_page.dart index 30664a7..49d2b22 100644 --- a/lib/views/tenders/pages/d_tenders_page.dart +++ b/lib/views/tenders/pages/d_tenders_page.dart @@ -282,7 +282,10 @@ class _DesktopPagination extends StatelessWidget { final selectedPage = await showDialog( context: context, builder: - (context) => PageSelectionDialog(totalPages: totalPages), + (context) => PageSelectionDialog( + totalPages: totalPages, + currentPage: currentPage, + ), ); if (selectedPage != null) { onPageSelected(selectedPage); diff --git a/lib/views/tenders/pages/t_tenders_page.dart b/lib/views/tenders/pages/t_tenders_page.dart index 88e0e8f..e3b38de 100644 --- a/lib/views/tenders/pages/t_tenders_page.dart +++ b/lib/views/tenders/pages/t_tenders_page.dart @@ -32,7 +32,11 @@ class _TabletTendersPageState extends State { return Scaffold( key: key, backgroundColor: AppColors.backgroundColor, - appBar: tabletAppBar(title: TendersStrings.tendersTitle, key: key), + appBar: tabletAppBar( + title: TendersStrings.tendersTitle, + key: key, + context: context, + ), drawer: const TabletNavigationWidget(currentIndex: 1), body: Consumer( builder: (context, viewModel, child) { diff --git a/lib/views/your_tenders/pages/your_tenders_tablet_page.dart b/lib/views/your_tenders/pages/your_tenders_tablet_page.dart index c40010c..d6f4f99 100644 --- a/lib/views/your_tenders/pages/your_tenders_tablet_page.dart +++ b/lib/views/your_tenders/pages/your_tenders_tablet_page.dart @@ -42,7 +42,11 @@ class _YourTendersTabletPageState extends State return Scaffold( key: key, backgroundColor: AppColors.backgroundColor, - appBar: tabletAppBar(title: YourTendersStrings.yourTenders, key: key), + appBar: tabletAppBar( + title: YourTendersStrings.yourTenders, + key: key, + context: context, + ), drawer: const TabletNavigationWidget(currentIndex: 1), body: SafeArea( child: Center( @@ -59,7 +63,7 @@ class _YourTendersTabletPageState extends State ), SizedBox(height: 24.0.h()), const FilterButton(platformType: PlatformType.tabletDesktop), - + Expanded( child: Consumer( builder: (context, viewModel, child) { @@ -72,13 +76,13 @@ class _YourTendersTabletPageState extends State ), ); } - + if (viewModel.errorMessage != null) { return Center(child: Text(viewModel.errorMessage!)); } - + Widget content; - + if (viewModel.selectedStatus == YourTendersStrings.likeTenders && viewModel.likedTendersData != null) { @@ -108,14 +112,14 @@ class _YourTendersTabletPageState extends State child: Text(YourTendersStrings.noTenders), ); } - + return Column( children: [ Expanded(child: content), SizedBox(height: 10.0.h()), - + _listPagesControll(context, viewModel), - + const SizedBox(height: 30.0), ], );