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(
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),
);
}
}

View File

@ -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',
);
}

View File

@ -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,
),
),
);

View File

@ -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,

View File

@ -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<List<Segment>>(
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<List<Segment>>(
buckets: buckets,
tileHeight: tileExtent,
columnCount: columnCount,
showStorageIndicator: showStorageIndicator,
spacing: spacing,
groupBy: groupBy,
).generate();

View File

@ -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,
),
),
],