123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:vitalapp/components/alert_dialog.dart';
- class ConfirmBox {
- static Future<bool> show({
- String? title,
- required String content,
- VoidCallback? onConfirm,
- VoidCallback? onCancel,
- double? width,
- bool showCancel = true,
- }) async {
- final result = await Get.dialog(
- VAlertDialog(
- title: title ?? "提示",
- width: width ?? 320,
- content: Container(
- height: 32,
- padding: const EdgeInsets.symmetric(horizontal: 24),
- alignment: Alignment.center,
- child: Text(content, style: TextStyle(fontSize: 20)),
- ),
- onConfirm: () async {
- onConfirm?.call();
- Get.back(result: true);
- },
- onCanceled: () {
- onCancel?.call();
- return false;
- },
- showCancel: showCancel,
- ),
- barrierDismissible: false,
- barrierColor: Colors.black.withOpacity(.4),
- );
- return result;
- }
- static Future<bool> showMultiLines({
- String? title,
- required List<String> contents,
- VoidCallback? onConfirm,
- VoidCallback? onCancel,
- double? width,
- bool showCancel = true,
- }) async {
- final result = await Get.dialog(
- VAlertDialog(
- title: title ?? "提示",
- width: width ?? 320,
- content: Column(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.start,
- children: [
- for (var content in contents)
- Container(
- height: 32,
- padding: const EdgeInsets.symmetric(horizontal: 24),
- alignment: Alignment.centerLeft,
- child: Text(content, style: TextStyle(fontSize: 20)),
- ),
- ],
- ),
- onConfirm: () async {
- onConfirm?.call();
- Get.back(result: true);
- },
- onCanceled: () {
- onCancel?.call();
- return false;
- },
- showCancel: showCancel,
- ),
- barrierDismissible: false,
- barrierColor: Colors.black.withOpacity(.4),
- );
- return result;
- }
- }
|