Skip to content

Commit

Permalink
image_manager: import directly from the bulk adding menu
Browse files Browse the repository at this point in the history
  • Loading branch information
resucutie committed Dec 3, 2024
1 parent 7802994 commit 66eb8bd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/views/image_manager/shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import 'package:go_router/go_router.dart';
import 'package:localbooru/api/index.dart';
import 'package:localbooru/api/preset/index.dart';
import 'package:localbooru/components/app_bar_linear_progress.dart';
import 'package:localbooru/components/dialogs/download_dialog.dart';
import 'package:localbooru/components/dialogs/image_selector_dialog.dart';
import 'package:localbooru/components/dialogs/textfield_dialogs.dart';
import 'package:localbooru/utils/platform_tools.dart';
import 'package:localbooru/views/image_manager/form.dart';
import 'package:localbooru/views/image_manager/general_collection_manager.dart';
Expand Down Expand Up @@ -222,6 +224,35 @@ class _ImageManagerShellState extends State<ImageManagerShell> {
setState(() => imagePage = preset.pages!.length - 1);
_scaffoldKey.currentState!.closeEndDrawer();
}
),
ListTile(
title: const Text("Import from external website"),
leading: const Icon(Icons.download),
onTap: () async {
final url = await showDialog<String>(
context: context,
builder: (context) {
return const InsertURLDialog();
},
);
if(url == null) return;
final downloadedPreset = await importImageFromURL(url);
// final images = await openSelectionDialog(
// context: context,
// excludeImages: preset.pages!.where((imagePreset) => imagePreset.replaceID != null,).map((imagePreset) => imagePreset.replaceID!).toList()
// );
if(downloadedPreset is PresetImage) {
downloadedPreset.key = UniqueKey();
preset.pages!.add(downloadedPreset);
errorOnPages.add(false);
} else if (downloadedPreset is VirtualPresetCollection) {
final presets = downloadedPreset.pages;
if(presets == null) return;
preset.pages!.addAll(presets);
}
setState(() => imagePage = preset.pages!.length - 1);
_scaffoldKey.currentState!.closeEndDrawer();
}
),
],
),
Expand Down

0 comments on commit 66eb8bd

Please sign in to comment.