From 89668fd2f11425150f543c99d9c2d396d2ee5637 Mon Sep 17 00:00:00 2001 From: amirrezaghabeli Date: Wed, 27 Aug 2025 09:05:18 +0330 Subject: [PATCH] submission dialog for tablet and web --- lib/data/services/auth_service.dart | 1 + .../detail/widgets/tender_detail_action.dart | 8 +- .../shared/select_submission_dialog.dart | 144 ++++++++++++++++++ .../widgets/tender_action_buttons_row.dart | 49 ++++-- 4 files changed, 183 insertions(+), 19 deletions(-) create mode 100644 lib/views/shared/select_submission_dialog.dart diff --git a/lib/data/services/auth_service.dart b/lib/data/services/auth_service.dart index 3e19a17..9b529d6 100644 --- a/lib/data/services/auth_service.dart +++ b/lib/data/services/auth_service.dart @@ -51,5 +51,6 @@ class AuthService { Future localLogout() async { final prefs = await SharedPreferences.getInstance(); await prefs.remove('bearer'); + await prefs.remove('refresh_token'); } } diff --git a/lib/views/detail/widgets/tender_detail_action.dart b/lib/views/detail/widgets/tender_detail_action.dart index 12ba5f1..a7745dc 100644 --- a/lib/views/detail/widgets/tender_detail_action.dart +++ b/lib/views/detail/widgets/tender_detail_action.dart @@ -8,6 +8,7 @@ import 'package:tm_app/views/shared/base_button.dart'; import 'package:tm_app/views/shared/select_submission_bottom_sheet.dart'; import '../../../data/services/model/tender_data/tender_data.dart'; +import '../../shared/select_submission_dialog.dart'; class TenderDetailActions extends StatelessWidget { final bool isScreenBig; @@ -161,12 +162,11 @@ class TenderDetailActions extends StatelessWidget { submissionMode: 'self-apply', ); } else { - showModalBottomSheet( - isDismissible: true, + showDialog( context: context, builder: (context) { - return SelectSubmissionBottomSheet( - onConfirm: (value) { + return SelectSubmissionDialog( + onConfirm: (String value) { viewModel.submitTenderApproval( tenderId: detail.id!, submissionMode: value, diff --git a/lib/views/shared/select_submission_dialog.dart b/lib/views/shared/select_submission_dialog.dart new file mode 100644 index 0000000..5e59bf3 --- /dev/null +++ b/lib/views/shared/select_submission_dialog.dart @@ -0,0 +1,144 @@ +import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import 'package:tm_app/core/utils/size_config.dart'; + +import '../../core/theme/colors.dart'; + +class SelectSubmissionDialog extends StatefulWidget { + const SelectSubmissionDialog({required this.onConfirm, super.key}); + final ValueChanged onConfirm; + + @override + State createState() => _SelectSubmissionDialogState(); +} + +class _SelectSubmissionDialogState extends State { + int selectedType = 0; + String type = 'self-apply'; + @override + Widget build(BuildContext context) { + return Dialog( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(16), + side: BorderSide.none, + ), + child: Container( + width: 560, + height: 300, + padding: EdgeInsets.symmetric(horizontal: 24.0.w(), vertical: 16.0.h()), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(16), + ), + child: Column( + children: [ + Text( + 'Select Submission', + style: TextStyle( + fontSize: 20.0.sp(), + fontWeight: FontWeight.w600, + color: AppColors.grey70, + ), + ), + SizedBox(height: 8.0.h()), + _submissionType( + title: 'self-apply', + isSelected: type == 'self-apply', + onTap: () { + selectedType = 0; + type = 'self-apply'; + setState(() {}); + }, + ), + SizedBox(height: 8.0.h()), + _submissionType( + title: 'Partnership', + isSelected: type == 'partnership', + onTap: () { + selectedType = 1; + type = 'partnership'; + setState(() {}); + }, + ), + SizedBox(height: 8.0.h()), + Align( + alignment: Alignment.centerRight, + child: InkWell( + onTap: () { + widget.onConfirm(type); + context.pop(); + }, + child: Container( + width: 150, + height: 56.0, + decoration: BoxDecoration( + color: AppColors.primary20, + borderRadius: BorderRadius.circular(100), + ), + alignment: Alignment.center, + child: Text( + 'Confirm', + style: TextStyle( + fontSize: 14.0.sp(), + fontWeight: FontWeight.w500, + color: AppColors.mainBlue, + ), + ), + ), + ), + ), + ], + ), + ), + ); + } + + Widget _submissionType({ + required VoidCallback onTap, + required String title, + required bool isSelected, + }) { + return InkWell( + onTap: onTap, + child: SizedBox( + width: double.infinity, + height: 56.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: 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, + ), + ), + ), + Text( + title, + style: TextStyle( + fontSize: 16.0.sp(), + fontWeight: FontWeight.w400, + color: AppColors.grey80, + ), + ), + ], + ), + ), + ); + } +} diff --git a/lib/views/tenders/widgets/tender_action_buttons_row.dart b/lib/views/tenders/widgets/tender_action_buttons_row.dart index 1001f4d..f58dc5e 100644 --- a/lib/views/tenders/widgets/tender_action_buttons_row.dart +++ b/lib/views/tenders/widgets/tender_action_buttons_row.dart @@ -9,6 +9,7 @@ import '../../../core/constants/assets.dart'; import '../../../core/theme/colors.dart'; import '../../../core/utils/size_config.dart'; import '../../shared/select_submission_bottom_sheet.dart'; +import '../../shared/select_submission_dialog.dart'; class TenderActionButtonsRow extends StatelessWidget { final TenderData tender; @@ -122,21 +123,39 @@ class TenderActionButtonsRow extends StatelessWidget { status: 'submitted', ); } else { - showModalBottomSheet( - isDismissible: true, - context: context, - builder: (context) { - return SelectSubmissionBottomSheet( - onConfirm: (value) { - viewModel.toggleApprovals( - tenderId: tender.id!, - submissionMode: value, - status: 'submitted', - ); - }, - ); - }, - ); + final isMobile = MediaQuery.sizeOf(context).width < 600; + if (isMobile) { + showModalBottomSheet( + isDismissible: true, + context: context, + builder: (context) { + return SelectSubmissionBottomSheet( + onConfirm: (value) { + viewModel.toggleApprovals( + tenderId: tender.id!, + submissionMode: value, + status: 'submitted', + ); + }, + ); + }, + ); + } else { + showDialog( + context: context, + builder: (context) { + return SelectSubmissionDialog( + onConfirm: (String value) { + viewModel.toggleApprovals( + tenderId: tender.id!, + submissionMode: value, + status: 'submitted', + ); + }, + ); + }, + ); + } } }, child: Column(