feat(mobile): hide storage indicator outside main timeline

This commit is contained in:
wuzihao051119 2025-07-09 13:53:36 +08:00
parent 4db76ddcf0
commit 1a46097162
6 changed files with 28 additions and 6 deletions

View File

@ -16,17 +16,18 @@ class MainTimelinePage extends ConsumerWidget {
return memoryLaneProvider.when( return memoryLaneProvider.when(
data: (memories) { data: (memories) {
return memories.isEmpty return memories.isEmpty
? const Timeline() ? const Timeline(showStorageIndicator: true)
: Timeline( : Timeline(
topSliverWidget: SliverToBoxAdapter( topSliverWidget: SliverToBoxAdapter(
key: Key('memory-lane-${memories.first.assets.first.id}'), key: Key('memory-lane-${memories.first.assets.first.id}'),
child: DriftMemoryLane(memories: memories), child: DriftMemoryLane(memories: memories),
), ),
topSliverWidgetHeight: 200, topSliverWidgetHeight: 200,
showStorageIndicator: true,
); );
}, },
loading: () => const Timeline(), loading: () => const Timeline(showStorageIndicator: true),
error: (error, stackTrace) => const Timeline(), error: (error, stackTrace) => const Timeline(showStorageIndicator: true),
); );
} }
} }

View File

