Refactor completion of documents routing and UI components

- Removed unused mobile route for completion of documents.
- Updated app routes to reflect the removal of the mobile route.
- Enhanced the desktop and mobile pages for completion of documents with improved layout and added TabletDesktopAppbar.
- Introduced meeting time handling in TenderDetailActions, integrating new bottom sheet and dialog components for better user interaction.
- Added meeting time state management in TenderDetailViewModel.
- Cleaned up deprecated files related to meeting time selection.
This commit is contained in:
amirrezaghabeli
2025-10-13 14:51:39 +03:30
parent be6b0bbe98
commit 919b9fb2ed
14 changed files with 448 additions and 282 deletions
@@ -6,6 +6,8 @@ import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/views/completion_of_documents/strings/completion_of_documents_string.dart';
import 'package:tm_app/views/shared/base_button.dart';
import 'package:tm_app/views/shared/desktop_navigation_widget.dart';
import 'package:tm_app/views/shared/tablet_desktop_appbar.dart'
show TabletDesktopAppbar;
class CompletionOfDocumentsDesktopPage extends StatelessWidget {
const CompletionOfDocumentsDesktopPage({super.key});
@@ -17,36 +19,24 @@ class CompletionOfDocumentsDesktopPage extends StatelessWidget {
body: Column(
children: [
const DesktopNavigationWidget(currentIndex: 0),
SizedBox(
width: 760,
Expanded(
child: SingleChildScrollView(
child: Center(
child: SizedBox(
child: Padding(
padding: EdgeInsets.symmetric(vertical: 24.0.h()),
child: Expanded(
child: SizedBox(
width: double.infinity,
child: Center(
child: SizedBox(
width: 760,
child: Center(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
SvgPicture.asset(
AssetsManager.arrowLeft,
width: 24.0.w(),
height: 24.0.h(),
),
SizedBox(width: 8.0.w()),
Text(
SizedBox(height: 40.0.h()),
const TabletDesktopAppbar(
title:
CompletionOfDocumentsStrings
.completionOfDocuments,
style: TextStyle(
color: AppColors.grey70,
fontSize: 16.0.sp(),
fontWeight: FontWeight.w600,
),
),
],
),
SizedBox(height: 24.0.h()),
_deadlineContainer(),
@@ -78,6 +68,7 @@ class CompletionOfDocumentsDesktopPage extends StatelessWidget {
textColor: AppColors.textBlue,
backgroundColor: AppColors.primary30,
),
SizedBox(height: 24.0.h()),
],
),
),
@@ -6,6 +6,8 @@ import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/views/completion_of_documents/strings/completion_of_documents_string.dart';
import 'package:tm_app/views/shared/base_button.dart';
import '../../shared/tender_app_bar.dart';
class CompletionOfDocumentsMobilePage extends StatelessWidget {
const CompletionOfDocumentsMobilePage({super.key});
@@ -13,10 +15,10 @@ class CompletionOfDocumentsMobilePage extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: AppColors.backgroundColor,
// appBar: appBar(
// context: context,
// title: CompletionOfDocumentsStrings.completionOfDocuments,
// ),
appBar: appBar(
context: context,
title: CompletionOfDocumentsStrings.completionOfDocuments,
),
body: SafeArea(
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(
@@ -26,26 +28,6 @@ class CompletionOfDocumentsMobilePage extends StatelessWidget {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
SvgPicture.asset(
AssetsManager.arrowLeft,
width: 24.0.w(),
height: 24.0.h(),
),
SizedBox(width: 8.0.w()),
Text(
CompletionOfDocumentsStrings.completionOfDocuments,
style: TextStyle(
color: AppColors.grey70,
fontSize: 16.0.sp(),
fontWeight: FontWeight.w600,
),
),
],
),
SizedBox(height: 24.0.h()),
Container(
width: double.infinity,
height: 24.0.h(),
@@ -126,6 +126,7 @@ class _TenderDetailDesktopPageState extends State<TenderDetailDesktopPage> {
TenderDetailActions(
isScreenBig: true,
detail: detail,
viewModel: viewModel,
),
],
),
@@ -114,7 +114,11 @@ class _TenderDetailMobilePageState extends State<TenderDetailMobilePage> {
SizedBox(height: 24.0.h()),
TenderDetailCard(detail: detail),
SizedBox(height: 24.0.h()),
TenderDetailActions(isScreenBig: false, detail: detail),
TenderDetailActions(
isScreenBig: false,
detail: detail,
viewModel: viewModel,
),
],
),
),
@@ -125,7 +125,11 @@ class _TenderDetailTabletPageState extends State<TenderDetailTabletPage> {
SizedBox(height: 28.0.h()),
TenderDetailCard(detail: detail),
SizedBox(height: 24.0.h()),
TenderDetailActions(isScreenBig: true, detail: detail),
TenderDetailActions(
isScreenBig: true,
detail: detail,
viewModel: viewModel,
),
],
),
),
@@ -37,4 +37,6 @@ class TenderDetailsStrings {
static const String pleaseReplyBy = 'If youd like to join, Please Reply by ';
static const String lastDayToPrepareProposal =
'Last day to prepare proposal is ';
static const String meetingTimeSuccessfullySet =
'meeting time successfully set';
}
@@ -1,21 +1,20 @@
import 'package:flutter/material.dart';
import 'package:tm_app/core/routes/app_routes.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:go_router/go_router.dart';
import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/views/detail/strings/tender_details_strings.dart';
class SelectMeetingTimeBottomSheet extends StatefulWidget {
const SelectMeetingTimeBottomSheet({required this.onConfirm, required this.isDialog, super.key});
import '../../../core/routes/app_routes.dart';
import '../../../core/theme/colors.dart';
import '../strings/tender_details_strings.dart';
class MeetingTimeBottomSheet extends StatefulWidget {
const MeetingTimeBottomSheet({required this.onConfirm, super.key});
final ValueChanged<String> onConfirm;
final bool isDialog;
@override
State<SelectMeetingTimeBottomSheet> createState() =>
_SelectMeetingTimeBottomSheetState();
State<MeetingTimeBottomSheet> createState() => _MeetingTimeBottomSheetState();
}
class _SelectMeetingTimeBottomSheetState
extends State<SelectMeetingTimeBottomSheet> {
class _MeetingTimeBottomSheetState extends State<MeetingTimeBottomSheet> {
int selectedType = 0;
late String type = '';
@@ -26,7 +25,6 @@ class _SelectMeetingTimeBottomSheetState
{'title': 'Sun 2025-06-18', 'value': 'mode4', 'time': '16:00'},
{'title': 'Sun 2025-06-19', 'value': 'mode5', 'time': '18:00'},
];
@override
Widget build(BuildContext context) {
return Wrap(
@@ -36,7 +34,7 @@ class _SelectMeetingTimeBottomSheetState
padding: EdgeInsets.fromLTRB(24.0.w(), 24.0.h(), 24.0.w(), 33.0.h()),
decoration: BoxDecoration(
color: AppColors.backgroundColor,
borderRadius: widget.isDialog ? const BorderRadius.all(Radius.circular(16.0)) : const BorderRadius.only(
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(16.0),
topRight: Radius.circular(16.0),
),
@@ -77,8 +75,9 @@ class _SelectMeetingTimeBottomSheetState
SizedBox(height: 8.0.h()),
InkWell(
onTap: () {
const CompletionOfDocumentsMobileRouteData().push(context);
//context.pop();
widget.onConfirm(type);
context.pop();
const CompletionOfDocumentsRouteData().push(context);
},
child: Container(
width: double.infinity,
@@ -118,61 +117,65 @@ class _SelectMeetingTimeBottomSheetState
color: isSelected ? AppColors.mainBlue : AppColors.grey40,
),
),
child: InkWell(
onTap: onTap,
child: SizedBox(
width: double.infinity,
height: 40.0.h(),
child: Row(
children: [
Container(
width: 20.0.w(),
height: 20.0.w(),
margin: EdgeInsets.symmetric(
horizontal: 10.0.w(),
vertical: 10.0.h(),
),
padding: const EdgeInsets.all(3),
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: isSelected ? AppColors.mainBlue : AppColors.grey70,
width: 2.0,
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
child: SizedBox(
width: double.infinity,
height: 40.0.h(),
child: Row(
children: [
Container(
width: 20.0.w(),
height: 20.0.w(),
margin: EdgeInsets.symmetric(
horizontal: 10.0.w(),
vertical: 10.0.h(),
),
),
alignment: Alignment.center,
child: Container(
padding: const EdgeInsets.all(3),
decoration: BoxDecoration(
shape: BoxShape.circle,
color: isSelected ? AppColors.mainBlue : Colors.transparent,
border: Border.all(
color: isSelected ? AppColors.mainBlue : AppColors.grey70,
width: 2.0,
),
),
alignment: Alignment.center,
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color:
isSelected ? AppColors.mainBlue : Colors.transparent,
),
),
),
),
Expanded(
child: Row(
children: [
Text(
title,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.grey80,
Expanded(
child: Row(
children: [
Text(
title,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.grey80,
),
),
),
const Spacer(),
Text(
time,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.grey80,
const Spacer(),
Text(
time,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.grey80,
),
),
),
SizedBox(width: 10.0.w()),
],
SizedBox(width: 10.0.w()),
],
),
),
),
],
],
),
),
),
),
@@ -0,0 +1,198 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.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/views/detail/strings/tender_details_strings.dart';
class MeetingTimeDialog extends StatefulWidget {
const MeetingTimeDialog({required this.onConfirm, super.key});
final ValueChanged<String> onConfirm;
@override
State<MeetingTimeDialog> createState() => _MeetingTimeDialogState();
}
class _MeetingTimeDialogState extends State<MeetingTimeDialog> {
int selectedType = 0;
late String type = '';
final List<Map<String, String>> times = [
{'title': 'Sun 2025-06-15', 'value': 'mode1', 'time': '10:00'},
{'title': 'Sun 2025-06-16', 'value': 'mode2', 'time': '12:00'},
{'title': 'Sun 2025-06-17', 'value': 'mode3', 'time': '14:00'},
{'title': 'Sun 2025-06-18', 'value': 'mode4', 'time': '16:00'},
{'title': 'Sun 2025-06-19', 'value': 'mode5', 'time': '18:00'},
];
@override
Widget build(BuildContext context) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide.none,
),
insetPadding: const EdgeInsets.symmetric(horizontal: 150),
child: Wrap(
children: [
Container(
// width: double.infinity,
padding: EdgeInsets.fromLTRB(
24.0.w(),
24.0.h(),
24.0.w(),
33.0.h(),
),
decoration: BoxDecoration(
color: AppColors.backgroundColor,
borderRadius: const BorderRadius.all(Radius.circular(16.0)),
),
child: Column(
children: [
Text(
TenderDetailsStrings.meetingTime,
style: TextStyle(
fontSize: 20.0.sp(),
fontWeight: FontWeight.w600,
color: AppColors.grey70,
),
),
SizedBox(height: 15.0.h()),
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: times.length,
itemBuilder: (context, index) {
final item = times[index];
return Padding(
padding: EdgeInsets.only(bottom: 8.0.h()),
child: _submissionType(
title: item['title']!,
time: item['time']!,
isSelected: type == item['value'],
onTap: () {
selectedType = index;
type = item['value']!;
setState(() {});
},
),
);
},
),
SizedBox(height: 8.0.h()),
SizedBox(height: 8.0.h()),
Material(
color: Colors.transparent,
child: InkWell(
onTap: () {
widget.onConfirm(type);
context.pop();
const CompletionOfDocumentsRouteData().push(context);
},
child: Container(
width: double.infinity,
height: 56.0.h(),
decoration: BoxDecoration(
color: AppColors.primary20,
borderRadius: BorderRadius.circular(100),
),
alignment: Alignment.center,
child: Text(
TenderDetailsStrings.apply,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.mainBlue,
),
),
),
),
),
],
),
),
],
),
);
}
Widget _submissionType({
required VoidCallback onTap,
required String title,
required String time,
required bool isSelected,
}) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0),
border: Border.all(
color: isSelected ? AppColors.mainBlue : AppColors.grey40,
),
),
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: onTap,
child: SizedBox(
width: double.infinity,
height: 40.0.h(),
child: Row(
children: [
Container(
width: 20.0.w(),
height: 20.0.w(),
margin: EdgeInsets.symmetric(
horizontal: 10.0.w(),
vertical: 10.0.h(),
),
padding: const EdgeInsets.all(3),
decoration: BoxDecoration(
shape: BoxShape.circle,
border: Border.all(
color: isSelected ? AppColors.mainBlue : AppColors.grey70,
width: 2.0,
),
),
alignment: Alignment.center,
child: Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color:
isSelected ? AppColors.mainBlue : Colors.transparent,
),
),
),
Expanded(
child: Row(
children: [
Text(
title,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.grey80,
),
),
const Spacer(),
Text(
time,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.grey80,
),
),
SizedBox(width: 10.0.w()),
],
),
),
],
),
),
),
),
);
}
}
@@ -1,29 +0,0 @@
import 'package:flutter/material.dart';
import 'package:tm_app/views/detail/widgets/select_meeting_time_bottom_sheet.dart';
Future<void> showSelectMeetingTimeDialog({
required BuildContext context,
required ValueChanged<String> onConfirm,
}) async {
await showDialog(
context: context,
barrierDismissible: true,
builder: (dialogContext) {
return Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
insetPadding: const EdgeInsets.symmetric(horizontal: 32, vertical: 24),
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 500),
child: SelectMeetingTimeBottomSheet(
isDialog: true,
onConfirm: (value) {
onConfirm(value);
},
),
),
);
},
);
}
@@ -3,30 +3,38 @@ import 'package:provider/provider.dart';
import 'package:tm_app/core/theme/colors.dart';
import 'package:tm_app/core/utils/size_config.dart';
import 'package:tm_app/view_models/tender_detail_view_model.dart';
import 'package:tm_app/views/detail/widgets/select_meeting_time_bottom_sheet.dart';
import 'package:tm_app/views/detail/widgets/show_select_meeting_time_bottom_sheet.dart';
import 'package:tm_app/views/detail/widgets/meeting_time_bottom_sheet.dart';
import 'package:tm_app/views/detail/widgets/meeting_time_dialog.dart';
import 'package:tm_app/views/shared/base_button.dart';
import 'package:tm_app/views/shared/select_submission_bottom_sheet.dart';
import '../../../core/constants/tender_approval_status.dart';
import '../../../core/constants/tender_submision_mode.dart';
import '../../../core/routes/app_routes.dart';
import '../../../core/utils/app_toast.dart';
import '../../../data/services/model/tender_data/tender_data.dart';
import '../../shared/select_submission_dialog.dart';
import '../strings/tender_details_strings.dart';
class TenderDetailActions extends StatelessWidget {
class TenderDetailActions extends StatefulWidget {
final bool isScreenBig;
final TenderData detail;
final TenderDetailViewModel viewModel;
const TenderDetailActions({
required this.isScreenBig,
required this.detail,
required this.viewModel,
super.key,
});
@override
State<TenderDetailActions> createState() => _TenderDetailActionsState();
}
class _TenderDetailActionsState extends State<TenderDetailActions> {
@override
Widget build(BuildContext context) {
return isScreenBig
return widget.isScreenBig
? _webActions()
: Column(
children: [
@@ -60,25 +68,34 @@ class TenderDetailActions extends StatelessWidget {
onConfirm: (String value) {
if (value ==
TenderSubmissionMode.selfApply.value) {
viewModel.submitTenderApproval(
tenderId: detail.id!,
submissionMode: value,
// viewModel.submitTenderApproval(
// tenderId: widget.detail.id!,
// submissionMode: value,
// );
const CompletionOfDocumentsRouteData().push(
context,
);
} else if (value ==
TenderSubmissionMode.partnership.value) {
Future.delayed(Duration.zero, () {
showDialog(
context: context,
builder: (context) {
return SelectMeetingTimeBottomSheet(
onConfirm: (String value) {
const CompletionOfDocumentsRouteData()
.push(context);
},
isDialog: false,
);
},
);
if (context.mounted) {
showModalBottomSheet(
context: context,
builder: (_) {
return MeetingTimeBottomSheet(
onConfirm: (value) {
AppToast.success(
context,
TenderDetailsStrings
.meetingTimeSuccessfullySet,
);
},
);
},
);
}
});
}
},
@@ -112,7 +129,7 @@ class TenderDetailActions extends StatelessWidget {
borderWidth: 1,
onPressed: () {
viewModel.rejectTenderApproval(
tenderId: detail.id!,
tenderId: widget.detail.id!,
submissionMode: TenderSubmissionMode.selfApply.value,
);
},
@@ -148,7 +165,7 @@ class TenderDetailActions extends StatelessWidget {
borderWidth: 1,
onPressed: () {
viewModel.rejectTenderApproval(
tenderId: detail.id!,
tenderId: widget.detail.id!,
submissionMode: TenderSubmissionMode.selfApply.value,
);
},
@@ -177,7 +194,7 @@ class TenderDetailActions extends StatelessWidget {
if (viewModel.status ==
TenderApprovalStatus.submitted.value) {
viewModel.submitTenderApproval(
tenderId: detail.id!,
tenderId: widget.detail.id!,
submissionMode: TenderSubmissionMode.selfApply.value,
);
} else {
@@ -189,20 +206,29 @@ class TenderDetailActions extends StatelessWidget {
onConfirm: (String value) {
if (value ==
TenderSubmissionMode.selfApply.value) {
const FinalCompletionOfDocumentsRouteData()
.push(context);
if (context.mounted) {
const FinalCompletionOfDocumentsRouteData()
.push(context);
}
} else if (value ==
TenderSubmissionMode.partnership.value) {
WidgetsBinding.instance.addPostFrameCallback((
timeStamp,
) {
showSelectMeetingTimeDialog(
context: context,
onConfirm: (String value) {
const CompletionOfDocumentsRouteData()
.push(context);
},
);
Future.delayed(Duration.zero, () {
if (context.mounted) {
showDialog(
context: context,
builder: (context) {
return MeetingTimeDialog(
onConfirm: (value) {
AppToast.success(
context,
TenderDetailsStrings
.meetingTimeSuccessfullySet,
);
},
);
},
);
}
});
}
},
@@ -216,22 +242,36 @@ class TenderDetailActions extends StatelessWidget {
onConfirm: (String value) {
if (value ==
TenderSubmissionMode.selfApply.value) {
viewModel.submitTenderApproval(
tenderId: detail.id!,
submissionMode: value,
);
// viewModel.submitTenderApproval(
// tenderId: widget.detail.id!,
// submissionMode: value,
// );
if (context.mounted) {
const FinalCompletionOfDocumentsRouteData()
.push(context);
}
} else if (value ==
TenderSubmissionMode.partnership.value) {
showDialog(
context: context,
builder: (context) {
return SelectMeetingTimeBottomSheet(
onConfirm: (String value) {
const CompletionOfDocumentsRouteData()
.push(context);
return MeetingTimeBottomSheet(
onConfirm: (value) {
AppToast.success(
context,
TenderDetailsStrings
.meetingTimeSuccessfullySet,
);
},
isDialog: false,
);
// return MeetingTimeDialog(
// onConfirm: (String value) {
// if (context.mounted) {
// const CompletionOfDocumentsRouteData()
// .push(context);
// }
// },
// );
},
);
}
@@ -23,67 +23,62 @@ class DesktopFinalCompletionOfDocumentsPage extends StatelessWidget {
return Scaffold(
body: Consumer<FinalCompletionOfDocumentsViewModel>(
builder:
(context, viewModel, child) => SafeArea(
child: Column(
children: [
const DesktopNavigationWidget(currentIndex: 1),
const SizedBox(height: 64.0),
SizedBox(
width: 740,
child: Column(
children: [
Expanded(
child: SizedBox(
child: SingleChildScrollView(
child: Column(
children: [
const TabletDesktopAppbar(
title:
FinalCompletionOfDocumentsStrings
.completionOfDocuments,
),
SizedBox(height: 32.0.h()),
(context, viewModel, child) => Column(
children: [
const DesktopNavigationWidget(currentIndex: 1),
const SizedBox(height: 42.0),
Expanded(
child: SingleChildScrollView(
child: SizedBox(
width: double.infinity,
child: Center(
child: SizedBox(
width: 740,
child: Column(
children: [
const TabletDesktopAppbar(
title:
FinalCompletionOfDocumentsStrings
.completionOfDocuments,
),
SizedBox(height: 32.0.h()),
const SizedBox(height: 32.0),
const CommentBox(),
const SizedBox(height: 32.0),
FormCard(viewModel: viewModel),
const SizedBox(height: 40.0),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
BaseButton(
isEnabled: true,
onPressed: () {},
width: 176,
backgroundColor: AppColors.primary10,
textColor: AppColors.mainBlue,
text:
FinalCompletionOfDocumentsStrings
.back,
),
const SizedBox(width: 16.0),
BaseButton(
isEnabled: true,
onPressed: () {},
width: 176,
text:
FinalCompletionOfDocumentsStrings
.next,
),
],
const SizedBox(height: 32.0),
const CommentBox(),
const SizedBox(height: 32.0),
FormCard(viewModel: viewModel),
const SizedBox(height: 40.0),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
BaseButton(
isEnabled: true,
onPressed: () {},
width: 176,
backgroundColor: AppColors.primary10,
textColor: AppColors.mainBlue,
text:
FinalCompletionOfDocumentsStrings.back,
),
const SizedBox(width: 16.0),
BaseButton(
isEnabled: true,
onPressed: () {},
width: 176,
text:
FinalCompletionOfDocumentsStrings.next,
),
const SizedBox(height: 35.0),
],
),
),
const SizedBox(height: 35.0),
],
),
),
],
),
),
),
],
),
),
],
),
),
);