Fix unread count

This commit is contained in:
kodjomoustapha 2024-05-02 15:45:22 +01:00
parent 932f26421f
commit 3a6fc6abe0
2 changed files with 53 additions and 40 deletions

View file

@ -134,7 +134,7 @@ class _LibraryGridViewWidgetState extends State<LibraryGridViewWidget> {
), ),
child: Row( child: Row(
children: [ children: [
if (widget.localSource && isLocalArchive) if (widget.localSource || isLocalArchive)
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: const BorderRadius.only( borderRadius: const BorderRadius.only(
@ -151,12 +151,12 @@ class _LibraryGridViewWidgetState extends State<LibraryGridViewWidget> {
), ),
), ),
), ),
if (widget.downloadedChapter) Padding(
Padding( padding: const EdgeInsets.only(right: 5),
padding: const EdgeInsets.only(right: 5), child: Consumer(
child: Consumer( builder: (context, ref, child) {
builder: (context, ref, child) { List nbrDown = [];
List nbrDown = []; if (widget.downloadedChapter) {
isar.txnSync(() { isar.txnSync(() {
for (var i = 0; for (var i = 0;
i < entry.chapters.length; i < entry.chapters.length;
@ -172,45 +172,54 @@ class _LibraryGridViewWidgetState extends State<LibraryGridViewWidget> {
if (entries.isNotEmpty && if (entries.isNotEmpty &&
entries.first.isDownload!) { entries.first.isDownload!) {
nbrDown.add(entries.first); nbrDown.add(1);
} }
} }
}); });
}
if (nbrDown.isNotEmpty) { return Row(
return Container( children: [
decoration: BoxDecoration( if (nbrDown.isNotEmpty &&
borderRadius: widget.downloadedChapter)
const BorderRadius.only( Container(
topLeft: decoration: BoxDecoration(
Radius.circular(3), borderRadius:
bottomLeft: const BorderRadius.only(
Radius.circular(3)), topLeft:
color: Radius.circular(
Theme.of(context).hintColor, 3),
), bottomLeft:
child: Padding( Radius.circular(
padding: const EdgeInsets.only( 3)),
left: 3, right: 3), color: Theme.of(context)
child: Text( .secondaryHeaderColor,
nbrDown.length.toString(), ),
style: const TextStyle( child: Padding(
color: Colors.white), padding:
const EdgeInsets.only(
left: 3, right: 3),
child: Text(
nbrDown.length.toString(),
),
), ),
), ),
); Padding(
} else { padding: const EdgeInsets.only(left: 3),
return Container(); child: Text(
} entry.chapters
}, .where((element) =>
), !element.isRead!)
), .length
Padding( .toString(),
padding: const EdgeInsets.only(right: 3), style: TextStyle(
child: Text( color: context
entry.chapters.length.toString(), .dynamicBlackWhiteColor),
style: ),
const TextStyle(color: Colors.white), ),
],
);
},
), ),
), ),
], ],

View file

@ -19,6 +19,10 @@ extension BuildContextExtensions on BuildContext {
return isLight ? Colors.black : Colors.white; return isLight ? Colors.black : Colors.white;
} }
Color get dynamicBlackWhiteColor {
return isLight ? Colors.white : Colors.black;
}
bool get isDesktop { bool get isDesktop {
return Platform.isMacOS || Platform.isLinux || Platform.isWindows; return Platform.isMacOS || Platform.isLinux || Platform.isWindows;
} }