瀏覽代碼

Fix bug with missing year and add date to drag handle (#761)

Matthias Rupp 2 年之前
父節點
當前提交
87ca031335

+ 5 - 9
mobile/lib/modules/home/providers/home_page_render_list_provider.dart

@@ -22,16 +22,14 @@ class RenderAssetGridElement {
   final RenderAssetGridElementType type;
   final RenderAssetGridElementType type;
   final RenderAssetGridRow? assetRow;
   final RenderAssetGridRow? assetRow;
   final String? title;
   final String? title;
-  final int? month;
-  final int? year;
+  final DateTime date;
   final List<AssetResponseDto>? relatedAssetList;
   final List<AssetResponseDto>? relatedAssetList;
 
 
   RenderAssetGridElement(
   RenderAssetGridElement(
     this.type, {
     this.type, {
     this.assetRow,
     this.assetRow,
     this.title,
     this.title,
-    this.month,
-    this.year,
+    required this.date,
     this.relatedAssetList,
     this.relatedAssetList,
   });
   });
 }
 }
@@ -51,7 +49,7 @@ final renderListProvider = StateProvider((ref) {
     if (lastDate == null || lastDate!.month != date.month) {
     if (lastDate == null || lastDate!.month != date.month) {
       elements.add(
       elements.add(
         RenderAssetGridElement(RenderAssetGridElementType.monthTitle,
         RenderAssetGridElement(RenderAssetGridElementType.monthTitle,
-            title: groupName, month: date.month, year: date.year),
+            title: groupName, date: date),
       );
       );
     }
     }
 
 
@@ -60,8 +58,7 @@ final renderListProvider = StateProvider((ref) {
       RenderAssetGridElement(
       RenderAssetGridElement(
         RenderAssetGridElementType.dayTitle,
         RenderAssetGridElementType.dayTitle,
         title: groupName,
         title: groupName,
-        month: date.month,
-        year: date.year,
+        date: date,
         relatedAssetList: assets,
         relatedAssetList: assets,
       ),
       ),
     );
     );
@@ -73,8 +70,7 @@ final renderListProvider = StateProvider((ref) {
 
 
       final rowElement = RenderAssetGridElement(
       final rowElement = RenderAssetGridElement(
         RenderAssetGridElementType.assetRow,
         RenderAssetGridElementType.assetRow,
-        month: date.month,
-        year: date.year,
+        date: date,
         assetRow: RenderAssetGridRow(
         assetRow: RenderAssetGridRow(
           assets.sublist(cursor, cursor + rowElements),
           assets.sublist(cursor, cursor + rowElements),
         ),
         ),

+ 1 - 2
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)),
           borderRadius: const BorderRadius.all(Radius.circular(16.0)),
           child: Container(
           child: Container(
             constraints: constraints ?? _defaultConstraints,
             constraints: constraints ?? _defaultConstraints,
+            padding: const EdgeInsets.symmetric(horizontal: 10.0),
             alignment: Alignment.center,
             alignment: Alignment.center,
             child: child,
             child: child,
           ),
           ),
@@ -257,8 +258,6 @@ class DraggableScrollbarState extends State<DraggableScrollbar>
   Widget build(BuildContext context) {
   Widget build(BuildContext context) {
     Text? labelText;
     Text? labelText;
     if (widget.labelTextBuilder != null && _isDragInProcess) {
     if (widget.labelTextBuilder != null && _isDragInProcess) {
-      int numberOfItems = widget.child.itemCount;
-
       labelText = widget.labelTextBuilder!(_currentItem);
       labelText = widget.labelTextBuilder!(_currentItem);
     }
     }
 
 

+ 3 - 2
mobile/lib/modules/home/ui/asset_list_v2/immich_asset_grid.dart

@@ -127,8 +127,8 @@ class ImmichAssetGrid extends HookConsumerWidget {
   }
   }
 
 
   Text _labelBuilder(int pos) {
   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(
       style: const TextStyle(
         color: Colors.white,
         color: Colors.white,
         fontWeight: FontWeight.bold,
         fontWeight: FontWeight.bold,
@@ -154,6 +154,7 @@ class ImmichAssetGrid extends HookConsumerWidget {
         controller: _itemScrollController,
         controller: _itemScrollController,
         backgroundColor: Theme.of(context).hintColor,
         backgroundColor: Theme.of(context).hintColor,
         labelTextBuilder: _labelBuilder,
         labelTextBuilder: _labelBuilder,
+        labelConstraints: const BoxConstraints(maxHeight: 28),
         scrollbarAnimationDuration: const Duration(seconds: 1),
         scrollbarAnimationDuration: const Duration(seconds: 1),
         scrollbarTimeToFade: const Duration(seconds: 4),
         scrollbarTimeToFade: const Duration(seconds: 4),
         child: ScrollablePositionedList.builder(
         child: ScrollablePositionedList.builder(