You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
car_provider_app/lib/views/appoinments/widget/sheets.dart

152 lines
5.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:mc_common_app/classes/consts.dart';
import 'package:mc_common_app/extensions/int_extensions.dart';
import 'package:mc_common_app/extensions/string_extensions.dart';
import 'package:mc_common_app/generated/locale_keys.g.dart';
import 'package:mc_common_app/models/chat_models/chat_message_model.dart';
import 'package:mc_common_app/theme/colors.dart';
import 'package:mc_common_app/utils/utils.dart';
import 'package:mc_common_app/widgets/button/show_fill_button.dart';
import 'package:mc_common_app/widgets/checkbox_with_title_desc.dart';
import 'package:mc_common_app/widgets/common_widgets/info_bottom_sheet.dart';
import 'package:mc_common_app/widgets/txt_field.dart';
import 'package:easy_localization/easy_localization.dart';
class ShowCollectPaymentSheet extends StatelessWidget {
final Function() onClickYes;
final Function() onClickNo;
const ShowCollectPaymentSheet({required this.onClickYes, required this.onClickNo, super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(left: 21, right: 21, bottom: 21, top: 12),
child: Column(
children: [
LocaleKeys.collectMoneyBefore.tr().toText(
fontSize: 24,
isBold: true,
),
21.height,
Row(
children: [
Expanded(
child: ShowFillButton(
title: LocaleKeys.yes.tr(),
onPressed: onClickYes,
),
),
12.width,
Expanded(
child: ShowFillButton(
title: LocaleKeys.no.tr(),
isFilled: false,
txtColor: MyColors.darkPrimaryColor,
onPressed: onClickNo,
),
),
],
),
],
),
);
}
}
class CancelAppointmentReasonSheet extends StatefulWidget {
final Function(String) onCancelClick;
const CancelAppointmentReasonSheet({required this.onCancelClick, super.key});
@override
State<CancelAppointmentReasonSheet> createState() => _CancelAppointmentReasonSheetState();
}
class _CancelAppointmentReasonSheetState extends State<CancelAppointmentReasonSheet> {
String reason = "";
String reasonDesc = "";
List<OfferRequestCommentModel> reasonList = [
OfferRequestCommentModel(title: LocaleKeys.operationalIssue.tr(), isSelected: true, index: 0),
OfferRequestCommentModel(title: LocaleKeys.materialIssue.tr(), isSelected: false, index: 1),
OfferRequestCommentModel(title: LocaleKeys.customerNotResponding.tr(), isSelected: false, index: 2),
OfferRequestCommentModel(title: LocaleKeys.otherVar.tr(), isSelected: false, index: 3),
];
@override
Widget build(BuildContext context) {
return InfoBottomSheet(
title: LocaleKeys.pleaseSpecify.tr().toText(fontSize: 28, isBold: true, letterSpacing: -1.44, height: 1),
description: Padding(
padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
LocaleKeys.selectReasonBeforeCancel.tr().toText(fontSize: 13, color: MyColors.lightTextColor, fontWeight: MyFonts.Medium),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
12.height,
ListView.separated(
shrinkWrap: true,
itemCount: reasonList.length,
separatorBuilder: (BuildContext context, int index) {
return const Divider(thickness: 0.5);
},
itemBuilder: (BuildContext context, int index) {
OfferRequestCommentModel offerRequestCommentModel = reasonList[index];
return CircleCheckBoxWithTitle(
isChecked: offerRequestCommentModel.isSelected ?? false,
title: '${offerRequestCommentModel.title}',
onSelected: () {
for (var element in reasonList) {
element.isSelected = false;
}
setState(() {
reason = reasonList[index].title ?? "";
reasonList[index].isSelected = true;
});
},
selectedColor: MyColors.darkPrimaryColor,
);
},
),
if (reason == LocaleKeys.otherVar.tr()) ...[
12.height,
TxtField(
maxLines: 5,
keyboardType: TextInputType.text,
hint: LocaleKeys.description.tr(),
onChanged: (v) {
reasonDesc = v;
},
),
],
],
),
25.height,
ShowFillButton(
title: LocaleKeys.cancel.tr(),
onPressed: () {
if (reasonDesc.isEmpty && reason == LocaleKeys.otherVar.tr()) {
Utils.showToast(LocaleKeys.pleaseSelectReason.tr());
} else {
reasonDesc = "";
if (reason == LocaleKeys.otherVar.tr()) {
widget.onCancelClick(reasonDesc);
} else {
widget.onCancelClick(reason);
}
}
},
maxWidth: double.infinity,
),
19.height,
],
),
));
}
}