From 1a46097162122521d6fd62f13d50bf173978fdbc Mon Sep 17 00:00:00 2001 From: wuzihao051119 Date: Wed, 9 Jul 2025 13:53:36 +0800 Subject: [PATCH] feat(mobile): hide storage indicator outside main timeline --- .../lib/presentation/pages/dev/main_timeline.page.dart | 7 ++++--- .../pages/drift_asset_selection_timeline.page.dart | 2 +- .../widgets/timeline/fixed/segment.model.dart | 9 +++++++++ .../widgets/timeline/fixed/segment_builder.dart | 3 +++ .../presentation/widgets/timeline/timeline.state.dart | 10 ++++++++-- .../presentation/widgets/timeline/timeline.widget.dart | 3 +++ 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/mobile/lib/presentation/pages/dev/main_timeline.page.dart b/mobile/lib/presentation/pages/dev/main_timeline.page.dart index 9ec8002463..7216b638e1 100644 --- a/mobile/lib/presentation/pages/dev/main_timeline.page.dart +++ b/mobile/lib/presentation/pages/dev/main_timeline.page.dart @@ -16,17 +16,18 @@ class MainTimelinePage extends ConsumerWidget { return memoryLaneProvider.when( data: (memories) { return memories.isEmpty - ? const Timeline() + ? const Timeline(showStorageIndicator: true) : Timeline( topSliverWidget: SliverToBoxAdapter( key: Key('memory-lane-${memories.first.assets.first.id}'), child: DriftMemoryLane(memories: memories), ), topSliverWidgetHeight: 200, + showStorageIndicator: true, ); }, - loading: () => const Timeline(), - error: (error, stackTrace) => const Timeline(), + loading: () => const Timeline(showStorageIndicator: true), + error: (error, stackTrace) => const Timeline(showStorageIndicator: true), ); } } diff --git a/mobile/lib/presentation/pages/drift_asset_selection_timeline.page.dart b/mobile/lib/presentation/pages/drift_asset_selection_timeline.page.dart index df6211c338..7ac378e4f5 100644 --- a/mobile/lib/presentation/pages/drift_asset_selection_timeline.page.dart +++ b/mobile/lib/presentation/pages/drift_asset_selection_timeline.page.dart @@ -33,7 +33,7 @@ class DriftAssetSelectionTimelinePage extends ConsumerWidget { final user = ref.watch(currentUserProvider); if (user == null) { throw Exception( - 'User must be logged in to access recently taken', + 'User must be logged in to access asset selection timeline', ); } diff --git a/mobile/lib/presentation/widgets/timeline/fixed/segment.model.dart b/mobile/lib/presentation/widgets/timeline/fixed/segment.model.dart index 14b1a4616d..7d91a87867 100644 --- a/mobile/lib/presentation/widgets/timeline/fixed/segment.model.dart +++ b/mobile/lib/presentation/widgets/timeline/fixed/segment.model.dart @@ -19,6 +19,7 @@ class FixedSegment extends Segment { final double tileHeight; final int columnCount; final double mainAxisExtend; + final bool showStorageIndicator; const FixedSegment({ required super.firstIndex, @@ -29,6 +30,7 @@ class FixedSegment extends Segment { required super.bucket, required this.tileHeight, required this.columnCount, + required this.showStorageIndicator, required super.headerExtent, required super.spacing, required super.header, @@ -78,6 +80,7 @@ class FixedSegment extends Segment { assetCount: numberOfAssets, tileHeight: tileHeight, spacing: spacing, + showStorageIndicator: showStorageIndicator, ); } } @@ -87,12 +90,14 @@ class _FixedSegmentRow extends ConsumerWidget { final int assetCount; final double tileHeight; final double spacing; + final bool showStorageIndicator; const _FixedSegmentRow({ required this.assetIndex, required this.assetCount, required this.tileHeight, required this.spacing, + required this.showStorageIndicator, }); @override @@ -143,6 +148,7 @@ class _FixedSegmentRow extends ConsumerWidget { key: ValueKey(assets[i].heroTag), asset: assets[i], assetIndex: assetIndex + i, + showStorageIndicator: showStorageIndicator, ), ], ); @@ -152,11 +158,13 @@ class _FixedSegmentRow extends ConsumerWidget { class _AssetTileWidget extends ConsumerWidget { final BaseAsset asset; final int assetIndex; + final bool showStorageIndicator; const _AssetTileWidget({ super.key, required this.asset, required this.assetIndex, + required this.showStorageIndicator, }); void _handleOnTap( @@ -217,6 +225,7 @@ class _AssetTileWidget extends ConsumerWidget { child: ThumbnailTile( asset, lockSelection: lockSelection, + showStorageIndicator: showStorageIndicator, ), ), ); diff --git a/mobile/lib/presentation/widgets/timeline/fixed/segment_builder.dart b/mobile/lib/presentation/widgets/timeline/fixed/segment_builder.dart index 327e690267..1f0bb8807e 100644 --- a/mobile/lib/presentation/widgets/timeline/fixed/segment_builder.dart +++ b/mobile/lib/presentation/widgets/timeline/fixed/segment_builder.dart @@ -6,11 +6,13 @@ import 'package:immich_mobile/presentation/widgets/timeline/segment_builder.dart class FixedSegmentBuilder extends SegmentBuilder { final double tileHeight; final int columnCount; + final bool showStorageIndicator; const FixedSegmentBuilder({ required super.buckets, required this.tileHeight, required this.columnCount, + required this.showStorageIndicator, super.spacing, super.groupBy, }); @@ -59,6 +61,7 @@ class FixedSegmentBuilder extends SegmentBuilder { bucket: bucket, tileHeight: tileHeight, columnCount: columnCount, + showStorageIndicator: showStorageIndicator, headerExtent: headerExtent, spacing: spacing, header: timelineHeader, diff --git a/mobile/lib/presentation/widgets/timeline/timeline.state.dart b/mobile/lib/presentation/widgets/timeline/timeline.state.dart index 629fac7831..db07dd2841 100644 --- a/mobile/lib/presentation/widgets/timeline/timeline.state.dart +++ b/mobile/lib/presentation/widgets/timeline/timeline.state.dart @@ -14,10 +14,12 @@ class TimelineArgs { final double maxHeight; final double spacing; final int columnCount; + final bool showStorageIndicator; const TimelineArgs({ required this.maxWidth, required this.maxHeight, + required this.showStorageIndicator, this.spacing = kTimelineSpacing, this.columnCount = kTimelineColumnCount, }); @@ -27,7 +29,8 @@ class TimelineArgs { return spacing == other.spacing && maxWidth == other.maxWidth && maxHeight == other.maxHeight && - columnCount == other.columnCount; + columnCount == other.columnCount && + showStorageIndicator == other.showStorageIndicator; } @override @@ -35,7 +38,8 @@ class TimelineArgs { maxWidth.hashCode ^ maxHeight.hashCode ^ spacing.hashCode ^ - columnCount.hashCode; + columnCount.hashCode ^ + showStorageIndicator.hashCode; } class TimelineState { @@ -90,6 +94,7 @@ final timelineSegmentProvider = StreamProvider.autoDispose>( final args = ref.watch(timelineArgsProvider); final columnCount = args.columnCount; final spacing = args.spacing; + final showStorageIndicator = args.showStorageIndicator; final availableTileWidth = args.maxWidth - (spacing * (columnCount - 1)); final tileExtent = math.max(0, availableTileWidth) / columnCount; @@ -102,6 +107,7 @@ final timelineSegmentProvider = StreamProvider.autoDispose>( buckets: buckets, tileHeight: tileExtent, columnCount: columnCount, + showStorageIndicator: showStorageIndicator, spacing: spacing, groupBy: groupBy, ).generate(); diff --git a/mobile/lib/presentation/widgets/timeline/timeline.widget.dart b/mobile/lib/presentation/widgets/timeline/timeline.widget.dart index 9fb164e2dc..88c27e7842 100644 --- a/mobile/lib/presentation/widgets/timeline/timeline.widget.dart +++ b/mobile/lib/presentation/widgets/timeline/timeline.widget.dart @@ -25,10 +25,12 @@ class Timeline extends StatelessWidget { super.key, this.topSliverWidget, this.topSliverWidgetHeight, + this.showStorageIndicator = false, }); final Widget? topSliverWidget; final double? topSliverWidgetHeight; + final bool showStorageIndicator; @override Widget build(BuildContext context) { @@ -43,6 +45,7 @@ class Timeline extends StatelessWidget { columnCount: ref.watch( settingsProvider.select((s) => s.get(Setting.tilesPerRow)), ), + showStorageIndicator: showStorageIndicator, ), ), ],