فهرست منبع

Added new album varient in AlbumListItemWidget

ashilkn 2 سال پیش
والد
کامیت
ed9c745cc2
2فایلهای تغییر یافته به همراه69 افزوده شده و 50 حذف شده
  1. 68 49
      lib/ui/components/album_list_item_widget.dart
  2. 1 1
      lib/ui/create_collection_sheet.dart

+ 68 - 49
lib/ui/components/album_list_item_widget.dart

@@ -1,3 +1,4 @@
+import 'package:dotted_border/dotted_border.dart';
 import 'package:flutter/material.dart';
 import 'package:logging/logging.dart';
 import 'package:photos/db/files_db.dart';
@@ -8,7 +9,12 @@ import 'package:photos/ui/viewer/file/thumbnail_widget.dart';
 
 class AlbumListItemWidget extends StatelessWidget {
   final CollectionWithThumbnail item;
-  const AlbumListItemWidget(this.item, {super.key});
+  final bool isNew;
+  const AlbumListItemWidget({
+    required this.item,
+    this.isNew = false,
+    super.key,
+  });
 
   @override
   Widget build(BuildContext context) {
@@ -28,63 +34,76 @@ class AlbumListItemWidget extends StatelessWidget {
                 height: sideOfThumbnail,
                 width: sideOfThumbnail,
                 key: Key("collection_item:" + (item.thumbnail?.tag ?? "")),
-                child: item.thumbnail != null
-                    ? ThumbnailWidget(
-                        item.thumbnail,
-                        showFavForAlbumOnly: true,
+                child: isNew
+                    ? Icon(
+                        Icons.add_outlined,
+                        color: colorScheme.strokeMuted,
                       )
-                    : const NoThumbnailWidget(),
+                    : item.thumbnail != null
+                        ? ThumbnailWidget(
+                            item.thumbnail,
+                            showFavForAlbumOnly: true,
+                          )
+                        : const NoThumbnailWidget(),
               ),
             ),
             Padding(
               padding: const EdgeInsets.only(left: 12),
-              child: Column(
-                crossAxisAlignment: CrossAxisAlignment.start,
-                children: [
-                  Text(item.collection.collectionName),
-                  FutureBuilder<int>(
-                    future: FilesDB.instance
-                        .collectionFileCount(item.collection.id),
-                    builder: (context, snapshot) {
-                      if (snapshot.hasData) {
-                        final text =
-                            snapshot.data == 1 ? " memory" : " memories";
-                        return Text(
-                          snapshot.data.toString() + text,
-                          style: textTheme.small.copyWith(
-                            color: colorScheme.textMuted,
-                          ),
-                        );
-                      } else {
-                        if (snapshot.hasError) {
-                          logger.severe(
-                            "Failed to fetch file count of collection id ${item.collection.id}",
-                          );
-                        }
-                        return Text(
-                          "",
-                          style: textTheme.small.copyWith(
-                            color: colorScheme.textMuted,
-                          ),
-                        );
-                      }
-                    },
-                  ),
-                ],
-              ),
+              child: isNew
+                  ? Text(
+                      "New album",
+                      style:
+                          textTheme.body.copyWith(color: colorScheme.textMuted),
+                    )
+                  : Column(
+                      crossAxisAlignment: CrossAxisAlignment.start,
+                      children: [
+                        Text(item.collection.collectionName),
+                        FutureBuilder<int>(
+                          future: FilesDB.instance
+                              .collectionFileCount(item.collection.id),
+                          builder: (context, snapshot) {
+                            if (snapshot.hasData) {
+                              final text =
+                                  snapshot.data == 1 ? " memory" : " memories";
+                              return Text(
+                                snapshot.data.toString() + text,
+                                style: textTheme.small.copyWith(
+                                  color: colorScheme.textMuted,
+                                ),
+                              );
+                            } else {
+                              if (snapshot.hasError) {
+                                logger.severe(
+                                  "Failed to fetch file count of collection id ${item.collection.id}",
+                                );
+                              }
+                              return Text(
+                                "",
+                                style: textTheme.small.copyWith(
+                                  color: colorScheme.textMuted,
+                                ),
+                              );
+                            }
+                          },
+                        ),
+                      ],
+                    ),
             ),
           ],
         ),
         IgnorePointer(
-          child: Container(
-            height: sideOfThumbnail,
-            //32 is to account for padding of 16pts on both sides
-            width: MediaQuery.of(context).size.width - 32,
-            decoration: BoxDecoration(
-              border: Border.all(color: colorScheme.strokeFainter),
-              borderRadius: const BorderRadius.all(
-                Radius.circular(4),
-              ),
+          child: DottedBorder(
+            dashPattern: isNew ? [4] : [300, 0],
+            color: colorScheme.strokeFainter,
+            strokeWidth: 1,
+            padding: const EdgeInsets.all(0),
+            borderType: BorderType.RRect,
+            radius: const Radius.circular(4),
+            child: SizedBox(
+              height: sideOfThumbnail,
+              //32 is to account for padding of 16pts on both sides
+              width: MediaQuery.of(context).size.width - 32,
             ),
           ),
         ),

+ 1 - 1
lib/ui/create_collection_sheet.dart

@@ -128,7 +128,7 @@ class _CreateCollectionSheetState extends State<CreateCollectionSheet> {
                           return ListView.separated(
                             itemBuilder: (context, index) {
                               return AlbumListItemWidget(
-                                collectionsWithThumbnail[index],
+                                item: collectionsWithThumbnail[index],
                               );
                               // return _buildCollectionItem(
                               //   collectionsWithThumbnail[index],