mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
chore: use totalAssets from service
This commit is contained in:
parent
b827d0023e
commit
f85efb8018
1 changed files with 26 additions and 8 deletions
|
|
@ -1,5 +1,9 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
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/domain/models/events.model.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';
|
||||||
import 'package:immich_mobile/generated/translations.g.dart';
|
import 'package:immich_mobile/generated/translations.g.dart';
|
||||||
import 'package:immich_mobile/presentation/widgets/bottom_sheet/base_bottom_sheet.widget.dart';
|
import 'package:immich_mobile/presentation/widgets/bottom_sheet/base_bottom_sheet.widget.dart';
|
||||||
|
|
@ -29,11 +33,6 @@ class MapBottomSheet extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final _mapAssetCountProvider = StreamProvider.autoDispose<int>((ref) {
|
|
||||||
final service = ref.watch(timelineServiceProvider);
|
|
||||||
return service.watchBuckets().map((buckets) => buckets.fold(0, (acc, b) => acc + b.assetCount));
|
|
||||||
}, dependencies: [timelineServiceProvider]);
|
|
||||||
|
|
||||||
class _ScopedMapTimeline extends StatelessWidget {
|
class _ScopedMapTimeline extends StatelessWidget {
|
||||||
const _ScopedMapTimeline();
|
const _ScopedMapTimeline();
|
||||||
|
|
||||||
|
|
@ -64,12 +63,31 @@ class _ScopedMapTimeline extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MapTimelineContent extends ConsumerWidget {
|
class _MapTimelineContent extends ConsumerStatefulWidget {
|
||||||
const _MapTimelineContent();
|
const _MapTimelineContent();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
ConsumerState<_MapTimelineContent> createState() => _MapTimelineContentState();
|
||||||
final count = ref.watch(_mapAssetCountProvider).valueOrNull ?? 0;
|
}
|
||||||
|
|
||||||
|
class _MapTimelineContentState extends ConsumerState<_MapTimelineContent> {
|
||||||
|
StreamSubscription? _reloadSubscription;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_reloadSubscription = EventStream.shared.listen<TimelineReloadEvent>((_) => setState(() {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_reloadSubscription?.cancel();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final count = ref.watch(timelineServiceProvider.select((s) => s.totalAssets));
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Text(context.t.map_assets_in_bounds(count: count), style: context.themeData.textTheme.headlineSmall),
|
Text(context.t.map_assets_in_bounds(count: count), style: context.themeData.textTheme.headlineSmall),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue