188 lines
7.0 KiB
Dart
188 lines
7.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
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/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';
|
|
import '../strings/tender_details_strings.dart';
|
|
|
|
class TenderDetailActions extends StatelessWidget {
|
|
final bool isScreenBig;
|
|
final TenderData detail;
|
|
const TenderDetailActions({
|
|
required this.isScreenBig,
|
|
required this.detail,
|
|
super.key,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return isScreenBig
|
|
? _webActions()
|
|
: Column(
|
|
children: [
|
|
Consumer<TenderDetailViewModel>(
|
|
builder: (context, viewModel, child) {
|
|
return viewModel.isSubmitApprovalLoading
|
|
? Container(
|
|
height: 56.0.h(),
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: AppColors.primary30,
|
|
borderRadius: BorderRadius.circular(100.0),
|
|
),
|
|
child: Center(
|
|
child: CircularProgressIndicator(
|
|
color: AppColors.mainBlue,
|
|
),
|
|
),
|
|
)
|
|
: BaseButton(
|
|
isEnabled: true,
|
|
text: TenderDetailsStrings.tenderSubmitButton,
|
|
backgroundColor: AppColors.primary30,
|
|
textColor: AppColors.mainBlue,
|
|
onPressed: () {
|
|
if (viewModel.status == 'submitted') {
|
|
viewModel.submitTenderApproval(
|
|
tenderId: detail.id!,
|
|
submissionMode: 'self-apply',
|
|
);
|
|
} else {
|
|
showModalBottomSheet(
|
|
isDismissible: true,
|
|
context: context,
|
|
builder: (context) {
|
|
return SelectSubmissionBottomSheet(
|
|
onConfirm: (value) {
|
|
viewModel.submitTenderApproval(
|
|
tenderId: detail.id!,
|
|
submissionMode: value,
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
},
|
|
);
|
|
},
|
|
),
|
|
SizedBox(height: 16.0.h()),
|
|
Consumer<TenderDetailViewModel>(
|
|
builder: (context, viewModel, child) {
|
|
return viewModel.isRejectApprovalLoading
|
|
? BaseButton(
|
|
isEnabled: true,
|
|
text: TenderDetailsStrings.tenderRejectButton,
|
|
borderColor: AppColors.error,
|
|
textColor: AppColors.error,
|
|
backgroundColor: AppColors.backgroundColor,
|
|
borderWidth: 1,
|
|
onPressed: () {},
|
|
)
|
|
: BaseButton(
|
|
isEnabled: true,
|
|
text: TenderDetailsStrings.tenderRejectButton,
|
|
borderColor: AppColors.error,
|
|
textColor: AppColors.error,
|
|
backgroundColor: AppColors.backgroundColor,
|
|
borderWidth: 1,
|
|
onPressed: () {
|
|
viewModel.rejectTenderApproval(
|
|
tenderId: detail.id!,
|
|
submissionMode: 'self-apply',
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
SizedBox(height: 16.0.h()),
|
|
],
|
|
);
|
|
}
|
|
|
|
Row _webActions() {
|
|
return Row(
|
|
children: [
|
|
Spacer(),
|
|
Consumer<TenderDetailViewModel>(
|
|
builder: (context, viewModel, child) {
|
|
return viewModel.isRejectApprovalLoading
|
|
? BaseButton(
|
|
isEnabled: true,
|
|
text: TenderDetailsStrings.tenderRejectButton,
|
|
textColor: AppColors.red10,
|
|
backgroundColor: AppColors.backgroundColor,
|
|
borderWidth: 1,
|
|
onPressed: () {},
|
|
width: 120.0.w(),
|
|
)
|
|
: BaseButton(
|
|
isEnabled: true,
|
|
text: TenderDetailsStrings.tenderRejectButton,
|
|
textColor: AppColors.red10,
|
|
backgroundColor: AppColors.backgroundColor,
|
|
borderWidth: 1,
|
|
onPressed: () {
|
|
viewModel.rejectTenderApproval(
|
|
tenderId: detail.id!,
|
|
submissionMode: 'self-apply',
|
|
);
|
|
},
|
|
width: 120.0.w(),
|
|
);
|
|
},
|
|
),
|
|
SizedBox(width: 5.0.w()),
|
|
Consumer<TenderDetailViewModel>(
|
|
builder: (context, viewModel, child) {
|
|
return viewModel.isSubmitApprovalLoading
|
|
? BaseButton(
|
|
isEnabled: true,
|
|
text: TenderDetailsStrings.tenderSubmitButton,
|
|
backgroundColor: AppColors.lightBlue,
|
|
textColor: AppColors.mainBlue,
|
|
onPressed: () {},
|
|
width: 120.0.w(),
|
|
)
|
|
: BaseButton(
|
|
isEnabled: true,
|
|
text: TenderDetailsStrings.tenderSubmitButton,
|
|
backgroundColor: AppColors.lightBlue,
|
|
textColor: AppColors.mainBlue,
|
|
onPressed: () {
|
|
if (viewModel.status == 'submitted') {
|
|
viewModel.submitTenderApproval(
|
|
tenderId: detail.id!,
|
|
submissionMode: 'self-apply',
|
|
);
|
|
} else {
|
|
showDialog(
|
|
context: context,
|
|
builder: (context) {
|
|
return SelectSubmissionDialog(
|
|
onConfirm: (String value) {
|
|
viewModel.submitTenderApproval(
|
|
tenderId: detail.id!,
|
|
submissionMode: value,
|
|
);
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
},
|
|
width: 120.0.w(),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|