mobile_skt/lib/util/modal.util.dart

69 lines
1.9 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'package:sk_base_mobile/widgets/core/zt_bottomsheet_picker.dart';
class ModalUtil {
static Future<bool> showWarningDialog(
String title, String msg, String button, VoidCallback onConfirm) async {
bool confirmed = false;
await showDialog(
context: Get.overlayContext!,
builder: (context) {
return AlertDialog(
title: Text(title),
content: Text(msg),
actions: [
TextButton(
child: const Text(
'Cancel',
style: TextStyle(color: Colors.black),
),
onPressed: () {
Navigator.of(context).pop();
confirmed = false;
},
),
TextButton(
child: Text(
button,
style: TextStyle(color: Colors.orange),
),
onPressed: () {
onConfirm();
Navigator.pop(context);
confirmed = true;
},
),
],
);
},
);
return confirmed;
}
/// 底部选择器支持3级
static Future<void> showBottomSheetPicker(
{title = '请选择',
required onChanged,
required firstLevel,
secondLevel,
thirdLevel,
itemHeight,
popupHeight}) async =>
showCupertinoModalPopup(
context: Get.overlayContext!,
builder: (BuildContext context) {
return ZtBottomSheetPicker(
title: title,
onChanged: onChanged,
firstLevel: firstLevel,
secondLevel: secondLevel,
thirdLevel: thirdLevel,
itemHeight: itemHeight ?? 80.0,
popupHeight: popupHeight ?? 400);
},
);
}