From 87ca0313358954b2d13fad1997545617b0258f7d Mon Sep 17 00:00:00 2001 From: Matthias Rupp Date: Thu, 29 Sep 2022 17:19:55 +0200 Subject: [PATCH] Fix bug with missing year and add date to drag handle (#761) --- .../providers/home_page_render_list_provider.dart | 14 +++++--------- .../asset_list_v2/draggable_scrollbar_custom.dart | 3 +-- .../home/ui/asset_list_v2/immich_asset_grid.dart | 5 +++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/mobile/lib/modules/home/providers/home_page_render_list_provider.dart b/mobile/lib/modules/home/providers/home_page_render_list_provider.dart index 2058b65158..edb6733624 100644 --- a/mobile/lib/modules/home/providers/home_page_render_list_provider.dart +++ b/mobile/lib/modules/home/providers/home_page_render_list_provider.dart @@ -22,16 +22,14 @@ class RenderAssetGridElement { final RenderAssetGridElementType type; final RenderAssetGridRow? assetRow; final String? title; - final int? month; - final int? year; + final DateTime date; final List? relatedAssetList; RenderAssetGridElement( this.type, { this.assetRow, this.title, - this.month, - this.year, + required this.date, this.relatedAssetList, }); } @@ -51,7 +49,7 @@ final renderListProvider = StateProvider((ref) { if (lastDate == null || lastDate!.month != date.month) { elements.add( RenderAssetGridElement(RenderAssetGridElementType.monthTitle, - title: groupName, month: date.month, year: date.year), + title: groupName, date: date), ); } @@ -60,8 +58,7 @@ final renderListProvider = StateProvider((ref) { RenderAssetGridElement( RenderAssetGridElementType.dayTitle, title: groupName, - month: date.month, - year: date.year, + date: date, relatedAssetList: assets, ), ); @@ -73,8 +70,7 @@ final renderListProvider = StateProvider((ref) { final rowElement = RenderAssetGridElement( RenderAssetGridElementType.assetRow, - month: date.month, - year: date.year, + date: date, assetRow: RenderAssetGridRow( assets.sublist(cursor, cursor + rowElements), ), diff --git a/mobile/lib/modules/home/ui/asset_list_v2/draggable_scrollbar_custom.dart b/mobile/lib/modules/home/ui/asset_list_v2/draggable_scrollbar_custom.dart index 6b7821c8e7..dbdc125d28 100644 --- a/mobile/lib/modules/home/ui/asset_list_v2/draggable_scrollbar_custom.dart +++ b/mobile/lib/modules/home/ui/asset_list_v2/draggable_scrollbar_custom.dart @@ -189,6 +189,7 @@ class ScrollLabel extends StatelessWidget { borderRadius: const BorderRadius.all(Radius.circular(16.0)), child: Container( constraints: constraints ?? _defaultConstraints, + padding: const EdgeInsets.symmetric(horizontal: 10.0), alignment: Alignment.center, child: child, ), @@ -257,8 +258,6 @@ class DraggableScrollbarState extends State Widget build(BuildContext context) { Text? labelText; if (widget.labelTextBuilder != null && _isDragInProcess) { - int numberOfItems = widget.child.itemCount; - labelText = widget.labelTextBuilder!(_currentItem); } diff --git a/mobile/lib/modules/home/ui/asset_list_v2/immich_asset_grid.dart b/mobile/lib/modules/home/ui/asset_list_v2/immich_asset_grid.dart index 7845de07b2..4a085f3bf2 100644 --- a/mobile/lib/modules/home/ui/asset_list_v2/immich_asset_grid.dart +++ b/mobile/lib/modules/home/ui/asset_list_v2/immich_asset_grid.dart @@ -127,8 +127,8 @@ class ImmichAssetGrid extends HookConsumerWidget { } Text _labelBuilder(int pos) { - return Text( - "${renderList[pos].month} / ${renderList[pos].year}", + final date = renderList[pos].date; + return Text(DateFormat.yMMMd().format(date), style: const TextStyle( color: Colors.white, fontWeight: FontWeight.bold, @@ -154,6 +154,7 @@ class ImmichAssetGrid extends HookConsumerWidget { controller: _itemScrollController, backgroundColor: Theme.of(context).hintColor, labelTextBuilder: _labelBuilder, + labelConstraints: const BoxConstraints(maxHeight: 28), scrollbarAnimationDuration: const Duration(seconds: 1), scrollbarTimeToFade: const Duration(seconds: 4), child: ScrollablePositionedList.builder(