showSuspendContentDialog static method

Future<void> showSuspendContentDialog(
  1. BuildContext context, {
  2. required String contentName,
  3. required Future<bool> onConfirm(
    1. String? reason
    ),
})

Shows suspend confirmation dialog with optional reason field. Calls onConfirm with the reason text if user confirms.

Implementation

static Future<void> showSuspendContentDialog(
  BuildContext context, {
  required String contentName,
  required Future<bool> Function(String? reason) onConfirm,
}) async {
  String? reason;
  Alert(
    context: context,
    style: AlertStyle(
      backgroundColor: AppColor.scaffold,
      titleStyle: const TextStyle(fontWeight: FontWeight.bold),
    ),
    title: CommonTranslationConstants.confirmSuspend.tr,
    content: Column(
      children: [
        Text(
          '${CommonTranslationConstants.suspendContentMsg.tr}\n\n"$contentName"',
          style: const TextStyle(fontSize: 15),
          textAlign: TextAlign.center,
        ),
        const SizedBox(height: 12),
        TextField(
          onChanged: (text) => reason = text,
          decoration: InputDecoration(
            labelText: CommonTranslationConstants.suspendReason.tr,
            border: const OutlineInputBorder(),
          ),
          maxLines: 2,
        ),
      ],
    ),
    buttons: [
      DialogButton(
        color: AppColor.bondiBlue75,
        onPressed: () => Sint.back(),
        child: Text(AppTranslationConstants.cancel.tr,
          style: const TextStyle(fontSize: 15),
        ),
      ),
      DialogButton(
        color: Colors.orange[700]!,
        onPressed: () async {
          Sint.back();
          final success = await onConfirm(reason);
          if (success) {
            AppUtilities.showSnackBar(
              message: CommonTranslationConstants.contentSuspended,
            );
          }
        },
        child: Text(CommonTranslationConstants.suspendContent.tr,
          style: const TextStyle(fontSize: 15, color: Colors.white),
        ),
      ),
    ],
  ).show();
}