44 lines
1.4 KiB
Dart
44 lines
1.4 KiB
Dart
import 'package:digiplug/bat_theme/bat_theme.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
// Fungsi helper untuk menampilkan dialog konfirmasi
|
|
Future<bool> showConfirmationDialog({
|
|
required BuildContext context,
|
|
required String title,
|
|
required String content,
|
|
String confirmText = 'Ya, Lanjutkan',
|
|
String cancelText = 'Batal',
|
|
}) async {
|
|
final theme = BatThemeData.of(context);
|
|
final result = await showDialog<bool>(
|
|
context: context,
|
|
builder: (BuildContext context) {
|
|
return AlertDialog(
|
|
backgroundColor: theme.colors.background,
|
|
title: Text(title, style: theme.typography.headline4),
|
|
content: Text(content, style: theme.typography.bodyCopy),
|
|
actions: <Widget>[
|
|
TextButton(
|
|
child: Text(cancelText,
|
|
style: TextStyle(color: theme.colors.tertiary)),
|
|
onPressed: () {
|
|
// Mengembalikan false saat tombol batal ditekan
|
|
Navigator.of(context).pop(false);
|
|
},
|
|
),
|
|
TextButton(
|
|
child: Text(confirmText,
|
|
style: const TextStyle(color: Colors.redAccent)),
|
|
onPressed: () {
|
|
// Mengembalikan true saat tombol konfirmasi ditekan
|
|
Navigator.of(context).pop(true);
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
// Mengembalikan false jika dialog ditutup tanpa menekan tombol
|
|
return result ?? false;
|
|
}
|