From d83280b5335da724350292de267035c822ecd7b1 Mon Sep 17 00:00:00 2001 From: poppingmoon <63451158+poppingmoon@users.noreply.github.com> Date: Sat, 29 Jul 2023 00:23:43 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=81=AE=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=88=E3=83=BB=E3=82=A8=E3=82=AF=E3=82=B9?= =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=88=E3=81=A7=E3=83=80=E3=82=A4=E3=82=A2?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=82=92=E9=96=89=E3=81=98=E3=82=89=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/repository/import_export_repository.dart | 31 +++++++++---------- .../folder_select_dialog.dart | 8 ++++- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/repository/import_export_repository.dart b/lib/repository/import_export_repository.dart index a8101b569..647428028 100644 --- a/lib/repository/import_export_repository.dart +++ b/lib/repository/import_export_repository.dart @@ -24,17 +24,16 @@ class ImportExportRepository extends ChangeNotifier { ImportExportRepository(this.reader); Future import(BuildContext context, Account account) async { - final folder = await showDialog( - barrierDismissible: false, + final result = await showDialog( context: context, - builder: (context2) => WillPopScope( - onWillPop: () async => false, - child: FolderSelectDialog( - account: account, - fileShowTarget: const ["miria.json", "miria.json.unknown"], - ), + builder: (context2) => FolderSelectDialog( + account: account, + fileShowTarget: const ["miria.json", "miria.json.unknown"], ), ); + if (result == null) return; + + final folder = result.folder; Iterable alreadyExists = await reader(misskeyProvider(account)).drive.files.find( @@ -53,6 +52,7 @@ class ImportExportRepository extends ChangeNotifier { ), ); + if (!context.mounted) return; if (alreadyExists.isEmpty) { await SimpleMessageDialog.show(context, "ここにMiriaの設定ファイルあれへんかったわ"); return; @@ -121,17 +121,16 @@ class ImportExportRepository extends ChangeNotifier { } Future export(BuildContext context, Account account) async { - final folder = await showDialog( - barrierDismissible: false, + final result = await showDialog( context: context, - builder: (context2) => WillPopScope( - onWillPop: () async => false, - child: FolderSelectDialog( - account: account, - fileShowTarget: const ["miria.json", "miria.json.unknown"], - ), + builder: (context2) => FolderSelectDialog( + account: account, + fileShowTarget: const ["miria.json", "miria.json.unknown"], ), ); + if (result == null) return; + + final folder = result.folder; final alreadyExists = await reader(misskeyProvider(account)).drive.files.find( diff --git a/lib/view/settings_page/import_export_page/folder_select_dialog.dart b/lib/view/settings_page/import_export_page/folder_select_dialog.dart index 7786fa67f..a3e6f4b27 100644 --- a/lib/view/settings_page/import_export_page/folder_select_dialog.dart +++ b/lib/view/settings_page/import_export_page/folder_select_dialog.dart @@ -6,6 +6,12 @@ import 'package:miria/view/common/futable_list_builder.dart'; import 'package:miria/view/common/pushable_listview.dart'; import 'package:misskey_dart/misskey_dart.dart'; +class FolderResult { + const FolderResult(this.folder); + + final DriveFolder? folder; +} + class FolderSelectDialog extends ConsumerStatefulWidget { final Account account; final List? fileShowTarget; @@ -123,7 +129,7 @@ class FolderSelectDialogState extends ConsumerState { actions: [ ElevatedButton( onPressed: () { - Navigator.of(context).pop(path.lastOrNull); + Navigator.of(context).pop(FolderResult(path.lastOrNull)); }, child: const Text("このフォルダーに保存する"), )