Added new album varient in AlbumListItemWidget

This commit is contained in:
ashilkn 2023-01-20 12:51:34 +05:30
parent 278fec90c4
commit ed9c745cc2
2 changed files with 69 additions and 50 deletions

View file

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

View file

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