fix: refresh timeline by key

This commit is contained in:
wuzihao051119 2025-07-16 19:13:45 +08:00 committed by mertalev
parent bcac0983d7
commit 34786f3d48
No known key found for this signature in database
GPG Key ID: DF6ABC77AAD98C95

View File

@ -6,37 +6,45 @@ import 'package:immich_mobile/presentation/widgets/timeline/timeline.widget.dart
import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart'; import 'package:immich_mobile/providers/infrastructure/timeline.provider.dart';
import 'package:maplibre_gl/maplibre_gl.dart'; import 'package:maplibre_gl/maplibre_gl.dart';
class MapBottomSheet extends ConsumerWidget { class MapBottomSheet extends ConsumerStatefulWidget {
const MapBottomSheet({super.key}); const MapBottomSheet({super.key});
@override @override
Widget build(BuildContext context, WidgetRef ref) { ConsumerState<MapBottomSheet> createState() => _MapBottomSheetState();
}
class _MapBottomSheetState extends ConsumerState<MapBottomSheet> {
GlobalKey key = GlobalKey();
@override
Widget build(BuildContext context) {
LatLngBounds bounds = ref.watch(mapStateProvider.select((s) => s.bounds)); LatLngBounds bounds = ref.watch(mapStateProvider.select((s) => s.bounds));
ref.listen(mapStateProvider, (previous, next) async { ref.listen(mapStateProvider, (previous, next) async {
bounds = next.bounds; bounds = next.bounds;
key = GlobalKey();
}); });
return ProviderScope( return BaseBottomSheet(
overrides: [ initialChildSize: 0.25,
// TODO: when ProviderScope changed, we should refresh timeline shouldCloseOnMinExtent: false,
timelineServiceProvider.overrideWith((ref) { actions: [],
final timelineService = slivers: [
ref.watch(timelineFactoryProvider).map(bounds); SliverFillRemaining(
ref.onDispose(timelineService.dispose); child: ProviderScope(
return timelineService; key: key,
}), overrides: [
], timelineServiceProvider.overrideWith((ref) {
child: const BaseBottomSheet( final timelineService =
initialChildSize: 0.25, ref.watch(timelineFactoryProvider).map(bounds);
shouldCloseOnMinExtent: false, ref.onDispose(timelineService.dispose);
actions: [], return timelineService;
slivers: [ }),
SliverFillRemaining( ],
child: Timeline(), child: const Timeline(),
), ),
], ),
), ],
); );
} }
} }