From eb4df7f6dadc86607e27643f05db26e599d01c34 Mon Sep 17 00:00:00 2001 From: llsajjad Date: Thu, 18 Sep 2025 09:04:24 +0330 Subject: [PATCH] refactor in notification and liked tenders page --- .../pages/liked_tenders_desktop_page.dart | 94 +----------- .../pages/liked_tenders_tablet_page.dart | 111 +------------- .../widgets/liked_tenders_filter_drawer.dart | 136 ++++++++++++++++++ .../pages/d_notification_page.dart | 43 ++---- .../pages/t_notification_page.dart | 40 ++---- .../strings/notification_strings.dart | 6 + lib/views/shared/page_selection_dialog.dart | 33 +++++ 7 files changed, 211 insertions(+), 252 deletions(-) create mode 100644 lib/views/liked_tenders/widgets/liked_tenders_filter_drawer.dart create mode 100644 lib/views/shared/page_selection_dialog.dart 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 172d724..92f83e6 100644 --- a/lib/views/liked_tenders/pages/liked_tenders_desktop_page.dart +++ b/lib/views/liked_tenders/pages/liked_tenders_desktop_page.dart @@ -6,10 +6,11 @@ import 'package:tm_app/core/theme/colors.dart'; import 'package:tm_app/core/utils/size_config.dart'; import 'package:tm_app/data/services/model/tender_approvals_data/tender_approvals_data.dart'; import 'package:tm_app/view_models/liked_tenders_view_model.dart'; +import 'package:tm_app/views/liked_tenders/widgets/liked_tenders_filter_drawer.dart'; import 'package:tm_app/views/liked_tenders/widgets/liked_tenders_list_item.dart'; +import 'package:tm_app/views/shared/page_selection_dialog.dart'; import '../../../core/utils/app_toast.dart'; -import '../../shared/base_button.dart'; import '../../shared/desktop_navigation_widget.dart'; import '../strings/liked_tenders_strings.dart'; @@ -54,46 +55,7 @@ class _LikedTendersDesktopPageState extends State { }, child: Scaffold( backgroundColor: AppColors.backgroundColor, - endDrawer: Drawer( - backgroundColor: AppColors.backgroundColor, - - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox(height: 30.0.h()), - Text( - LikedTendersStrings.filter, - style: TextStyle( - fontWeight: FontWeight.w600, - color: AppColors.grey70, - fontSize: 20.0.sp(), - ), - ), - SizedBox(height: 20.0.h()), - _buildFilterOption('Industry'), - _buildFilterOption('Finance'), - _buildFilterOption('Business'), - _buildFilterOption('IT'), - _buildFilterOption('Software'), - const Spacer(), - BaseButton( - backgroundColor: AppColors.primary2, - borderRadius: 24, - isEnabled: true, - onPressed: () { - Navigator.pop(context); - }, - text: LikedTendersStrings.apply, - textColor: AppColors.textBlue, - ), - SizedBox(height: 20.0.h()), - ], - ), - ), - ), - + endDrawer: const LikedTendersFilterDrawer(isTablet: false,), body: Column( children: [ const DesktopNavigationWidget(currentIndex: 1, haveFilter: true), @@ -198,35 +160,10 @@ class _LikedTendersDesktopPageState extends State { onTap: () async { final selectedPage = await showDialog( context: context, - builder: (context) { - return AlertDialog( - backgroundColor: - AppColors.backgroundColor, - title: const Text( - LikedTendersStrings.selectPage, + builder: + (context) => PageSelectionDialog( + totalPages: totalPages, ), - content: SizedBox( - width: 200, - height: 300, - child: ListView.builder( - itemCount: totalPages, - itemBuilder: (context, index) { - final pageNumber = index + 1; - return ListTile( - title: Text( - '${LikedTendersStrings.page} $pageNumber', - ), - onTap: - () => Navigator.pop( - context, - pageNumber, - ), - ); - }, - ), - ), - ); - }, ); if (selectedPage != null) { @@ -295,21 +232,4 @@ class _LikedTendersDesktopPageState extends State { ), ); } -} - -Widget _buildFilterOption(String title) { - return Padding( - padding: EdgeInsets.symmetric(vertical: 8.0.h()), - child: Align( - alignment: Alignment.centerLeft, - child: Text( - title, - style: TextStyle( - fontSize: 16.0.sp(), - color: AppColors.grey80, - fontWeight: FontWeight.w400, - ), - ), - ), - ); -} +} \ No newline at end of file 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 fd61c08..8396e83 100644 --- a/lib/views/liked_tenders/pages/liked_tenders_tablet_page.dart +++ b/lib/views/liked_tenders/pages/liked_tenders_tablet_page.dart @@ -7,8 +7,9 @@ import 'package:tm_app/core/theme/colors.dart'; import 'package:tm_app/core/utils/size_config.dart'; import 'package:tm_app/view_models/liked_tenders_view_model.dart'; import 'package:tm_app/views/liked_tenders/strings/liked_tenders_strings.dart'; +import 'package:tm_app/views/liked_tenders/widgets/liked_tenders_filter_drawer.dart'; import 'package:tm_app/views/liked_tenders/widgets/liked_tenders_list_item.dart'; -import 'package:tm_app/views/shared/base_button.dart'; +import 'package:tm_app/views/shared/page_selection_dialog.dart'; import 'package:tm_app/views/shared/tender_app_bar.dart'; import '../../../core/utils/app_toast.dart'; @@ -176,66 +177,7 @@ class _LikedTendersTabletPageState extends State { ), ), actions: [ - IconButton( - icon: SvgPicture.asset( - AssetsManager.filter, - height: 24.0.w(), - width: 24.0.w(), - ), - onPressed: () { - showModalBottomSheet( - context: context, - isScrollControlled: true, - backgroundColor: AppColors.backgroundColor, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical( - top: Radius.circular(20), - ), - ), - constraints: BoxConstraints( - maxWidth: MediaQuery.of(context).size.width, - maxHeight: MediaQuery.of(context).size.height, - ), - builder: (context) { - return SizedBox( - width: double.infinity, - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - SizedBox(height: 10.0.h()), - Text( - LikedTendersStrings.filter, - style: TextStyle( - fontWeight: FontWeight.w600, - color: AppColors.grey70, - fontSize: 20.0.sp(), - ), - ), - SizedBox(height: 20.0.h()), - _buildFilterOption('Industry'), - _buildFilterOption('Finance'), - _buildFilterOption('Business'), - _buildFilterOption('IT'), - _buildFilterOption('Software'), - SizedBox(height: 20.0.h()), - BaseButton( - backgroundColor: AppColors.primary2, - borderRadius: 24, - isEnabled: true, - onPressed: () => Navigator.pop(context), - text: 'Apply', - textColor: AppColors.textBlue, - ), - ], - ), - ), - ); - }, - ); - }, - ), + const LikedTendersFilterDrawer(isTablet: true,), SizedBox(width: 16.0.w()), ], ), @@ -347,35 +289,10 @@ class _LikedTendersTabletPageState extends State { onTap: () async { final selectedPage = await showDialog( context: context, - builder: (context) { - return AlertDialog( - backgroundColor: - AppColors.backgroundColor, - title: const Text( - LikedTendersStrings.selectPage, + builder: + (context) => PageSelectionDialog( + totalPages: totalPages, ), - content: SizedBox( - width: 200, - height: 300, - child: ListView.builder( - itemCount: totalPages, - itemBuilder: (context, index) { - final pageNumber = index + 1; - return ListTile( - title: Text( - '${LikedTendersStrings.page} $pageNumber', - ), - onTap: - () => Navigator.pop( - context, - pageNumber, - ), - ); - }, - ), - ), - ); - }, ); if (selectedPage != null) { @@ -448,19 +365,3 @@ class _LikedTendersTabletPageState extends State { } } -Widget _buildFilterOption(String title) { - return Padding( - padding: EdgeInsets.symmetric(vertical: 8.0.h()), - child: Align( - alignment: Alignment.centerLeft, - child: Text( - title, - style: TextStyle( - fontSize: 16.0.sp(), - color: AppColors.grey80, - fontWeight: FontWeight.w400, - ), - ), - ), - ); -} diff --git a/lib/views/liked_tenders/widgets/liked_tenders_filter_drawer.dart b/lib/views/liked_tenders/widgets/liked_tenders_filter_drawer.dart new file mode 100644 index 0000000..ba16e3c --- /dev/null +++ b/lib/views/liked_tenders/widgets/liked_tenders_filter_drawer.dart @@ -0,0 +1,136 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_svg/svg.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 'package:tm_app/views/liked_tenders/strings/liked_tenders_strings.dart'; + +import '../../shared/base_button.dart'; + +class LikedTendersFilterDrawer extends StatelessWidget { + const LikedTendersFilterDrawer({required this.isTablet, super.key}); + + final bool isTablet; + + @override + Widget build(BuildContext context) { + return isTablet + ? IconButton( + icon: SvgPicture.asset( + AssetsManager.filter, + height: 24.0.w(), + width: 24.0.w(), + ), + onPressed: () { + showModalBottomSheet( + context: context, + isScrollControlled: true, + backgroundColor: AppColors.backgroundColor, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(20)), + ), + constraints: BoxConstraints( + maxWidth: MediaQuery.of(context).size.width, + maxHeight: MediaQuery.of(context).size.height, + ), + builder: (context) { + return SizedBox( + width: double.infinity, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + SizedBox(height: 10.0.h()), + Text( + LikedTendersStrings.filter, + style: TextStyle( + fontWeight: FontWeight.w600, + color: AppColors.grey70, + fontSize: 20.0.sp(), + ), + ), + SizedBox(height: 20.0.h()), + _buildFilterOption('Industry'), + _buildFilterOption('Finance'), + _buildFilterOption('Business'), + _buildFilterOption('IT'), + _buildFilterOption('Software'), + SizedBox(height: 20.0.h()), + BaseButton( + backgroundColor: AppColors.primary2, + borderRadius: 24, + isEnabled: true, + onPressed: () => Navigator.pop(context), + text: 'Apply', + textColor: AppColors.textBlue, + ), + ], + ), + ), + ); + }, + ); + }, + ) + : Drawer( + backgroundColor: AppColors.backgroundColor, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: 30.0.h()), + Text( + LikedTendersStrings.filter, + style: TextStyle( + fontWeight: FontWeight.w600, + color: AppColors.grey70, + fontSize: 20.0.sp(), + ), + ), + SizedBox(height: 20.0.h()), + + _buildFilterOption('Industry'), + _buildFilterOption('Finance'), + _buildFilterOption('Business'), + _buildFilterOption('IT'), + _buildFilterOption('Software'), + + const Spacer(), + + BaseButton( + backgroundColor: AppColors.primary2, + borderRadius: 24, + isEnabled: true, + onPressed: () { + Navigator.pop(context); + }, + text: LikedTendersStrings.apply, + textColor: AppColors.textBlue, + ), + + SizedBox(height: 20.0.h()), + ], + ), + ), + ); + } + + Widget _buildFilterOption(String title) { + return Padding( + padding: EdgeInsets.symmetric(vertical: 8.0.h()), + child: Align( + alignment: Alignment.centerLeft, + child: Text( + title, + style: TextStyle( + fontSize: 16.0.sp(), + color: AppColors.grey80, + fontWeight: FontWeight.w400, + ), + ), + ), + ); + } +} diff --git a/lib/views/notification/pages/d_notification_page.dart b/lib/views/notification/pages/d_notification_page.dart index 5d00836..e05ff43 100644 --- a/lib/views/notification/pages/d_notification_page.dart +++ b/lib/views/notification/pages/d_notification_page.dart @@ -4,6 +4,7 @@ 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 'package:tm_app/views/notification/strings/notification_strings.dart'; +import 'package:tm_app/views/shared/page_selection_dialog.dart'; import 'package:tm_app/views/shared/desktop_navigation_widget.dart'; import '../../shared/main_tab_bar.dart'; @@ -106,7 +107,7 @@ class _DesktopNotificationPageState extends State children: [ const Spacer(), Text( - 'page', + NotificationStrings.page, style: TextStyle( fontSize: 13.0.sp(), fontWeight: FontWeight.w300, @@ -116,36 +117,16 @@ class _DesktopNotificationPageState extends State SizedBox(width: 10.0.w()), InkWell( onTap: () async { - final _ = await showDialog( + final selectedPage = await showDialog( context: context, - builder: (context) { - return AlertDialog( - backgroundColor: AppColors.backgroundColor, - title: const Text('selectPage'), - content: SizedBox( - width: 200, - height: 300, - child: ListView.builder( - itemCount: 1, - itemBuilder: (context, index) { - final pageNumber = index + 1; - return ListTile( - title: Text( - '{LikedTendersStrings.page} $pageNumber', - ), - onTap: - () => Navigator.pop( - context, - pageNumber, - ), - ); - }, - ), - ), - ); - }, + builder: + (context) => + const PageSelectionDialog(totalPages: 10), ); + + if (selectedPage != null) {} }, + child: Container( decoration: BoxDecoration( border: Border.all( @@ -158,7 +139,7 @@ class _DesktopNotificationPageState extends State children: [ SizedBox(width: 5.0.w()), Text( - 'currentPage', + NotificationStrings.currentPage, style: TextStyle( fontSize: 14.0.sp(), fontWeight: FontWeight.w500, @@ -180,7 +161,7 @@ class _DesktopNotificationPageState extends State ), SizedBox(width: 5.0.w()), Text( - 'of', + NotificationStrings.of, style: TextStyle( fontSize: 14.0.sp(), fontWeight: FontWeight.w400, @@ -189,7 +170,7 @@ class _DesktopNotificationPageState extends State ), SizedBox(width: 5.0.w()), Text( - 'totalPages', + NotificationStrings.totalPages, style: TextStyle( fontSize: 13.0.sp(), fontWeight: FontWeight.w400, diff --git a/lib/views/notification/pages/t_notification_page.dart b/lib/views/notification/pages/t_notification_page.dart index 4457363..09185b7 100644 --- a/lib/views/notification/pages/t_notification_page.dart +++ b/lib/views/notification/pages/t_notification_page.dart @@ -4,6 +4,7 @@ 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 'package:tm_app/views/notification/strings/notification_strings.dart'; +import 'package:tm_app/views/shared/page_selection_dialog.dart'; import 'package:tm_app/views/shared/tablet_navigation_widget.dart'; import 'package:tm_app/views/shared/tender_app_bar.dart'; @@ -105,7 +106,7 @@ class _TabletNotificationPageState extends State children: [ const Spacer(), Text( - 'page', + NotificationStrings.page, style: TextStyle( fontSize: 13.0.sp(), fontWeight: FontWeight.w300, @@ -115,33 +116,14 @@ class _TabletNotificationPageState extends State SizedBox(width: 10.0.w()), InkWell( onTap: () async { - final _ = await showDialog( + final selectedPage = await showDialog( context: context, - builder: (context) { - return AlertDialog( - backgroundColor: AppColors.backgroundColor, - title: const Text('selectPage'), - content: SizedBox( - width: 200, - height: 300, - child: ListView.builder( - itemCount: 1, - itemBuilder: (context, index) { - final pageNumber = index + 1; - return ListTile( - title: Text( - '{LikedTendersStrings.page} $pageNumber', - ), - onTap: - () => - Navigator.pop(context, pageNumber), - ); - }, - ), - ), - ); - }, + builder: + (context) => + const PageSelectionDialog(totalPages: 10), ); + + if (selectedPage != null) {} }, child: Container( decoration: BoxDecoration( @@ -152,7 +134,7 @@ class _TabletNotificationPageState extends State children: [ SizedBox(width: 5.0.w()), Text( - 'currentPage', + NotificationStrings.currentPage, style: TextStyle( fontSize: 14.0.sp(), fontWeight: FontWeight.w500, @@ -174,7 +156,7 @@ class _TabletNotificationPageState extends State ), SizedBox(width: 5.0.w()), Text( - 'of', + NotificationStrings.of, style: TextStyle( fontSize: 14.0.sp(), fontWeight: FontWeight.w400, @@ -183,7 +165,7 @@ class _TabletNotificationPageState extends State ), SizedBox(width: 5.0.w()), Text( - 'totalPages', + NotificationStrings.totalPages, style: TextStyle( fontSize: 13.0.sp(), fontWeight: FontWeight.w400, diff --git a/lib/views/notification/strings/notification_strings.dart b/lib/views/notification/strings/notification_strings.dart index 811fe99..2fd9c3e 100644 --- a/lib/views/notification/strings/notification_strings.dart +++ b/lib/views/notification/strings/notification_strings.dart @@ -6,4 +6,10 @@ class NotificationStrings { static const String unread = 'Unread'; 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 currentPage = 'currentPage'; + static const String of = 'of'; + static const String totalPages = 'totalPages'; + } diff --git a/lib/views/shared/page_selection_dialog.dart b/lib/views/shared/page_selection_dialog.dart new file mode 100644 index 0000000..cc194bf --- /dev/null +++ b/lib/views/shared/page_selection_dialog.dart @@ -0,0 +1,33 @@ +import 'package:flutter/material.dart'; +import 'package:tm_app/core/theme/colors.dart'; +import 'package:tm_app/views/notification/strings/notification_strings.dart'; + +class PageSelectionDialog extends StatelessWidget { + final int totalPages; + + const PageSelectionDialog({ + required this.totalPages, super.key, + }); + + @override + Widget build(BuildContext context) { + return AlertDialog( + backgroundColor: AppColors.backgroundColor, + title: const Text(NotificationStrings.selectPage), + content: SizedBox( + width: 200, + height: 300, + child: ListView.builder( + itemCount: totalPages, + itemBuilder: (context, index) { + final pageNumber = index + 1; + return ListTile( + title: Text('$pageNumber'), + onTap: () => Navigator.pop(context, pageNumber), + ); + }, + ), + ), + ); + } +}