import 'package:flutter/material.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/helper/utils.dart'; import 'package:test_sa/models/lookup.dart'; import 'package:test_sa/new_views/app_style/app_color.dart'; import 'package:test_sa/new_views/common_widgets/app_filled_button.dart'; import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart'; import 'package:test_sa/new_views/common_widgets/single_item_drop_down_menu.dart'; import 'package:test_sa/providers/service_request_providers/reject_reason_provider.dart'; class RejectionReasonBottomSheet extends StatelessWidget { final Future Function(int reasonId, String comment) onRejectPressed; final VoidCallback? onRefreshed; RejectionReasonBottomSheet({Key? key, this.onRefreshed, required this.onRejectPressed}) : super(key: key); @override Widget build(BuildContext context) { TextEditingController _commentController = TextEditingController(); final GlobalKey _formKey = GlobalKey(); Lookup? selectedReason; return Form( key: _formKey, child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ SingleItemDropDownMenu( context: context, title: context.translation.reason, backgroundColor: AppColor.fieldBgColor(context), showShadow: false, showAsBottomSheet: true, validator: (value) { if (value == null) return "Mandatory"; return null; }, onSelect: (value) { selectedReason = value; }, ), 12.height, AppTextFormField( backgroundColor: AppColor.fieldBgColor(context), labelText: context.translation.comments, controller: _commentController, textInputType: TextInputType.multiline, alignLabelWithHint: true, showSpeechToText: true, showShadow: false, style: TextStyle(fontWeight: FontWeight.w500, fontSize: context.isTablet() ? 16 : 12, color: context.isDark ? Colors.white : const Color(0xff3B3D4A)), labelStyle: TextStyle(fontWeight: FontWeight.w500, fontSize: context.isTablet() ? 16 : 12, color: context.isDark ? Colors.white : const Color(0xff767676)), floatingLabelStyle: TextStyle(fontWeight: FontWeight.w500, fontSize: context.isTablet() ? 16 : 12, color: context.isDark ? Colors.white : const Color(0xff3B3D4A)), validator: (value) { if ((value ?? "").isEmpty) return "Mandatory"; return null; }, ), 16.height, AppFilledButton( label: context.translation.reject, buttonColor: AppColor.red30, onPressed: () async { if (_formKey.currentState!.validate()) { _formKey.currentState!.save(); Utils.showLoading(context); bool isSuccess = await onRejectPressed(selectedReason!.id!, _commentController.text); Utils.hideLoading(context); if (isSuccess) { Navigator.of(context).pop(); onRefreshed?.call(); } } }, ), 16.height, ], ), ); } }