showAyahMenuDialog function

Future<void> showAyahMenuDialog({
  1. required BuildContext context,
  2. required bool isDark,
  3. required AyahModel ayah,
  4. required Offset position,
  5. required int index,
  6. required int pageIndex,
  7. Widget? anotherMenuChild,
  8. void anotherMenuChildOnTap(
    1. AyahModel ayah
    )?,
  9. Widget? secondMenuChild,
  10. void secondMenuChildOnTap(
    1. AyahModel ayah
    )?,
  11. TafsirStyle? externalTafsirStyle,
})

Implementation

Future<void> showAyahMenuDialog({
  required BuildContext context,
  required bool isDark,
  required AyahModel ayah,
  required Offset position,
  required int index,
  required int pageIndex,
  Widget? anotherMenuChild,
  void Function(AyahModel ayah)? anotherMenuChildOnTap,
  Widget? secondMenuChild,
  void Function(AyahModel ayah)? secondMenuChildOnTap,
  TafsirStyle? externalTafsirStyle,
}) async {
  final ctrl = QuranCtrl.instance;
  if (ctrl.state.isShowMenu.value) return;

  ctrl.state.isShowMenu.value = true;
  await showGeneralDialog<void>(
    context: context,
    barrierDismissible: true,
    barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
    barrierColor: Colors.transparent,
    transitionDuration: Duration.zero,
    pageBuilder: (dialogContext, _, __) {
      return Material(
        type: MaterialType.transparency,
        child: Stack(
          children: [
            AyahMenuDialog(
              context: context,
              isDark: isDark,
              ayah: ayah,
              position: position,
              index: index,
              pageIndex: pageIndex,
              anotherMenuChild: anotherMenuChild,
              anotherMenuChildOnTap: anotherMenuChildOnTap,
              secondMenuChild: secondMenuChild,
              secondMenuChildOnTap: secondMenuChildOnTap,
              externalTafsirStyle: externalTafsirStyle,
              onDismiss: () {
                ctrl.showControlToggle();
                Navigator.of(dialogContext).pop();
              },
            ),
          ],
        ),
      );
    },
  ).whenComplete(() {
    ctrl.state.isShowMenu.value = false;
  });
}