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. TafsirStyle? externalTafsirStyle,
})

Implementation

Future<void> showAyahMenuDialog({
  required BuildContext context,
  required bool isDark,
  required AyahModel ayah,
  required Offset position,
  required int index,
  required int pageIndex,
  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,
              externalTafsirStyle: externalTafsirStyle,
              onDismiss: () {
                ctrl.showControlToggle();
                Navigator.of(dialogContext).pop();
              },
            ),
          ],
        ),
      );
    },
  ).whenComplete(() {
    ctrl.state.isShowMenu.value = false;
  });
}