@ -33,7 +33,7 @@ class DriftAssetSelectionTimelinePage extends ConsumerWidget {
final user = ref.watch(currentUserProvider); final user = ref.watch(currentUserProvider);
if (user == null) { if (user == null) {
throw Exception( throw Exception(
'User must be logged in to access recently taken', 'User must be logged in to access asset selection timeline',
); );
} }

View File

@ -19,6 +19,7 @@ class FixedSegment extends Segment {
final double tileHeight; final double tileHeight;
final int columnCount; final int columnCount;
final double mainAxisExtend; final double mainAxisExtend;
final bool showStorageIndicator;
const FixedSegment({ const FixedSegment({
required super.firstIndex, required super.firstIndex,
@ -29,6 +30,7 @@ class FixedSegment extends Segment {
required super.bucket, required super.bucket,
required this.tileHeight, required this.tileHeight,
required this.columnCount, required this.columnCount,
required this.showStorageIndicator,
required super.headerExtent, required super.headerExtent,
required super.spacing, required super.spacing,
required super.header, required super.header,
@ -78,6 +80,7 @@ class FixedSegment extends Segment {
assetCount: numberOfAssets, assetCount: numberOfAssets,
tileHeight: tileHeight, tileHeight: tileHeight,
spacing: spacing, spacing: spacing,
showStorageIndicator: showStorageIndicator,
); );
} }
} }
@ -87,12 +90,14 @@ class _FixedSegmentRow extends ConsumerWidget {
final int assetCount; final int assetCount;
final double tileHeight; final double tileHeight;
final double spacing; final double spacing;
final bool showStorageIndicator;
const _FixedSegmentRow({ const _FixedSegmentRow({
required this.assetIndex, required this.assetIndex,
required this.assetCount, required this.assetCount,
required this.tileHeight, required this.tileHeight,
required this.spacing, required this.spacing,
required this.showStorageIndicator,
}); });
@override @override
@ -143,6 +148,7 @@ class _FixedSegmentRow extends ConsumerWidget {
key: ValueKey(assets[i].heroTag), key: ValueKey(assets[i].heroTag),
asset: assets[i], asset: assets[i],
assetIndex: assetIndex + i, assetIndex: assetIndex + i,
showStorageIndicator: showStorageIndicator,
), ),
], ],
); );
@ -152,11 +158,13 @@ class _FixedSegmentRow extends ConsumerWidget {
class _AssetTileWidget extends ConsumerWidget { class _AssetTileWidget extends ConsumerWidget {
final BaseAsset asset; final BaseAsset asset;
final int assetIndex; final int assetIndex;
final bool showStorageIndicator;
const _AssetTileWidget({ const _AssetTileWidget({
super.key, super.key,
required this.asset, required this.asset,
required this.assetIndex, required this.assetIndex,
required this.showStorageIndicator,
}); });
void _handleOnTap( void _handleOnTap(
@ -217,6 +225,7 @@ class _AssetTileWidget extends ConsumerWidget {
child: ThumbnailTile( child: ThumbnailTile(
asset, asset,
lockSelection: lockSelection, lockSelection: lockSelection,
showStorageIndicator: showStorageIndicator,
), ),
), ),
); );

View File

@ -6,11 +6,13 @@ import 'package:immich_mobile/presentation/widgets/timeline/segment_builder.dart
class FixedSegmentBuilder extends SegmentBuilder { class FixedSegmentBuilder extends SegmentBuilder {
final double tileHeight; final double tileHeight;
final int columnCount; final int columnCount;
final bool showStorageIndicator;
const FixedSegmentBuilder({ const FixedSegmentBuilder({
required super.buckets, required super.buckets,
required this.tileHeight, required this.tileHeight,
required this.columnCount, required this.columnCount,
required this.showStorageIndicator,
super.spacing, super.spacing,
super.groupBy, super.groupBy,
}); });
@ -59,6 +61,7 @@ class FixedSegmentBuilder extends SegmentBuilder {
bucket: bucket, bucket: bucket,
tileHeight: tileHeight, tileHeight: tileHeight,
columnCount: columnCount, columnCount: columnCount,
showStorageIndicator: showStorageIndicator,
headerExtent: headerExtent, headerExtent: headerExtent,
spacing: spacing, spacing: spacing,
header: timelineHeader, header: timelineHeader,

View File

@ -14,10 +14,12 @@ class TimelineArgs {
final double maxHeight; final double maxHeight;
final double spacing; final double spacing;
final int columnCount; final int columnCount;
final bool showStorageIndicator;
const TimelineArgs({ const TimelineArgs({
required this.maxWidth, required this.maxWidth,
required this.maxHeight, required this.maxHeight,
required this.showStorageIndicator,
this.spacing = kTimelineSpacing, this.spacing = kTimelineSpacing,
this.columnCount = kTimelineColumnCount, this.columnCount = kTimelineColumnCount,
}); });
@ -27,7 +29,8 @@ class TimelineArgs {
return spacing == other.spacing && return spacing == other.spacing &&
maxWidth == other.maxWidth && maxWidth == other.maxWidth &&
maxHeight == other.maxHeight && maxHeight == other.maxHeight &&
columnCount == other.columnCount; columnCount == other.columnCount &&
showStorageIndicator == other.showStorageIndicator;
} }
@override @override
@ -35,7 +38,8 @@ class TimelineArgs {
maxWidth.hashCode ^ maxWidth.hashCode ^
maxHeight.hashCode ^ maxHeight.hashCode ^
spacing.hashCode ^ spacing.hashCode ^
columnCount.hashCode; columnCount.hashCode ^
showStorageIndicator.hashCode;
} }
class TimelineState { class TimelineState {
@ -90,6 +94,7 @@ final timelineSegmentProvider = StreamProvider.autoDispose<List<Segment>>(
final args = ref.watch(timelineArgsProvider); final args = ref.watch(timelineArgsProvider);
final columnCount = args.columnCount; final columnCount = args.columnCount;
final spacing = args.spacing; final spacing = args.spacing;
final showStorageIndicator = args.showStorageIndicator;
final availableTileWidth = args.maxWidth - (spacing * (columnCount - 1)); final availableTileWidth = args.maxWidth - (spacing * (columnCount - 1));
final tileExtent = math.max(0, availableTileWidth) / columnCount; final tileExtent = math.max(0, availableTileWidth) / columnCount;
@ -102,6 +107,7 @@ final timelineSegmentProvider = StreamProvider.autoDispose<List<Segment>>(
buckets: buckets, buckets: buckets,
tileHeight: tileExtent, tileHeight: tileExtent,
columnCount: columnCount, columnCount: columnCount,
showStorageIndicator: showStorageIndicator,
spacing: spacing, spacing: spacing,
groupBy: groupBy, groupBy: groupBy,
).generate(); ).generate();

View File

@ -25,10 +25,12 @@ class Timeline extends StatelessWidget {
super.key, super.key,
this.topSliverWidget, this.topSliverWidget,
this.topSliverWidgetHeight, this.topSliverWidgetHeight,
this.showStorageIndicator = false,
}); });
final Widget? topSliverWidget; final Widget? topSliverWidget;
final double? topSliverWidgetHeight; final double? topSliverWidgetHeight;
final bool showStorageIndicator;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -43,6 +45,7 @@ class Timeline extends StatelessWidget {
columnCount: ref.watch( columnCount: ref.watch(
settingsProvider.select((s) => s.get(Setting.tilesPerRow)), settingsProvider.select((s) => s.get(Setting.tilesPerRow)),
), ),
showStorageIndicator: showStorageIndicator,
), ),
), ),
], ],