mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-21 16:01:58 +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:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
|
||||||
|
|
||||||
import 'package:epubx/epubx.dart';
|
import 'package:epubx/epubx.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
|
||||||
|
|
@ -40,29 +40,24 @@ Future<dynamic> updateMangaDetail(
|
||||||
.toSet()
|
.toSet()
|
||||||
.toList() ??
|
.toList() ??
|
||||||
[];
|
[];
|
||||||
final tempName = getManga.name?.trim().trimLeft().trimRight();
|
|
||||||
final tempLink = getManga.link?.trim().trimLeft().trimRight();
|
final imgUrl = getManga.imageUrl.trimmedOrDefault(manga.imageUrl);
|
||||||
final imgUrl = getManga.imageUrl ?? manga.imageUrl;
|
|
||||||
manga
|
manga
|
||||||
..imageUrl = imgUrl == null
|
..imageUrl = imgUrl == null
|
||||||
? null
|
? null
|
||||||
: imgUrl.startsWith('http')
|
: imgUrl.startsWith('http')
|
||||||
? imgUrl
|
? imgUrl
|
||||||
: '${source.baseUrl ?? ''}/${imgUrl.getUrlWithoutDomain}'
|
: '${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 ?? []
|
..genre = (genre.isEmpty ? null : genre) ?? manga.genre ?? []
|
||||||
..author =
|
..author = getManga.author.trimmedOrDefault(manga.author) ?? ""
|
||||||
getManga.author?.trim().trimLeft().trimRight() ?? manga.author ?? ""
|
..artist = getManga.artist.trimmedOrDefault(manga.artist) ?? ""
|
||||||
..artist =
|
|
||||||
getManga.artist?.trim().trimLeft().trimRight() ?? manga.artist ?? ""
|
|
||||||
..status = getManga.status == Status.unknown
|
..status = getManga.status == Status.unknown
|
||||||
? manga.status
|
? manga.status
|
||||||
: getManga.status ?? Status.unknown
|
: getManga.status ?? Status.unknown
|
||||||
..description =
|
..description =
|
||||||
getManga.description?.trim().trimLeft().trimRight() ??
|
getManga.description.trimmedOrDefault(manga.description) ?? ""
|
||||||
manga.description ??
|
..link = getManga.link.trimmedOrDefault(manga.link)
|
||||||
""
|
|
||||||
..link = tempLink != null && tempLink.isNotEmpty ? tempLink : manga.link
|
|
||||||
..source = manga.source
|
..source = manga.source
|
||||||
..lang = manga.lang
|
..lang = manga.lang
|
||||||
..itemType = source.itemType
|
..itemType = source.itemType
|
||||||
|
|
@ -173,3 +168,12 @@ Future<dynamic> updateMangaDetail(
|
||||||
return;
|
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),
|
onLongPress: () => _handleInteraction(ref),
|
||||||
onSecondaryTap: () => _handleInteraction(ref),
|
onSecondaryTap: () => _handleInteraction(ref),
|
||||||
child: ListTile(
|
child: ListTile(
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
minLeadingWidth: 0,
|
minLeadingWidth: 0,
|
||||||
horizontalTitleGap: 13,
|
horizontalTitleGap: 13,
|
||||||
leading: Container(
|
leading: Container(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue