Skip to content

Commit

Permalink
設定のインポート・エクスポートでダイアログを閉じられるように
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Sep 2, 2023
1 parent c843ec5 commit ce417bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
30 changes: 14 additions & 16 deletions lib/repository/import_export_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ class ImportExportRepository extends ChangeNotifier {
ImportExportRepository(this.reader);

Future<void> import(BuildContext context, Account account) async {
final folder = await showDialog<DriveFolder>(
barrierDismissible: false,
final result = await showDialog<FolderResult>(
context: context,
builder: (context2) => WillPopScope(
onWillPop: () async => false,
child: FolderSelectDialog(
account: account,
fileShowTarget: "miria.json.unknown",
),
builder: (context2) => FolderSelectDialog(
account: account,
fileShowTarget: "miria.json.unknown",
),
);
if (result == null) return;

final folder = result.folder;

final alreadyExists =
await reader(misskeyProvider(account)).drive.files.find(
Expand Down Expand Up @@ -112,17 +111,16 @@ class ImportExportRepository extends ChangeNotifier {
}

Future<void> export(BuildContext context, Account account) async {
final folder = await showDialog<DriveFolder>(
barrierDismissible: false,
final folders = await showDialog<List<DriveFolder>>(
context: context,
builder: (context2) => WillPopScope(
onWillPop: () async => false,
child: FolderSelectDialog(
account: account,
fileShowTarget: "miria.json.unknown",
),
builder: (context2) => FolderSelectDialog(
account: account,
fileShowTarget: "miria.json.unknown",
),
);
if (folders == null) return;

final folder = folders.lastOrNull;

final alreadyExists =
await reader(misskeyProvider(account)).drive.files.find(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 String? fileShowTarget;
Expand Down Expand Up @@ -118,7 +124,7 @@ class FolderSelectDialogState extends ConsumerState<FolderSelectDialog> {
actions: [
ElevatedButton(
onPressed: () {
Navigator.of(context).pop(path.lastOrNull);
Navigator.of(context).pop(FolderResult(path.lastOrNull));
},
child: const Text("このフォルダーに保存する"),
)
Expand Down

0 comments on commit ce417bd

Please sign in to comment.