implement custom alert dialog
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:game_tracker/l10n/generated/app_localizations.dart';
|
|||||||
import 'package:game_tracker/presentation/widgets/tiles/settings_list_tile.dart';
|
import 'package:game_tracker/presentation/widgets/tiles/settings_list_tile.dart';
|
||||||
import 'package:game_tracker/services/data_transfer_service.dart';
|
import 'package:game_tracker/services/data_transfer_service.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
|
import 'package:game_tracker/presentation/widgets/custom_alert_dialog.dart';
|
||||||
|
|
||||||
class SettingsView extends StatefulWidget {
|
class SettingsView extends StatefulWidget {
|
||||||
const SettingsView({super.key});
|
const SettingsView({super.key});
|
||||||
@@ -92,17 +93,17 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog<bool>(
|
showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => CustomAlertDialog(
|
||||||
title: Text('${loc.delete_all_data}?'),
|
title: '${loc.delete_all_data}?',
|
||||||
content: Text(loc.this_cannot_be_undone),
|
content: loc.this_cannot_be_undone,
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(false),
|
onPressed: () => Navigator.of(context).pop(false),
|
||||||
child: Text(loc.cancel),
|
child: Text(loc.cancel, style: TextStyle(color: CustomTheme.textColor),),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(context).pop(true),
|
onPressed: () => Navigator.of(context).pop(true),
|
||||||
child: Text(loc.delete),
|
child: Text(loc.delete, style: TextStyle(color: CustomTheme.secondaryColor),),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
29
lib/presentation/widgets/custom_alert_dialog.dart
Normal file
29
lib/presentation/widgets/custom_alert_dialog.dart
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:game_tracker/core/custom_theme.dart';
|
||||||
|
|
||||||
|
class CustomAlertDialog extends StatelessWidget {
|
||||||
|
final String title;
|
||||||
|
final String content;
|
||||||
|
final List<Widget> actions;
|
||||||
|
|
||||||
|
const CustomAlertDialog({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
required this.content,
|
||||||
|
required this.actions,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return AlertDialog(
|
||||||
|
title: Text(title, style: const TextStyle(color: CustomTheme.textColor,),),
|
||||||
|
content: Text(content, style: const TextStyle(color: CustomTheme.textColor),),
|
||||||
|
actions: actions,
|
||||||
|
backgroundColor: CustomTheme.boxColor,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: CustomTheme.standardBorderRadiusAll,
|
||||||
|
side: BorderSide(color: CustomTheme.boxBorder),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user