some changes and fixes
This commit is contained in:
@@ -8,8 +8,8 @@ import 'package:tm_app/data/services/model/tender_approvals_data/tender_approval
|
||||
import 'package:tm_app/view_models/liked_tenders_view_model.dart';
|
||||
import 'package:tm_app/views/liked_tenders/widgets/liked_tenders_list_item.dart';
|
||||
|
||||
import '../../../core/routes/app_routes.dart';
|
||||
import '../../shared/desktop_navigation_widget.dart';
|
||||
import '../strings/liked_tenders_strings.dart';
|
||||
|
||||
class LikedTendersDesktopPage extends StatefulWidget {
|
||||
const LikedTendersDesktopPage({super.key});
|
||||
@@ -20,220 +20,221 @@ class LikedTendersDesktopPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LikedTendersDesktopPageState extends State<LikedTendersDesktopPage> {
|
||||
late final LikedTendersViewModel viewModel;
|
||||
@override
|
||||
void initState() {
|
||||
viewModel = context.read<LikedTendersViewModel>();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
body: Column(
|
||||
children: [
|
||||
DesktopNavigationWidget(
|
||||
currentIndex: 1,
|
||||
onTabChanged: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
Router.neglect(context, () => HomeRouteData().go(context));
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
Router.neglect(context, () => ProfileRouteData().go(context));
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
width: 740,
|
||||
child: Consumer<LikedTendersViewModel>(
|
||||
builder: (context, viewModel, child) {
|
||||
if (viewModel.isLoading &&
|
||||
(viewModel.data?.data?.feedback ?? []).isEmpty) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.secondary50,
|
||||
),
|
||||
);
|
||||
}
|
||||
return PopScope(
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
viewModel.updateHome();
|
||||
});
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
body: Column(
|
||||
children: [
|
||||
DesktopNavigationWidget(currentIndex: 1),
|
||||
Expanded(
|
||||
child: SizedBox(
|
||||
width: 740,
|
||||
child: Consumer<LikedTendersViewModel>(
|
||||
builder: (context, viewModel, child) {
|
||||
if (viewModel.isLoading &&
|
||||
(viewModel.data?.data?.feedback ?? []).isEmpty) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.secondary50,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (viewModel.errorMessage != null) {
|
||||
return Center(child: Text(viewModel.errorMessage!));
|
||||
}
|
||||
if (viewModel.errorMessage != null) {
|
||||
return Center(child: Text(viewModel.errorMessage!));
|
||||
}
|
||||
|
||||
final feedback = viewModel.data?.data?.feedback ?? [];
|
||||
final feedback = viewModel.data?.data?.feedback ?? [];
|
||||
|
||||
if (feedback.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('You haven’t liked any tenders yet.'),
|
||||
);
|
||||
}
|
||||
if (feedback.isEmpty) {
|
||||
return const Center(
|
||||
child: Text(LikedTendersStrings.noLikedTenders),
|
||||
);
|
||||
}
|
||||
|
||||
final currentPage = viewModel.currentPage;
|
||||
final totalPages = viewModel.data?.data?.meta?.pages ?? 1;
|
||||
final currentPage = viewModel.currentPage;
|
||||
final totalPages = viewModel.data?.data?.meta?.pages ?? 1;
|
||||
|
||||
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,
|
||||
),
|
||||
),
|
||||
onDismissed: (_) {
|
||||
if (item.tenderId != null) {
|
||||
viewModel.removeTenderById(
|
||||
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!,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: LikedListItem(
|
||||
tender: item.tender!,
|
||||
approval: approval,
|
||||
isDesktop: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 10.0.h()),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
'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) {
|
||||
return AlertDialog(
|
||||
title: const Text('Select Page'),
|
||||
content: SizedBox(
|
||||
width: 200,
|
||||
height: 300,
|
||||
child: ListView.builder(
|
||||
itemCount: totalPages,
|
||||
itemBuilder: (context, index) {
|
||||
final pageNumber = index + 1;
|
||||
return ListTile(
|
||||
title: Text('Page $pageNumber'),
|
||||
onTap:
|
||||
() => Navigator.pop(
|
||||
context,
|
||||
pageNumber,
|
||||
),
|
||||
);
|
||||
},
|
||||
} 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,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
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,
|
||||
onDismissed: (_) {
|
||||
if (item.tenderId != null) {
|
||||
viewModel.removeTenderById(
|
||||
item.tenderId!,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: LikedListItem(
|
||||
tender: item.tender!,
|
||||
approval: approval,
|
||||
isDesktop: true,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
SvgPicture.asset(
|
||||
AssetsManager.arrowdownSmall,
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 10.0.h()),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
'Page',
|
||||
style: TextStyle(
|
||||
fontSize: 13.0.sp(),
|
||||
fontWeight: FontWeight.w300,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10.0.w()),
|
||||
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
'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,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
final selectedPage = await showDialog<int>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Select Page'),
|
||||
content: SizedBox(
|
||||
width: 200,
|
||||
height: 300,
|
||||
child: ListView.builder(
|
||||
itemCount: totalPages,
|
||||
itemBuilder: (context, index) {
|
||||
final pageNumber = index + 1;
|
||||
return ListTile(
|
||||
title: Text('Page $pageNumber'),
|
||||
onTap:
|
||||
() => Navigator.pop(
|
||||
context,
|
||||
pageNumber,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
SizedBox(height: 30.0.h()),
|
||||
],
|
||||
);
|
||||
},
|
||||
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(
|
||||
'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(height: 30.0.h()),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
@@ -19,9 +20,11 @@ class LikedTendersMobilePage extends StatefulWidget {
|
||||
|
||||
class _LikedTendersMobilePageState extends State<LikedTendersMobilePage> {
|
||||
late final ScrollController _scrollController;
|
||||
late final LikedTendersViewModel viewModel;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
viewModel = context.read<LikedTendersViewModel>();
|
||||
super.initState();
|
||||
_scrollController = ScrollController()..addListener(_onScroll);
|
||||
}
|
||||
@@ -48,109 +51,124 @@ class _LikedTendersMobilePageState extends State<LikedTendersMobilePage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
appBar: appBar(context: context, title: LikedTendersStrings.likedTenders),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Consumer<LikedTendersViewModel>(
|
||||
builder: (context, viewModel, child) {
|
||||
if (viewModel.isLoading &&
|
||||
(viewModel.data?.data?.feedback ?? []).isEmpty) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.secondary50,
|
||||
),
|
||||
);
|
||||
}
|
||||
return PopScope(
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (kIsWeb) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
viewModel.updateHome();
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
appBar: appBar(
|
||||
context: context,
|
||||
title: LikedTendersStrings.likedTenders,
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Consumer<LikedTendersViewModel>(
|
||||
builder: (context, viewModel, child) {
|
||||
if (viewModel.isLoading &&
|
||||
(viewModel.data?.data?.feedback ?? []).isEmpty) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.secondary50,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (viewModel.errorMessage != null) {
|
||||
return Center(child: Text(viewModel.errorMessage!));
|
||||
}
|
||||
if (viewModel.errorMessage != null) {
|
||||
return Center(child: Text(viewModel.errorMessage!));
|
||||
}
|
||||
|
||||
final feedback = viewModel.data?.data?.feedback ?? [];
|
||||
final feedback = viewModel.data?.data?.feedback ?? [];
|
||||
|
||||
if (feedback.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('You haven’t liked any tenders yet.'),
|
||||
);
|
||||
}
|
||||
if (feedback.isEmpty) {
|
||||
return const Center(
|
||||
child: Text(LikedTendersStrings.noLikedTenders),
|
||||
);
|
||||
}
|
||||
|
||||
final itemCount =
|
||||
feedback.length + (viewModel.isLoadingMore ? 1 : 0);
|
||||
final itemCount =
|
||||
feedback.length + (viewModel.isLoadingMore ? 1 : 0);
|
||||
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await viewModel.getLikedTenders(reset: true);
|
||||
},
|
||||
child: ListView.builder(
|
||||
controller: _scrollController,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.0.w(),
|
||||
vertical: 15.0.h(),
|
||||
),
|
||||
itemCount: itemCount,
|
||||
itemBuilder: (context, index) {
|
||||
if (index < feedback.length) {
|
||||
final item = feedback[index];
|
||||
TenderApprovalsData? approval;
|
||||
bool hasApproval = viewModel.hasTenderApprovalForTender(
|
||||
item.tenderId!,
|
||||
);
|
||||
if (hasApproval) {
|
||||
approval = viewModel.getApprovalStatusForTender(
|
||||
item.tenderId!,
|
||||
return RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
await viewModel.getLikedTenders(reset: true);
|
||||
},
|
||||
child: ListView.builder(
|
||||
controller: _scrollController,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 24.0.w(),
|
||||
vertical: 15.0.h(),
|
||||
),
|
||||
itemCount: itemCount,
|
||||
itemBuilder: (context, index) {
|
||||
if (index < feedback.length) {
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
approval = null;
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 20.0.h()),
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 24.0.w(),
|
||||
height: 24.0.h(),
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.secondary50,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 20.0.h()),
|
||||
child: Center(
|
||||
child: SizedBox(
|
||||
width: 24.0.w(),
|
||||
height: 24.0.h(),
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.secondary50,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/core/constants/assets.dart';
|
||||
import 'package:tm_app/core/routes/app_routes.dart';
|
||||
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';
|
||||
@@ -22,226 +21,230 @@ class LikedTendersTabletPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LikedTendersTabletPageState extends State<LikedTendersTabletPage> {
|
||||
late final LikedTendersViewModel viewModel;
|
||||
@override
|
||||
void initState() {
|
||||
viewModel = context.read<LikedTendersViewModel>();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final GlobalKey<ScaffoldState> key = GlobalKey();
|
||||
return Scaffold(
|
||||
key: key,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
appBar: tabletAppBar(title: LikedTendersStrings.likedTenders, key: key),
|
||||
drawer: TabletNavigationWidget(
|
||||
currentIndex: 1,
|
||||
onTabChanged: (index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
Router.neglect(context, () => HomeRouteData().go(context));
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
context.pop();
|
||||
Router.neglect(context, () => ProfileRouteData().go(context));
|
||||
break;
|
||||
}
|
||||
},
|
||||
),
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 720,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Consumer<LikedTendersViewModel>(
|
||||
builder: (context, viewModel, child) {
|
||||
if (viewModel.isLoading &&
|
||||
(viewModel.data?.data?.feedback ?? []).isEmpty) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.secondary50,
|
||||
),
|
||||
);
|
||||
}
|
||||
return PopScope(
|
||||
onPopInvokedWithResult: (didPop, result) {
|
||||
if (kIsWeb) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
viewModel.updateHome();
|
||||
});
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
key: key,
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
appBar: tabletAppBar(title: LikedTendersStrings.likedTenders, key: key),
|
||||
drawer: TabletNavigationWidget(currentIndex: 1),
|
||||
body: Center(
|
||||
child: SizedBox(
|
||||
width: 720,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Consumer<LikedTendersViewModel>(
|
||||
builder: (context, viewModel, child) {
|
||||
if (viewModel.isLoading &&
|
||||
(viewModel.data?.data?.feedback ?? []).isEmpty) {
|
||||
return const Center(
|
||||
child: CircularProgressIndicator(
|
||||
color: AppColors.secondary50,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (viewModel.errorMessage != null) {
|
||||
return Center(child: Text(viewModel.errorMessage!));
|
||||
}
|
||||
if (viewModel.errorMessage != null) {
|
||||
return Center(child: Text(viewModel.errorMessage!));
|
||||
}
|
||||
|
||||
final feedback = viewModel.data?.data?.feedback ?? [];
|
||||
final feedback = viewModel.data?.data?.feedback ?? [];
|
||||
|
||||
if (feedback.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('You haven’t liked any tenders yet.'),
|
||||
);
|
||||
}
|
||||
if (feedback.isEmpty) {
|
||||
return const Center(
|
||||
child: Text(LikedTendersStrings.noLikedTenders),
|
||||
);
|
||||
}
|
||||
|
||||
final currentPage = viewModel.currentPage;
|
||||
final totalPages = viewModel.data?.data?.meta?.pages ?? 1;
|
||||
final currentPage = viewModel.currentPage;
|
||||
final totalPages = viewModel.data?.data?.meta?.pages ?? 1;
|
||||
|
||||
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(
|
||||
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!,
|
||||
);
|
||||
} 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(
|
||||
if (hasApproval) {
|
||||
approval = viewModel
|
||||
.getApprovalStatusForTender(
|
||||
item.tenderId!,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: LikedListItem(
|
||||
tender: item.tender!,
|
||||
approval: approval!,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 10.0.h()),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
'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) {
|
||||
return AlertDialog(
|
||||
title: const Text('Select Page'),
|
||||
content: SizedBox(
|
||||
width: 200,
|
||||
height: 300,
|
||||
child: ListView.builder(
|
||||
itemCount: totalPages,
|
||||
itemBuilder: (context, index) {
|
||||
final pageNumber = index + 1;
|
||||
return ListTile(
|
||||
title: Text('Page $pageNumber'),
|
||||
onTap:
|
||||
() => Navigator.pop(
|
||||
context,
|
||||
pageNumber,
|
||||
),
|
||||
);
|
||||
},
|
||||
} 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(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
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,
|
||||
onDismissed: (_) {
|
||||
if (item.tenderId != null) {
|
||||
viewModel.removeTenderById(
|
||||
item.tenderId!,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: LikedListItem(
|
||||
tender: item.tender!,
|
||||
approval: approval!,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
SvgPicture.asset(
|
||||
AssetsManager.arrowdownSmall,
|
||||
),
|
||||
SizedBox(width: 5.0.w()),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(height: 10.0.h()),
|
||||
|
||||
Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
Text(
|
||||
'Page',
|
||||
style: TextStyle(
|
||||
fontSize: 13.0.sp(),
|
||||
fontWeight: FontWeight.w300,
|
||||
color: AppColors.grey60,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 10.0.w()),
|
||||
|
||||
SizedBox(width: 5.0.w()),
|
||||
Text(
|
||||
'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()),
|
||||
],
|
||||
),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
final selectedPage = await showDialog<int>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Select Page'),
|
||||
content: SizedBox(
|
||||
width: 200,
|
||||
height: 300,
|
||||
child: ListView.builder(
|
||||
itemCount: totalPages,
|
||||
itemBuilder: (context, index) {
|
||||
final pageNumber = index + 1;
|
||||
return ListTile(
|
||||
title: Text('Page $pageNumber'),
|
||||
onTap:
|
||||
() => Navigator.pop(
|
||||
context,
|
||||
pageNumber,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
SizedBox(height: 30.0.h()),
|
||||
],
|
||||
);
|
||||
},
|
||||
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(
|
||||
'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()),
|
||||
],
|
||||
),
|
||||
|
||||
SizedBox(height: 30.0.h()),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -12,4 +12,5 @@ class LikedTendersStrings {
|
||||
static const startDate = 'YYYY/MM/DD';
|
||||
static const endDate = 'YYYY/MM/DD';
|
||||
static const approvedTenders = 'Approved tenders';
|
||||
static const noLikedTenders = 'You haven’t liked any tenders yet.';
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ class LikedListItem extends StatelessWidget {
|
||||
submissionMode: 'self-apply',
|
||||
);
|
||||
} else {
|
||||
kIsWeb
|
||||
(kIsWeb && MediaQuery.sizeOf(context).width > 600)
|
||||
? showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
|
||||
Reference in New Issue
Block a user