mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-01-11 22:40:36 +00:00
refactor
This commit is contained in:
parent
cf871f5d7c
commit
f2fbaf5ec5
3 changed files with 17 additions and 13 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:epubx/epubx.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
|
|
|||
|
|
@ -40,29 +40,24 @@ Future<dynamic> updateMangaDetail(
|
|||
.toSet()
|
||||
.toList() ??
|
||||
[];
|
||||
final tempName = getManga.name?.trim().trimLeft().trimRight();
|
||||
final tempLink = getManga.link?.trim().trimLeft().trimRight();
|
||||
final imgUrl = getManga.imageUrl ?? manga.imageUrl;
|
||||
|
||||
final imgUrl = getManga.imageUrl.trimmedOrDefault(manga.imageUrl);
|
||||
manga
|
||||
..imageUrl = imgUrl == null
|
||||
? null
|
||||
: imgUrl.startsWith('http')
|
||||
? imgUrl
|
||||
: '${source.baseUrl ?? ''}/${imgUrl.getUrlWithoutDomain}'
|
||||
..name = tempName != null && tempName.isNotEmpty ? tempName : manga.name
|
||||
..name = getManga.name.trimmedOrDefault(manga.name)
|
||||
..genre = (genre.isEmpty ? null : genre) ?? manga.genre ?? []
|
||||
..author =
|
||||
getManga.author?.trim().trimLeft().trimRight() ?? manga.author ?? ""
|
||||
..artist =
|
||||
getManga.artist?.trim().trimLeft().trimRight() ?? manga.artist ?? ""
|
||||
..author = getManga.author.trimmedOrDefault(manga.author) ?? ""
|
||||
..artist = getManga.artist.trimmedOrDefault(manga.artist) ?? ""
|
||||
..status = getManga.status == Status.unknown
|
||||
? manga.status
|
||||
: getManga.status ?? Status.unknown
|
||||
..description =
|
||||
getManga.description?.trim().trimLeft().trimRight() ??
|
||||
manga.description ??
|
||||
""
|
||||
..link = tempLink != null && tempLink.isNotEmpty ? tempLink : manga.link
|
||||
getManga.description.trimmedOrDefault(manga.description) ?? ""
|
||||
..link = getManga.link.trimmedOrDefault(manga.link)
|
||||
..source = manga.source
|
||||
..lang = manga.lang
|
||||
..itemType = source.itemType
|
||||
|
|
@ -173,3 +168,12 @@ Future<dynamic> updateMangaDetail(
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
extension DefaultValueExtension on String? {
|
||||
String? trimmedOrDefault(String? defaultValue) {
|
||||
if (this?.trim().trimLeft().trimRight().isNotEmpty ?? false) {
|
||||
return this!.trim().trimLeft().trimRight();
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ class ChapterListTileWidget extends ConsumerWidget {
|
|||
onLongPress: () => _handleInteraction(ref),
|
||||
onSecondaryTap: () => _handleInteraction(ref),
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 15),
|
||||
minLeadingWidth: 0,
|
||||
horizontalTitleGap: 13,
|
||||
leading: Container(
|
||||
|
|
|
|||
Loading…
Reference in a new issue