viewer: fixed delete action
This commit is contained in:
parent
730c8bd632
commit
23a20a9343
3 changed files with 17 additions and 10 deletions
|
@ -1,5 +1,4 @@
|
||||||
import 'package:aves/model/image_entry.dart';
|
import 'package:aves/model/image_entry.dart';
|
||||||
import 'package:aves/model/image_file_service.dart';
|
|
||||||
import 'package:aves/model/image_metadata.dart';
|
import 'package:aves/model/image_metadata.dart';
|
||||||
import 'package:aves/model/metadata_db.dart';
|
import 'package:aves/model/metadata_db.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
@ -121,7 +120,7 @@ class CollectionSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> delete(ImageEntry entry) async {
|
Future<bool> delete(ImageEntry entry) async {
|
||||||
final success = await ImageFileService.delete(entry);
|
final success = await entry.delete();
|
||||||
if (success) {
|
if (success) {
|
||||||
_rawEntries.remove(entry);
|
_rawEntries.remove(entry);
|
||||||
eventBus.fire(EntryRemovedEvent(entry));
|
eventBus.fire(EntryRemovedEvent(entry));
|
||||||
|
|
|
@ -103,6 +103,10 @@ class ImageEntry {
|
||||||
|
|
||||||
bool get isCatalogued => catalogMetadata != null;
|
bool get isCatalogued => catalogMetadata != null;
|
||||||
|
|
||||||
|
bool get canPrint => !isVideo;
|
||||||
|
|
||||||
|
bool get canRotate => mimeType == MimeTypes.MIME_JPEG || mimeType == MimeTypes.MIME_PNG;
|
||||||
|
|
||||||
double get aspectRatio {
|
double get aspectRatio {
|
||||||
if (width == 0 || height == 0) return 1;
|
if (width == 0 || height == 0) return 1;
|
||||||
if (isVideo && isCatalogued) {
|
if (isVideo && isCatalogued) {
|
||||||
|
@ -214,10 +218,6 @@ class ImageEntry {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get canPrint => !isVideo;
|
|
||||||
|
|
||||||
bool get canRotate => mimeType == MimeTypes.MIME_JPEG || mimeType == MimeTypes.MIME_PNG;
|
|
||||||
|
|
||||||
Future<bool> rotate({@required bool clockwise}) async {
|
Future<bool> rotate({@required bool clockwise}) async {
|
||||||
final newFields = await ImageFileService.rotate(this, clockwise: clockwise);
|
final newFields = await ImageFileService.rotate(this, clockwise: clockwise);
|
||||||
if (newFields.isEmpty) return false;
|
if (newFields.isEmpty) return false;
|
||||||
|
@ -232,4 +232,6 @@ class ImageEntry {
|
||||||
imageChangeNotifier.notifyListeners();
|
imageChangeNotifier.notifyListeners();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> delete() => ImageFileService.delete(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ class FullscreenActionDelegate {
|
||||||
@required this.showInfo,
|
@required this.showInfo,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
bool get hasCollection => collection != null;
|
||||||
|
|
||||||
void onActionSelected(BuildContext context, ImageEntry entry, FullscreenAction action) {
|
void onActionSelected(BuildContext context, ImageEntry entry, FullscreenAction action) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case FullscreenAction.delete:
|
case FullscreenAction.delete:
|
||||||
|
@ -109,10 +111,14 @@ class FullscreenActionDelegate {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (confirmed == null || !confirmed) return;
|
if (confirmed == null || !confirmed) return;
|
||||||
if (!await collection.source.delete(entry)) {
|
if (hasCollection) {
|
||||||
_showFeedback(context, 'Failed');
|
if (!await collection.source.delete(entry)) {
|
||||||
} else if (collection.sortedEntries.isEmpty) {
|
_showFeedback(context, 'Failed');
|
||||||
Navigator.pop(context);
|
} else if (collection.sortedEntries.isEmpty) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
} else if (await entry.delete()) {
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue