chore: Lots of bug fixes and navigation improvements

This commit is contained in:
PartyDonut 2025-09-01 20:21:36 +02:00
parent 9bb5e81812
commit 92d5391b93
35 changed files with 513 additions and 455 deletions

View file

@ -90,7 +90,13 @@ class _PhotoViewerScreenState extends ConsumerState<PhotoViewerScreen> with Widg
if (context.mounted) {
setState(() {
photos = {...photos, ...newItems}.toList();
if (photos.length == 1 && newItems.contains(photos.first)) {
photos = newItems;
currentPage = photos.indexWhere((value) => value.id == widget.selected).clamp(0, photos.length - 1);
controller.jumpToPage(currentPage);
} else {
photos = {...photos, ...newItems}.toList();
}
loadingItems = false;
});
}
@ -165,14 +171,14 @@ class _PhotoViewerScreenState extends ConsumerState<PhotoViewerScreen> with Widg
? Center(
child: Text(context.localized.noItemsToShow),
)
: buildViewer(),
: buildViewer(context),
),
),
),
);
}
Widget buildViewer() {
Widget buildViewer(BuildContext context) {
final currentPhoto = photos[currentPage];
final imageHash = currentPhoto.images?.primary?.hash;
return Stack(
@ -498,8 +504,8 @@ class _PhotoViewerScreenState extends ConsumerState<PhotoViewerScreen> with Widg
},
);
void markAsFavourite(PhotoModel photo, {bool? value}) {
ref.read(userProvider.notifier).setAsFavorite(value ?? !photo.userData.isFavourite, photo.id);
Future<void> markAsFavourite(PhotoModel photo, {bool? value}) async {
await ref.read(userProvider.notifier).setAsFavorite(value ?? !photo.userData.isFavourite, photo.id);
setState(() {
int index = photos.indexOf(photo);