showLimeniaReportSheet function

Future<ReportResult?> showLimeniaReportSheet(
  1. BuildContext context, {
  2. required Future<ReportResult> onSubmit(
    1. ReportDraft draft
    ),
  3. List<ReportCategoryOption>? categories,
  4. GoodFaithConfirmation goodFaith = GoodFaithConfirmation.hidden,
  5. ReportEmergencyHint? emergencyHint = const ReportEmergencyHint(),
  6. String? title,
  7. LimeniaUiStrings? strings,
})

Shows the report form (LimeniaReportForm) in a modal bottom sheet.

The sheet calls onSubmit with what the user entered and shows its result. It completes with the last result when it closes, or null if the user closed it before a result arrived (the report goes on in onSubmit). The other arguments are those of LimeniaReportForm.

final result = await showLimeniaReportSheet(
  context,
  onSubmit: (draft) => limenia.report(ReportRequest.content(...)),
);

Implementation

Future<ReportResult?> showLimeniaReportSheet(
  BuildContext context, {
  required Future<ReportResult> Function(ReportDraft draft) onSubmit,
  List<ReportCategoryOption>? categories,
  GoodFaithConfirmation goodFaith = GoodFaithConfirmation.hidden,
  ReportEmergencyHint? emergencyHint = const ReportEmergencyHint(),
  String? title,
  LimeniaUiStrings? strings,
}) async {
  ReportResult? last;
  await showLimeniaSheet(
    context,
    (sheetContext) => LimeniaReportForm(
      onSubmit: onSubmit,
      categories: categories,
      goodFaith: goodFaith,
      emergencyHint: emergencyHint,
      title: title,
      strings: strings,
      onResult: (result) => last = result,
      onClose: () => Navigator.of(sheetContext).pop(),
    ),
  );
  return last;
}