Inkwell for library cover card
This commit is contained in:
parent
225b755d47
commit
92b04a62aa
9 changed files with 540 additions and 507 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
|
@ -7,7 +8,6 @@ import 'package:mangayomi/modules/history/providers/isar_providers.dart';
|
|||
import 'package:mangayomi/modules/library/providers/library_state_provider.dart';
|
||||
import 'package:mangayomi/modules/manga/reader/providers/push_router.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/utils/cached_network.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
import 'package:mangayomi/utils/headers.dart';
|
||||
import 'package:mangayomi/modules/more/providers/incognito_mode_state_provider.dart';
|
||||
|
|
@ -39,24 +39,27 @@ class LibraryGridViewWidget extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GridViewWidget(
|
||||
mainAxisExtent: isComfortableGrid ? 310 : 280,
|
||||
childAspectRatio: isComfortableGrid ? 0.642 : 0.69,
|
||||
itemCount: entriesManga.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Consumer(builder: (context, ref, child) {
|
||||
final isLongPressed = ref.watch(isLongPressedMangaStateProvider);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.all(0),
|
||||
backgroundColor: mangaIdsList.contains(entriesManga[index].id)
|
||||
? primaryColor(context).withOpacity(0.4)
|
||||
: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5)),
|
||||
elevation: 0,
|
||||
shadowColor: Colors.transparent),
|
||||
onPressed: () {
|
||||
child: CoverViewWidget(
|
||||
isLongPressed: mangaIdsList.contains(entriesManga[index].id),
|
||||
bottomTextWidget: BottomTextWidget(
|
||||
maxLines: 1,
|
||||
text: entriesManga[index].name!,
|
||||
isComfortableGrid: isComfortableGrid,
|
||||
),
|
||||
isComfortableGrid: isComfortableGrid,
|
||||
image: CachedNetworkImageProvider(
|
||||
entriesManga[index].imageUrl!,
|
||||
headers: ref.watch(
|
||||
headersProvider(source: entriesManga[index].source!)),
|
||||
),
|
||||
onTap: () {
|
||||
if (isLongPressed) {
|
||||
ref
|
||||
.read(mangasListStateProvider.notifier)
|
||||
|
|
@ -83,191 +86,150 @@ class LibraryGridViewWidget extends StatelessWidget {
|
|||
.update(entriesManga[index]);
|
||||
}
|
||||
},
|
||||
child: CoverViewWidget(
|
||||
bottomTextWidget: BottomTextWidget(
|
||||
text: entriesManga[index].name!,
|
||||
isComfortableGrid: isComfortableGrid,
|
||||
),
|
||||
isComfortableGrid: isComfortableGrid,
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
cachedNetworkImage(
|
||||
headers: ref.watch(headersProvider(
|
||||
source: entriesManga[index].source!)),
|
||||
imageUrl: entriesManga[index].imageUrl!,
|
||||
width: 200,
|
||||
height: 270,
|
||||
fit: BoxFit.cover),
|
||||
children: [
|
||||
Stack(
|
||||
children: [
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
color: primaryColor(context),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
if (downloadedChapter)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: Consumer(
|
||||
builder: (context, ref, child) {
|
||||
List nbrDown = [];
|
||||
isar.txnSync(() {
|
||||
for (var i = 0;
|
||||
i <
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.length;
|
||||
i++) {
|
||||
final entries = isar.downloads
|
||||
.filter()
|
||||
.idIsNotNull()
|
||||
.chapterIdEqualTo(
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.toList()[i]
|
||||
.id)
|
||||
.findAllSync();
|
||||
|
||||
if (entries.isNotEmpty &&
|
||||
entries.first.isDownload!) {
|
||||
nbrDown.add(entries.first);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (nbrDown.isNotEmpty) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
const BorderRadius.only(
|
||||
topLeft:
|
||||
Radius.circular(3),
|
||||
bottomLeft:
|
||||
Radius.circular(3)),
|
||||
color:
|
||||
Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 3, right: 3),
|
||||
child: Text(
|
||||
nbrDown.length.toString(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 3),
|
||||
child: Text(
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.length
|
||||
.toString(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
if (language)
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
color: primaryColor(context),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
if (downloadedChapter)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: Consumer(
|
||||
builder: (context, ref, child) {
|
||||
List nbrDown = [];
|
||||
isar.txnSync(() {
|
||||
for (var i = 0;
|
||||
i <
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.length;
|
||||
i++) {
|
||||
final entries = isar.downloads
|
||||
.filter()
|
||||
.idIsNotNull()
|
||||
.chapterIdEqualTo(
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.toList()[i]
|
||||
.id)
|
||||
.findAllSync();
|
||||
|
||||
if (entries.isNotEmpty &&
|
||||
entries.first.isDownload!) {
|
||||
nbrDown.add(entries.first);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (nbrDown.isNotEmpty) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
const BorderRadius.only(
|
||||
topLeft:
|
||||
Radius.circular(3),
|
||||
bottomLeft:
|
||||
Radius.circular(3)),
|
||||
color:
|
||||
Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 3, right: 3),
|
||||
child: Text(
|
||||
nbrDown.length.toString(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 3),
|
||||
child: Text(
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.length
|
||||
.toString(),
|
||||
style:
|
||||
const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
if (language)
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
color: primaryColor(context),
|
||||
child: Container(
|
||||
color: primaryColor(context),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(3),
|
||||
bottomLeft: Radius.circular(3)),
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 3, right: 3),
|
||||
child: Text(
|
||||
entriesManga[index].lang!.toUpperCase(),
|
||||
style:
|
||||
const TextStyle(color: Colors.white),
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(3),
|
||||
bottomLeft: Radius.circular(3)),
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 3, right: 3),
|
||||
child: Text(
|
||||
entriesManga[index].lang!.toUpperCase(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
if (!isComfortableGrid)
|
||||
if (!isCoverOnlyGrid)
|
||||
BottomTextWidget(text: entriesManga[index].name!),
|
||||
if (continueReaderBtn)
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(9),
|
||||
child: Consumer(
|
||||
builder: (context, ref, child) {
|
||||
final history =
|
||||
ref.watch(getAllHistoryStreamProvider);
|
||||
return history.when(
|
||||
data: (data) {
|
||||
final incognitoMode =
|
||||
ref.watch(incognitoModeStateProvider);
|
||||
final entries = data
|
||||
.where((element) =>
|
||||
element.mangaId ==
|
||||
entriesManga[index].id)
|
||||
.toList();
|
||||
if (entries.isNotEmpty && !incognitoMode) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
chapter:
|
||||
entries.first.chapter.value!,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(5),
|
||||
color: primaryColor(context)
|
||||
.withOpacity(0.9),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Icon(
|
||||
Icons.play_arrow,
|
||||
size: 19,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
)),
|
||||
],
|
||||
),
|
||||
if (!isComfortableGrid)
|
||||
if (!isCoverOnlyGrid)
|
||||
BottomTextWidget(text: entriesManga[index].name!),
|
||||
if (continueReaderBtn)
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
right: 0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(9),
|
||||
child: Consumer(
|
||||
builder: (context, ref, child) {
|
||||
final history =
|
||||
ref.watch(getAllHistoryStreamProvider);
|
||||
return history.when(
|
||||
data: (data) {
|
||||
final incognitoMode =
|
||||
ref.watch(incognitoModeStateProvider);
|
||||
final entries = data
|
||||
.where((element) =>
|
||||
element.mangaId ==
|
||||
entriesManga[index].id)
|
||||
.toList();
|
||||
if (entries.isNotEmpty && !incognitoMode) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
chapter: entriesManga[index]
|
||||
.chapters
|
||||
.last);
|
||||
context: context,
|
||||
chapter: entries.first.chapter.value!,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
|
|
@ -285,18 +247,41 @@ class LibraryGridViewWidget extends StatelessWidget {
|
|||
)),
|
||||
),
|
||||
);
|
||||
},
|
||||
error: (Object error, StackTrace stackTrace) {
|
||||
return ErrorText(error);
|
||||
},
|
||||
loading: () {
|
||||
return const ProgressCenter();
|
||||
},
|
||||
);
|
||||
},
|
||||
)))
|
||||
],
|
||||
),
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
chapter: entriesManga[index]
|
||||
.chapters
|
||||
.last);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: primaryColor(context)
|
||||
.withOpacity(0.9),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Icon(
|
||||
Icons.play_arrow,
|
||||
size: 19,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
);
|
||||
},
|
||||
error: (Object error, StackTrace stackTrace) {
|
||||
return ErrorText(error);
|
||||
},
|
||||
loading: () {
|
||||
return const ProgressCenter();
|
||||
},
|
||||
);
|
||||
},
|
||||
)))
|
||||
],
|
||||
),
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
|
|
@ -7,7 +8,6 @@ import 'package:mangayomi/modules/history/providers/isar_providers.dart';
|
|||
import 'package:mangayomi/modules/library/providers/library_state_provider.dart';
|
||||
import 'package:mangayomi/modules/manga/reader/providers/push_router.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/utils/cached_network.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
import 'package:mangayomi/utils/headers.dart';
|
||||
import 'package:mangayomi/modules/more/providers/incognito_mode_state_provider.dart';
|
||||
|
|
@ -37,247 +37,269 @@ class LibraryListViewWidget extends StatelessWidget {
|
|||
itemBuilder: (context, index) {
|
||||
return Consumer(builder: (context, ref, child) {
|
||||
final isLongPressed = ref.watch(isLongPressedMangaStateProvider);
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: mangaIdsList.contains(entriesManga[index].id)
|
||||
? primaryColor(context).withOpacity(0.4)
|
||||
: Colors.transparent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(0)),
|
||||
elevation: 0,
|
||||
shadowColor: Colors.transparent),
|
||||
onPressed: () {
|
||||
if (isLongPressed) {
|
||||
ref
|
||||
.read(mangasListStateProvider.notifier)
|
||||
.update(entriesManga[index]);
|
||||
} else {
|
||||
pushToMangaReaderDetail(
|
||||
return Material(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: Colors.transparent,
|
||||
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
if (isLongPressed) {
|
||||
ref
|
||||
.read(mangasListStateProvider.notifier)
|
||||
.update(entriesManga[index]);
|
||||
} else {
|
||||
pushToMangaReaderDetail(
|
||||
context: context,
|
||||
lang: entriesManga[index].lang!,
|
||||
mangaM: entriesManga[index]);
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
if (!isLongPressed) {
|
||||
ref
|
||||
.read(mangasListStateProvider.notifier)
|
||||
.update(entriesManga[index]);
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
if (!isLongPressed) {
|
||||
ref
|
||||
.read(mangasListStateProvider.notifier)
|
||||
.update(entriesManga[index]);
|
||||
|
||||
ref
|
||||
.read(isLongPressedMangaStateProvider.notifier)
|
||||
.update(!isLongPressed);
|
||||
} else {
|
||||
ref
|
||||
.read(mangasListStateProvider.notifier)
|
||||
.update(entriesManga[index]);
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
ref
|
||||
.read(isLongPressedMangaStateProvider.notifier)
|
||||
.update(!isLongPressed);
|
||||
} else {
|
||||
ref
|
||||
.read(mangasListStateProvider.notifier)
|
||||
.update(entriesManga[index]);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
height: 45,
|
||||
decoration:
|
||||
BoxDecoration(borderRadius: BorderRadius.circular(5)),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(5),
|
||||
bottomLeft: Radius.circular(5)),
|
||||
child: cachedNetworkImage(
|
||||
headers: ref.watch(headersProvider(
|
||||
source: entriesManga[index].source!)),
|
||||
imageUrl: entriesManga[index].imageUrl!,
|
||||
width: 40,
|
||||
height: 40,
|
||||
fit: BoxFit.cover),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: Text(entriesManga[index].name!),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
color: primaryColor(context)),
|
||||
child: SizedBox(
|
||||
height: 22,
|
||||
color: mangaIdsList.contains(entriesManga[index].id)
|
||||
? primaryColor(context).withOpacity(0.4)
|
||||
: Colors.transparent,
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
child: Container(
|
||||
height: 45,
|
||||
decoration:
|
||||
BoxDecoration(borderRadius: BorderRadius.circular(5)),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
if (downloadedChapter)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: Consumer(
|
||||
builder: (context, ref, child) {
|
||||
List nbrDown = [];
|
||||
isar.txnSync(() {
|
||||
for (var i = 0;
|
||||
i <
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.length;
|
||||
i++) {
|
||||
final entries = isar.downloads
|
||||
.filter()
|
||||
.idIsNotNull()
|
||||
.chapterIdEqualTo(
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.toList()[i]
|
||||
.id)
|
||||
.findAllSync();
|
||||
|
||||
if (entries.isNotEmpty &&
|
||||
entries.first.isDownload!) {
|
||||
nbrDown.add(entries.first);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (nbrDown.isNotEmpty) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
const BorderRadius.only(
|
||||
topLeft: Radius.circular(3),
|
||||
bottomLeft:
|
||||
Radius.circular(3)),
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 3, right: 3),
|
||||
child: Text(
|
||||
nbrDown.length.toString(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
child: Material(
|
||||
child: Ink.image(
|
||||
fit: BoxFit.cover,
|
||||
width: 40,
|
||||
height: 45,
|
||||
image: CachedNetworkImageProvider(
|
||||
entriesManga[index].imageUrl!,
|
||||
headers: ref.watch(headersProvider(
|
||||
source: entriesManga[index].source!)),
|
||||
),
|
||||
child: InkWell(
|
||||
child: Container(
|
||||
color: mangaIdsList
|
||||
.contains(entriesManga[index].id)
|
||||
? primaryColor(context)
|
||||
.withOpacity(0.4)
|
||||
: Colors.transparent,
|
||||
)),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 3),
|
||||
child: Text(
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.length
|
||||
.toString(),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
if (language)
|
||||
Container(
|
||||
color: primaryColor(context),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(3),
|
||||
bottomRight: Radius.circular(3)),
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 3, right: 3),
|
||||
child: Text(
|
||||
entriesManga[index].lang!.toUpperCase(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 10),
|
||||
child: Text(entriesManga[index].name!),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (continueReaderBtn)
|
||||
Consumer(
|
||||
builder: (context, ref, child) {
|
||||
final history =
|
||||
ref.watch(getAllHistoryStreamProvider);
|
||||
return history.when(
|
||||
data: (data) {
|
||||
final incognitoMode =
|
||||
ref.watch(incognitoModeStateProvider);
|
||||
final entries = data
|
||||
.where((element) =>
|
||||
element.mangaId == entriesManga[index].id)
|
||||
.toList();
|
||||
if (entries.isNotEmpty && !incognitoMode) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
chapter: entries.first.chapter.value!,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: primaryColor(context)
|
||||
.withOpacity(0.9),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
color: primaryColor(context)),
|
||||
child: SizedBox(
|
||||
height: 22,
|
||||
child: Row(
|
||||
children: [
|
||||
if (downloadedChapter)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 5),
|
||||
child: Consumer(
|
||||
builder: (context, ref, child) {
|
||||
List nbrDown = [];
|
||||
isar.txnSync(() {
|
||||
for (var i = 0;
|
||||
i <
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.length;
|
||||
i++) {
|
||||
final entries = isar.downloads
|
||||
.filter()
|
||||
.idIsNotNull()
|
||||
.chapterIdEqualTo(
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.toList()[i]
|
||||
.id)
|
||||
.findAllSync();
|
||||
|
||||
if (entries.isNotEmpty &&
|
||||
entries.first.isDownload!) {
|
||||
nbrDown.add(entries.first);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (nbrDown.isNotEmpty) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
const BorderRadius.only(
|
||||
topLeft:
|
||||
Radius.circular(3),
|
||||
bottomLeft:
|
||||
Radius.circular(3)),
|
||||
color:
|
||||
Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 3, right: 3),
|
||||
child: Text(
|
||||
nbrDown.length.toString(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Container();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 3),
|
||||
child: Text(
|
||||
entriesManga[index]
|
||||
.chapters
|
||||
.length
|
||||
.toString(),
|
||||
style:
|
||||
const TextStyle(color: Colors.white),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Icon(
|
||||
Icons.play_arrow,
|
||||
size: 19,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
chapter:
|
||||
entriesManga[index].chapters.last);
|
||||
if (language)
|
||||
Container(
|
||||
color: primaryColor(context),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topRight: Radius.circular(3),
|
||||
bottomRight: Radius.circular(3)),
|
||||
color: Theme.of(context).hintColor,
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 3, right: 3),
|
||||
child: Text(
|
||||
entriesManga[index]
|
||||
.lang!
|
||||
.toUpperCase(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (continueReaderBtn)
|
||||
Consumer(
|
||||
builder: (context, ref, child) {
|
||||
final history =
|
||||
ref.watch(getAllHistoryStreamProvider);
|
||||
return history.when(
|
||||
data: (data) {
|
||||
final incognitoMode =
|
||||
ref.watch(incognitoModeStateProvider);
|
||||
final entries = data
|
||||
.where((element) =>
|
||||
element.mangaId ==
|
||||
entriesManga[index].id)
|
||||
.toList();
|
||||
if (entries.isNotEmpty && !incognitoMode) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
chapter: entries.first.chapter.value!,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius:
|
||||
BorderRadius.circular(5),
|
||||
color: primaryColor(context)
|
||||
.withOpacity(0.9),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Icon(
|
||||
Icons.play_arrow,
|
||||
size: 19,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
);
|
||||
}
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushMangaReaderView(
|
||||
context: context,
|
||||
chapter: entriesManga[index]
|
||||
.chapters
|
||||
.last);
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: primaryColor(context)
|
||||
.withOpacity(0.9),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Icon(
|
||||
Icons.play_arrow,
|
||||
size: 19,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
);
|
||||
},
|
||||
error: (Object error, StackTrace stackTrace) {
|
||||
return ErrorText(error);
|
||||
},
|
||||
loading: () {
|
||||
return const ProgressCenter();
|
||||
},
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color:
|
||||
primaryColor(context).withOpacity(0.9),
|
||||
),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(7),
|
||||
child: Icon(
|
||||
Icons.play_arrow,
|
||||
size: 19,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
);
|
||||
},
|
||||
error: (Object error, StackTrace stackTrace) {
|
||||
return ErrorText(error);
|
||||
},
|
||||
loading: () {
|
||||
return const ProgressCenter();
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ class _MangaHomeScreenState extends ConsumerState<MangaHomeScreen> {
|
|||
_getManga = ref.watch(
|
||||
searchMangaProvider(source: widget.mangaType.source!, query: _query));
|
||||
} else if (_selectedIndex == 1 && !_isSearch && _query.isEmpty) {
|
||||
_getManga = ref.watch(
|
||||
getLatestUpdatesMangaProvider(source: widget.mangaType.source!, page: 1));
|
||||
_getManga = ref.watch(getLatestUpdatesMangaProvider(
|
||||
source: widget.mangaType.source!, page: 1));
|
||||
} else if (_selectedIndex == 0 && !_isSearch && _query.isEmpty) {
|
||||
_getManga = ref.watch(
|
||||
getPopularMangaProvider(source: widget.mangaType.source!, page: 1));
|
||||
|
|
@ -283,18 +283,15 @@ class _MangaHomeImageCardState extends ConsumerState<MangaHomeImageCard>
|
|||
lang: widget.lang,
|
||||
);
|
||||
},
|
||||
loading: () => CoverViewWidget(children: [
|
||||
loading: () => CoverViewWidget(onTap: () {}, children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
child: Container(
|
||||
color: Theme.of(context).cardColor,
|
||||
width: 200,
|
||||
height: 270,
|
||||
),
|
||||
),
|
||||
BottomTextWidget(
|
||||
text: widget.manga.name!,
|
||||
isLoading: true,
|
||||
)
|
||||
]),
|
||||
error: (error, stackTrace) => Center(child: Text(error.toString())),
|
||||
|
|
|
|||
|
|
@ -1,16 +1,19 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
|
||||
class BottomTextWidget extends StatelessWidget {
|
||||
final bool isLoading;
|
||||
final String text;
|
||||
final bool isComfortableGrid;
|
||||
final double? fontSize;
|
||||
final int? maxLines;
|
||||
const BottomTextWidget(
|
||||
{super.key,
|
||||
required this.text,
|
||||
this.isLoading = false,
|
||||
this.isComfortableGrid = false,
|
||||
this.fontSize = 13.0});
|
||||
this.fontSize = 12.0,
|
||||
this.maxLines = 2});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -24,12 +27,10 @@ class BottomTextWidget extends StatelessWidget {
|
|||
text,
|
||||
style: TextStyle(
|
||||
fontSize: fontSize,
|
||||
color: Colors.white,
|
||||
shadows: const [
|
||||
Shadow(offset: Offset(0.5, 0.9), blurRadius: 3.0)
|
||||
],
|
||||
fontWeight: FontWeight.w600,
|
||||
color: primaryColor(context),
|
||||
),
|
||||
maxLines: 2,
|
||||
maxLines: maxLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.start,
|
||||
),
|
||||
|
|
@ -57,7 +58,7 @@ class BottomTextWidget extends StatelessWidget {
|
|||
Shadow(offset: Offset(0.5, 0.9), blurRadius: 3.0)
|
||||
],
|
||||
),
|
||||
maxLines: 2,
|
||||
maxLines: maxLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.start,
|
||||
),
|
||||
|
|
@ -94,7 +95,7 @@ class BottomTextWidget extends StatelessWidget {
|
|||
offset: Offset(0.5, 0.9), blurRadius: 3.0)
|
||||
],
|
||||
),
|
||||
maxLines: 2,
|
||||
maxLines: maxLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.start,
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,37 +1,63 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
|
||||
class CoverViewWidget extends StatelessWidget {
|
||||
final List<Widget> children;
|
||||
final bool? isLongPressed;
|
||||
final ImageProvider? image;
|
||||
final bool isComfortableGrid;
|
||||
final Widget? bottomTextWidget;
|
||||
final VoidCallback onTap;
|
||||
final VoidCallback? onLongPress;
|
||||
const CoverViewWidget(
|
||||
{super.key,
|
||||
required this.children,
|
||||
this.isComfortableGrid = false,
|
||||
this.bottomTextWidget});
|
||||
this.bottomTextWidget,
|
||||
required this.onTap,
|
||||
this.image,
|
||||
this.onLongPress,
|
||||
this.isLongPressed});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: isComfortableGrid
|
||||
? Column(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
child: Stack(
|
||||
children: children,
|
||||
),
|
||||
),
|
||||
bottomTextWidget!
|
||||
],
|
||||
)
|
||||
: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
child: Stack(
|
||||
children: children,
|
||||
padding: const EdgeInsets.all(5),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: Colors.transparent,
|
||||
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
onLongPress: onLongPress,
|
||||
child: Container(
|
||||
color: isLongPressed != null && isLongPressed!
|
||||
? primaryColor(context).withOpacity(0.4)
|
||||
: Colors.transparent,
|
||||
child: image == null
|
||||
? isComfortableGrid
|
||||
? Column(
|
||||
children: [...children, bottomTextWidget!],
|
||||
)
|
||||
: Stack(
|
||||
children: children,
|
||||
)
|
||||
: Ink.image(
|
||||
height: 200,
|
||||
fit: BoxFit.cover,
|
||||
image: image!,
|
||||
child: Stack(
|
||||
children: children,
|
||||
),
|
||||
),
|
||||
)),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (isComfortableGrid) bottomTextWidget!
|
||||
],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class GridViewWidget extends StatelessWidget {
|
|||
final ScrollController? controller;
|
||||
final int? itemCount;
|
||||
final bool reverse;
|
||||
final double mainAxisExtent;
|
||||
final double? childAspectRatio;
|
||||
final Widget? Function(BuildContext, int) itemBuilder;
|
||||
const GridViewWidget(
|
||||
{super.key,
|
||||
|
|
@ -12,17 +12,18 @@ class GridViewWidget extends StatelessWidget {
|
|||
required this.itemCount,
|
||||
required this.itemBuilder,
|
||||
this.reverse = false,
|
||||
this.mainAxisExtent = 280});
|
||||
this.childAspectRatio = 0.69});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: GridView.builder(
|
||||
padding: const EdgeInsets.only(top: 13),
|
||||
controller: controller,
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
childAspectRatio: childAspectRatio!,
|
||||
maxCrossAxisExtent: 220,
|
||||
mainAxisExtent: mainAxisExtent,
|
||||
),
|
||||
itemCount: itemCount,
|
||||
itemBuilder: itemBuilder),
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class ListViewWidget extends StatelessWidget {
|
|||
return Container(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.only(top: 13),
|
||||
controller: controller,
|
||||
itemCount: itemCount,
|
||||
itemBuilder: itemBuilder),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
|
@ -7,7 +8,6 @@ import 'package:mangayomi/models/chapter.dart';
|
|||
import 'package:mangayomi/models/manga.dart';
|
||||
import 'package:mangayomi/models/settings.dart';
|
||||
import 'package:mangayomi/sources/service.dart';
|
||||
import 'package:mangayomi/utils/cached_network.dart';
|
||||
import 'package:mangayomi/utils/colors.dart';
|
||||
import 'package:mangayomi/utils/headers.dart';
|
||||
import 'package:mangayomi/modules/widgets/bottom_text_widget.dart';
|
||||
|
|
@ -26,56 +26,56 @@ class MangaImageCardWidget extends ConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
pushToMangaReaderDetail(
|
||||
context: context, getManga: getMangaDetail!, lang: lang);
|
||||
},
|
||||
child: StreamBuilder(
|
||||
stream: isar.mangas
|
||||
.filter()
|
||||
.langEqualTo(lang)
|
||||
.nameEqualTo(getMangaDetail!.name)
|
||||
.sourceEqualTo(getMangaDetail!.source)
|
||||
.favoriteEqualTo(true)
|
||||
.watch(fireImmediately: true),
|
||||
builder: (context, snapshot) {
|
||||
return CoverViewWidget(children: [
|
||||
cachedNetworkImage(
|
||||
headers: ref
|
||||
.watch(headersProvider(source: getMangaDetail!.source!)),
|
||||
imageUrl: getMangaDetail!.imageUrl!,
|
||||
width: 200,
|
||||
height: 270,
|
||||
fit: BoxFit.cover),
|
||||
Container(
|
||||
color: snapshot.hasData && snapshot.data!.isNotEmpty
|
||||
? Colors.black.withOpacity(0.7)
|
||||
: null,
|
||||
return StreamBuilder(
|
||||
stream: isar.mangas
|
||||
.filter()
|
||||
.langEqualTo(lang)
|
||||
.nameEqualTo(getMangaDetail!.name)
|
||||
.sourceEqualTo(getMangaDetail!.source)
|
||||
.favoriteEqualTo(true)
|
||||
.watch(fireImmediately: true),
|
||||
builder: (context, snapshot) {
|
||||
return CoverViewWidget(
|
||||
image: CachedNetworkImageProvider(
|
||||
getMangaDetail!.imageUrl!,
|
||||
headers:
|
||||
ref.watch(headersProvider(source: getMangaDetail!.source!)),
|
||||
),
|
||||
if (snapshot.hasData && snapshot.data!.isNotEmpty)
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor(context),
|
||||
borderRadius: BorderRadius.circular(5)),
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(2),
|
||||
child: Text(
|
||||
"In library",
|
||||
style: TextStyle(fontSize: 12),
|
||||
onTap: () {
|
||||
pushToMangaReaderDetail(
|
||||
context: context, getManga: getMangaDetail!, lang: lang);
|
||||
},
|
||||
children: [
|
||||
Container(
|
||||
color: snapshot.hasData && snapshot.data!.isNotEmpty
|
||||
? Colors.black.withOpacity(0.7)
|
||||
: null,
|
||||
),
|
||||
if (snapshot.hasData && snapshot.data!.isNotEmpty)
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: primaryColor(context),
|
||||
borderRadius: BorderRadius.circular(5)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: Text(
|
||||
"In library",
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Theme.of(context)
|
||||
.scaffoldBackgroundColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)),
|
||||
BottomTextWidget(text: getMangaDetail!.name!)
|
||||
]);
|
||||
}),
|
||||
);
|
||||
)),
|
||||
BottomTextWidget(text: getMangaDetail!.name!)
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@ import 'package:mangayomi/sources/src/fr/japscan/japscan_source.dart';
|
|||
import 'package:mangayomi/sources/multisrc/mangathemesia/mangathemesia_source_list.dart';
|
||||
import 'package:mangayomi/sources/multisrc/mmrcms/mmrcms_source_list.dart';
|
||||
import 'package:mangayomi/sources/multisrc/madara/madara_source_list.dart';
|
||||
import 'package:mangayomi/sources/src/fr/mangakawaii/mangakawaii_source.dart';
|
||||
// import 'package:mangayomi/sources/src/fr/mangakawaii/mangakawaii_source.dart';
|
||||
List<Source> get sourcesList => _sourcesList;
|
||||
List<Source> _sourcesList = [
|
||||
mangahereSource,
|
||||
mangakawaiiSource,
|
||||
// mangakawaiiSource,
|
||||
...mangathemesiaSourcesList,
|
||||
...comickSourcesList,
|
||||
...mmrcmsSourcesList,
|
||||
|
|
|
|||
Loading…
Reference in a new issue