Merge pull request 'refactor in notification and liked tenders page' (#144) from refactor_cod into main

Reviewed-on: https://repo.ravanertebat.com/TM/tm_app/pulls/144
This commit is contained in:
a.ghabeli
2025-09-18 09:07:04 +03:30
7 changed files with 211 additions and 252 deletions
@@ -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/core/utils/size_config.dart';
import 'package:tm_app/data/services/model/tender_approvals_data/tender_approvals_data.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/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/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 '../../../core/utils/app_toast.dart';
import '../../shared/base_button.dart';
import '../../shared/desktop_navigation_widget.dart'; import '../../shared/desktop_navigation_widget.dart';
import '../strings/liked_tenders_strings.dart'; import '../strings/liked_tenders_strings.dart';
@@ -54,46 +55,7 @@ class _LikedTendersDesktopPageState extends State<LikedTendersDesktopPage> {
}, },
child: Scaffold( child: Scaffold(
backgroundColor: AppColors.backgroundColor, backgroundColor: AppColors.backgroundColor,
endDrawer: Drawer( endDrawer: const LikedTendersFilterDrawer(isTablet: false,),
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()),
],
),
),
),
body: Column( body: Column(
children: [ children: [
const DesktopNavigationWidget(currentIndex: 1, haveFilter: true), const DesktopNavigationWidget(currentIndex: 1, haveFilter: true),
@@ -198,35 +160,10 @@ class _LikedTendersDesktopPageState extends State<LikedTendersDesktopPage> {
onTap: () async { onTap: () async {
final selectedPage = await showDialog<int>( final selectedPage = await showDialog<int>(
context: context, context: context,
builder: (context) { builder:
return AlertDialog( (context) => PageSelectionDialog(
backgroundColor: totalPages: totalPages,
AppColors.backgroundColor,
title: const Text(
LikedTendersStrings.selectPage,
), ),
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) { if (selectedPage != null) {
@@ -296,20 +233,3 @@ class _LikedTendersDesktopPageState extends State<LikedTendersDesktopPage> {
); );
} }
} }
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,
),
),
),
);
}
@@ -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/core/utils/size_config.dart';
import 'package:tm_app/view_models/liked_tenders_view_model.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/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/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 'package:tm_app/views/shared/tender_app_bar.dart';
import '../../../core/utils/app_toast.dart'; import '../../../core/utils/app_toast.dart';
@@ -176,66 +177,7 @@ class _LikedTendersTabletPageState extends State<LikedTendersTabletPage> {
), ),
), ),
actions: [ actions: [
IconButton( const LikedTendersFilterDrawer(isTablet: true,),
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,
),
],
),
),
);
},
);
},
),
SizedBox(width: 16.0.w()), SizedBox(width: 16.0.w()),
], ],
), ),
@@ -347,35 +289,10 @@ class _LikedTendersTabletPageState extends State<LikedTendersTabletPage> {
onTap: () async { onTap: () async {
final selectedPage = await showDialog<int>( final selectedPage = await showDialog<int>(
context: context, context: context,
builder: (context) { builder:
return AlertDialog( (context) => PageSelectionDialog(
backgroundColor: totalPages: totalPages,
AppColors.backgroundColor,
title: const Text(
LikedTendersStrings.selectPage,
), ),
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) { if (selectedPage != null) {
@@ -448,19 +365,3 @@ class _LikedTendersTabletPageState extends State<LikedTendersTabletPage> {
} }
} }
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,
),
),
),
);
}
@@ -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,
),
),
),
);
}
}
@@ -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/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.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/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 'package:tm_app/views/shared/desktop_navigation_widget.dart';
import '../../shared/main_tab_bar.dart'; import '../../shared/main_tab_bar.dart';
@@ -106,7 +107,7 @@ class _DesktopNotificationPageState extends State<DesktopNotificationPage>
children: [ children: [
const Spacer(), const Spacer(),
Text( Text(
'page', NotificationStrings.page,
style: TextStyle( style: TextStyle(
fontSize: 13.0.sp(), fontSize: 13.0.sp(),
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
@@ -116,36 +117,16 @@ class _DesktopNotificationPageState extends State<DesktopNotificationPage>
SizedBox(width: 10.0.w()), SizedBox(width: 10.0.w()),
InkWell( InkWell(
onTap: () async { onTap: () async {
final _ = await showDialog<int>( final selectedPage = await showDialog<int>(
context: context, context: context,
builder: (context) { builder:
return AlertDialog( (context) =>
backgroundColor: AppColors.backgroundColor, const PageSelectionDialog(totalPages: 10),
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,
),
);
},
),
),
);
},
); );
if (selectedPage != null) {}
}, },
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
@@ -158,7 +139,7 @@ class _DesktopNotificationPageState extends State<DesktopNotificationPage>
children: [ children: [
SizedBox(width: 5.0.w()), SizedBox(width: 5.0.w()),
Text( Text(
'currentPage', NotificationStrings.currentPage,
style: TextStyle( style: TextStyle(
fontSize: 14.0.sp(), fontSize: 14.0.sp(),
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
@@ -180,7 +161,7 @@ class _DesktopNotificationPageState extends State<DesktopNotificationPage>
), ),
SizedBox(width: 5.0.w()), SizedBox(width: 5.0.w()),
Text( Text(
'of', NotificationStrings.of,
style: TextStyle( style: TextStyle(
fontSize: 14.0.sp(), fontSize: 14.0.sp(),
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
@@ -189,7 +170,7 @@ class _DesktopNotificationPageState extends State<DesktopNotificationPage>
), ),
SizedBox(width: 5.0.w()), SizedBox(width: 5.0.w()),
Text( Text(
'totalPages', NotificationStrings.totalPages,
style: TextStyle( style: TextStyle(
fontSize: 13.0.sp(), fontSize: 13.0.sp(),
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
@@ -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/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.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/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/tablet_navigation_widget.dart';
import 'package:tm_app/views/shared/tender_app_bar.dart'; import 'package:tm_app/views/shared/tender_app_bar.dart';
@@ -105,7 +106,7 @@ class _TabletNotificationPageState extends State<TabletNotificationPage>
children: [ children: [
const Spacer(), const Spacer(),
Text( Text(
'page', NotificationStrings.page,
style: TextStyle( style: TextStyle(
fontSize: 13.0.sp(), fontSize: 13.0.sp(),
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
@@ -115,33 +116,14 @@ class _TabletNotificationPageState extends State<TabletNotificationPage>
SizedBox(width: 10.0.w()), SizedBox(width: 10.0.w()),
InkWell( InkWell(
onTap: () async { onTap: () async {
final _ = await showDialog<int>( final selectedPage = await showDialog<int>(
context: context, context: context,
builder: (context) { builder:
return AlertDialog( (context) =>
backgroundColor: AppColors.backgroundColor, const PageSelectionDialog(totalPages: 10),
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),
);
},
),
),
);
},
); );
if (selectedPage != null) {}
}, },
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -152,7 +134,7 @@ class _TabletNotificationPageState extends State<TabletNotificationPage>
children: [ children: [
SizedBox(width: 5.0.w()), SizedBox(width: 5.0.w()),
Text( Text(
'currentPage', NotificationStrings.currentPage,
style: TextStyle( style: TextStyle(
fontSize: 14.0.sp(), fontSize: 14.0.sp(),
fontWeight: FontWeight.w500, fontWeight: FontWeight.w500,
@@ -174,7 +156,7 @@ class _TabletNotificationPageState extends State<TabletNotificationPage>
), ),
SizedBox(width: 5.0.w()), SizedBox(width: 5.0.w()),
Text( Text(
'of', NotificationStrings.of,
style: TextStyle( style: TextStyle(
fontSize: 14.0.sp(), fontSize: 14.0.sp(),
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
@@ -183,7 +165,7 @@ class _TabletNotificationPageState extends State<TabletNotificationPage>
), ),
SizedBox(width: 5.0.w()), SizedBox(width: 5.0.w()),
Text( Text(
'totalPages', NotificationStrings.totalPages,
style: TextStyle( style: TextStyle(
fontSize: 13.0.sp(), fontSize: 13.0.sp(),
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
@@ -6,4 +6,10 @@ class NotificationStrings {
static const String unread = 'Unread'; static const String unread = 'Unread';
static const String important = 'Important'; static const String important = 'Important';
static const String markAllAsReadButton = 'Mark all as read'; 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';
} }
@@ -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),
);
},
),
),
);
}
}