import 'package:flutter/material.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/theme/colors.dart'; import 'package:mc_common_app/utils/navigator.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/extensions/extensions_widget.dart'; import 'package:mc_common_app/widgets/txt_field.dart'; import 'package:easy_localization/easy_localization.dart'; class ShowCollectPaymentSheet extends StatelessWidget { Function() onClickYes; Function() onClickNo; ShowCollectPaymentSheet( {required this.onClickYes, required this.onClickNo, Key? key}) : super(key: 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 Reason { String title; bool isSelected; Reason(this.title, this.isSelected); } class CancelAppointmentReasonSheet extends StatefulWidget { Function(String) onCancelClick; CancelAppointmentReasonSheet({required this.onCancelClick, Key? key}) : super(key: key); @override State createState() => _CancelAppointmentReasonSheetState(); } class _CancelAppointmentReasonSheetState extends State { String reason = ""; List reasonList = [ Reason("Operational Issue", true), Reason("Material Issue", false), Reason("The customer no longer responding", false), Reason("Other", false), ]; @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.only(left: 21, right: 21, top: 12, bottom: 21), width: double.infinity, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ LocaleKeys.reason.tr().toText(fontSize: 24, isBold: true), ListView.separated( itemBuilder: (context, index) { return Padding( padding: const EdgeInsets.only(top: 12, bottom: 12), child: Row( children: [ Container( width: 14, height: 14, decoration: BoxDecoration( color: reasonList[index].isSelected ? MyColors.darkPrimaryColor : Colors.transparent, borderRadius: BorderRadius.circular(122), border: Border.all( color: reasonList[index].isSelected ? MyColors.darkPrimaryColor : borderColor, width: 1), ), child: const Icon( Icons.done, size: 12, color: Colors.white, ), ), 12.width, reasonList[index].title.toText(isBold: true) ], ), ).onPress(() { for (var element in reasonList) { element.isSelected = false; } setState(() { reason = reasonList[index].title; reasonList[index].isSelected = true; }); }); }, separatorBuilder: (context, index) { return Container( width: double.infinity, height: 1, color: MyColors.borderColor, ); }, physics: const NeverScrollableScrollPhysics(), shrinkWrap: true, itemCount: reasonList.length, ), if (reason == "Other") TxtField( hint: LocaleKeys.typeHere.tr(), maxLines: 5, onChanged: (v) { reason = v; }, ), 12.height, Row( children: [ Expanded( child: ShowFillButton( title: LocaleKeys.no.tr(), isFilled: false, txtColor: MyColors.darkPrimaryColor, onPressed: () { pop(context); }, ), ), 12.width, Expanded( child: ShowFillButton( title: LocaleKeys.yes.tr(), onPressed: () { if (reason.isEmpty || reason == "Other") { Utils.showToast(LocaleKeys.pleaseSelectReason.tr()); } else { widget.onCancelClick(reason); pop(context); } }, ), ), ], ) ], ), ); } }