refactors on codes
This commit is contained in:
@@ -4,15 +4,17 @@ 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 'package:tm_app/data/services/model/liked_tender_feedback/liked_tender_feedback.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/desktop_navigation_widget.dart';
|
||||
import '../../shared/tablet_desktop_appbar.dart';
|
||||
import '../strings/liked_tenders_strings.dart';
|
||||
import '../widgets/like_filters_drawer.dart';
|
||||
|
||||
class LikedTendersDesktopPage extends StatefulWidget {
|
||||
const LikedTendersDesktopPage({super.key});
|
||||
@@ -24,6 +26,7 @@ class LikedTendersDesktopPage extends StatefulWidget {
|
||||
|
||||
class _LikedTendersDesktopPageState extends State<LikedTendersDesktopPage> {
|
||||
late final LikedTendersViewModel viewModel;
|
||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
||||
@override
|
||||
void initState() {
|
||||
viewModel = context.read<LikedTendersViewModel>();
|
||||
@@ -54,11 +57,24 @@ class _LikedTendersDesktopPageState extends State<LikedTendersDesktopPage> {
|
||||
});
|
||||
},
|
||||
child: Scaffold(
|
||||
key: scaffoldKey,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
endDrawer: const LikedTendersFilterDrawer(isTablet: false,),
|
||||
endDrawer: const LikeFiltersDrawer(),
|
||||
body: Column(
|
||||
children: [
|
||||
const DesktopNavigationWidget(currentIndex: 1, haveFilter: true),
|
||||
const SizedBox(height: 40),
|
||||
SizedBox(
|
||||
width: 740,
|
||||
child: TabletDesktopAppbar(
|
||||
title: LikedTendersStrings.likedTenders,
|
||||
haveFilter: true,
|
||||
onFilterPressed: () {
|
||||
scaffoldKey.currentState?.openEndDrawer();
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
width: 740,
|
||||
@@ -90,134 +106,15 @@ class _LikedTendersDesktopPageState extends State<LikedTendersDesktopPage> {
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.0.w(),
|
||||
vertical: 15.0.h(),
|
||||
),
|
||||
itemCount: feedback.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = feedback[index];
|
||||
TenderApprovalsData? approval;
|
||||
bool hasApproval = viewModel
|
||||
.hasTenderApprovalForTender(item.tenderId!);
|
||||
if (hasApproval) {
|
||||
approval = viewModel.getApprovalStatusForTender(
|
||||
item.tenderId!,
|
||||
);
|
||||
} else {
|
||||
approval = null;
|
||||
}
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: 20.0.h()),
|
||||
child: Dismissible(
|
||||
key: ValueKey(item.tenderId ?? index),
|
||||
direction: DismissDirection.endToStart,
|
||||
background: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 20.0.w(),
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
AssetsManager.trash,
|
||||
),
|
||||
),
|
||||
onDismissed: (_) {
|
||||
if (item.tenderId != null) {
|
||||
viewModel.removeTenderById(
|
||||
item.tenderId!,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: LikedListItem(
|
||||
tender: item.tender!,
|
||||
approval: approval,
|
||||
isDesktop: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
_likedTendersList(feedback, viewModel),
|
||||
|
||||
SizedBox(height: 10.0.h()),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
LikedTendersStrings.page,
|
||||
style: TextStyle(
|
||||
fontSize: 13.0.sp(),
|
||||
fontWeight: FontWeight.w300,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10.0.w()),
|
||||
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
final selectedPage = await showDialog<int>(
|
||||
context: context,
|
||||
builder:
|
||||
(context) => PageSelectionDialog(
|
||||
totalPages: totalPages,
|
||||
),
|
||||
);
|
||||
|
||||
if (selectedPage != null) {
|
||||
await viewModel.jumpToPage(selectedPage);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: AppColors.grey30,
|
||||
width: 1,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
'$currentPage',
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.grey70,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
SvgPicture.asset(
|
||||
AssetsManager.arrowDownSmall,
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
LikedTendersStrings.of,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
'$totalPages',
|
||||
style: TextStyle(
|
||||
fontSize: 13.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
],
|
||||
_likedTenersListPageControll(
|
||||
context,
|
||||
totalPages,
|
||||
viewModel,
|
||||
currentPage,
|
||||
),
|
||||
|
||||
SizedBox(height: 30.0.h()),
|
||||
@@ -232,4 +129,126 @@ class _LikedTendersDesktopPageState extends State<LikedTendersDesktopPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _likedTenersListPageControll(
|
||||
BuildContext context,
|
||||
int totalPages,
|
||||
LikedTendersViewModel viewModel,
|
||||
int currentPage,
|
||||
) {
|
||||
return Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
LikedTendersStrings.page,
|
||||
style: TextStyle(
|
||||
fontSize: 13.0.sp(),
|
||||
fontWeight: FontWeight.w300,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10.0.w()),
|
||||
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
final selectedPage = await showDialog<int>(
|
||||
context: context,
|
||||
builder: (context) => PageSelectionDialog(totalPages: totalPages),
|
||||
);
|
||||
|
||||
if (selectedPage != null) {
|
||||
await viewModel.jumpToPage(selectedPage);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AppColors.grey30, width: 1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
'$currentPage',
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.grey70,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
SvgPicture.asset(AssetsManager.arrowDownSmall),
|
||||
SizedBox(width: 5.0.w()),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
LikedTendersStrings.of,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
'$totalPages',
|
||||
style: TextStyle(
|
||||
fontSize: 13.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _likedTendersList(
|
||||
List<LikedTenderFeedback> feedback,
|
||||
LikedTendersViewModel viewModel,
|
||||
) {
|
||||
return Expanded(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(vertical: 15.0.h()),
|
||||
itemCount: feedback.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = feedback[index];
|
||||
TenderApprovalsData? approval;
|
||||
bool hasApproval = viewModel.hasTenderApprovalForTender(
|
||||
item.tenderId!,
|
||||
);
|
||||
if (hasApproval) {
|
||||
approval = viewModel.getApprovalStatusForTender(item.tenderId!);
|
||||
} else {
|
||||
approval = null;
|
||||
}
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: 20.0.h()),
|
||||
child: Dismissible(
|
||||
key: ValueKey(item.tenderId ?? index),
|
||||
direction: DismissDirection.endToStart,
|
||||
background: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
padding: EdgeInsets.symmetric(horizontal: 20.0.w()),
|
||||
child: SvgPicture.asset(AssetsManager.trash),
|
||||
),
|
||||
onDismissed: (_) {
|
||||
if (item.tenderId != null) {
|
||||
viewModel.removeTenderById(item.tenderId!);
|
||||
}
|
||||
},
|
||||
child: LikedListItem(
|
||||
tender: item.tender!,
|
||||
approval: approval,
|
||||
isDesktop: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,18 @@ 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 'package:tm_app/data/services/model/liked_tender_feedback/liked_tender_feedback.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/page_selection_dialog.dart';
|
||||
import 'package:tm_app/views/shared/tender_app_bar.dart';
|
||||
|
||||
import '../../../core/utils/app_toast.dart';
|
||||
import '../../../data/services/model/tender_approvals_data/tender_approvals_data.dart';
|
||||
import '../../shared/tablet_desktop_appbar.dart';
|
||||
import '../../shared/tablet_navigation_widget.dart';
|
||||
import '../widgets/like_filters_bottom_sheet.dart';
|
||||
|
||||
class LikedTendersTabletPage extends StatefulWidget {
|
||||
const LikedTendersTabletPage({super.key});
|
||||
@@ -60,126 +62,33 @@ class _LikedTendersTabletPageState extends State<LikedTendersTabletPage> {
|
||||
child: Scaffold(
|
||||
key: key,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
appBar:
|
||||
// PreferredSize(
|
||||
// preferredSize: const Size.fromHeight(60),
|
||||
// child: AppBar(
|
||||
// backgroundColor: AppColors.backgroundColor,
|
||||
// elevation: 0,
|
||||
// titleSpacing: 0,
|
||||
// leading: IconButton(
|
||||
// icon: SvgPicture.asset(
|
||||
// AssetsManager.arrowLeft,
|
||||
// height: 24.0.w(),
|
||||
// width: 24.0.w(),
|
||||
// ),
|
||||
// onPressed: () => Navigator.pop(context),
|
||||
// ),
|
||||
// title: Text(
|
||||
// LikedTendersStrings.likedTenders,
|
||||
// style: TextStyle(
|
||||
// color: AppColors.grey70,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// fontSize: 20.0.sp(),
|
||||
// ),
|
||||
// ),
|
||||
// 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,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// SizedBox(width: 16.0.w()),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
tabletAppBar(title: LikedTendersStrings.likedTenders, key: key),
|
||||
appBar: tabletAppBar(title: LikedTendersStrings.likedTenders, key: key),
|
||||
drawer: const TabletNavigationWidget(currentIndex: 1),
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 720,
|
||||
child: Column(
|
||||
children: [
|
||||
AppBar(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
elevation: 0,
|
||||
titleSpacing: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
leading: IconButton(
|
||||
icon: SvgPicture.asset(
|
||||
AssetsManager.arrowLeft,
|
||||
height: 24.0.w(),
|
||||
width: 24.0.w(),
|
||||
),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
title: Text(
|
||||
LikedTendersStrings.likedTenders,
|
||||
style: TextStyle(
|
||||
color: AppColors.grey70,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 20.0.sp(),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
const LikedTendersFilterDrawer(isTablet: true,),
|
||||
SizedBox(width: 16.0.w()),
|
||||
],
|
||||
TabletDesktopAppbar(
|
||||
title: LikedTendersStrings.likedTenders,
|
||||
haveFilter: true,
|
||||
onFilterPressed: () {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(20),
|
||||
),
|
||||
),
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: MediaQuery.sizeOf(context).width,
|
||||
maxHeight: MediaQuery.sizeOf(context).height,
|
||||
),
|
||||
builder: (context) => const LikeFiltersBottomSheet(),
|
||||
);
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: Consumer<LikedTendersViewModel>(
|
||||
@@ -210,144 +119,15 @@ class _LikedTendersTabletPageState extends State<LikedTendersTabletPage> {
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await viewModel.getLikedTenders(reset: true);
|
||||
},
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.0.w(),
|
||||
vertical: 15.0.h(),
|
||||
),
|
||||
itemCount: feedback.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = feedback[index];
|
||||
TenderApprovalsData? approval;
|
||||
bool hasApproval = viewModel
|
||||
.hasTenderApprovalForTender(
|
||||
item.tenderId!,
|
||||
);
|
||||
if (hasApproval) {
|
||||
approval = viewModel
|
||||
.getApprovalStatusForTender(
|
||||
item.tenderId!,
|
||||
);
|
||||
} else {
|
||||
approval = null;
|
||||
}
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: 20.0.h()),
|
||||
child: Dismissible(
|
||||
key: ValueKey(item.tenderId ?? index),
|
||||
direction: DismissDirection.endToStart,
|
||||
background: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 20.0.w(),
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
AssetsManager.trash,
|
||||
width: 32.0.w(),
|
||||
height: 32.0.h(),
|
||||
),
|
||||
),
|
||||
onDismissed: (_) {
|
||||
if (item.tenderId != null) {
|
||||
viewModel.removeTenderById(
|
||||
item.tenderId!,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: LikedListItem(
|
||||
tender: item.tender!,
|
||||
approval: approval,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
_likedTendersList(feedback, viewModel),
|
||||
|
||||
SizedBox(height: 10.0.h()),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
LikedTendersStrings.page,
|
||||
style: TextStyle(
|
||||
fontSize: 13.0.sp(),
|
||||
fontWeight: FontWeight.w300,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10.0.w()),
|
||||
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
final selectedPage = await showDialog<int>(
|
||||
context: context,
|
||||
builder:
|
||||
(context) => PageSelectionDialog(
|
||||
totalPages: totalPages,
|
||||
),
|
||||
);
|
||||
|
||||
if (selectedPage != null) {
|
||||
await viewModel.jumpToPage(selectedPage);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: AppColors.grey30,
|
||||
width: 1,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
'$currentPage',
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.grey70,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
SvgPicture.asset(
|
||||
AssetsManager.arrowDownSmall,
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
LikedTendersStrings.of,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
'$totalPages',
|
||||
style: TextStyle(
|
||||
fontSize: 13.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 30.0.w()),
|
||||
],
|
||||
_likeTendersListPagesControll(
|
||||
context,
|
||||
totalPages,
|
||||
viewModel,
|
||||
currentPage,
|
||||
),
|
||||
|
||||
SizedBox(height: 30.0.h()),
|
||||
@@ -363,5 +143,127 @@ class _LikedTendersTabletPageState extends State<LikedTendersTabletPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _likeTendersListPagesControll(
|
||||
BuildContext context,
|
||||
int totalPages,
|
||||
LikedTendersViewModel viewModel,
|
||||
int currentPage,
|
||||
) {
|
||||
return Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
LikedTendersStrings.page,
|
||||
style: TextStyle(
|
||||
fontSize: 13.0.sp(),
|
||||
fontWeight: FontWeight.w300,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10.0.w()),
|
||||
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
final selectedPage = await showDialog<int>(
|
||||
context: context,
|
||||
builder: (context) => PageSelectionDialog(totalPages: totalPages),
|
||||
);
|
||||
|
||||
if (selectedPage != null) {
|
||||
await viewModel.jumpToPage(selectedPage);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: AppColors.grey30, width: 1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
'$currentPage',
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.grey70,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
SvgPicture.asset(AssetsManager.arrowDownSmall),
|
||||
SizedBox(width: 5.0.w()),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
LikedTendersStrings.of,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
'$totalPages',
|
||||
style: TextStyle(
|
||||
fontSize: 13.0.sp(),
|
||||
fontWeight: FontWeight.w400,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 30.0.w()),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _likedTendersList(
|
||||
List<LikedTenderFeedback> feedback,
|
||||
LikedTendersViewModel viewModel,
|
||||
) {
|
||||
return Expanded(
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(vertical: 15.0.h()),
|
||||
itemCount: feedback.length,
|
||||
itemBuilder: (context, index) {
|
||||
final item = feedback[index];
|
||||
TenderApprovalsData? approval;
|
||||
bool hasApproval = viewModel.hasTenderApprovalForTender(
|
||||
item.tenderId!,
|
||||
);
|
||||
if (hasApproval) {
|
||||
approval = viewModel.getApprovalStatusForTender(item.tenderId!);
|
||||
} else {
|
||||
approval = null;
|
||||
}
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(bottom: 20.0.h()),
|
||||
child: Dismissible(
|
||||
key: ValueKey(item.tenderId ?? index),
|
||||
direction: DismissDirection.endToStart,
|
||||
background: Container(
|
||||
alignment: Alignment.centerRight,
|
||||
padding: EdgeInsets.symmetric(horizontal: 20.0.w()),
|
||||
child: SvgPicture.asset(
|
||||
AssetsManager.trash,
|
||||
width: 32.0.w(),
|
||||
height: 32.0.h(),
|
||||
),
|
||||
),
|
||||
onDismissed: (_) {
|
||||
if (item.tenderId != null) {
|
||||
viewModel.removeTenderById(item.tenderId!);
|
||||
}
|
||||
},
|
||||
child: LikedListItem(tender: item.tender!, approval: approval),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user