mirror of
https://github.com/immich-app/immich.git
synced 2025-11-11 09:06:53 -05:00
fix: view in timeline does not jump to the timeline correctly (#23428)
This commit is contained in:
parent
f5d7e5acca
commit
ceb36a304d
@ -53,3 +53,8 @@ const int kMinMonthsToEnableScrubberSnap = 12;
|
|||||||
const String kImmichAppStoreLink = "https://apps.apple.com/app/immich/id6449244941";
|
const String kImmichAppStoreLink = "https://apps.apple.com/app/immich/id6449244941";
|
||||||
const String kImmichPlayStoreLink = "https://play.google.com/store/apps/details?id=app.alextran.immich";
|
const String kImmichPlayStoreLink = "https://play.google.com/store/apps/details?id=app.alextran.immich";
|
||||||
const String kImmichLatestRelease = "https://github.com/immich-app/immich/releases/latest";
|
const String kImmichLatestRelease = "https://github.com/immich-app/immich/releases/latest";
|
||||||
|
|
||||||
|
const int kPhotoTabIndex = 0;
|
||||||
|
const int kSearchTabIndex = 1;
|
||||||
|
const int kAlbumTabIndex = 2;
|
||||||
|
const int kLibraryTabIndex = 3;
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import 'package:auto_route/auto_route.dart';
|
|||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/constants/constants.dart';
|
||||||
import 'package:immich_mobile/domain/models/timeline.model.dart';
|
import 'package:immich_mobile/domain/models/timeline.model.dart';
|
||||||
import 'package:immich_mobile/domain/utils/event_stream.dart';
|
import 'package:immich_mobile/domain/utils/event_stream.dart';
|
||||||
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||||
@ -13,6 +14,7 @@ import 'package:immich_mobile/providers/infrastructure/album.provider.dart';
|
|||||||
import 'package:immich_mobile/providers/infrastructure/memory.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/memory.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/people.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/people.provider.dart';
|
||||||
import 'package:immich_mobile/providers/infrastructure/readonly_mode.provider.dart';
|
import 'package:immich_mobile/providers/infrastructure/readonly_mode.provider.dart';
|
||||||
|
import 'package:immich_mobile/providers/routes.provider.dart';
|
||||||
import 'package:immich_mobile/providers/search/search_input_focus.provider.dart';
|
import 'package:immich_mobile/providers/search/search_input_focus.provider.dart';
|
||||||
import 'package:immich_mobile/providers/tab.provider.dart';
|
import 'package:immich_mobile/providers/tab.provider.dart';
|
||||||
import 'package:immich_mobile/providers/timeline/multiselect.provider.dart';
|
import 'package:immich_mobile/providers/timeline/multiselect.provider.dart';
|
||||||
@ -106,31 +108,33 @@ class _TabShellPageState extends ConsumerState<TabShellPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onNavigationSelected(TabsRouter router, int index, WidgetRef ref) {
|
void _onNavigationSelected(TabsRouter router, int index, WidgetRef ref) {
|
||||||
|
ref.read(currentTabIndexProvider.notifier).state = index;
|
||||||
|
|
||||||
// On Photos page menu tapped
|
// On Photos page menu tapped
|
||||||
if (router.activeIndex == 0 && index == 0) {
|
if (router.activeIndex == kPhotoTabIndex && index == kPhotoTabIndex) {
|
||||||
EventStream.shared.emit(const ScrollToTopEvent());
|
EventStream.shared.emit(const ScrollToTopEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index == 0) {
|
if (index == kPhotoTabIndex) {
|
||||||
ref.invalidate(driftMemoryFutureProvider);
|
ref.invalidate(driftMemoryFutureProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (router.activeIndex != 1 && index == 1) {
|
if (router.activeIndex != kSearchTabIndex && index == kSearchTabIndex) {
|
||||||
ref.read(searchPreFilterProvider.notifier).clear();
|
ref.read(searchPreFilterProvider.notifier).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Search page tapped
|
// On Search page tapped
|
||||||
if (router.activeIndex == 1 && index == 1) {
|
if (router.activeIndex == kSearchTabIndex && index == kSearchTabIndex) {
|
||||||
ref.read(searchInputFocusProvider).requestFocus();
|
ref.read(searchInputFocusProvider).requestFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Album page
|
// Album page
|
||||||
if (index == 2) {
|
if (index == kAlbumTabIndex) {
|
||||||
ref.read(remoteAlbumProvider.notifier).refresh();
|
ref.read(remoteAlbumProvider.notifier).refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Library page
|
// Library page
|
||||||
if (index == 3) {
|
if (index == kLibraryTabIndex) {
|
||||||
ref.invalidate(localAlbumProvider);
|
ref.invalidate(localAlbumProvider);
|
||||||
ref.invalidate(driftGetAllPeopleProvider);
|
ref.invalidate(driftGetAllPeopleProvider);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,12 +3,14 @@ import 'dart:async';
|
|||||||
import 'package:auto_route/auto_route.dart';
|
import 'package:auto_route/auto_route.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||||
|
import 'package:immich_mobile/constants/constants.dart';
|
||||||
import 'package:immich_mobile/entities/asset.entity.dart';
|
import 'package:immich_mobile/entities/asset.entity.dart';
|
||||||
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
import 'package:immich_mobile/extensions/translate_extensions.dart';
|
||||||
import 'package:immich_mobile/models/search/search_filter.model.dart';
|
import 'package:immich_mobile/models/search/search_filter.model.dart';
|
||||||
import 'package:immich_mobile/presentation/pages/search/paginated_search.provider.dart';
|
import 'package:immich_mobile/presentation/pages/search/paginated_search.provider.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/action_buttons/base_action_button.widget.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
|
import 'package:immich_mobile/presentation/widgets/asset_viewer/asset_viewer.state.dart';
|
||||||
|
import 'package:immich_mobile/providers/routes.provider.dart';
|
||||||
import 'package:immich_mobile/routing/router.dart';
|
import 'package:immich_mobile/routing/router.dart';
|
||||||
|
|
||||||
class SimilarPhotosActionButton extends ConsumerWidget {
|
class SimilarPhotosActionButton extends ConsumerWidget {
|
||||||
@ -35,7 +37,21 @@ class SimilarPhotosActionButton extends ConsumerWidget {
|
|||||||
mediaType: AssetType.image,
|
mediaType: AssetType.image,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
unawaited(context.router.popAndPush(const DriftSearchRoute()));
|
|
||||||
|
/// Using and currentTabIndex to make sure we are using the correct
|
||||||
|
/// navigation behavior. We want to be able to navigate back to the
|
||||||
|
/// main timline using View In Timeline button without the need of
|
||||||
|
/// waiting for the timeline to be rebuild. At the same time, we want
|
||||||
|
/// to refresh the search page when tapping the Similar Photos button
|
||||||
|
/// while already in the Search tab.
|
||||||
|
final currentTabIndex = (ref.read(currentTabIndexProvider.notifier).state);
|
||||||
|
|
||||||
|
if (currentTabIndex != kSearchTabIndex) {
|
||||||
|
unawaited(context.router.navigate(const DriftSearchRoute()));
|
||||||
|
ref.read(currentTabIndexProvider.notifier).state = kSearchTabIndex;
|
||||||
|
} else {
|
||||||
|
unawaited(context.router.popAndPush(const DriftSearchRoute()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@ -228,6 +228,8 @@ class _SliverTimelineState extends ConsumerState<_SliverTimeline> {
|
|||||||
curve: Curves.easeInOut,
|
curve: Curves.easeInOut,
|
||||||
)
|
)
|
||||||
.whenComplete(() => ref.read(timelineStateProvider.notifier).setScrubbing(false));
|
.whenComplete(() => ref.read(timelineStateProvider.notifier).setScrubbing(false));
|
||||||
|
} else {
|
||||||
|
ref.read(timelineStateProvider.notifier).setScrubbing(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,3 +5,4 @@ final inLockedViewProvider = StateProvider<bool>((ref) => false);
|
|||||||
final currentRouteNameProvider = StateProvider<String?>((ref) => null);
|
final currentRouteNameProvider = StateProvider<String?>((ref) => null);
|
||||||
final previousRouteNameProvider = StateProvider<String?>((ref) => null);
|
final previousRouteNameProvider = StateProvider<String?>((ref) => null);
|
||||||
final previousRouteDataProvider = StateProvider<RouteSettings?>((ref) => null);
|
final previousRouteDataProvider = StateProvider<RouteSettings?>((ref) => null);
|
||||||
|
final currentTabIndexProvider = StateProvider<int>((ref) => 0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user