|
|
|
@ -9,19 +9,36 @@ 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/new_views/common_widgets/single_item_drop_down_menu.dart';
|
|
|
|
import 'package:test_sa/providers/service_request_providers/reject_reason_provider.dart';
|
|
|
|
import 'package:test_sa/providers/service_request_providers/reject_reason_provider.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class RejectionReasonBottomSheet extends StatelessWidget {
|
|
|
|
class RejectionReasonBottomSheet extends StatefulWidget {
|
|
|
|
final Future<bool> Function(int reasonId, String comment) onRejectPressed;
|
|
|
|
final Future<bool> Function(int reasonId, String comment) onRejectPressed;
|
|
|
|
final VoidCallback? onRefreshed;
|
|
|
|
final VoidCallback? onRefreshed;
|
|
|
|
|
|
|
|
|
|
|
|
RejectionReasonBottomSheet({Key? key, this.onRefreshed, required this.onRejectPressed}) : super(key: key);
|
|
|
|
const RejectionReasonBottomSheet({Key? key, this.onRefreshed, required this.onRejectPressed}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
State<RejectionReasonBottomSheet> createState() => _RejectionReasonBottomSheetState();
|
|
|
|
TextEditingController _commentController = TextEditingController();
|
|
|
|
}
|
|
|
|
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
|
|
|
|
|
|
|
|
|
|
|
class _RejectionReasonBottomSheetState extends State<RejectionReasonBottomSheet> {
|
|
|
|
|
|
|
|
late TextEditingController _commentController;
|
|
|
|
|
|
|
|
late GlobalKey<FormState> _formKey;
|
|
|
|
|
|
|
|
Lookup? selectedReason;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
_commentController = TextEditingController();
|
|
|
|
|
|
|
|
_formKey = GlobalKey<FormState>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Lookup? selectedReason;
|
|
|
|
@override
|
|
|
|
|
|
|
|
void dispose() {
|
|
|
|
|
|
|
|
_commentController.dispose();
|
|
|
|
|
|
|
|
super.dispose();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Form(
|
|
|
|
return Form(
|
|
|
|
key: _formKey,
|
|
|
|
key: _formKey,
|
|
|
|
child: Column(
|
|
|
|
child: Column(
|
|
|
|
@ -67,11 +84,11 @@ class RejectionReasonBottomSheet extends StatelessWidget {
|
|
|
|
if (_formKey.currentState!.validate()) {
|
|
|
|
if (_formKey.currentState!.validate()) {
|
|
|
|
_formKey.currentState!.save();
|
|
|
|
_formKey.currentState!.save();
|
|
|
|
Utils.showLoading(context);
|
|
|
|
Utils.showLoading(context);
|
|
|
|
bool isSuccess = await onRejectPressed(selectedReason!.id!, _commentController.text);
|
|
|
|
bool isSuccess = await widget.onRejectPressed(selectedReason!.id!, _commentController.text);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
Utils.hideLoading(context);
|
|
|
|
if (isSuccess) {
|
|
|
|
if (isSuccess) {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
onRefreshed?.call();
|
|
|
|
widget.onRefreshed?.call();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|