treewide: replace confirm_dialog with builtin AlertDialog
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:confirm_dialog/confirm_dialog.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
@@ -39,6 +38,26 @@ class _LibraryContentViewState extends State<LibraryContentView> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<bool> _confirm(BuildContext context, {required Widget content}) async {
|
||||
return await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
content: content,
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
) ??
|
||||
false;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -49,7 +68,7 @@ class _LibraryContentViewState extends State<LibraryContentView> {
|
||||
onPressed: () async {
|
||||
final entryCount = widget.library.totalCount;
|
||||
if (!context.mounted) return;
|
||||
final bool userIsSure = await confirm(
|
||||
final bool userIsSure = await _confirm(
|
||||
context,
|
||||
content: Text(
|
||||
'Are you sure that you want to clear all $entryCount entries?',
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:confirm_dialog/confirm_dialog.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@@ -32,6 +31,29 @@ class _SettingsViewState extends State<SettingsView> {
|
||||
bool dataExportIsLoading = false;
|
||||
bool dataImportIsLoading = false;
|
||||
|
||||
Future<bool> confirm(
|
||||
BuildContext context, {
|
||||
required Widget content,
|
||||
}) async {
|
||||
return await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
content: content,
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
) ??
|
||||
false;
|
||||
}
|
||||
|
||||
Future<void> clearHistory(BuildContext context) async {
|
||||
final historyCount = await GetIt.instance
|
||||
.get<Database>()
|
||||
|
||||
@@ -97,14 +97,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.19.1"
|
||||
confirm_dialog:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: confirm_dialog
|
||||
sha256: "99b431d2f13bf64a6056fc8f1b2b85a1fc7be572da3f28a17f8a009438542327"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
cross_file:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -12,7 +12,6 @@ dependencies:
|
||||
cupertino_icons: ^1.0.8
|
||||
animated_size_and_fade: ^5.1.1
|
||||
collection: ^1.19.0
|
||||
confirm_dialog: ^1.0.4
|
||||
division: ^0.9.0
|
||||
file_picker: ^10.2.0
|
||||
flutter_bloc: ^9.1.0
|
||||
|
||||
Reference in New Issue
Block a user