Files
tm_app/lib/views/shared/select_submission_dialog.dart
T
amirrezaghabeli 13dbb5fae5 Enhance Customer model to include role attribute and update related components
- Added a new `role` attribute to the `Customer` model in `customer.dart` and updated the corresponding generated files.
- Modified the `AuthViewModel` to set the user role based on the logged-in user's role.
- Updated UI components in `TenderDetailActions` and `DesktopTendersPage` to conditionally render elements based on the user's role.
- Refactored tests to validate the new role attribute in the `Customer` model.
2025-10-14 09:12:24 +03:30

205 lines
6.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:tm_app/core/utils/size_config.dart';
import '../../core/constants/common_strings.dart';
import '../../core/constants/tender_submision_mode.dart';
import '../../core/theme/colors.dart';
class SelectSubmissionDialog extends StatefulWidget {
const SelectSubmissionDialog({required this.onConfirm, super.key});
final ValueChanged<String> onConfirm;
@override
State<SelectSubmissionDialog> createState() => _SelectSubmissionDialogState();
}
class _SelectSubmissionDialogState extends State<SelectSubmissionDialog> {
int selectedType = 0;
String type = TenderSubmissionMode.selfApply.value;
@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: AppColors.backgroundColor,
borderRadius: BorderRadius.circular(16),
),
child: Column(
children: [
Text(
CommonStrings.selectSubmission,
style: TextStyle(
fontSize: 20.0.sp(),
fontWeight: FontWeight.w600,
color: AppColors.grey70,
),
),
SizedBox(height: 8.0.h()),
_submissionType(
title: CommonStrings.selfApply,
isSelected: type == TenderSubmissionMode.selfApply.value,
onTap: () {
selectedType = 0;
type = TenderSubmissionMode.selfApply.value;
setState(() {});
},
),
SizedBox(height: 8.0.h()),
_submissionType(
title: CommonStrings.partnership,
isSelected: type == TenderSubmissionMode.partnership.value,
onTap: () {
selectedType = 1;
type = TenderSubmissionMode.partnership.value;
setState(() {});
},
),
SizedBox(height: 8.0.h()),
Align(
alignment: Alignment.centerRight,
child: Row(
children: [
const Spacer(),
// InkWell(
// onTap: () {
// context.pop();
// },
// child: Container(
// width: 150,
// height: 56.0,
// decoration: BoxDecoration(
// color: AppColors.red10,
// borderRadius: BorderRadius.circular(100),
// ),
// alignment: Alignment.center,
// child: Text(
// CommonStrings.cancel,
// style: TextStyle(
// fontSize: 14.0.sp(),
// fontWeight: FontWeight.w500,
// color: AppColors.red20,
// ),
// ),
// ),
// ),
InkWell(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
onTap: () {
context.pop();
},
child: Container(
width: 150,
height: 56.0,
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.circular(100),
border: Border.all(
color: AppColors.errorColor,
width: 2.0,
),
),
alignment: Alignment.center,
child: Text(
CommonStrings.cancel,
style: TextStyle(
fontSize: 14.0.sp(),
fontWeight: FontWeight.w500,
color: AppColors.errorColor,
),
),
),
),
SizedBox(width: 10.0.w()),
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(
CommonStrings.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: 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,
),
),
),
Text(
title,
style: TextStyle(
fontSize: 16.0.sp(),
fontWeight: FontWeight.w400,
color: AppColors.grey80,
),
),
],
),
),
);
}
}