mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-20 23:22:07 +00:00
Desktop right-click for long press on chapter
just like with the LibraryGridView
This commit is contained in:
parent
775e51e617
commit
aef659000d
1 changed files with 89 additions and 86 deletions
|
|
@ -24,113 +24,116 @@ class ChapterListTileWidget extends ConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final isLongPressed = ref.watch(isLongPressedStateProvider);
|
||||
final l10n = l10nLocalizations(context)!;
|
||||
return Container(
|
||||
color: chapterList.contains(chapter)
|
||||
? context.primaryColor.withValues(alpha: 0.4)
|
||||
: null,
|
||||
child: ListTile(
|
||||
textColor: chapter.isRead!
|
||||
? context.isLight
|
||||
? Colors.black.withValues(alpha: 0.4)
|
||||
: Colors.white.withValues(alpha: 0.3)
|
||||
: null,
|
||||
selectedColor: chapter.isRead!
|
||||
? Colors.white.withValues(alpha: 0.3)
|
||||
: Colors.white,
|
||||
onLongPress: () {
|
||||
if (!isLongPressed) {
|
||||
ref.read(chaptersListStateProvider.notifier).update(chapter);
|
||||
|
||||
ref
|
||||
.read(isLongPressedStateProvider.notifier)
|
||||
.update(!isLongPressed);
|
||||
} else {
|
||||
ref.read(chaptersListStateProvider.notifier).update(chapter);
|
||||
}
|
||||
},
|
||||
onTap: () async {
|
||||
if (isLongPressed) {
|
||||
ref.read(chaptersListStateProvider.notifier).update(chapter);
|
||||
} else {
|
||||
chapter.pushToReaderView(context, ignoreIsRead: true);
|
||||
}
|
||||
},
|
||||
title: Row(
|
||||
children: [
|
||||
chapter.isBookmarked!
|
||||
? Icon(Icons.bookmark, size: 16, color: context.primaryColor)
|
||||
: Container(),
|
||||
Flexible(child: _buildTitle(chapter.name!, context)),
|
||||
],
|
||||
),
|
||||
subtitle: Row(
|
||||
children: [
|
||||
if ((chapter.manga.value!.isLocalArchive ?? false) == false)
|
||||
Text(
|
||||
chapter.dateUpload == null || chapter.dateUpload!.isEmpty
|
||||
? ""
|
||||
: dateFormat(
|
||||
chapter.dateUpload!,
|
||||
ref: ref,
|
||||
context: context,
|
||||
child: GestureDetector(
|
||||
onLongPress: () => _handleInteraction(ref),
|
||||
onSecondaryTap: () => _handleInteraction(ref),
|
||||
child: ListTile(
|
||||
textColor: chapter.isRead!
|
||||
? context.isLight
|
||||
? Colors.black.withValues(alpha: 0.4)
|
||||
: Colors.white.withValues(alpha: 0.3)
|
||||
: null,
|
||||
selectedColor: chapter.isRead!
|
||||
? Colors.white.withValues(alpha: 0.3)
|
||||
: Colors.white,
|
||||
onTap: () async => _handleInteraction(ref, context),
|
||||
title: Row(
|
||||
children: [
|
||||
chapter.isBookmarked!
|
||||
? Icon(Icons.bookmark, size: 16, color: context.primaryColor)
|
||||
: Container(),
|
||||
Flexible(child: _buildTitle(chapter.name!, context)),
|
||||
],
|
||||
),
|
||||
subtitle: Row(
|
||||
children: [
|
||||
if ((chapter.manga.value!.isLocalArchive ?? false) == false)
|
||||
Text(
|
||||
chapter.dateUpload == null || chapter.dateUpload!.isEmpty
|
||||
? ""
|
||||
: dateFormat(
|
||||
chapter.dateUpload!,
|
||||
ref: ref,
|
||||
context: context,
|
||||
),
|
||||
style: const TextStyle(fontSize: 11),
|
||||
),
|
||||
if (!chapter.isRead!)
|
||||
if (chapter.lastPageRead!.isNotEmpty &&
|
||||
chapter.lastPageRead != "1")
|
||||
Row(
|
||||
children: [
|
||||
const Text(' • '),
|
||||
Text(
|
||||
chapter.manga.value!.itemType == ItemType.anime
|
||||
? l10n.episode_progress(
|
||||
Duration(
|
||||
milliseconds: int.parse(
|
||||
chapter.lastPageRead!,
|
||||
),
|
||||
).toString().substringBefore("."),
|
||||
)
|
||||
: l10n.page(
|
||||
chapter.manga.value!.itemType == ItemType.manga
|
||||
? chapter.lastPageRead!
|
||||
: "${((double.tryParse(chapter.lastPageRead!) ?? 0) * 100).toStringAsFixed(0)} %",
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: context.isLight
|
||||
? Colors.black.withValues(alpha: 0.4)
|
||||
: Colors.white.withValues(alpha: 0.3),
|
||||
),
|
||||
),
|
||||
style: const TextStyle(fontSize: 11),
|
||||
),
|
||||
if (!chapter.isRead!)
|
||||
if (chapter.lastPageRead!.isNotEmpty &&
|
||||
chapter.lastPageRead != "1")
|
||||
],
|
||||
),
|
||||
if (chapter.scanlator?.isNotEmpty ?? false)
|
||||
Row(
|
||||
children: [
|
||||
const Text(' • '),
|
||||
Text(
|
||||
chapter.manga.value!.itemType == ItemType.anime
|
||||
? l10n.episode_progress(
|
||||
Duration(
|
||||
milliseconds: int.parse(chapter.lastPageRead!),
|
||||
).toString().substringBefore("."),
|
||||
)
|
||||
: l10n.page(
|
||||
chapter.manga.value!.itemType == ItemType.manga
|
||||
? chapter.lastPageRead!
|
||||
: "${((double.tryParse(chapter.lastPageRead!) ?? 0) * 100).toStringAsFixed(0)} %",
|
||||
),
|
||||
chapter.scanlator!,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: context.isLight
|
||||
? Colors.black.withValues(alpha: 0.4)
|
||||
: Colors.white.withValues(alpha: 0.3),
|
||||
color: chapter.isRead!
|
||||
? context.isLight
|
||||
? Colors.black.withValues(alpha: 0.4)
|
||||
: Colors.white.withValues(alpha: 0.3)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (chapter.scanlator?.isNotEmpty ?? false)
|
||||
Row(
|
||||
children: [
|
||||
const Text(' • '),
|
||||
Text(
|
||||
chapter.scanlator!,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: chapter.isRead!
|
||||
? context.isLight
|
||||
? Colors.black.withValues(alpha: 0.4)
|
||||
: Colors.white.withValues(alpha: 0.3)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
trailing:
|
||||
!sourceExist || (chapter.manga.value!.isLocalArchive ?? false)
|
||||
? null
|
||||
: ChapterPageDownload(chapter: chapter),
|
||||
),
|
||||
trailing: !sourceExist || (chapter.manga.value!.isLocalArchive ?? false)
|
||||
? null
|
||||
: ChapterPageDownload(chapter: chapter),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _handleInteraction(WidgetRef ref, [BuildContext? context]) {
|
||||
final isLongPressed = ref.read(isLongPressedStateProvider);
|
||||
if (isLongPressed) {
|
||||
ref.read(chaptersListStateProvider.notifier).update(chapter);
|
||||
} else {
|
||||
if (context != null) {
|
||||
chapter.pushToReaderView(context, ignoreIsRead: true);
|
||||
} else {
|
||||
ref.read(chaptersListStateProvider.notifier).update(chapter);
|
||||
ref.read(isLongPressedStateProvider.notifier).update(!isLongPressed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildTitle(String text, BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue