From 5fa9704a65dc7ce7acd46b1da8cec52121bf9b3c Mon Sep 17 00:00:00 2001 From: X Date: Sun, 13 Aug 2023 21:39:46 +0800 Subject: [PATCH] fix(mobile): Empty albums don't show title (#3576) --- .../home/ui/asset_grid/immich_asset_grid_view.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid_view.dart b/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid_view.dart index aca9729683..1ad7f3a28f 100644 --- a/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid_view.dart +++ b/mobile/lib/modules/home/ui/asset_grid/immich_asset_grid_view.dart @@ -248,8 +248,6 @@ class ImmichAssetGridViewState extends State { key: ValueKey(section.offset), crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (section.offset == 0 && widget.topWidget != null) - widget.topWidget!, if (section.type == RenderAssetGridElementType.monthTitle) _buildMonthTitle(context, section.date), if (section.type == RenderAssetGridElementType.groupDividerTitle || @@ -289,7 +287,15 @@ class ImmichAssetGridViewState extends State { } Widget _itemBuilder(BuildContext c, int position) { - final item = widget.renderList.elements[position]; + int index = position; + if (widget.topWidget != null) { + if (index == 0) { + return widget.topWidget!; + } + index--; + } + + final item = widget.renderList.elements[index]; return _buildSection(c, item, _scrolling); } @@ -329,7 +335,7 @@ class ImmichAssetGridViewState extends State { itemBuilder: _itemBuilder, itemPositionsListener: _itemPositionsListener, itemScrollController: _itemScrollController, - itemCount: widget.renderList.elements.length, + itemCount: widget.renderList.elements.length + (widget.topWidget != null ? 1 : 0), addRepaintBoundaries: true, );