diff --git a/lib/eval/dart/bridge/document.dart b/lib/eval/dart/bridge/document.dart index 4256ab3..11ccbb6 100644 --- a/lib/eval/dart/bridge/document.dart +++ b/lib/eval/dart/bridge/document.dart @@ -9,13 +9,15 @@ import 'package:mangayomi/eval/model/element.dart'; class $MDocument implements MDocument, $Instance { $MDocument.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MDocument')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MDocument')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { '': BridgeConstructorDef( BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('document', BridgeTypeAnnotation($Element.$type, nullable: true), false), + BridgeParameter('document', + BridgeTypeAnnotation($Element.$type, nullable: true), false), ]), ) }, @@ -36,60 +38,118 @@ class $MDocument implements MDocument, $Instance { returns: BridgeTypeAnnotation($MElement.$type, nullable: true), )), 'outerHtml': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'text': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'children': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$MElement.$type]), nullable: true), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [$MElement.$type]), + nullable: true), )), }, methods: { 'select': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$MElement.$type]), nullable: true), - params: [BridgeParameter('selector', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [$MElement.$type]), + nullable: true), + params: [ + BridgeParameter( + 'selector', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'selectFirst': BridgeMethodDef( BridgeFunctionDef( returns: BridgeTypeAnnotation($MElement.$type, nullable: true), - params: [BridgeParameter('selector', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + params: [ + BridgeParameter( + 'selector', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'getElementsByClassName': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$type]), nullable: true), - params: [BridgeParameter('classNames', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [$type]), + nullable: true), + params: [ + BridgeParameter( + 'classNames', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'getElementsByTagName': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$type]), nullable: true), - params: [BridgeParameter('localNames', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [$type]), + nullable: true), + params: [ + BridgeParameter( + 'localNames', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'getElementById': BridgeMethodDef( BridgeFunctionDef( returns: BridgeTypeAnnotation($MElement.$type, nullable: true), - params: [BridgeParameter('id', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + params: [ + BridgeParameter( + 'id', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'xpath': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), - params: [BridgeParameter('xpath', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + returns: BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), + params: [ + BridgeParameter( + 'xpath', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'xpathFirst': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), - params: [BridgeParameter('xpath', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + params: [ + BridgeParameter( + 'xpath', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'attr': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('attr', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), false) - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'attr', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + false) + ]), ), 'hasAttr': BridgeMethodDef( BridgeFunctionDef( returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), - params: [BridgeParameter('attr', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + params: [ + BridgeParameter( + 'attr', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), }, wrap: true); @@ -125,7 +185,9 @@ class $MDocument implements MDocument, $Instance { return res == null ? const $null() : $String(res); case 'children': final res = $value.children; - return res == null ? const $null() : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); + return res == null + ? const $null() + : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); case 'select': return __select; case 'selectFirst': @@ -156,59 +218,79 @@ class $MDocument implements MDocument, $Instance { void $setProperty(Runtime runtime, String identifier, $Value value) {} static const $Function __select = $Function(_select); - static $Value? _select(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _select( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MDocument).select(args[0]?.$value); - return res == null ? const $null() : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); + return res == null + ? const $null() + : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); } static const $Function __selectFirst = $Function(_selectFirst); - static $Value? _selectFirst(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _selectFirst( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MDocument).selectFirst(args[0]?.$value); return res == null ? const $null() : $MElement.wrap(res); } - static $Value? $new(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? $new( + final Runtime runtime, final $Value? target, final List<$Value?> args) { return $MDocument.wrap(MDocument(args[0]?.$value)); } - static const $Function __getElementsByClassName = $Function(_getElementsByClassName); - static $Value? _getElementsByClassName(final Runtime runtime, final $Value? target, final List<$Value?> args) { - final res = (target!.$value as MDocument).getElementsByClassName(args[0]?.$value); - return res == null ? const $null() : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); + static const $Function __getElementsByClassName = + $Function(_getElementsByClassName); + static $Value? _getElementsByClassName( + final Runtime runtime, final $Value? target, final List<$Value?> args) { + final res = + (target!.$value as MDocument).getElementsByClassName(args[0]?.$value); + return res == null + ? const $null() + : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); } - static const $Function __getElementsByTagName = $Function(_getElementsByTagName); - static $Value? _getElementsByTagName(final Runtime runtime, final $Value? target, final List<$Value?> args) { - final res = (target!.$value as MDocument).getElementsByTagName(args[0]?.$value); - return res == null ? const $null() : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); + static const $Function __getElementsByTagName = + $Function(_getElementsByTagName); + static $Value? _getElementsByTagName( + final Runtime runtime, final $Value? target, final List<$Value?> args) { + final res = + (target!.$value as MDocument).getElementsByTagName(args[0]?.$value); + return res == null + ? const $null() + : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); } static const $Function __getElementById = $Function(_getElementById); - static $Value? _getElementById(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _getElementById( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MDocument).getElementById(args[0]?.$value); return res == null ? const $null() : $MElement.wrap(res); } static const $Function __xpath = $Function(_xpath); - static $Value? _xpath(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _xpath( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MDocument).xpath(args[0]?.$value); return $List.wrap(res.map((e) => $String(e)).toList()); } static const $Function __xpathFirst = $Function(_xpathFirst); - static $Value? _xpathFirst(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _xpathFirst( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MDocument).xpathFirst(args[0]?.$value); return res == null ? const $null() : $String(res); } static const $Function __attr = $Function(_attr); - static $Value? _attr(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _attr( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MDocument).attr(args[0]?.$value ?? ""); return res == null ? const $null() : $String(res); } static const $Function __hasAttr = $Function(_hasAttr); - static $Value? _hasAttr(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _hasAttr( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MDocument).attr(args[0]?.$value ?? ""); return res == null ? const $null() : $String(res); } @@ -226,10 +308,12 @@ class $MDocument implements MDocument, $Instance { String? xpathFirst(String xpath) => $value.xpathFirst(xpath); @override - List? getElementsByClassName(String classNames) => $value.getElementsByClassName(classNames); + List? getElementsByClassName(String classNames) => + $value.getElementsByClassName(classNames); @override - List? getElementsByTagName(String localNames) => $value.getElementsByTagName(localNames); + List? getElementsByTagName(String localNames) => + $value.getElementsByTagName(localNames); @override String? attr(String attr) => $value.attr(attr); @@ -265,11 +349,15 @@ class $MDocument implements MDocument, $Instance { class $Document implements $Instance { $Document.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'Document')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'Document')); static const $declaration = BridgeClassDef( BridgeClassType($type), - constructors: {'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type, nullable: true)))}, + constructors: { + '': BridgeConstructorDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation($type, nullable: true))) + }, wrap: true, ); diff --git a/lib/eval/dart/bridge/element.dart b/lib/eval/dart/bridge/element.dart index ab1ded5..a95f598 100644 --- a/lib/eval/dart/bridge/element.dart +++ b/lib/eval/dart/bridge/element.dart @@ -5,13 +5,15 @@ import 'package:mangayomi/eval/model/element.dart'; class $MElement implements MElement, $Instance { $MElement.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MElement')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MElement')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { '': BridgeConstructorDef( BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('element', BridgeTypeAnnotation($Element.$type, nullable: true), false), + BridgeParameter('element', + BridgeTypeAnnotation($Element.$type, nullable: true), false), ]), ) }, @@ -20,37 +22,48 @@ class $MElement implements MElement, $Instance { }, getters: { 'outerHtml': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'innerHtml': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'text': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'className': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'localName': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'namespaceUri': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'getSrc': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'getImg': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'getHref': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'getDataSrc': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'children': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$type]), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$type]), + nullable: true), )), 'parent': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation($type, nullable: true), @@ -64,48 +77,100 @@ class $MElement implements MElement, $Instance { }, methods: { 'attr': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('attr', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), false) - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'attr', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + false) + ]), ), 'text': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true)), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true)), ), 'select': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$type]), nullable: true), - params: [BridgeParameter('selector', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [$type]), + nullable: true), + params: [ + BridgeParameter( + 'selector', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'selectFirst': BridgeMethodDef( BridgeFunctionDef( returns: BridgeTypeAnnotation($type, nullable: true), - params: [BridgeParameter('selector', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + params: [ + BridgeParameter( + 'selector', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'getElementsByClassName': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$type]), nullable: true), - params: [BridgeParameter('classNames', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [$type]), + nullable: true), + params: [ + BridgeParameter( + 'classNames', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'getElementsByTagName': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$type]), nullable: true), - params: [BridgeParameter('localNames', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [$type]), + nullable: true), + params: [ + BridgeParameter( + 'localNames', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'xpath': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]), + returns: BridgeTypeAnnotation( + BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]), nullable: true), - params: [BridgeParameter('xpath', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + params: [ + BridgeParameter( + 'xpath', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'xpathFirst': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), - params: [BridgeParameter('xpath', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + params: [ + BridgeParameter( + 'xpath', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), 'hasAttr': BridgeMethodDef( BridgeFunctionDef( returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), - params: [BridgeParameter('attr', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false)]), + params: [ + BridgeParameter( + 'attr', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false) + ]), ), }, wrap: true); @@ -129,28 +194,44 @@ class $MElement implements MElement, $Instance { return res == null ? const $null() : $String(res); case 'text': final res = $value.text; - return res == null ? const $null() : $String(res.trim().trimLeft().trimRight()); + return res == null + ? const $null() + : $String(res.trim().trimLeft().trimRight()); case 'className': final res = $value.className; - return res == null ? const $null() : $String(res.trim().trimLeft().trimRight()); + return res == null + ? const $null() + : $String(res.trim().trimLeft().trimRight()); case 'localName': final res = $value.localName; - return res == null ? const $null() : $String(res.trim().trimLeft().trimRight()); + return res == null + ? const $null() + : $String(res.trim().trimLeft().trimRight()); case 'namespaceUri': final res = $value.namespaceUri; - return res == null ? const $null() : $String(res.trim().trimLeft().trimRight()); + return res == null + ? const $null() + : $String(res.trim().trimLeft().trimRight()); case 'getSrc': final res = $value.getSrc; - return res == null ? const $null() : $String(res.trim().trimLeft().trimRight()); + return res == null + ? const $null() + : $String(res.trim().trimLeft().trimRight()); case 'getImg': final res = $value.getImg; - return res == null ? const $null() : $String(res.trim().trimLeft().trimRight()); + return res == null + ? const $null() + : $String(res.trim().trimLeft().trimRight()); case 'getHref': final res = $value.getHref; - return res == null ? const $null() : $String(res.trim().trimLeft().trimRight()); + return res == null + ? const $null() + : $String(res.trim().trimLeft().trimRight()); case 'getDataSrc': final res = $value.getDataSrc; - return res == null ? const $null() : $String(res.trim().trimLeft().trimRight()); + return res == null + ? const $null() + : $String(res.trim().trimLeft().trimRight()); case 'parent': final res = $value.parent; return res == null ? const $null() : $MElement.wrap(res); @@ -187,62 +268,83 @@ class $MElement implements MElement, $Instance { @override void $setProperty(Runtime runtime, String identifier, $Value value) {} - static $Value? $new(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? $new( + final Runtime runtime, final $Value? target, final List<$Value?> args) { return $MElement.wrap(MElement(args[0]?.$value)); } static const $Function __attr = $Function(_attr); - static $Value? _attr(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _attr( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MElement).attr(args[0]?.$value ?? ""); return res == null ? const $null() : $String(res); } static const $Function __select = $Function(_select); - static $Value? _select(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _select( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MElement).select(args[0]?.$value); - return res == null ? const $null() : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); + return res == null + ? const $null() + : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); } static const $Function __selectFirst = $Function(_selectFirst); - static $Value? _selectFirst(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _selectFirst( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MElement).selectFirst(args[0]?.$value); return res == null ? const $null() : $MElement.wrap(res); } - static const $Function __getElementsByClassName = $Function(_getElementsByClassName); + static const $Function __getElementsByClassName = + $Function(_getElementsByClassName); - static $Value? _getElementsByClassName(final Runtime runtime, final $Value? target, final List<$Value?> args) { - final res = (target!.$value as MElement).getElementsByClassName(args[0]?.$value); - return res == null ? const $null() : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); + static $Value? _getElementsByClassName( + final Runtime runtime, final $Value? target, final List<$Value?> args) { + final res = + (target!.$value as MElement).getElementsByClassName(args[0]?.$value); + return res == null + ? const $null() + : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); } - static const $Function __getElementsByTagName = $Function(_getElementsByTagName); + static const $Function __getElementsByTagName = + $Function(_getElementsByTagName); - static $Value? _getElementsByTagName(final Runtime runtime, final $Value? target, final List<$Value?> args) { - final res = (target!.$value as MElement).getElementsByTagName(args[0]?.$value); - return res == null ? const $null() : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); + static $Value? _getElementsByTagName( + final Runtime runtime, final $Value? target, final List<$Value?> args) { + final res = + (target!.$value as MElement).getElementsByTagName(args[0]?.$value); + return res == null + ? const $null() + : $List.wrap(res.map((e) => $MElement.wrap(e)).toList()); } static const $Function __xpath = $Function(_xpath); - static $Value? _xpath(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _xpath( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MElement).xpath(args[0]?.$value); - return res == null ? const $null() : $List.wrap(res.map((e) => $String(e)).toList()); + return res == null + ? const $null() + : $List.wrap(res.map((e) => $String(e)).toList()); } static const $Function __xpathFirst = $Function(_xpathFirst); - static $Value? _xpathFirst(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _xpathFirst( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MElement).xpathFirst(args[0]?.$value); return res == null ? const $null() : $String(res); } static const $Function __hasAttr = $Function(_hasAttr); - static $Value? _hasAttr(final Runtime runtime, final $Value? target, final List<$Value?> args) { + static $Value? _hasAttr( + final Runtime runtime, final $Value? target, final List<$Value?> args) { final res = (target!.$value as MElement).attr(args[0]?.$value ?? ""); return res == null ? const $null() : $String(res); } @@ -266,10 +368,12 @@ class $MElement implements MElement, $Instance { List? get children => $value.children; @override - List? getElementsByClassName(String classNames) => $value.getElementsByClassName(classNames); + List? getElementsByClassName(String classNames) => + $value.getElementsByClassName(classNames); @override - List? getElementsByTagName(String localNames) => $value.getElementsByTagName(localNames); + List? getElementsByTagName(String localNames) => + $value.getElementsByTagName(localNames); @override bool hasAttr(String attr) => $value.hasAttr(attr); @@ -317,11 +421,15 @@ class $MElement implements MElement, $Instance { class $Element implements $Instance { $Element.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'Element')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'Element')); static const $declaration = BridgeClassDef( BridgeClassType($type), - constructors: {'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type, nullable: true)))}, + constructors: { + '': BridgeConstructorDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation($type, nullable: true))) + }, wrap: true, ); diff --git a/lib/eval/dart/bridge/filter.dart b/lib/eval/dart/bridge/filter.dart index c723af7..1e59f31 100644 --- a/lib/eval/dart/bridge/filter.dart +++ b/lib/eval/dart/bridge/filter.dart @@ -5,18 +5,24 @@ import 'package:mangayomi/eval/model/filter.dart'; class $FilterList implements FilterList, $Instance { $FilterList.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'FilterList')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'FilterList')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('filters', - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), false), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter( + 'filters', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + false), ])) }, fields: { 'filters': BridgeFieldDef( - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), ), }, wrap: true); @@ -51,7 +57,9 @@ class $FilterList implements FilterList, $Instance { void $setProperty(Runtime runtime, String identifier, $Value value) { switch (identifier) { case 'filters': - $value.filters = (value.$reified as List).map((e) => e is $Value ? e.$reified : e).toList(); + $value.filters = (value.$reified as List) + .map((e) => e is $Value ? e.$reified : e) + .toList(); default: _superclass.$setProperty(runtime, identifier, value); } @@ -72,26 +80,37 @@ class $FilterList implements FilterList, $Instance { class $SelectFilter implements SelectFilter, $Instance { $SelectFilter.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'SelectFilter')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'SelectFilter')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('type', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('name', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('state', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter('type', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('name', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('state', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), BridgeParameter( - 'values', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), false), + 'values', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + false), ])) }, fields: { - 'type': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'name': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'type': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'name': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), 'state': BridgeFieldDef(BridgeTypeAnnotation( BridgeTypeRef(CoreTypes.int), )), 'values': BridgeFieldDef( - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), ), }, wrap: true); @@ -109,7 +128,8 @@ class $SelectFilter implements SelectFilter, $Instance { map = value.map((key, value) => MapEntry(key.toString(), value)); if (map['type'] == 'SelectOption') { final filter = map['filter'] as Map; - return SelectFilterOption.fromJson(filter.map((key, value) => MapEntry(key.toString(), value))); + return SelectFilterOption.fromJson(filter + .map((key, value) => MapEntry(key.toString(), value))); } } return value; @@ -202,23 +222,30 @@ class $SelectFilter implements SelectFilter, $Instance { class $SelectFilterOption implements SelectFilterOption, $Instance { $SelectFilterOption.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'SelectFilterOption')); + static const $type = BridgeTypeRef(BridgeTypeSpec( + 'package:mangayomi/bridge_lib.dart', 'SelectFilterOption')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('name', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('value', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter('name', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('value', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), ])) }, fields: { - 'name': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'value': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'name': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'value': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), }, wrap: true); static $Value? $new(Runtime runtime, $Value? target, List<$Value?> args) { - return $SelectFilterOption.wrap(SelectFilterOption(args[0]!.$value, args[1]!.$value, null)); + return $SelectFilterOption + .wrap(SelectFilterOption(args[0]!.$value, args[1]!.$value, null)); } @override @@ -285,21 +312,26 @@ class $SelectFilterOption implements SelectFilterOption, $Instance { class $SeparatorFilter implements SeparatorFilter, $Instance { $SeparatorFilter.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'SeparatorFilter')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'SeparatorFilter')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('type', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter('type', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), ])) }, fields: { - 'type': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'type': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), }, wrap: true); static $Value? $new(Runtime runtime, $Value? target, List<$Value?> args) { - return $SeparatorFilter.wrap(SeparatorFilter(null, type: args[0]?.$value ?? '')); + return $SeparatorFilter + .wrap(SeparatorFilter(null, type: args[0]?.$value ?? '')); } @override @@ -355,23 +387,30 @@ class $SeparatorFilter implements SeparatorFilter, $Instance { class $HeaderFilter implements HeaderFilter, $Instance { $HeaderFilter.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'HeaderFilter')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'HeaderFilter')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('name', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('type', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter('name', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('type', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), ])) }, fields: { - 'name': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'type': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'name': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'type': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), }, wrap: true); static $Value? $new(Runtime runtime, $Value? target, List<$Value?> args) { - return $HeaderFilter.wrap(HeaderFilter(args[0]!.$value, null, type: args[1]?.$value ?? '')); + return $HeaderFilter + .wrap(HeaderFilter(args[0]!.$value, null, type: args[1]?.$value ?? '')); } @override @@ -438,18 +477,24 @@ class $HeaderFilter implements HeaderFilter, $Instance { class $TextFilter implements TextFilter, $Instance { $TextFilter.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'TextFilter')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'TextFilter')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('type', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('name', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter('type', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('name', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), ])) }, fields: { - 'type': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'name': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'type': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'name': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), }, wrap: true); @@ -530,24 +575,35 @@ class $TextFilter implements TextFilter, $Instance { class $SortFilter implements SortFilter, $Instance { $SortFilter.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'SortFilter')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'SortFilter')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('type', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('name', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('state', BridgeTypeAnnotation($SortState.$type), false), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter('type', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('name', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), BridgeParameter( - 'values', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), false), + 'state', BridgeTypeAnnotation($SortState.$type), false), + BridgeParameter( + 'values', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + false), ])) }, fields: { - 'type': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'name': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'type': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'name': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), 'state': BridgeFieldDef(BridgeTypeAnnotation($SortState.$type)), 'values': BridgeFieldDef( - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), ), }, wrap: true); @@ -557,7 +613,10 @@ class $SortFilter implements SortFilter, $Instance { args[0]!.$value, args[1]!.$value, args[2]!.$value, - (args[3]!.$value as List).map((e) => SelectFilterOption(e.$reified.name, e.$reified.value, null)).toList(), + (args[3]!.$value as List) + .map((e) => + SelectFilterOption(e.$reified.name, e.$reified.value, null)) + .toList(), null)); } @@ -644,13 +703,17 @@ class $SortFilter implements SortFilter, $Instance { class $SortState implements SortState, $Instance { $SortState.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'SortState')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'SortState')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('index', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), - BridgeParameter('ascending', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), false), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter('index', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + BridgeParameter('ascending', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), false), ])) }, fields: { @@ -731,22 +794,31 @@ class $SortState implements SortState, $Instance { class $TriStateFilter implements TriStateFilter, $Instance { $TriStateFilter.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'TriStateFilter')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'TriStateFilter')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('name', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('value', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('type', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter('name', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('value', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('type', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), ], namedParams: [ - BridgeParameter('state', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), true) + BridgeParameter( + 'state', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), true) ])) }, fields: { - 'name': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'value': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'type': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'name': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'value': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'type': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), 'state': BridgeFieldDef(BridgeTypeAnnotation( BridgeTypeRef(CoreTypes.int), )), @@ -754,8 +826,9 @@ class $TriStateFilter implements TriStateFilter, $Instance { wrap: true); static $Value? $new(Runtime runtime, $Value? target, List<$Value?> args) { - return $TriStateFilter.wrap( - TriStateFilter(args[2]?.$value ?? '', args[0]!.$value, args[1]!.$value, null, state: args[3]?.$value ?? 0)); + return $TriStateFilter.wrap(TriStateFilter( + args[2]?.$value ?? '', args[0]!.$value, args[1]!.$value, null, + state: args[3]?.$value ?? 0)); } @override @@ -842,22 +915,32 @@ class $TriStateFilter implements TriStateFilter, $Instance { class $GroupFilter implements GroupFilter, $Instance { $GroupFilter.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'GroupFilter')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'GroupFilter')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('type', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('name', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter('type', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('name', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), BridgeParameter( - 'state', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), false), + 'state', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + false), ])) }, fields: { - 'type': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'name': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'type': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'name': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), 'state': BridgeFieldDef( - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), ), }, wrap: true); @@ -874,10 +957,12 @@ class $GroupFilter implements GroupFilter, $Instance { map = value.map((key, value) => MapEntry(key.toString(), value)); if (map['type'] == 'TriState') { final filter = map['filter'] as Map; - return TriStateFilter.fromJson(filter.map((key, value) => MapEntry(key.toString(), value))); + return TriStateFilter.fromJson(filter + .map((key, value) => MapEntry(key.toString(), value))); } else if (map['type'] == 'CheckBox') { final filter = map['filter'] as Map; - return CheckBoxFilter.fromJson(filter.map((key, value) => MapEntry(key.toString(), value))); + return CheckBoxFilter.fromJson(filter + .map((key, value) => MapEntry(key.toString(), value))); } } return value; @@ -961,22 +1046,31 @@ class $GroupFilter implements GroupFilter, $Instance { class $CheckBoxFilter implements CheckBoxFilter, $Instance { $CheckBoxFilter.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'CheckBoxFilter')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'CheckBoxFilter')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('name', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('value', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('type', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter('name', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('value', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('type', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), ], namedParams: [ - BridgeParameter('state', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), true), + BridgeParameter('state', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), true), ])) }, fields: { - 'name': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'value': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'type': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'name': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'value': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'type': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), 'state': BridgeFieldDef(BridgeTypeAnnotation( BridgeTypeRef(CoreTypes.bool), )), @@ -984,8 +1078,9 @@ class $CheckBoxFilter implements CheckBoxFilter, $Instance { wrap: true); static $Value? $new(Runtime runtime, $Value? target, List<$Value?> args) { - return $CheckBoxFilter.wrap( - CheckBoxFilter(args[2]?.$value ?? '', args[0]!.$value, args[1]!.$value, null, state: args[3]?.$value ?? false)); + return $CheckBoxFilter.wrap(CheckBoxFilter( + args[2]?.$value ?? '', args[0]!.$value, args[1]!.$value, null, + state: args[3]?.$value ?? false)); } @override diff --git a/lib/eval/dart/bridge/http.dart b/lib/eval/dart/bridge/http.dart index 08ea353..af042c0 100644 --- a/lib/eval/dart/bridge/http.dart +++ b/lib/eval/dart/bridge/http.dart @@ -17,104 +17,165 @@ class $Client implements $Instance { late final $Instance _superclass = $Object($value); /// Compile-time bridged type reference for [$InterceptedClient] - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'Client')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'Client')); /// Compile-time bridged class declaration for [$InterceptedClient] static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ BridgeParameter('source', BridgeTypeAnnotation($MSource.$type), true), - BridgeParameter('reqcopyWith', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), + BridgeParameter('reqcopyWith', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), ], namedParams: [])) }, methods: { 'get': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [$Response.$type])), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.future, [$Response.$type])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), + BridgeParameter('url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), ], namedParams: [ BridgeParameter( 'headers', BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), nullable: true), true), ])), 'post': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [$Response.$type])), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.future, [$Response.$type])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), + BridgeParameter('url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), ], namedParams: [ BridgeParameter( 'headers', BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), nullable: true), true), - BridgeParameter('body', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.object), nullable: true), true), BridgeParameter( - 'encoding', BridgeTypeAnnotation(BridgeTypeRef(ConvertTypes.encoding), nullable: true), true), + 'body', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.object), + nullable: true), + true), + BridgeParameter( + 'encoding', + BridgeTypeAnnotation(BridgeTypeRef(ConvertTypes.encoding), + nullable: true), + true), ])), 'put': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [$Response.$type])), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.future, [$Response.$type])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), + BridgeParameter('url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), ], namedParams: [ BridgeParameter( 'headers', BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), nullable: true), true), - BridgeParameter('body', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.object), nullable: true), true), BridgeParameter( - 'encoding', BridgeTypeAnnotation(BridgeTypeRef(ConvertTypes.encoding), nullable: true), true), + 'body', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.object), + nullable: true), + true), + BridgeParameter( + 'encoding', + BridgeTypeAnnotation(BridgeTypeRef(ConvertTypes.encoding), + nullable: true), + true), ])), 'delete': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [$Response.$type])), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.future, [$Response.$type])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), + BridgeParameter('url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), ], namedParams: [ BridgeParameter( 'headers', BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), nullable: true), true), - BridgeParameter('body', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.object), nullable: true), true), BridgeParameter( - 'encoding', BridgeTypeAnnotation(BridgeTypeRef(ConvertTypes.encoding), nullable: true), true), + 'body', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.object), + nullable: true), + true), + BridgeParameter( + 'encoding', + BridgeTypeAnnotation(BridgeTypeRef(ConvertTypes.encoding), + nullable: true), + true), ])), 'patch': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [$Response.$type])), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.future, [$Response.$type])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), + BridgeParameter('url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), ], namedParams: [ BridgeParameter( 'headers', BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), nullable: true), true), - BridgeParameter('body', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.object), nullable: true), true), BridgeParameter( - 'encoding', BridgeTypeAnnotation(BridgeTypeRef(ConvertTypes.encoding), nullable: true), true), + 'body', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.object), + nullable: true), + true), + BridgeParameter( + 'encoding', + BridgeTypeAnnotation(BridgeTypeRef(ConvertTypes.encoding), + nullable: true), + true), ])), 'read': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [BridgeTypeRef(CoreTypes.string)])), + returns: BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.future, [BridgeTypeRef(CoreTypes.string)])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), + BridgeParameter('url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), ], namedParams: [ BridgeParameter( 'headers', BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), nullable: true), true), ])), @@ -123,20 +184,26 @@ class $Client implements $Instance { BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.int)]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), + BridgeParameter('url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.uri)), false), ], namedParams: [ BridgeParameter( 'headers', BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), nullable: true), true), ])), 'send': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [BridgeTypeRef(CoreTypes.list)])), + returns: BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.future, [BridgeTypeRef(CoreTypes.list)])), params: [ - BridgeParameter('request', BridgeTypeAnnotation($BaseRequest.$type), false), + BridgeParameter( + 'request', BridgeTypeAnnotation($BaseRequest.$type), false), ])), 'close': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.voidType)), @@ -147,7 +214,8 @@ class $Client implements $Instance { static $Client $new(Runtime runtime, $Value? target, List<$Value?> args) { final reqcopyWith = args[1]?.$value == null ? null - : (jsonDecode(args[1]!.$value) as Map).map((key, value) => MapEntry(key.toString(), value)); + : (jsonDecode(args[1]!.$value) as Map) + .map((key, value) => MapEntry(key.toString(), value)); return $Client.wrap( MClient.init(source: args[0]?.$value, reqcopyWith: reqcopyWith), ); @@ -183,8 +251,10 @@ class $Client implements $Instance { final url = args[0]!.$value as Uri; final headers = _toMapString(args[1]?.$value); - final request = (target!.$value as InterceptedClient).get(url, headers: headers); - return $Future.wrap(request.then((value) => $Response.wrap(value)).onErrorMessage()); + final request = + (target!.$value as InterceptedClient).get(url, headers: headers); + return $Future + .wrap(request.then((value) => $Response.wrap(value)).onErrorMessage()); } static const $Function __post = $Function(_post); @@ -195,8 +265,10 @@ class $Client implements $Instance { final body = _toBodyObject(args[2]?.$value); final encoding = args[3]?.$value as Encoding?; - final request = (target!.$value as InterceptedClient).post(url, headers: headers, body: body, encoding: encoding); - return $Future.wrap(request.then((value) => $Response.wrap(value)).onErrorMessage()); + final request = (target!.$value as InterceptedClient) + .post(url, headers: headers, body: body, encoding: encoding); + return $Future + .wrap(request.then((value) => $Response.wrap(value)).onErrorMessage()); } static const $Function __put = $Function(_put); @@ -207,8 +279,10 @@ class $Client implements $Instance { final body = _toBodyObject(args[2]?.$value); final encoding = args[3]?.$value as Encoding?; - final request = (target!.$value as InterceptedClient).put(url, headers: headers, body: body, encoding: encoding); - return $Future.wrap(request.then((value) => $Response.wrap(value)).onErrorMessage()); + final request = (target!.$value as InterceptedClient) + .put(url, headers: headers, body: body, encoding: encoding); + return $Future + .wrap(request.then((value) => $Response.wrap(value)).onErrorMessage()); } static const $Function __delete = $Function(_delete); @@ -219,8 +293,10 @@ class $Client implements $Instance { final body = _toBodyObject(args[2]?.$value); final encoding = args[3]?.$value as Encoding?; - final request = (target!.$value as InterceptedClient).delete(url, headers: headers, body: body, encoding: encoding); - return $Future.wrap(request.then((value) => $Response.wrap(value)).onErrorMessage()); + final request = (target!.$value as InterceptedClient) + .delete(url, headers: headers, body: body, encoding: encoding); + return $Future + .wrap(request.then((value) => $Response.wrap(value)).onErrorMessage()); } static const $Function __patch = $Function(_patch); @@ -231,8 +307,10 @@ class $Client implements $Instance { final body = _toBodyObject(args[2]?.$value); final encoding = args[3]?.$value as Encoding?; - final request = (target!.$value as InterceptedClient).patch(url, headers: headers, body: body, encoding: encoding); - return $Future.wrap(request.then((value) => $Response.wrap(value)).onErrorMessage()); + final request = (target!.$value as InterceptedClient) + .patch(url, headers: headers, body: body, encoding: encoding); + return $Future + .wrap(request.then((value) => $Response.wrap(value)).onErrorMessage()); } static const $Function __read = $Function(_read); @@ -241,19 +319,25 @@ class $Client implements $Instance { final url = args[0]!.$value as Uri; final headers = _toMapString(args[1]?.$value); - final request = (target!.$value as InterceptedClient).read(url, headers: headers); - return $Future.wrap(request.then((value) => $String(value)).onErrorMessage()); + final request = + (target!.$value as InterceptedClient).read(url, headers: headers); + return $Future + .wrap(request.then((value) => $String(value)).onErrorMessage()); } static const $Function __readBytes = $Function(_readBytes); - static $Value? _readBytes(Runtime runtime, $Value? target, List<$Value?> args) { + static $Value? _readBytes( + Runtime runtime, $Value? target, List<$Value?> args) { final url = args[0]!.$value as Uri; - final headers = (args[1]?.$value as Map<$Value, $Value>?) - ?.map((key, value) => MapEntry((key.$reified).toString(), (value.$reified).toString())); + final headers = (args[1]?.$value as Map<$Value, $Value>?)?.map( + (key, value) => + MapEntry((key.$reified).toString(), (value.$reified).toString())); - final request = (target!.$value as InterceptedClient).readBytes(url, headers: headers); - return $Future.wrap(request.then((value) => $List.wrap(value)).onErrorMessage()); + final request = + (target!.$value as InterceptedClient).readBytes(url, headers: headers); + return $Future + .wrap(request.then((value) => $List.wrap(value)).onErrorMessage()); } static const $Function __close = $Function(_close); @@ -281,46 +365,52 @@ class $BaseRequest implements $Instance { final BaseRequest $value; /// Compile-time bridged type reference for [$BaseRequest] - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'BaseRequest')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'BaseRequest')); /// Compile-time bridged class declaration for [$BaseRequest] - static const $declaration = BridgeClassDef(BridgeClassType($type, isAbstract: true), - constructors: {}, - getters: { - 'contentLength': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int), nullable: true), - )), - 'finalized': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), - )), - 'followRedirects': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), - )), - 'headers': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), - ), - )), - 'maxRedirects': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), - )), - 'method': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.string), - ), - )), - 'persistentConnection': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.string), - ), - )), - 'url': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.uri), - ), - )), - }, - wrap: true); + static const $declaration = + BridgeClassDef(BridgeClassType($type, isAbstract: true), + constructors: {}, + getters: { + 'contentLength': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int), + nullable: true), + )), + 'finalized': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), + )), + 'followRedirects': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), + )), + 'headers': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), + ), + )), + 'maxRedirects': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), + )), + 'method': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.string), + ), + )), + 'persistentConnection': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.string), + ), + )), + 'url': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.uri), + ), + )), + }, + wrap: true); final $Instance _superclass; @@ -369,25 +459,34 @@ class $Response implements $Instance { final Response $value; /// Compile-time bridged type reference for [$Response] - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'Response')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'Response')); /// Compile-time bridged class declaration for [$Response] static const $declaration = BridgeClassDef( BridgeClassType($type), - constructors: {'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type)))}, + constructors: { + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type))) + }, getters: { 'body': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), )), 'bodyBytes': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.int)])), + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.int)])), )), 'contentLength': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int), nullable: true), + returns: + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int), nullable: true), )), 'headers': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), ), )), 'isRedirect': BridgeMethodDef(BridgeFunctionDef( @@ -397,7 +496,8 @@ class $Response implements $Instance { returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), )), 'reasonPhrase': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'statusCode': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), @@ -460,22 +560,30 @@ class $StreamedResponse implements $Instance { final StreamedResponse $value; /// Compile-time bridged type reference for [$StreamedResponse] - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'StreamedResponse')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'StreamedResponse')); /// Compile-time bridged class declaration for [$StreamedResponse] static const $declaration = BridgeClassDef( BridgeClassType($type), - constructors: {'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type)))}, + constructors: { + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type))) + }, getters: { 'stream': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation($ByteStream.$type), )), 'contentLength': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int), nullable: true), + returns: + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int), nullable: true), )), 'headers': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), ), )), 'isRedirect': BridgeMethodDef(BridgeFunctionDef( @@ -485,7 +593,8 @@ class $StreamedResponse implements $Instance { returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), )), 'reasonPhrase': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), )), 'statusCode': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), @@ -546,12 +655,16 @@ class $ByteStream implements $Instance { final ByteStream $value; /// Compile-time bridged type reference for [$ByteStream] - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'ByteStream')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'ByteStream')); /// Compile-time bridged class declaration for [$ByteStream] static const $declaration = BridgeClassDef( BridgeClassType($type), - constructors: {'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type)))}, + constructors: { + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type))) + }, getters: {}, wrap: true, ); @@ -579,13 +692,15 @@ class $ByteStream implements $Instance { } Map? _toMapString(Map<$Value, $Value>? value) { - return value?.map((key, value) => MapEntry((key.$reified).toString(), (value.$reified).toString())); + return value?.map((key, value) => + MapEntry((key.$reified).toString(), (value.$reified).toString())); } Object? _toBodyObject(Object? value) { Object? body; if (value is Map<$Value, $Value>) { - body = value.map((key, value) => MapEntry((key.$reified).toString(), (value.$reified).toString())); + body = value.map((key, value) => + MapEntry((key.$reified).toString(), (value.$reified).toString())); } else if (value is List<$Value>) { body = value.map((e) => e.$reified).toList(); } else { diff --git a/lib/eval/dart/bridge/m_chapter.dart b/lib/eval/dart/bridge/m_chapter.dart index 5e177e8..ec47377 100644 --- a/lib/eval/dart/bridge/m_chapter.dart +++ b/lib/eval/dart/bridge/m_chapter.dart @@ -5,23 +5,35 @@ import 'package:mangayomi/eval/model/m_chapter.dart'; class $MChapter implements MChapter, $Instance { $MChapter.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MChapter')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MChapter')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [], namedParams: [ - BridgeParameter('name', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('dateUpload', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('scanlator', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), - ])) + '': BridgeConstructorDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation($type), + params: [], + namedParams: [ + BridgeParameter('name', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('dateUpload', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('scanlator', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), true), + ])) }, // Specify class fields fields: { - 'name': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'url': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'dateUpload': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'scanlator': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'name': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'url': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'dateUpload': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'scanlator': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), }, wrap: true); @@ -102,5 +114,10 @@ class $MChapter implements MChapter, $Instance { set scanlator(String? scanlator) {} @override - Map toJson() => {'name': name, 'url': url, 'dateUpload': dateUpload, 'scanlator': scanlator}; + Map toJson() => { + 'name': name, + 'url': url, + 'dateUpload': dateUpload, + 'scanlator': scanlator + }; } diff --git a/lib/eval/dart/bridge/m_manga.dart b/lib/eval/dart/bridge/m_manga.dart index 69d43ac..cf92a16 100644 --- a/lib/eval/dart/bridge/m_manga.dart +++ b/lib/eval/dart/bridge/m_manga.dart @@ -10,25 +10,36 @@ import 'package:mangayomi/utils/extensions/string_extensions.dart'; class $MManga implements MManga, $Instance { $MManga.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MManga')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MManga')); static const $declaration = BridgeClassDef(BridgeClassType($type), - constructors: {'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: []))}, + constructors: { + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [])) + }, // Specify class fields fields: { - 'author': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'artist': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'author': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'artist': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), 'status': BridgeFieldDef(BridgeTypeAnnotation($MStatus.$type)), 'genre': BridgeFieldDef( BridgeTypeAnnotation( BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]), ), ), - 'imageUrl': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'name': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'link': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'description': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'chapters': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$MChapter.$type]))), + 'imageUrl': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'name': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'link': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'description': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'chapters': BridgeFieldDef(BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [$MChapter.$type]))), }, wrap: true); @@ -65,7 +76,8 @@ class $MManga implements MManga, $Instance { case 'description': return $String($value.description!); case 'chapters': - return $List.wrap($value.chapters!.map((e) => $MChapter.wrap(e)).toList()); + return $List + .wrap($value.chapters!.map((e) => $MChapter.wrap(e)).toList()); default: return _superclass.$getProperty(runtime, identifier); @@ -85,7 +97,8 @@ class $MManga implements MManga, $Instance { case 'status': $value.status = value.$reified; case 'genre': - $value.genre = (value.$reified as List).map((e) => e.toString()).toList(); + $value.genre = + (value.$reified as List).map((e) => e.toString()).toList(); case 'imageUrl': $value.imageUrl = value.$reified; case 'name': @@ -96,7 +109,11 @@ class $MManga implements MManga, $Instance { $value.description = value.$reified; case 'chapters': $value.chapters = (value.$reified as List) - .map((e) => MChapter(dateUpload: e.dateUpload, url: e.url, name: e.name, scanlator: e.scanlator)) + .map((e) => MChapter( + dateUpload: e.dateUpload, + url: e.url, + name: e.name, + scanlator: e.scanlator)) .toList(); default: diff --git a/lib/eval/dart/bridge/m_pages.dart b/lib/eval/dart/bridge/m_pages.dart index 1249cd0..dfee87a 100644 --- a/lib/eval/dart/bridge/m_pages.dart +++ b/lib/eval/dart/bridge/m_pages.dart @@ -7,26 +7,40 @@ import 'package:mangayomi/eval/model/m_pages.dart'; class $MPages implements MPages, $Instance { $MPages.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MPages')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MPages')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ - BridgeParameter('list', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$MManga.$type])), false), - BridgeParameter('hasNextPage', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool), nullable: true), true), + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [ + BridgeParameter( + 'list', + BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [$MManga.$type])), + false), + BridgeParameter( + 'hasNextPage', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool), + nullable: true), + true), ])) }, fields: { 'list': BridgeFieldDef( BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$MManga.$type])), ), - 'hasNextPage': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool), nullable: true)), + 'hasNextPage': BridgeFieldDef(BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.bool), + nullable: true)), }, wrap: true); static $Value? $new(Runtime runtime, $Value? target, List<$Value?> args) { List<$Value> list = args[0]!.$value; - return $MPages.wrap(MPages(list: list.map((e) => e as MManga).toList(), hasNextPage: args[1]?.$value ?? false)); + return $MPages.wrap(MPages( + list: list.map((e) => e as MManga).toList(), + hasNextPage: args[1]?.$value ?? false)); } @override diff --git a/lib/eval/dart/bridge/m_provider.dart b/lib/eval/dart/bridge/m_provider.dart index 779293a..6ba3f7b 100644 --- a/lib/eval/dart/bridge/m_provider.dart +++ b/lib/eval/dart/bridge/m_provider.dart @@ -21,106 +21,177 @@ import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:mangayomi/utils/log/log.dart'; class $MProvider extends MProvider with $Bridge { - static $MProvider $construct(Runtime runtime, $Value? target, List<$Value?> args) => $MProvider(); + static $MProvider $construct( + Runtime runtime, $Value? target, List<$Value?> args) => + $MProvider(); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MProvider')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MProvider')); - static const $declaration = BridgeClassDef(BridgeClassType($type, isAbstract: true), - constructors: {'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type)))}, + static const $declaration = BridgeClassDef( + BridgeClassType($type, isAbstract: true), + constructors: { + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type))) + }, getters: { 'supportsLatest': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), )), - 'baseUrl': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true))), + 'baseUrl': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true))), 'headers': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), nullable: true))), }, methods: { - 'getLatestUpdates': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [$MPages.$type])), params: [ - BridgeParameter('page', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), - ])), - 'getPopular': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [$MPages.$type])), params: [ - BridgeParameter('page', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), - ])), - 'search': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [$MPages.$type])), params: [ - BridgeParameter('query', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter( - 'page', - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), - false, - ), - ])), - 'getDetail': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [$MManga.$type])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ])), + 'getLatestUpdates': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.future, [$MPages.$type])), + params: [ + BridgeParameter('page', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + ])), + 'getPopular': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.future, [$MPages.$type])), + params: [ + BridgeParameter('page', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + ])), + 'search': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.future, [$MPages.$type])), + params: [ + BridgeParameter('query', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'page', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), + false, + ), + ])), + 'getDetail': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.future, [$MManga.$type])), + params: [ + BridgeParameter('url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + ])), 'getPageList': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [ BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), ])), 'getVideoList': BridgeMethodDef(BridgeFunctionDef( returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [ BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), ])), 'getFilterList': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + returns: BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), params: [])), 'getSourcePreferences': BridgeMethodDef(BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + returns: BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), params: [])), - 'getPreferenceValue': - BridgeMethodDef(BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.dynamic)), params: [ - BridgeParameter('sourceId', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), - BridgeParameter('key', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ])), - 'getPrefStringValue': - BridgeMethodDef(BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('sourceId', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), - BridgeParameter('key', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('value', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ])), - 'setPrefStringValue': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.voidType)), params: [ - BridgeParameter('sourceId', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), - BridgeParameter('key', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('value', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ])), + 'getPreferenceValue': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.dynamic)), + params: [ + BridgeParameter('sourceId', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + BridgeParameter('key', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + ])), + 'getPrefStringValue': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter('sourceId', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + BridgeParameter('key', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('value', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + ])), + 'setPrefStringValue': BridgeMethodDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.voidType)), + params: [ + BridgeParameter('sourceId', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + BridgeParameter('key', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('value', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + ])), 'cryptoHandler': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('text', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('iv', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('secretKeyString', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('encrypt', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'text', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'iv', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'secretKeyString', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter('encrypt', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), false), + ]), ), 'encryptAESCryptoJS': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('plainText', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('passphrase', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'plainText', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'passphrase', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ]), ), 'decryptAESCryptoJS': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('encrypted', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('passphrase', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'encrypted', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'passphrase', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ]), ), 'deobfuscateJsPassword': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('inputString', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'inputString', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ]), ), 'sibnetExtractor': BridgeMethodDef( BridgeFunctionDef( @@ -128,8 +199,15 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('prefix', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), true), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'prefix', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + true), ]), ), 'myTvExtractor': BridgeMethodDef( @@ -138,7 +216,10 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'okruExtractor': BridgeMethodDef( @@ -147,7 +228,10 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'voeExtractor': BridgeMethodDef( @@ -156,8 +240,15 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('quality', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), true), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'quality', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + true), ]), ), 'vidBomExtractor': BridgeMethodDef( @@ -166,7 +257,10 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'streamlareExtractor': BridgeMethodDef( @@ -175,9 +269,18 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('prefix', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('suffix', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'prefix', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'suffix', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'sendVidExtractor': BridgeMethodDef( @@ -186,10 +289,19 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), BridgeParameter( - 'headers', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), false), - BridgeParameter('prefix', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'headers', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + false), + BridgeParameter( + 'prefix', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'yourUploadExtractor': BridgeMethodDef( @@ -198,11 +310,25 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), BridgeParameter( - 'headers', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), false), - BridgeParameter('name', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), false), - BridgeParameter('prefix', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), false), + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'headers', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + false), + BridgeParameter( + 'name', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + false), + BridgeParameter( + 'prefix', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + false), ]), ), 'quarkVideosExtractor': BridgeMethodDef( @@ -211,8 +337,14 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('cookie', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'cookie', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'ucVideosExtractor': BridgeMethodDef( @@ -221,123 +353,257 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('cookie', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'cookie', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'quarkFilesExtractor': BridgeMethodDef( BridgeFunctionDef( returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [ BridgeTypeRef(CoreTypes.list, [ - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]) + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]) ]) ])), params: [ - BridgeParameter('url', - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), false), - BridgeParameter('cookie', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), + false), + BridgeParameter( + 'cookie', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'ucFilesExtractor': BridgeMethodDef( BridgeFunctionDef( returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [ BridgeTypeRef(CoreTypes.list, [ - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]) + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]) ]) ])), params: [ - BridgeParameter('url', - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), false), - BridgeParameter('cookie', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), + false), + BridgeParameter( + 'cookie', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'substringAfter': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('text', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('pattern', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'text', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'pattern', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ]), ), 'substringBefore': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('text', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('pattern', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'text', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'pattern', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ]), ), 'substringBeforeLast': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('text', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('pattern', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'text', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'pattern', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ]), ), 'substringAfterLast': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('text', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('pattern', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'text', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'pattern', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ]), ), 'toVideo': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.dynamic)), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('quality', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('originalUrl', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('headers', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), true), - BridgeParameter( - 'subtitles', - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)]), nullable: true), - true), - BridgeParameter( - 'audios', - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)]), nullable: true), - true), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.dynamic)), + params: [ + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'quality', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'originalUrl', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'headers', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + true), + BridgeParameter( + 'subtitles', + BridgeTypeAnnotation( + BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)]), + nullable: true), + true), + BridgeParameter( + 'audios', + BridgeTypeAnnotation( + BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)]), + nullable: true), + true), + ]), ), 'jsonPathToString': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('source', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('expression', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('join', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'source', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'expression', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'join', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ]), ), 'getMapValue': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('source', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('attr', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ], namedParams: [ - BridgeParameter('encode', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool), nullable: true), true), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'source', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'attr', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ], + namedParams: [ + BridgeParameter( + 'encode', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool), + nullable: true), + true), + ]), ), 'jsonPathToList': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), + returns: BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), params: [ - BridgeParameter('source', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('expression', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('type', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + BridgeParameter( + 'source', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'expression', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter('type', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), ]), ), 'parseStatus': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation($MStatus.$type), params: [ - BridgeParameter('status', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('statusList', - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation($MStatus.$type), + params: [ + BridgeParameter( + 'status', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'statusList', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + false), + ]), ), 'parseDates': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + returns: BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), params: [ - BridgeParameter('value', - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), false), - BridgeParameter('dateFormat', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('dateFormatLocale', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'value', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + false), + BridgeParameter( + 'dateFormat', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'dateFormatLocale', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'xpath': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), + returns: BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), params: [ - BridgeParameter('html', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('xpath', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'html', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'xpath', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'gogoCdnExtractor': BridgeMethodDef( @@ -346,7 +612,10 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'doodExtractor': BridgeMethodDef( @@ -355,8 +624,15 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('quality', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), true), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'quality', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + true), ]), ), 'streamTapeExtractor': BridgeMethodDef( @@ -365,8 +641,15 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('quality', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), true), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'quality', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + true), ]), ), 'mp4UploadExtractor': BridgeMethodDef( @@ -375,11 +658,23 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), BridgeParameter( - 'headers', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), false), - BridgeParameter('prefix', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('suffix', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'headers', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + false), + BridgeParameter( + 'prefix', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'suffix', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'streamWishExtractor': BridgeMethodDef( @@ -388,8 +683,14 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('prefix', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'prefix', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'filemoonExtractor': BridgeMethodDef( @@ -398,67 +699,140 @@ class $MProvider extends MProvider with $Bridge { BridgeTypeRef(CoreTypes.list, [$MVideo.$type]) ])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('prefix', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), false), - BridgeParameter('suffix', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), nullable: true), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'prefix', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + false), + BridgeParameter( + 'suffix', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string), + nullable: true), + false), ]), ), 'getHtmlViaWebview': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [BridgeTypeRef(CoreTypes.string)])), + returns: BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.future, [BridgeTypeRef(CoreTypes.string)])), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('rule', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'rule', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'unpackJs': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('code', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'code', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ]), ), 'unpackJsAndCombine': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('code', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'code', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ]), ), 'evalJs': BridgeMethodDef( BridgeFunctionDef( - returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.future, [BridgeTypeRef(CoreTypes.string)])), + returns: BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.future, [BridgeTypeRef(CoreTypes.string)])), params: [ - BridgeParameter('code', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'code', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), ]), ), 'regExp': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('expression', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('source', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('replace', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('type', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), - BridgeParameter('group', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'expression', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'source', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter( + 'replace', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter('type', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + BridgeParameter('group', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + ]), ), 'sortMapList': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter( - 'list', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), false), - BridgeParameter('value', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('type', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), - ]), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'list', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.dynamic)])), + false), + BridgeParameter( + 'value', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + BridgeParameter('type', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + ]), ), 'parseHtml': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation($MDocument.$type), params: [ - BridgeParameter('html', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ], namedParams: []), + BridgeFunctionDef( + returns: BridgeTypeAnnotation($MDocument.$type), + params: [ + BridgeParameter( + 'html', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ], + namedParams: []), isStatic: true), 'getUrlWithoutDomain': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), params: [ - BridgeParameter('url', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ], namedParams: []), + BridgeFunctionDef( + returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + params: [ + BridgeParameter( + 'url', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), + false), + ], + namedParams: []), isStatic: true), 'print': BridgeMethodDef( - BridgeFunctionDef(returns: BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.voidType)), params: [ - BridgeParameter('object', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.dynamic)), false), - ], namedParams: []), + BridgeFunctionDef( + returns: + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.voidType)), + params: [ + BridgeParameter( + 'object', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.dynamic)), + false), + ], + namedParams: []), isStatic: true), }, bridge: true); @@ -476,7 +850,9 @@ class $MProvider extends MProvider with $Bridge { }), 'evalJs' => $Function((_, __, List<$Value?> args) { final runtime = getJavascriptRuntime(); - return $Future.wrap(runtime.evaluateAsync(args[0]!.$reified).then((value) => $String(value.stringResult))); + return $Future.wrap(runtime + .evaluateAsync(args[0]!.$reified) + .then((value) => $String(value.stringResult))); }), 'getUrlWithoutDomain' => $Function((_, __, List<$Value?> args) { return $String((args[0]!.$value as String).getUrlWithoutDomain); @@ -486,7 +862,8 @@ class $MProvider extends MProvider with $Bridge { return $MDocument.wrap(res); }), 'getPreferenceValue' => $Function((_, __, List<$Value?> args) { - final value = getPreferenceValue(args[0]!.$reified, args[1]!.$reified); + final value = + getPreferenceValue(args[0]!.$reified, args[1]!.$reified); if (value is String) { return $String(value); } else if (value is bool) { @@ -495,21 +872,26 @@ class $MProvider extends MProvider with $Bridge { return $List.wrap(value.map((e) => $String(e)).toList()); }), 'getPrefStringValue' => $Function((_, __, List<$Value?> args) { - final value = getSourcePreferenceStringValue(args[0]!.$reified, args[1]!.$reified, args[2]!.$reified); + final value = getSourcePreferenceStringValue( + args[0]!.$reified, args[1]!.$reified, args[2]!.$reified); return $String(value); }), 'setPrefStringValue' => $Function((_, __, List<$Value?> args) { - setSourcePreferenceStringValue(args[0]!.$reified, args[1]!.$reified, args[2]!.$reified); + setSourcePreferenceStringValue( + args[0]!.$reified, args[1]!.$reified, args[2]!.$reified); return; }), "cryptoHandler" => $Function((_, __, List<$Value?> args) { - return $String(MBridge.cryptoHandler(args[0]!.$value, args[1]!.$value, args[2]!.$value, args[3]!.$value)); + return $String(MBridge.cryptoHandler(args[0]!.$value, args[1]!.$value, + args[2]!.$value, args[3]!.$value)); }), "encryptAESCryptoJS" => $Function((_, __, List<$Value?> args) { - return $String(MBridge.encryptAESCryptoJS(args[0]!.$value, args[1]!.$value)); + return $String( + MBridge.encryptAESCryptoJS(args[0]!.$value, args[1]!.$value)); }), "decryptAESCryptoJS" => $Function((_, __, List<$Value?> args) { - return $String(MBridge.decryptAESCryptoJS(args[0]!.$value, args[1]!.$value)); + return $String( + MBridge.decryptAESCryptoJS(args[0]!.$value, args[1]!.$value)); }), "deobfuscateJsPassword" => $Function((_, __, List<$Value?> args) { return $String(MBridge.deobfuscateJsPassword(args[0]!.$value)); @@ -518,68 +900,91 @@ class $MProvider extends MProvider with $Bridge { /////////////////////////////////////////////////////////////////////// "substringAfter" => $Function((_, __, List<$Value?> args) { - return $String(MBridge.substringAfter(args[0]!.$value, args[1]!.$value)); + return $String( + MBridge.substringAfter(args[0]!.$value, args[1]!.$value)); }), "substringBefore" => $Function((_, __, List<$Value?> args) { - return $String(MBridge.substringBefore(args[0]!.$value, args[1]!.$value)); + return $String( + MBridge.substringBefore(args[0]!.$value, args[1]!.$value)); }), "substringBeforeLast" => $Function((_, __, List<$Value?> args) { - return $String(MBridge.substringBeforeLast(args[0]!.$value, args[1]!.$value)); + return $String( + MBridge.substringBeforeLast(args[0]!.$value, args[1]!.$value)); }), "substringAfterLast" => $Function((_, __, List<$Value?> args) { - return $String(MBridge.substringAfterLast(args[0]!.$value, args[1]!.$value)); + return $String( + MBridge.substringAfterLast(args[0]!.$value, args[1]!.$value)); }), /////////////////////////////////////////////////////////////////////// - "sibnetExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.sibnetExtractor(args[0]!.$value, args[1]?.$value ?? "") - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "sibnetExtractor" => $Function((_, __, List<$Value?> args) => $Future + .wrap(MBridge.sibnetExtractor(args[0]!.$value, args[1]?.$value ?? "") + .then((value) => + $List.wrap(value.map((e) => _toMVideo(e)).toList())))), "myTvExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.myTvExtractor(args[0]!.$value).then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + MBridge.myTvExtractor(args[0]!.$value).then( + (value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), "okruExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.okruExtractor(args[0]!.$value).then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + MBridge.okruExtractor(args[0]!.$value).then( + (value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), "voeExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.voeExtractor(args[0]!.$value, args[1]?.$value) - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), - "vidBomExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.vidBomExtractor(args[0]!.$value) - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), - "streamlareExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.streamlareExtractor(args[0]!.$value, args[1]?.$value, args[2]?.$value) - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), - "sendVidExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.sendVidExtractor(args[0]!.$value, args[1]?.$value, args[2]?.$value) - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), - "yourUploadExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.yourUploadExtractor(args[0]!.$value, args[1]?.$value, args[2]?.$value, args[3]?.$value ?? "") - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), - "gogoCdnExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.gogoCdnExtractor(args[0]!.$value) - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + MBridge.voeExtractor(args[0]!.$value, args[1]?.$value).then( + (value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "vidBomExtractor" => $Function((_, __, List<$Value?> args) => + $Future.wrap(MBridge.vidBomExtractor(args[0]!.$value).then( + (value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "streamlareExtractor" => $Function((_, __, List<$Value?> args) => + $Future.wrap(MBridge.streamlareExtractor( + args[0]!.$value, args[1]?.$value, args[2]?.$value) + .then((value) => + $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "sendVidExtractor" => $Function((_, __, List<$Value?> args) => + $Future.wrap(MBridge.sendVidExtractor( + args[0]!.$value, args[1]?.$value, args[2]?.$value) + .then((value) => + $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "yourUploadExtractor" => $Function((_, __, List<$Value?> args) => + $Future.wrap(MBridge.yourUploadExtractor(args[0]!.$value, + args[1]?.$value, args[2]?.$value, args[3]?.$value ?? "") + .then((value) => + $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "gogoCdnExtractor" => $Function((_, __, List<$Value?> args) => + $Future.wrap(MBridge.gogoCdnExtractor(args[0]!.$value).then( + (value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), "doodExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.doodExtractor(args[0]!.$value, args[1]?.$value) - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), - "streamTapeExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.streamTapeExtractor(args[0]!.$value, args[1]!.$value) - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), - "mp4UploadExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.mp4UploadExtractor(args[0]!.$value, args[1]!.$value, args[2]?.$value, args[3]!.$value) - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), - "streamWishExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.streamWishExtractor(args[0]!.$value, args[1]!.$value) - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), - "filemoonExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.filemoonExtractor(args[0]!.$value, args[1]?.$value ?? "", args[2]?.$value ?? "") - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), - "quarkVideosExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.quarkVideosExtractor(args[0]!.$value, args[1]!.$value) - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), - "ucVideosExtractor" => $Function((_, __, List<$Value?> args) => $Future.wrap( - MBridge.ucVideosExtractor(args[0]!.$value, args[1]!.$value) - .then((value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + MBridge.doodExtractor(args[0]!.$value, args[1]?.$value).then( + (value) => $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "streamTapeExtractor" => $Function((_, __, List<$Value?> args) => $Future + .wrap(MBridge.streamTapeExtractor(args[0]!.$value, args[1]!.$value) + .then((value) => + $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "mp4UploadExtractor" => $Function((_, __, List<$Value?> args) => + $Future.wrap(MBridge.mp4UploadExtractor(args[0]!.$value, + args[1]!.$value, args[2]?.$value, args[3]!.$value) + .then((value) => + $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "streamWishExtractor" => $Function((_, __, List<$Value?> args) => $Future + .wrap(MBridge.streamWishExtractor(args[0]!.$value, args[1]!.$value) + .then((value) => + $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "filemoonExtractor" => $Function((_, __, List<$Value?> args) => + $Future.wrap(MBridge.filemoonExtractor( + args[0]!.$value, args[1]?.$value ?? "", args[2]?.$value ?? "") + .then((value) => + $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "quarkVideosExtractor" => $Function((_, __, List<$Value?> args) => $Future + .wrap(MBridge.quarkVideosExtractor(args[0]!.$value, args[1]!.$value) + .then((value) => + $List.wrap(value.map((e) => _toMVideo(e)).toList())))), + "ucVideosExtractor" => $Function((_, __, List<$Value?> args) => $Future + .wrap(MBridge.ucVideosExtractor(args[0]!.$value, args[1]!.$value) + .then((value) => + $List.wrap(value.map((e) => _toMVideo(e)).toList())))), "quarkFilesExtractor" => $Function((_, __, List<$Value?> args) => - $Future.wrap(MBridge.quarkFilesExtractor(args[0]!.$value, args[1]!.$value).then((value) { + $Future.wrap( + MBridge.quarkFilesExtractor(args[0]!.$value, args[1]!.$value) + .then((value) { return $List.wrap(value .map((e) => $Map.wrap({ $String('name'): $String(e['name'] ?? ''), @@ -587,8 +992,9 @@ class $MProvider extends MProvider with $Bridge { })) .toList()); }))), - "ucFilesExtractor" => $Function((_, __, List<$Value?> args) => - $Future.wrap(MBridge.ucFilesExtractor(args[0]!.$value, args[1]!.$value).then((value) { + "ucFilesExtractor" => $Function((_, __, List<$Value?> args) => $Future + .wrap(MBridge.ucFilesExtractor(args[0]!.$value, args[1]!.$value) + .then((value) { return $List.wrap(value .map((e) => $Map.wrap({ $String('name'): $String(e['name'] ?? ''), @@ -598,7 +1004,12 @@ class $MProvider extends MProvider with $Bridge { }))), "toVideo" => $Function((_, __, List<$Value?> args) { final value = MBridge.toVideo( - args[0]!.$value, args[1]!.$value, args[2]!.$value, args[3]?.$value, args[4]?.$value, args[5]?.$value); + args[0]!.$value, + args[1]!.$value, + args[2]!.$value, + args[3]?.$value, + args[4]?.$value, + args[5]?.$value); return _toMVideo(value); }), @@ -606,8 +1017,8 @@ class $MProvider extends MProvider with $Bridge { "unpackJsAndCombine" => MBridge.unpackJsAndCombine, "unpackJs" => MBridge.unpackJs, "regExp" => $Function((_, __, List<$Value?> args) { - return $String( - MBridge.regExp(args[0]!.$value, args[1]!.$value, args[2]!.$value, args[3]!.$value, args[4]!.$value)); + return $String(MBridge.regExp(args[0]!.$value, args[1]!.$value, + args[2]!.$value, args[3]!.$value, args[4]!.$value)); }), "jsonPathToString" => MBridge.jsonPathToString, "jsonPathToList" => MBridge.jsonPathToList, @@ -622,7 +1033,8 @@ class $MProvider extends MProvider with $Bridge { } return e; }).toList(); - return $String(jsonEncode(MBridge.sortMapList(list, args[1]!.$value, args[2]!.$value))); + return $String(jsonEncode( + MBridge.sortMapList(list, args[1]!.$value, args[2]!.$value))); }), "getMapValue" => $Function((_, __, List<$Value?> args) { return $String(MBridge.getMapValue( @@ -641,8 +1053,10 @@ class $MProvider extends MProvider with $Bridge { return $MStatus.wrap(MBridge.parseStatus(args[0]!.$value, argss2)); }), "parseDates" => $Function((_, __, List<$Value?> args) { - return $List.wrap( - MBridge.parseDates(args[0]!.$value, args[1]!.$value, args[2]!.$value).map((e) => $String(e)).toList()); + return $List.wrap(MBridge.parseDates( + args[0]!.$value, args[1]!.$value, args[2]!.$value) + .map((e) => $String(e)) + .toList()); }), "xpath" => MBridge.xpath, _ => $Function((_, __, List<$Value?> args) { @@ -663,17 +1077,24 @@ class $MProvider extends MProvider with $Bridge { String? get baseUrl => $_get('baseUrl'); @override - Future getDetail(String url) async => await $_invoke('getDetail', [$String(url)]); + Future getDetail(String url) async => + await $_invoke('getDetail', [$String(url)]); @override - Future getLatestUpdates(int page) async => await $_invoke('getLatestUpdates', [$int(page)]); + Future getLatestUpdates(int page) async => + await $_invoke('getLatestUpdates', [$int(page)]); @override - Future getPopular(int page) async => await $_invoke('getPopular', [$int(page)]); + Future getPopular(int page) async => + await $_invoke('getPopular', [$int(page)]); @override - Future search(String query, int page, FilterList filterList) async => await $_invoke( - 'search', [$String(query), $int(page), $FilterList.wrap(FilterList(_toValueList(filterList.filters)))]); + Future search(String query, int page, FilterList filterList) async => + await $_invoke('search', [ + $String(query), + $int(page), + $FilterList.wrap(FilterList(_toValueList(filterList.filters))) + ]); @override Future> getPageList(String url) async { @@ -728,17 +1149,25 @@ class $MProvider extends MProvider with $Bridge { } } - $MVideo _toMVideo(Video e) => $MVideo.wrap(Video(e.url, e.quality, e.originalUrl) - ..headers = e.headers - ..subtitles = $List.wrap( - e.subtitles == null ? [] : e.subtitles!.map((t) => $MTrack.wrap(Track(file: t.file, label: t.label))).toList()) - ..audios = $List.wrap( - e.audios == null ? [] : e.audios!.map((t) => $MTrack.wrap(Track(file: t.file, label: t.label))).toList())); + $MVideo _toMVideo(Video e) => + $MVideo.wrap(Video(e.url, e.quality, e.originalUrl) + ..headers = e.headers + ..subtitles = $List.wrap(e.subtitles == null + ? [] + : e.subtitles! + .map((t) => $MTrack.wrap(Track(file: t.file, label: t.label))) + .toList()) + ..audios = $List.wrap(e.audios == null + ? [] + : e.audios! + .map((t) => $MTrack.wrap(Track(file: t.file, label: t.label))) + .toList())); _toValueList(List filters) { return (filters).map((e) { if (e is SelectFilter) { - return $SelectFilter.wrap(SelectFilter(e.type, e.name, e.state, _toValueList(e.values), e.typeName)); + return $SelectFilter.wrap(SelectFilter( + e.type, e.name, e.state, _toValueList(e.values), e.typeName)); } else if (e is TextFilter) { return $TextFilter.wrap(e); } else if (e is HeaderFilter) { @@ -750,7 +1179,8 @@ class $MProvider extends MProvider with $Bridge { } else if (e is SeparatorFilter) { return $SeparatorFilter.wrap(e); } else if (e is SortFilter) { - return $SortFilter.wrap(SortFilter(e.type, e.name, e.state, _toValueList(e.values), e.typeName)); + return $SortFilter.wrap(SortFilter( + e.type, e.name, e.state, _toValueList(e.values), e.typeName)); } else if (e is SortState) { return $SortState.wrap(e); } else if (e is CheckBoxFilter) { @@ -758,7 +1188,8 @@ class $MProvider extends MProvider with $Bridge { } else if (e is SelectFilterOption) { return $SelectFilterOption.wrap(e); } else if (e is GroupFilter) { - return $GroupFilter.wrap(GroupFilter(e.type, e.name, _toValueList(e.state), e.typeName)); + return $GroupFilter.wrap( + GroupFilter(e.type, e.name, _toValueList(e.state), e.typeName)); } return e; }).toList(); diff --git a/lib/eval/dart/bridge/m_source.dart b/lib/eval/dart/bridge/m_source.dart index f4e0766..e50f7a3 100644 --- a/lib/eval/dart/bridge/m_source.dart +++ b/lib/eval/dart/bridge/m_source.dart @@ -5,21 +5,35 @@ import 'package:mangayomi/eval/model/m_source.dart'; class $MSource implements MSource, $Instance { $MSource.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MSource')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MSource')); static const $declaration = BridgeClassDef(BridgeClassType($type), - constructors: {'': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: []))}, + constructors: { + '': BridgeConstructorDef( + BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [])) + }, fields: { - 'id': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int))), - 'name': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'baseUrl': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'lang': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'isFullData': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool))), - 'hasCloudflare': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool))), - 'dateFormat': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'dateFormatLocale': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'apiUrl': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'additionalParams': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'id': + BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int))), + 'name': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'baseUrl': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'lang': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'isFullData': + BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool))), + 'hasCloudflare': + BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool))), + 'dateFormat': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'dateFormatLocale': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'apiUrl': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'additionalParams': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), }, wrap: true); diff --git a/lib/eval/dart/bridge/m_status.dart b/lib/eval/dart/bridge/m_status.dart index 46bac08..1929dcf 100644 --- a/lib/eval/dart/bridge/m_status.dart +++ b/lib/eval/dart/bridge/m_status.dart @@ -3,14 +3,18 @@ import 'package:dart_eval/stdlib/core.dart'; import 'package:mangayomi/models/manga.dart'; class $MStatus implements $Instance { - static $MStatus $wrap(Runtime runtime, $Value? target, List<$Value?> args) => $MStatus.wrap(args[0]!.$value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MStatus')); - static const $declaration = BridgeEnumDef($type, - values: ['ongoing', 'completed', 'canceled', 'unknown', 'onHiatus', 'publishingFinished'], - methods: {}, - getters: {}, - setters: {}, - fields: {}); + static $MStatus $wrap(Runtime runtime, $Value? target, List<$Value?> args) => + $MStatus.wrap(args[0]!.$value); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MStatus')); + static const $declaration = BridgeEnumDef($type, values: [ + 'ongoing', + 'completed', + 'canceled', + 'unknown', + 'onHiatus', + 'publishingFinished' + ], methods: {}, getters: {}, setters: {}, fields: {}); static final $values = Status.values.asNameMap().map( (key, value) => MapEntry(key, $MStatus.wrap(value)), ); diff --git a/lib/eval/dart/bridge/m_track.dart b/lib/eval/dart/bridge/m_track.dart index 4183dd7..466ac27 100644 --- a/lib/eval/dart/bridge/m_track.dart +++ b/lib/eval/dart/bridge/m_track.dart @@ -5,7 +5,8 @@ import 'package:mangayomi/models/video.dart'; class $MTrack implements Track, $Instance { $MTrack.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MTrack')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MTrack')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { @@ -15,8 +16,10 @@ class $MTrack implements Track, $Instance { }, // Specify class fields fields: { - 'file': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'label': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'file': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'label': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), }, wrap: true); diff --git a/lib/eval/dart/bridge/m_video.dart b/lib/eval/dart/bridge/m_video.dart index 293f631..0d213f7 100644 --- a/lib/eval/dart/bridge/m_video.dart +++ b/lib/eval/dart/bridge/m_video.dart @@ -6,7 +6,8 @@ import 'package:mangayomi/models/video.dart'; class $MVideo implements Video, $Instance { $MVideo.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MVideo')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MVideo')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { @@ -16,14 +17,22 @@ class $MVideo implements Video, $Instance { }, // Specify class fields fields: { - 'url': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'quality': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'originalUrl': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'url': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'quality': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'originalUrl': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), 'headers': BridgeFieldDef(BridgeTypeAnnotation( - BridgeTypeRef(CoreTypes.map, [BridgeTypeRef(CoreTypes.string), BridgeTypeRef(CoreTypes.string)]), + BridgeTypeRef(CoreTypes.map, [ + BridgeTypeRef(CoreTypes.string), + BridgeTypeRef(CoreTypes.string) + ]), nullable: true)), - 'subtitles': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$MTrack.$type]))), - 'audios': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [$MTrack.$type]))), + 'subtitles': BridgeFieldDef(BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [$MTrack.$type]))), + 'audios': BridgeFieldDef(BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [$MTrack.$type]))), }, wrap: true); @@ -51,9 +60,13 @@ class $MVideo implements Video, $Instance { case 'headers': return $Map.wrap($value.headers ?? {}); case 'subtitles': - return $List.wrap($value.subtitles!.map((e) => $MTrack.wrap(Track(file: e.file, label: e.label))).toList()); + return $List.wrap($value.subtitles! + .map((e) => $MTrack.wrap(Track(file: e.file, label: e.label))) + .toList()); case 'audios': - return $List.wrap($value.audios!.map((e) => $MTrack.wrap(Track(file: e.file, label: e.label))).toList()); + return $List.wrap($value.audios! + .map((e) => $MTrack.wrap(Track(file: e.file, label: e.label))) + .toList()); default: return _superclass.$getProperty(runtime, identifier); @@ -73,12 +86,17 @@ class $MVideo implements Video, $Instance { case 'originalUrl': $value.originalUrl = value.$reified; case 'headers': - $value.headers = (value.$reified as Map).map((key, value) => MapEntry(key.toString(), value.toString())); + $value.headers = (value.$reified as Map) + .map((key, value) => MapEntry(key.toString(), value.toString())); case 'subtitles': - $value.subtitles = (value.$reified as List).map((e) => Track(file: e.file, label: e.label)).toList(); + $value.subtitles = (value.$reified as List) + .map((e) => Track(file: e.file, label: e.label)) + .toList(); case 'audios': - $value.audios = (value.$reified as List).map((e) => Track(file: e.file, label: e.label)).toList(); + $value.audios = (value.$reified as List) + .map((e) => Track(file: e.file, label: e.label)) + .toList(); default: _superclass.$setProperty(runtime, identifier, value); diff --git a/lib/eval/dart/bridge/source_preference.dart b/lib/eval/dart/bridge/source_preference.dart index 2cbddd4..5087a52 100644 --- a/lib/eval/dart/bridge/source_preference.dart +++ b/lib/eval/dart/bridge/source_preference.dart @@ -6,30 +6,44 @@ import 'package:mangayomi/eval/model/source_preference.dart'; class $CheckBoxPreference implements SourcePreference, $Instance { $CheckBoxPreference.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'CheckBoxPreference')); + static const $type = BridgeTypeRef(BridgeTypeSpec( + 'package:mangayomi/bridge_lib.dart', 'CheckBoxPreference')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [], namedParams: [ - BridgeParameter('key', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('title', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('summary', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('value', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), false), - ])) + '': BridgeConstructorDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation($type), + params: [], + namedParams: [ + BridgeParameter('key', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('title', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('summary', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('value', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), false), + ])) }, fields: { - 'key': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'title': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'summary': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'value': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool))), + 'key': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'title': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'summary': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'value': + BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool))), }, wrap: true); static $Value? $new(Runtime runtime, $Value? target, List<$Value?> args) { return $CheckBoxPreference.wrap(SourcePreference( key: args[0]!.$value, - checkBoxPreference: - CheckBoxPreference(title: args[1]!.$value, summary: args[2]!.$value, value: args[3]!.$value))); + checkBoxPreference: CheckBoxPreference( + title: args[1]!.$value, + summary: args[2]!.$value, + value: args[3]!.$value))); } @override @@ -78,10 +92,12 @@ class $CheckBoxPreference implements SourcePreference, $Instance { ListPreference? get listPreference => $value.listPreference; @override - MultiSelectListPreference? get multiSelectListPreference => $value.multiSelectListPreference; + MultiSelectListPreference? get multiSelectListPreference => + $value.multiSelectListPreference; @override - SwitchPreferenceCompat? get switchPreferenceCompat => $value.switchPreferenceCompat; + SwitchPreferenceCompat? get switchPreferenceCompat => + $value.switchPreferenceCompat; @override Id? get id => $value.id; @@ -108,7 +124,8 @@ class $CheckBoxPreference implements SourcePreference, $Instance { set listPreference(ListPreference? listPreference) {} @override - set multiSelectListPreference(MultiSelectListPreference? multiSelectListPreference) {} + set multiSelectListPreference( + MultiSelectListPreference? multiSelectListPreference) {} @override set sourceId(int? sourceId) {} @@ -125,30 +142,44 @@ class $CheckBoxPreference implements SourcePreference, $Instance { class $SwitchPreferenceCompat implements SourcePreference, $Instance { $SwitchPreferenceCompat.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'SwitchPreferenceCompat')); + static const $type = BridgeTypeRef(BridgeTypeSpec( + 'package:mangayomi/bridge_lib.dart', 'SwitchPreferenceCompat')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [], namedParams: [ - BridgeParameter('key', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('title', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('summary', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('value', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), false), - ])) + '': BridgeConstructorDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation($type), + params: [], + namedParams: [ + BridgeParameter('key', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('title', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('summary', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('value', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool)), false), + ])) }, fields: { - 'key': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'title': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'summary': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'value': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool))), + 'key': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'title': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'summary': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'value': + BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.bool))), }, wrap: true); static $Value? $new(Runtime runtime, $Value? target, List<$Value?> args) { return $SwitchPreferenceCompat.wrap(SourcePreference( key: args[0]!.$value, - switchPreferenceCompat: - SwitchPreferenceCompat(title: args[1]!.$value, summary: args[2]!.$value, value: args[3]!.$value))); + switchPreferenceCompat: SwitchPreferenceCompat( + title: args[1]!.$value, + summary: args[2]!.$value, + value: args[3]!.$value))); } @override @@ -197,10 +228,12 @@ class $SwitchPreferenceCompat implements SourcePreference, $Instance { ListPreference? get listPreference => $value.listPreference; @override - MultiSelectListPreference? get multiSelectListPreference => $value.multiSelectListPreference; + MultiSelectListPreference? get multiSelectListPreference => + $value.multiSelectListPreference; @override - SwitchPreferenceCompat? get switchPreferenceCompat => $value.switchPreferenceCompat; + SwitchPreferenceCompat? get switchPreferenceCompat => + $value.switchPreferenceCompat; @override Id? get id => $value.id; @@ -227,7 +260,8 @@ class $SwitchPreferenceCompat implements SourcePreference, $Instance { set listPreference(ListPreference? listPreference) {} @override - set multiSelectListPreference(MultiSelectListPreference? multiSelectListPreference) {} + set multiSelectListPreference( + MultiSelectListPreference? multiSelectListPreference) {} @override set sourceId(int? sourceId) {} @@ -244,30 +278,48 @@ class $SwitchPreferenceCompat implements SourcePreference, $Instance { class $ListPreference implements SourcePreference, $Instance { $ListPreference.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'ListPreference')); + static const $type = BridgeTypeRef( + BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'ListPreference')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [], namedParams: [ - BridgeParameter('key', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('title', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('summary', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('valueIndex', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), - BridgeParameter( - 'entries', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), false), - BridgeParameter('entryValues', - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), false), - ])) + '': BridgeConstructorDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation($type), + params: [], + namedParams: [ + BridgeParameter('key', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('title', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('summary', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('valueIndex', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int)), false), + BridgeParameter( + 'entries', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), + false), + BridgeParameter( + 'entryValues', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), + false), + ])) }, fields: { - 'key': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'title': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'summary': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'valueIndex': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int))), - 'entries': - BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]))), - 'entryValues': - BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]))), + 'key': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'title': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'summary': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'valueIndex': + BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.int))), + 'entries': BridgeFieldDef(BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]))), + 'entryValues': BridgeFieldDef(BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]))), }, wrap: true); @@ -278,8 +330,12 @@ class $ListPreference implements SourcePreference, $Instance { title: args[1]!.$value, summary: args[2]!.$value, valueIndex: args[3]!.$value, - entries: (args[4]!.$value as List).map((e) => (e is $Value ? e.$reified : e).toString()).toList(), - entryValues: (args[5]!.$value as List).map((e) => (e is $Value ? e.$reified : e).toString()).toList()))); + entries: (args[4]!.$value as List) + .map((e) => (e is $Value ? e.$reified : e).toString()) + .toList(), + entryValues: (args[5]!.$value as List) + .map((e) => (e is $Value ? e.$reified : e).toString()) + .toList()))); } @override @@ -332,10 +388,12 @@ class $ListPreference implements SourcePreference, $Instance { ListPreference? get listPreference => $value.listPreference; @override - MultiSelectListPreference? get multiSelectListPreference => $value.multiSelectListPreference; + MultiSelectListPreference? get multiSelectListPreference => + $value.multiSelectListPreference; @override - SwitchPreferenceCompat? get switchPreferenceCompat => $value.switchPreferenceCompat; + SwitchPreferenceCompat? get switchPreferenceCompat => + $value.switchPreferenceCompat; @override Id? get id => $value.id; @@ -362,7 +420,8 @@ class $ListPreference implements SourcePreference, $Instance { set listPreference(ListPreference? listPreference) {} @override - set multiSelectListPreference(MultiSelectListPreference? multiSelectListPreference) {} + set multiSelectListPreference( + MultiSelectListPreference? multiSelectListPreference) {} @override set sourceId(int? sourceId) {} @@ -379,32 +438,51 @@ class $ListPreference implements SourcePreference, $Instance { class $MultiSelectListPreference implements SourcePreference, $Instance { $MultiSelectListPreference.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'MultiSelectListPreference')); + static const $type = BridgeTypeRef(BridgeTypeSpec( + 'package:mangayomi/bridge_lib.dart', 'MultiSelectListPreference')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [], namedParams: [ - BridgeParameter('key', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('title', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('summary', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter( - 'entries', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), false), - BridgeParameter('entryValues', - BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), false), - BridgeParameter( - 'values', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), false), - ])) + '': BridgeConstructorDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation($type), + params: [], + namedParams: [ + BridgeParameter('key', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('title', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('summary', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter( + 'entries', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), + false), + BridgeParameter( + 'entryValues', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), + false), + BridgeParameter( + 'values', + BridgeTypeAnnotation(BridgeTypeRef( + CoreTypes.list, [BridgeTypeRef(CoreTypes.string)])), + false), + ])) }, fields: { - 'key': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'title': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'summary': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'entries': - BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]))), - 'entryValues': - BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]))), - 'values': - BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]))), + 'key': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'title': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'summary': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'entries': BridgeFieldDef(BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]))), + 'entryValues': BridgeFieldDef(BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]))), + 'values': BridgeFieldDef(BridgeTypeAnnotation( + BridgeTypeRef(CoreTypes.list, [BridgeTypeRef(CoreTypes.string)]))), }, wrap: true); @@ -414,9 +492,15 @@ class $MultiSelectListPreference implements SourcePreference, $Instance { multiSelectListPreference: MultiSelectListPreference( title: args[1]!.$value, summary: args[2]!.$value, - entries: (args[3]!.$value as List).map((e) => (e is $Value ? e.$reified : e).toString()).toList(), - entryValues: (args[4]!.$value as List).map((e) => (e is $Value ? e.$reified : e).toString()).toList(), - values: (args[5]!.$value as List).map((e) => (e is $Value ? e.$reified : e).toString()).toList()))); + entries: (args[3]!.$value as List) + .map((e) => (e is $Value ? e.$reified : e).toString()) + .toList(), + entryValues: (args[4]!.$value as List) + .map((e) => (e is $Value ? e.$reified : e).toString()) + .toList(), + values: (args[5]!.$value as List) + .map((e) => (e is $Value ? e.$reified : e).toString()) + .toList()))); } @override @@ -469,10 +553,12 @@ class $MultiSelectListPreference implements SourcePreference, $Instance { ListPreference? get listPreference => $value.listPreference; @override - MultiSelectListPreference? get multiSelectListPreference => $value.multiSelectListPreference; + MultiSelectListPreference? get multiSelectListPreference => + $value.multiSelectListPreference; @override - SwitchPreferenceCompat? get switchPreferenceCompat => $value.switchPreferenceCompat; + SwitchPreferenceCompat? get switchPreferenceCompat => + $value.switchPreferenceCompat; @override Id? get id => $value.id; @@ -499,7 +585,8 @@ class $MultiSelectListPreference implements SourcePreference, $Instance { set listPreference(ListPreference? listPreference) {} @override - set multiSelectListPreference(MultiSelectListPreference? multiSelectListPreference) {} + set multiSelectListPreference( + MultiSelectListPreference? multiSelectListPreference) {} @override set sourceId(int? sourceId) {} @@ -516,28 +603,46 @@ class $MultiSelectListPreference implements SourcePreference, $Instance { class $EditTextPreference implements SourcePreference, $Instance { $EditTextPreference.wrap(this.$value) : _superclass = $Object($value); - static const $type = BridgeTypeRef(BridgeTypeSpec('package:mangayomi/bridge_lib.dart', 'EditTextPreference')); + static const $type = BridgeTypeRef(BridgeTypeSpec( + 'package:mangayomi/bridge_lib.dart', 'EditTextPreference')); static const $declaration = BridgeClassDef(BridgeClassType($type), constructors: { - '': BridgeConstructorDef(BridgeFunctionDef(returns: BridgeTypeAnnotation($type), params: [], namedParams: [ - BridgeParameter('key', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('title', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('summary', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('value', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('dialogTitle', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('dialogMessage', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - BridgeParameter('text', BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), - ])) + '': BridgeConstructorDef(BridgeFunctionDef( + returns: BridgeTypeAnnotation($type), + params: [], + namedParams: [ + BridgeParameter('key', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('title', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('summary', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('value', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('dialogTitle', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('dialogMessage', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + BridgeParameter('text', + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string)), false), + ])) }, fields: { - 'key': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'title': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'summary': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'value': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'dialogTitle': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'dialogMessage': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), - 'text': BridgeFieldDef(BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'key': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'title': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'summary': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'value': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'dialogTitle': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'dialogMessage': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), + 'text': BridgeFieldDef( + BridgeTypeAnnotation(BridgeTypeRef(CoreTypes.string))), }, wrap: true); @@ -605,10 +710,12 @@ class $EditTextPreference implements SourcePreference, $Instance { ListPreference? get listPreference => $value.listPreference; @override - MultiSelectListPreference? get multiSelectListPreference => $value.multiSelectListPreference; + MultiSelectListPreference? get multiSelectListPreference => + $value.multiSelectListPreference; @override - SwitchPreferenceCompat? get switchPreferenceCompat => $value.switchPreferenceCompat; + SwitchPreferenceCompat? get switchPreferenceCompat => + $value.switchPreferenceCompat; @override Id? get id => $value.id; @@ -635,7 +742,8 @@ class $EditTextPreference implements SourcePreference, $Instance { set listPreference(ListPreference? listPreference) {} @override - set multiSelectListPreference(MultiSelectListPreference? multiSelectListPreference) {} + set multiSelectListPreference( + MultiSelectListPreference? multiSelectListPreference) {} @override set sourceId(int? sourceId) {} diff --git a/lib/eval/dart/plugin.dart b/lib/eval/dart/plugin.dart index f6ee4d1..d8360c7 100644 --- a/lib/eval/dart/plugin.dart +++ b/lib/eval/dart/plugin.dart @@ -61,39 +61,64 @@ class MEvalPlugin extends EvalPlugin { @override void configureForRuntime(Runtime runtime) { - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'MProvider.', $MProvider.$construct, + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'MProvider.', $MProvider.$construct, isBridge: true); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'MChapter.', $MChapter.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'MManga.', $MManga.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'MPages.', $MPages.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'MSource.', $MSource.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'MVideo.', $MVideo.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'MTrack.', $MTrack.$new); - runtime.registerBridgeEnumValues('package:mangayomi/bridge_lib.dart', 'MStatus', $MStatus.$values); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'MChapter.', $MChapter.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'MManga.', $MManga.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'MPages.', $MPages.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'MSource.', $MSource.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'MVideo.', $MVideo.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'MTrack.', $MTrack.$new); + runtime.registerBridgeEnumValues( + 'package:mangayomi/bridge_lib.dart', 'MStatus', $MStatus.$values); //Filter - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'FilterList.', $FilterList.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'SelectFilter.', $SelectFilter.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'SeparatorFilter.', $SeparatorFilter.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'HeaderFilter.', $HeaderFilter.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'TextFilter.', $TextFilter.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'SortFilter.', $SortFilter.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'TriStateFilter.', $TriStateFilter.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'GroupFilter.', $GroupFilter.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'CheckBoxFilter.', $CheckBoxFilter.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'SortState.', $SortState.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'SelectFilterOption.', $SelectFilterOption.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'FilterList.', $FilterList.$new); + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'SelectFilter.', $SelectFilter.$new); + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'SeparatorFilter.', $SeparatorFilter.$new); + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'HeaderFilter.', $HeaderFilter.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'TextFilter.', $TextFilter.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'SortFilter.', $SortFilter.$new); + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'TriStateFilter.', $TriStateFilter.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'GroupFilter.', $GroupFilter.$new); + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'CheckBoxFilter.', $CheckBoxFilter.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'SortState.', $SortState.$new); + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'SelectFilterOption.', $SelectFilterOption.$new); //Sources preferences - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'CheckBoxPreference.', $CheckBoxPreference.$new); - runtime.registerBridgeFunc( - 'package:mangayomi/bridge_lib.dart', 'SwitchPreferenceCompat.', $SwitchPreferenceCompat.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'ListPreference.', $ListPreference.$new); - runtime.registerBridgeFunc( - 'package:mangayomi/bridge_lib.dart', 'MultiSelectListPreference.', $MultiSelectListPreference.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'EditTextPreference.', $EditTextPreference.$new); + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'CheckBoxPreference.', $CheckBoxPreference.$new); + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'SwitchPreferenceCompat.', $SwitchPreferenceCompat.$new); + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'ListPreference.', $ListPreference.$new); + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'MultiSelectListPreference.', $MultiSelectListPreference.$new); + runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', + 'EditTextPreference.', $EditTextPreference.$new); //DOM HTML - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'MElement.', $MElement.$new); - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'MDocument.', $MDocument.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'MElement.', $MElement.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'MDocument.', $MDocument.$new); //HTTP CLIENT - runtime.registerBridgeFunc('package:mangayomi/bridge_lib.dart', 'Client.', $Client.$new); + runtime.registerBridgeFunc( + 'package:mangayomi/bridge_lib.dart', 'Client.', $Client.$new); } } diff --git a/lib/eval/dart/service.dart b/lib/eval/dart/service.dart index 9da8c17..56c3493 100644 --- a/lib/eval/dart/service.dart +++ b/lib/eval/dart/service.dart @@ -26,7 +26,8 @@ class DartExtensionService implements ExtensionService { final runtime = runtimeEval(bytecode); - return runtime.executeLib('package:mangayomi/main.dart', 'main', [$MSource.wrap(source.toMSource())]) as MProvider; + return runtime.executeLib('package:mangayomi/main.dart', 'main', + [$MSource.wrap(source.toMSource())]) as MProvider; } @override @@ -103,7 +104,9 @@ class DartExtensionService implements ExtensionService { @override Future> getPageList(String url) async { return (await _executeLib().getPageList(url)) - .map((e) => e is String ? PageUrl(e.toString().trim()) : PageUrl.fromJson((e as Map).toMapStringDynamic!)) + .map((e) => e is String + ? PageUrl(e.toString().trim()) + : PageUrl.fromJson((e as Map).toMapStringDynamic!)) .toList(); } @@ -117,7 +120,10 @@ class DartExtensionService implements ExtensionService { List list; try { - list = _executeLib().getFilterList().map((e) => e is $Value ? e.$reified : e).toList(); + list = _executeLib() + .getFilterList() + .map((e) => e is $Value ? e.$reified : e) + .toList(); } catch (_) { list = []; } diff --git a/lib/eval/javascript/dom_selector.dart b/lib/eval/javascript/dom_selector.dart index 3c1a685..0c49554 100644 --- a/lib/eval/javascript/dom_selector.dart +++ b/lib/eval/javascript/dom_selector.dart @@ -67,8 +67,10 @@ class JsDomSelector { final type = args[0]; final key = args[1]; final ele = _elements[key]; - final element = - switch (type) { 'nextElementSibling' => ele?.nextElementSibling, _ => ele?.previousElementSibling }; + final element = switch (type) { + 'nextElementSibling' => ele?.nextElementSibling, + _ => ele?.previousElementSibling + }; _elementKey++; _elements[_elementKey] = element; return _elementKey; diff --git a/lib/eval/javascript/extractors.dart b/lib/eval/javascript/extractors.dart index 762810a..d636a57 100644 --- a/lib/eval/javascript/extractors.dart +++ b/lib/eval/javascript/extractors.dart @@ -10,7 +10,8 @@ class JsVideosExtractors { void init() { runtime.onMessage('sibnetExtractor', (dynamic args) async { - return (await MBridge.sibnetExtractor(args[0], args[1] ?? "")).encodeToJson(); + return (await MBridge.sibnetExtractor(args[0], args[1] ?? "")) + .encodeToJson(); }); runtime.onMessage('myTvExtractor', (dynamic args) async { return (await MBridge.myTvExtractor(args[0])).encodeToJson(); @@ -25,7 +26,8 @@ class JsVideosExtractors { return (await MBridge.vidBomExtractor(args[0])).encodeToJson(); }); runtime.onMessage('quarkVideosExtractor', (dynamic args) async { - return (await MBridge.quarkVideosExtractor(args[0], args[1])).encodeToJson(); + return (await MBridge.quarkVideosExtractor(args[0], args[1])) + .encodeToJson(); }); runtime.onMessage('ucVideosExtractor', (dynamic args) async { return (await MBridge.ucVideosExtractor(args[0], args[1])).encodeToJson(); @@ -39,16 +41,27 @@ class JsVideosExtractors { return (await MBridge.ucFilesExtractor(urls, args[1])); }); runtime.onMessage('streamlareExtractor', (dynamic args) async { - return (await MBridge.streamlareExtractor(args[0], args[1] ?? "", args[2] ?? "")).encodeToJson(); + return (await MBridge.streamlareExtractor( + args[0], args[1] ?? "", args[2] ?? "")) + .encodeToJson(); }); runtime.onMessage('sendVidExtractor', (dynamic args) async { return (await MBridge.sendVidExtractor( - args[0], args[1] != null ? jsonEncode((args[1] as Map?).toMapStringString) : null, args[2] ?? "")) + args[0], + args[1] != null + ? jsonEncode((args[1] as Map?).toMapStringString) + : null, + args[2] ?? "")) .encodeToJson(); }); runtime.onMessage('yourUploadExtractor', (dynamic args) async { - return (await MBridge.yourUploadExtractor(args[0], - args[1] != null ? jsonEncode((args[1] as Map?).toMapStringString) : null, args[2], args[3] ?? "")) + return (await MBridge.yourUploadExtractor( + args[0], + args[1] != null + ? jsonEncode((args[1] as Map?).toMapStringString) + : null, + args[2], + args[3] ?? "")) .encodeToJson(); }); runtime.onMessage('gogoCdnExtractor', (dynamic args) async { @@ -58,18 +71,27 @@ class JsVideosExtractors { return (await MBridge.doodExtractor(args[0], args[1])).encodeToJson(); }); runtime.onMessage('streamTapeExtractor', (dynamic args) async { - return (await MBridge.streamTapeExtractor(args[0], args[1])).encodeToJson(); + return (await MBridge.streamTapeExtractor(args[0], args[1])) + .encodeToJson(); }); runtime.onMessage('mp4UploadExtractor', (dynamic args) async { - return (await MBridge.mp4UploadExtractor(args[0], - args[1] != null ? jsonEncode((args[1] as Map?).toMapStringString) : null, args[2] ?? "", args[3] ?? "")) + return (await MBridge.mp4UploadExtractor( + args[0], + args[1] != null + ? jsonEncode((args[1] as Map?).toMapStringString) + : null, + args[2] ?? "", + args[3] ?? "")) .encodeToJson(); }); runtime.onMessage('streamWishExtractor', (dynamic args) async { - return (await MBridge.streamWishExtractor(args[0], args[1] ?? "")).encodeToJson(); + return (await MBridge.streamWishExtractor(args[0], args[1] ?? "")) + .encodeToJson(); }); runtime.onMessage('filemoonExtractor', (dynamic args) async { - return (await MBridge.filemoonExtractor(args[0], args[1] ?? "", args[2] ?? "")).encodeToJson(); + return (await MBridge.filemoonExtractor( + args[0], args[1] ?? "", args[2] ?? "")) + .encodeToJson(); }); runtime.evaluate(''' diff --git a/lib/eval/javascript/http.dart b/lib/eval/javascript/http.dart index b64080f..2ad8ead 100644 --- a/lib/eval/javascript/http.dart +++ b/lib/eval/javascript/http.dart @@ -11,7 +11,8 @@ class JsHttpClient { void init() { InterceptedClient client(dynamic reqcopyWith) { - return MClient.init(reqcopyWith: (reqcopyWith as Map?)?.toMapStringDynamic); + return MClient.init( + reqcopyWith: (reqcopyWith as Map?)?.toMapStringDynamic); } runtime.onMessage('http_get', (dynamic args) async { @@ -85,7 +86,9 @@ Future _toHttpResponse(Client client, String method, List args) async { final body = args.length >= 5 ? (args[4] as Map?)?.toMapStringDynamic : null; var request = http.Request(method, Uri.parse(url)); request.headers.addAll(headers ?? {}); - if ((request.headers[HttpHeaders.contentTypeHeader]?.contains("application/json")) ?? false) { + if ((request.headers[HttpHeaders.contentTypeHeader] + ?.contains("application/json")) ?? + false) { request.body = json.encode(body); request.headers.addAll(headers ?? {}); http.StreamedResponse response = await client.send(request); @@ -136,6 +139,7 @@ extension ToMapExtension on Map? { } Map? get toMapStringString { - return this?.map((key, value) => MapEntry(key.toString(), value.toString())); + return this + ?.map((key, value) => MapEntry(key.toString(), value.toString())); } } diff --git a/lib/eval/javascript/service.dart b/lib/eval/javascript/service.dart index 9cc1ab9..7435d80 100644 --- a/lib/eval/javascript/service.dart +++ b/lib/eval/javascript/service.dart @@ -78,7 +78,8 @@ var extention = new DefaultExtension(); @override Map getHeaders() { - return _extensionCall('getHeaders(`${source.baseUrl ?? ''}`)', {}).toMapStringString!; + return _extensionCall('getHeaders(`${source.baseUrl ?? ''}`)', {}) + .toMapStringString!; } @override @@ -98,13 +99,15 @@ var extention = new DefaultExtension(); @override Future getLatestUpdates(int page) async { - return MPages.fromJson(await _extensionCallAsync('getLatestUpdates($page)', {})); + return MPages.fromJson( + await _extensionCallAsync('getLatestUpdates($page)', {})); } @override Future search(String query, int page, List filters) async { - return MPages.fromJson( - await _extensionCallAsync('search("$query",$page,${jsonEncode(filterValuesListToJson(filters))})', {})); + return MPages.fromJson(await _extensionCallAsync( + 'search("$query",$page,${jsonEncode(filterValuesListToJson(filters))})', + {})); } @override @@ -115,14 +118,17 @@ var extention = new DefaultExtension(); @override Future> getPageList(String url) async { return (await _extensionCallAsync('getPageList(`$url`)', [])) - .map((e) => e is String ? PageUrl(e.trim()) : PageUrl.fromJson((e as Map).toMapStringDynamic!)) + .map((e) => e is String + ? PageUrl(e.trim()) + : PageUrl.fromJson((e as Map).toMapStringDynamic!)) .toList(); } @override Future> getVideoList(String url) async { return (await _extensionCallAsync('getVideoList(`$url`)', [])) - .where((element) => element['url'] != null && element['originalUrl'] != null) + .where((element) => + element['url'] != null && element['originalUrl'] != null) .map((e) => Video.fromJson(e)) .toList() .toSet() @@ -149,12 +155,11 @@ var extention = new DefaultExtension(); .toList(); } - T _extensionCall(String call, T def) { _init(); try { - final res = runtime.evaluate('JSON.stringify(extention.`$call`)'); + final res = runtime.evaluate('JSON.stringify(extention.$call)'); return jsonDecode(res.stringResult) as T; } catch (_) { @@ -170,7 +175,8 @@ var extention = new DefaultExtension(); _init(); try { - final promised = await runtime.handlePromise(await runtime.evaluateAsync('jsonStringify(() => extention.$call)')); + final promised = await runtime.handlePromise( + await runtime.evaluateAsync('jsonStringify(() => extention.$call)')); return jsonDecode(promised.stringResult) as T; } catch (_) { diff --git a/lib/eval/model/document.dart b/lib/eval/model/document.dart index 974dc76..1b245b8 100644 --- a/lib/eval/model/document.dart +++ b/lib/eval/model/document.dart @@ -19,7 +19,8 @@ class MDocument { String? get text => _document?.text; - List? get children => _document?.children.map((e) => MElement(e)).toList(); + List? get children => + _document?.children.map((e) => MElement(e)).toList(); List? select(String selector) { return _document?.select(selector)?.map((e) => MElement(e)).toList(); @@ -34,11 +35,17 @@ class MDocument { } List? getElementsByClassName(String classNames) { - return _document?.getElementsByClassName(classNames).map((e) => MElement(e)).toList(); + return _document + ?.getElementsByClassName(classNames) + .map((e) => MElement(e)) + .toList(); } List? getElementsByTagName(String localNames) { - return _document?.getElementsByTagName(localNames).map((e) => MElement(e)).toList(); + return _document + ?.getElementsByTagName(localNames) + .map((e) => MElement(e)) + .toList(); } MElement? getElementById(String id) { diff --git a/lib/eval/model/element.dart b/lib/eval/model/element.dart index 6fbb71a..35ce093 100644 --- a/lib/eval/model/element.dart +++ b/lib/eval/model/element.dart @@ -26,13 +26,15 @@ class MElement { String? get getDataSrc => _element?.getDataSrc; - List? get children => _element?.children.map((e) => MElement(e)).toList(); + List? get children => + _element?.children.map((e) => MElement(e)).toList(); MElement? get parent => MElement(_element?.parent); MElement? get nextElementSibling => MElement(_element?.nextElementSibling); - MElement? get previousElementSibling => MElement(_element?.previousElementSibling); + MElement? get previousElementSibling => + MElement(_element?.previousElementSibling); String? xpathFirst(String xpath) { return _element?.outerHtml == null ? null : _element?.xpathFirst(xpath); @@ -43,11 +45,17 @@ class MElement { } List? getElementsByClassName(String classNames) { - return _element?.getElementsByClassName(classNames).map((e) => MElement(e)).toList(); + return _element + ?.getElementsByClassName(classNames) + .map((e) => MElement(e)) + .toList(); } List? getElementsByTagName(String localNames) { - return _element?.getElementsByTagName(localNames).map((e) => MElement(e)).toList(); + return _element + ?.getElementsByTagName(localNames) + .map((e) => MElement(e)) + .toList(); } List? select(String selector) { diff --git a/lib/eval/model/filter.dart b/lib/eval/model/filter.dart index d9ca494..700259f 100644 --- a/lib/eval/model/filter.dart +++ b/lib/eval/model/filter.dart @@ -18,8 +18,8 @@ class SelectFilter { SelectFilter(this.type, this.name, this.state, this.values, this.typeName); factory SelectFilter.fromJson(Map json) { - return SelectFilter( - json['type'], json['name'], json['state'] ?? 0, fromJsonFilterValuesToList(json['values']), json['type_name']); + return SelectFilter(json['type'], json['name'], json['state'] ?? 0, + fromJsonFilterValuesToList(json['values']), json['type_name']); } Map toJson() => { 'type': type, @@ -39,7 +39,8 @@ class SelectFilterOption { factory SelectFilterOption.fromJson(Map json) { return SelectFilterOption(json['name'], json['value'], json['type_name']); } - Map toJson() => {'value': value, 'name': name, 'type_name': "SelectOption"}; + Map toJson() => + {'value': value, 'name': name, 'type_name': "SelectOption"}; } class SeparatorFilter { @@ -49,7 +50,8 @@ class SeparatorFilter { factory SeparatorFilter.fromJson(Map json) { return SeparatorFilter(type: json['type'], json['type_name']); } - Map toJson() => {'type': type, 'type_name': "SeparatorFilter"}; + Map toJson() => + {'type': type, 'type_name': "SeparatorFilter"}; } class HeaderFilter { @@ -60,7 +62,8 @@ class HeaderFilter { factory HeaderFilter.fromJson(Map json) { return HeaderFilter(json['name'], json['type_name'], type: json['value']); } - Map toJson() => {'type': type, 'name': name, 'type_name': "HeaderFilter"}; + Map toJson() => + {'type': type, 'name': name, 'type_name': "HeaderFilter"}; } class TextFilter { @@ -71,9 +74,11 @@ class TextFilter { TextFilter(this.type, this.name, this.typeName, {this.state = ""}); factory TextFilter.fromJson(Map json) { - return TextFilter(json['type'], json['name'], json['type_name'], state: json['state'] ?? ""); + return TextFilter(json['type'], json['name'], json['type_name'], + state: json['state'] ?? ""); } - Map toJson() => {'type': type, 'name': name, 'state': state, 'type_name': "TextFilter"}; + Map toJson() => + {'type': type, 'name': name, 'state': state, 'type_name': "TextFilter"}; } class SortFilter { @@ -88,7 +93,9 @@ class SortFilter { return SortFilter( json['type'], json['name'], - json['state'] == null ? SortState(0, false, "") : SortState.fromJson(json['state']), + json['state'] == null + ? SortState(0, false, "") + : SortState.fromJson(json['state']), fromJsonFilterValuesToList(json['values']), json['type_name']); } @@ -110,7 +117,8 @@ class SortState { factory SortState.fromJson(Map json) { return SortState(json['index'], json['ascending'], json['type_name']); } - Map toJson() => {'index': index, 'ascending': ascending, 'type_name': "SortState"}; + Map toJson() => + {'index': index, 'ascending': ascending, 'type_name': "SortState"}; } class TriStateFilter { @@ -121,11 +129,19 @@ class TriStateFilter { String? typeName; factory TriStateFilter.fromJson(Map json) { - return TriStateFilter(json['type'], json['name'], json['value'], json['type_name'], state: json['state'] ?? 0); + return TriStateFilter( + json['type'], json['name'], json['value'], json['type_name'], + state: json['state'] ?? 0); } - TriStateFilter(this.type, this.name, this.value, this.typeName, {this.state = 0}); - Map toJson() => - {'type': type, 'name': name, 'value': value, 'state': state, 'type_name': "TriState"}; + TriStateFilter(this.type, this.name, this.value, this.typeName, + {this.state = 0}); + Map toJson() => { + 'type': type, + 'name': name, + 'value': value, + 'state': state, + 'type_name': "TriState" + }; } class GroupFilter { @@ -136,10 +152,15 @@ class GroupFilter { GroupFilter(this.type, this.name, this.state, this.typeName); factory GroupFilter.fromJson(Map json) { - return GroupFilter(json['type'], json['name'], fromJsonFilterValuesToList(json['state']), json['type_name']); + return GroupFilter(json['type'], json['name'], + fromJsonFilterValuesToList(json['state']), json['type_name']); } - Map toJson() => - {'type': type, 'name': name, 'state': filterValuesListToJson(state), 'type_name': "GroupFilter"}; + Map toJson() => { + 'type': type, + 'name': name, + 'state': filterValuesListToJson(state), + 'type_name': "GroupFilter" + }; } class CheckBoxFilter { @@ -149,12 +170,20 @@ class CheckBoxFilter { bool state; String? typeName; - CheckBoxFilter(this.type, this.name, this.value, this.typeName, {this.state = false}); + CheckBoxFilter(this.type, this.name, this.value, this.typeName, + {this.state = false}); factory CheckBoxFilter.fromJson(Map json) { - return CheckBoxFilter(json['type'], json['name'], json['value'], json['type_name'], state: json['state'] ?? false); + return CheckBoxFilter( + json['type'], json['name'], json['value'], json['type_name'], + state: json['state'] ?? false); } - Map toJson() => - {'type': type, 'name': name, 'value': value, 'state': state, 'type_name': "CheckBox"}; + Map toJson() => { + 'type': type, + 'name': name, + 'value': value, + 'state': state, + 'type_name': "CheckBox" + }; } List fromJsonFilterValuesToList(List list) { @@ -165,9 +194,11 @@ List fromJsonFilterValuesToList(List list) { return switch (map['type_name']) { 'TriState' => TriStateFilter.fromJson(map.toMapStringDynamic!), 'CheckBox' => CheckBoxFilter.fromJson(map.toMapStringDynamic!), - 'SelectOption' => SelectFilterOption.fromJson(map.toMapStringDynamic!), + 'SelectOption' => + SelectFilterOption.fromJson(map.toMapStringDynamic!), 'SelectFilter' => SelectFilter.fromJson(map.toMapStringDynamic!), - 'SeparatorFilter' => SeparatorFilter.fromJson(map.toMapStringDynamic!), + 'SeparatorFilter' => + SeparatorFilter.fromJson(map.toMapStringDynamic!), 'HeaderFilter' => HeaderFilter.fromJson(map.toMapStringDynamic!), 'TextFilter' => TextFilter.fromJson(map.toMapStringDynamic!), 'SortFilter' => SortFilter.fromJson(map.toMapStringDynamic!), diff --git a/lib/eval/model/m_bridge.dart b/lib/eval/model/m_bridge.dart index 38c5dae..f228539 100644 --- a/lib/eval/model/m_bridge.dart +++ b/lib/eval/model/m_bridge.dart @@ -44,15 +44,18 @@ class WordSet { WordSet(this.words); bool anyWordIn(String dateString) { - return words.any((word) => dateString.toLowerCase().contains(word.toLowerCase())); + return words + .any((word) => dateString.toLowerCase().contains(word.toLowerCase())); } bool startsWith(String dateString) { - return words.any((word) => dateString.toLowerCase().startsWith(word.toLowerCase())); + return words + .any((word) => dateString.toLowerCase().startsWith(word.toLowerCase())); } bool endsWith(String dateString) { - return words.any((word) => dateString.toLowerCase().endsWith(word.toLowerCase())); + return words + .any((word) => dateString.toLowerCase().endsWith(word.toLowerCase())); } } @@ -79,7 +82,8 @@ class MBridge { //Return one attr else if (query.nodes.length == 1) { - String attr = query.attr != null ? query.attr!.trim().trimLeft().trimRight() : ""; + String attr = + query.attr != null ? query.attr!.trim().trimLeft().trimRight() : ""; if (attr.isNotEmpty) { attrs = [attr]; } @@ -102,7 +106,10 @@ class MBridge { statusMap = element; } for (var element in statusMap.entries) { - if (element.key.toString().toLowerCase().contains(status.toLowerCase().trim().trimLeft().trimRight())) { + if (element.key + .toString() + .toLowerCase() + .contains(status.toLowerCase().trim().trimLeft().trimRight())) { return switch (element.value as int) { 0 => Status.ongoing, 1 => Status.completed, @@ -259,7 +266,8 @@ class MBridge { } //Parse a list of dates to millisecondsSinceEpoch - static List parseDates(List value, String dateFormat, String dateFormatLocale) { + static List parseDates( + List value, String dateFormat, String dateFormatLocale) { List val = []; for (var element in value) { if (element is $Value) { @@ -304,7 +312,8 @@ class MBridge { } //Utility to use RegExp - static String regExp(String expression, String source, String replace, int type, int group) { + static String regExp( + String expression, String source, String replace, int type, int group) { if (type == 0) { return expression.replaceAll(RegExp(source), replace); } @@ -319,48 +328,58 @@ class MBridge { return await DoodExtractor().videosFromUrl(url, quality: quality); } - static Future> streamWishExtractor(String url, String prefix) async { + static Future> streamWishExtractor( + String url, String prefix) async { return await StreamWishExtractor().videosFromUrl(url, prefix); } - static Future> filemoonExtractor(String url, String prefix, String suffix) async { + static Future> filemoonExtractor( + String url, String prefix, String suffix) async { return await FilemoonExtractor().videosFromUrl(url, prefix, suffix); } - static Future> mp4UploadExtractor(String url, String? headers, String prefix, String suffix) async { + static Future> mp4UploadExtractor( + String url, String? headers, String prefix, String suffix) async { Map newHeaders = {}; if (headers != null) { newHeaders = (jsonDecode(headers) as Map).toMapStringString!; } - return await Mp4uploadExtractor().videosFromUrl(url, newHeaders, prefix: prefix, suffix: suffix); + return await Mp4uploadExtractor() + .videosFromUrl(url, newHeaders, prefix: prefix, suffix: suffix); } - static Future>> quarkFilesExtractor(List url, String cookie) async { + static Future>> quarkFilesExtractor( + List url, String cookie) async { QuarkUcExtractor quark = QuarkUcExtractor(); await quark.initCloudDrive(cookie, CloudDriveType.quark); return await quark.videoFilesFromUrl(url); } - static Future>> ucFilesExtractor(List url, String cookie) async { + static Future>> ucFilesExtractor( + List url, String cookie) async { QuarkUcExtractor uc = QuarkUcExtractor(); await uc.initCloudDrive(cookie, CloudDriveType.uc); return await uc.videoFilesFromUrl(url); } - static Future> quarkVideosExtractor(String url, String cookie) async { + static Future> quarkVideosExtractor( + String url, String cookie) async { QuarkUcExtractor quark = QuarkUcExtractor(); await quark.initCloudDrive(cookie, CloudDriveType.quark); return await quark.videosFromUrl(url); } - static Future> ucVideosExtractor(String url, String cookie) async { + static Future> ucVideosExtractor( + String url, String cookie) async { QuarkUcExtractor uc = QuarkUcExtractor(); await uc.initCloudDrive(cookie, CloudDriveType.uc); return await uc.videosFromUrl(url); } - static Future> streamTapeExtractor(String url, String? quality) async { - return await StreamTapeExtractor().videosFromUrl(url, quality: quality ?? "StreamTape"); + static Future> streamTapeExtractor( + String url, String? quality) async { + return await StreamTapeExtractor() + .videosFromUrl(url, quality: quality ?? "StreamTape"); } //Utility to use substring @@ -383,28 +402,55 @@ class MBridge { } //Parse a chapter date to millisecondsSinceEpoch - static String parseChapterDate( - String date, String dateFormat, String dateFormatLocale, Function((String, String, bool)) newLocale) { + static String parseChapterDate(String date, String dateFormat, + String dateFormatLocale, Function((String, String, bool)) newLocale) { int parseRelativeDate(String date) { final number = int.tryParse(RegExp(r"(\d+)").firstMatch(date)!.group(0)!); if (number == null) return 0; final cal = DateTime.now(); - if (WordSet(["hari", "gün", "jour", "día", "dia", "day", "วัน", "ngày", "giorni", "أيام", "天"]).anyWordIn(date)) { + if (WordSet([ + "hari", + "gün", + "jour", + "día", + "dia", + "day", + "วัน", + "ngày", + "giorni", + "أيام", + "天" + ]).anyWordIn(date)) { return cal.subtract(Duration(days: number)).millisecondsSinceEpoch; - } else if (WordSet(["jam", "saat", "heure", "hora", "hour", "ชั่วโมง", "giờ", "ore", "ساعة", "小时"]) - .anyWordIn(date)) { + } else if (WordSet([ + "jam", + "saat", + "heure", + "hora", + "hour", + "ชั่วโมง", + "giờ", + "ore", + "ساعة", + "小时" + ]).anyWordIn(date)) { return cal.subtract(Duration(hours: number)).millisecondsSinceEpoch; - } else if (WordSet(["menit", "dakika", "min", "minute", "minuto", "นาที", "دقائق"]).anyWordIn(date)) { + } else if (WordSet( + ["menit", "dakika", "min", "minute", "minuto", "นาที", "دقائق"]) + .anyWordIn(date)) { return cal.subtract(Duration(minutes: number)).millisecondsSinceEpoch; - } else if (WordSet(["detik", "segundo", "second", "วินาที", "sec"]).anyWordIn(date)) { + } else if (WordSet(["detik", "segundo", "second", "วินาที", "sec"]) + .anyWordIn(date)) { return cal.subtract(Duration(seconds: number)).millisecondsSinceEpoch; } else if (WordSet(["week", "semana"]).anyWordIn(date)) { return cal.subtract(Duration(days: number * 7)).millisecondsSinceEpoch; } else if (WordSet(["month", "mes"]).anyWordIn(date)) { return cal.subtract(Duration(days: number * 30)).millisecondsSinceEpoch; } else if (WordSet(["year", "año"]).anyWordIn(date)) { - return cal.subtract(Duration(days: number * 365)).millisecondsSinceEpoch; + return cal + .subtract(Duration(days: number * 365)) + .millisecondsSinceEpoch; } else { return 0; } @@ -430,11 +476,19 @@ class MBridge { } else if (date.contains(RegExp(r"\d(st|nd|rd|th)"))) { final cleanedDate = date .split(" ") - .map((it) => it.contains(RegExp(r"\d\D\D")) ? it.replaceAll(RegExp(r"\D"), "") : it) + .map((it) => it.contains(RegExp(r"\d\D\D")) + ? it.replaceAll(RegExp(r"\D"), "") + : it) .join(" "); - return DateFormat(dateFormat, dateFormatLocale).parse(cleanedDate).millisecondsSinceEpoch.toString(); + return DateFormat(dateFormat, dateFormatLocale) + .parse(cleanedDate) + .millisecondsSinceEpoch + .toString(); } else { - return DateFormat(dateFormat, dateFormatLocale).parse(date).millisecondsSinceEpoch.toString(); + return DateFormat(dateFormat, dateFormatLocale) + .parse(date) + .millisecondsSinceEpoch + .toString(); } } catch (e) { final supportedLocales = DateFormat.allLocalesWithSymbols(); @@ -456,18 +510,27 @@ class MBridge { DateTime cal = DateTime.now().subtract(const Duration(days: 2)); cal = DateTime(cal.year, cal.month, cal.day); return cal.millisecondsSinceEpoch.toString(); - } else if (WordSet(["ago", "atrás", "önce", "قبل"]).endsWith(date)) { + } else if (WordSet(["ago", "atrás", "önce", "قبل"]) + .endsWith(date)) { return parseRelativeDate(date).toString(); } else if (WordSet(["hace"]).startsWith(date)) { return parseRelativeDate(date).toString(); } else if (date.contains(RegExp(r"\d(st|nd|rd|th)"))) { final cleanedDate = date .split(" ") - .map((it) => it.contains(RegExp(r"\d\D\D")) ? it.replaceAll(RegExp(r"\D"), "") : it) + .map((it) => it.contains(RegExp(r"\d\D\D")) + ? it.replaceAll(RegExp(r"\D"), "") + : it) .join(" "); - return DateFormat(dateFormat, locale).parse(cleanedDate).millisecondsSinceEpoch.toString(); + return DateFormat(dateFormat, locale) + .parse(cleanedDate) + .millisecondsSinceEpoch + .toString(); } else { - return DateFormat(dateFormat, locale).parse(date).millisecondsSinceEpoch.toString(); + return DateFormat(dateFormat, locale) + .parse(date) + .millisecondsSinceEpoch + .toString(); } } catch (_) {} } @@ -485,13 +548,15 @@ class MBridge { return await SibnetExtractor().videosFromUrl(url, prefix: prefix); } - static Future> sendVidExtractor(String url, String? headers, String prefix) async { + static Future> sendVidExtractor( + String url, String? headers, String prefix) async { Map newHeaders = {}; if (headers != null) { newHeaders = (jsonDecode(headers) as Map).toMapStringString!; } - return await SendvidExtractor(newHeaders).videosFromUrl(url, prefix: prefix); + return await SendvidExtractor(newHeaders) + .videosFromUrl(url, prefix: prefix); } static Future> myTvExtractor(String url) async { @@ -502,12 +567,14 @@ class MBridge { return await OkruExtractor().videosFromUrl(url); } - static Future> yourUploadExtractor(String url, String? headers, String? name, String prefix) async { + static Future> yourUploadExtractor( + String url, String? headers, String? name, String prefix) async { Map newHeaders = {}; if (headers != null) { newHeaders = (jsonDecode(headers) as Map).toMapStringString!; } - return await YourUploadExtractor().videosFromUrl(url, newHeaders, prefix: prefix, name: name ?? "YourUpload"); + return await YourUploadExtractor().videosFromUrl(url, newHeaders, + prefix: prefix, name: name ?? "YourUpload"); } static Future> voeExtractor(String url, String? quality) async { @@ -518,8 +585,10 @@ class MBridge { return await VidBomExtractor().videosFromUrl(url); } - static Future> streamlareExtractor(String url, String prefix, String suffix) async { - return await StreamlareExtractor().videosFromUrl(url, prefix: prefix, suffix: suffix); + static Future> streamlareExtractor( + String url, String prefix, String suffix) async { + return await StreamlareExtractor() + .videosFromUrl(url, prefix: prefix, suffix: suffix); } static String encryptAESCryptoJS(String plainText, String passphrase) { @@ -530,16 +599,18 @@ class MBridge { return CryptoAES.decryptAESCryptoJS(encrypted, passphrase); } - static Video toVideo( - String url, String quality, String originalUrl, String? headers, List? subtitles, List? audios) { + static Video toVideo(String url, String quality, String originalUrl, + String? headers, List? subtitles, List? audios) { Map newHeaders = {}; if (headers != null) { newHeaders = (jsonDecode(headers) as Map).toMapStringString!; } - return Video(url, quality, originalUrl, headers: newHeaders, subtitles: subtitles ?? [], audios: audios ?? []); + return Video(url, quality, originalUrl, + headers: newHeaders, subtitles: subtitles ?? [], audios: audios ?? []); } - static String cryptoHandler(String text, String iv, String secretKeyString, bool encrypt) { + static String cryptoHandler( + String text, String iv, String secretKeyString, bool encrypt) { try { if (encrypt) { final encryptt = _encrypt(secretKeyString, iv); @@ -603,7 +674,10 @@ void botToast(String title, bool hasCloudFlare = false, String? url}) { final context = navigatorKey.currentState?.context; - final assets = ['assets/app_icons/icon-black.png', 'assets/app_icons/icon-red.png']; + final assets = [ + 'assets/app_icons/icon-black.png', + 'assets/app_icons/icon-red.png' + ]; BotToast.showNotification( onlyOne: true, dismissDirections: [DismissDirection.horizontal, DismissDirection.down], @@ -617,9 +691,11 @@ void botToast(String title, ? (_) => OutlinedButton.icon( style: OutlinedButton.styleFrom(elevation: 10), onPressed: () { - context?.push("/mangawebview", extra: {'url': url, 'title': ''}); + context + ?.push("/mangawebview", extra: {'url': url, 'title': ''}); }, - label: Text("Resolve Cloudflare challenge", style: TextStyle(color: context?.secondaryColor)), + label: Text("Resolve Cloudflare challenge", + style: TextStyle(color: context?.secondaryColor)), icon: const Icon(Icons.public), ) : null, @@ -629,6 +705,7 @@ void botToast(String title, (encrypt.Encrypter, encrypt.IV) _encrypt(String keyy, String ivv) { final key = encrypt.Key.fromUtf8(keyy); final iv = encrypt.IV.fromUtf8(ivv); - final encrypter = encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.cbc, padding: 'PKCS7')); + final encrypter = encrypt.Encrypter( + encrypt.AES(key, mode: encrypt.AESMode.cbc, padding: 'PKCS7')); return (encrypter, iv); } diff --git a/lib/eval/model/m_chapter.dart b/lib/eval/model/m_chapter.dart index 9fa36b7..e396cb6 100644 --- a/lib/eval/model/m_chapter.dart +++ b/lib/eval/model/m_chapter.dart @@ -8,7 +8,16 @@ class MChapter { String? scanlator; MChapter({this.name, this.url, this.dateUpload, this.scanlator}); factory MChapter.fromJson(Map json) { - return MChapter(name: json['name'], url: json['url'], dateUpload: json['dateUpload'], scanlator: json['scanlator']); + return MChapter( + name: json['name'], + url: json['url'], + dateUpload: json['dateUpload'], + scanlator: json['scanlator']); } - Map toJson() => {'name': name, 'url': url, 'dateUpload': dateUpload, 'scanlator': scanlator}; + Map toJson() => { + 'name': name, + 'url': url, + 'dateUpload': dateUpload, + 'scanlator': scanlator + }; } diff --git a/lib/eval/model/m_manga.dart b/lib/eval/model/m_manga.dart index f1fd7db..d5b24b2 100644 --- a/lib/eval/model/m_manga.dart +++ b/lib/eval/model/m_manga.dart @@ -48,11 +48,16 @@ class MManga { 4 => Status.publishingFinished, _ => Status.unknown, }, - genre: (json['genre'] as List?)?.map((e) => e.toString()).toList() ?? [], + genre: + (json['genre'] as List?)?.map((e) => e.toString()).toList() ?? [], chapters: json['chapters'] != null - ? (json['chapters'] as List).map((e) => MChapter.fromJson(e)).toList() + ? (json['chapters'] as List) + .map((e) => MChapter.fromJson(e)) + .toList() : json['episodes'] != null - ? (json['episodes'] as List).map((e) => MChapter.fromJson(e)).toList() + ? (json['episodes'] as List) + .map((e) => MChapter.fromJson(e)) + .toList() : []); } Map toJson() => { diff --git a/lib/eval/model/m_pages.dart b/lib/eval/model/m_pages.dart index 6b8343d..d40f818 100644 --- a/lib/eval/model/m_pages.dart +++ b/lib/eval/model/m_pages.dart @@ -7,7 +7,9 @@ class MPages { factory MPages.fromJson(Map json) { return MPages( - list: json['list'] != null ? (json['list'] as List).map((e) => MManga.fromJson(e)).toList() : [], + list: json['list'] != null + ? (json['list'] as List).map((e) => MManga.fromJson(e)).toList() + : [], hasNextPage: json['hasNextPage']); } diff --git a/lib/eval/model/m_video.dart b/lib/eval/model/m_video.dart index 8db1fcb..1b750d9 100644 --- a/lib/eval/model/m_video.dart +++ b/lib/eval/model/m_video.dart @@ -6,7 +6,8 @@ class MVideo { List? subtitles; List? audios; - MVideo(this.url, this.quality, this.originalUrl, {this.headers, this.subtitles, this.audios}); + MVideo(this.url, this.quality, this.originalUrl, + {this.headers, this.subtitles, this.audios}); } class MTrack { diff --git a/lib/eval/model/source_preference.dart b/lib/eval/model/source_preference.dart index 393cf5f..e424fe8 100644 --- a/lib/eval/model/source_preference.dart +++ b/lib/eval/model/source_preference.dart @@ -27,11 +27,15 @@ class SourcePreference { 'id': id, 'sourceId': sourceId, 'key': key, - if (checkBoxPreference != null) 'checkBoxPreference': checkBoxPreference!.toJson(), - if (switchPreferenceCompat != null) 'switchPreferenceCompat': switchPreferenceCompat!.toJson(), + if (checkBoxPreference != null) + 'checkBoxPreference': checkBoxPreference!.toJson(), + if (switchPreferenceCompat != null) + 'switchPreferenceCompat': switchPreferenceCompat!.toJson(), if (listPreference != null) 'listPreference': listPreference!.toJson(), - if (multiSelectListPreference != null) 'multiSelectListPreference': multiSelectListPreference!.toJson(), - if (editTextPreference != null) 'editTextPreference': editTextPreference!.toJson() + if (multiSelectListPreference != null) + 'multiSelectListPreference': multiSelectListPreference!.toJson(), + if (editTextPreference != null) + 'editTextPreference': editTextPreference!.toJson() }; factory SourcePreference.fromJson(Map json) { @@ -39,17 +43,22 @@ class SourcePreference { id: json['id'] ?? Isar.autoIncrement, sourceId: json['sourceId'], key: json['key'], - checkBoxPreference: - json['checkBoxPreference'] != null ? CheckBoxPreference.fromJson(json['checkBoxPreference']) : null, + checkBoxPreference: json['checkBoxPreference'] != null + ? CheckBoxPreference.fromJson(json['checkBoxPreference']) + : null, switchPreferenceCompat: json['switchPreferenceCompat'] != null ? SwitchPreferenceCompat.fromJson(json['switchPreferenceCompat']) : null, - listPreference: json['listPreference'] != null ? ListPreference.fromJson(json['listPreference']) : null, - multiSelectListPreference: json['multiSelectListPreference'] != null - ? MultiSelectListPreference.fromJson(json['multiSelectListPreference']) + listPreference: json['listPreference'] != null + ? ListPreference.fromJson(json['listPreference']) : null, - editTextPreference: - json['editTextPreference'] != null ? EditTextPreference.fromJson(json['editTextPreference']) : null); + multiSelectListPreference: json['multiSelectListPreference'] != null + ? MultiSelectListPreference.fromJson( + json['multiSelectListPreference']) + : null, + editTextPreference: json['editTextPreference'] != null + ? EditTextPreference.fromJson(json['editTextPreference']) + : null); } } @@ -61,10 +70,12 @@ class CheckBoxPreference { CheckBoxPreference({this.title, this.summary, this.value}); - Map toJson() => {'title': title, 'summary': summary, 'value': value}; + Map toJson() => + {'title': title, 'summary': summary, 'value': value}; factory CheckBoxPreference.fromJson(Map json) { - return CheckBoxPreference(title: json['title'], summary: json['summary'], value: json['value']); + return CheckBoxPreference( + title: json['title'], summary: json['summary'], value: json['value']); } } @@ -76,10 +87,12 @@ class SwitchPreferenceCompat { SwitchPreferenceCompat({this.title, this.summary, this.value}); - Map toJson() => {'title': title, 'summary': summary, 'value': value}; + Map toJson() => + {'title': title, 'summary': summary, 'value': value}; factory SwitchPreferenceCompat.fromJson(Map json) { - return SwitchPreferenceCompat(title: json['title'], summary: json['summary'], value: json['value']); + return SwitchPreferenceCompat( + title: json['title'], summary: json['summary'], value: json['value']); } } @@ -91,10 +104,20 @@ class ListPreference { List? entries; List? entryValues; - ListPreference({this.title, this.summary, this.valueIndex, this.entries, this.entryValues}); + ListPreference( + {this.title, + this.summary, + this.valueIndex, + this.entries, + this.entryValues}); - Map toJson() => - {'title': title, 'summary': summary, 'valueIndex': valueIndex, 'entries': entries, 'entryValues': entryValues}; + Map toJson() => { + 'title': title, + 'summary': summary, + 'valueIndex': valueIndex, + 'entries': entries, + 'entryValues': entryValues + }; factory ListPreference.fromJson(Map json) { return ListPreference( @@ -114,7 +137,8 @@ class MultiSelectListPreference { List? entryValues; List? values; - MultiSelectListPreference({this.title, this.summary, this.entries, this.entryValues, this.values}); + MultiSelectListPreference( + {this.title, this.summary, this.entries, this.entryValues, this.values}); Map toJson() => { 'title': title, @@ -143,7 +167,13 @@ class EditTextPreference { String? dialogMessage; String? text; - EditTextPreference({this.title, this.summary, this.value, this.dialogTitle, this.dialogMessage, this.text}); + EditTextPreference( + {this.title, + this.summary, + this.value, + this.dialogTitle, + this.dialogMessage, + this.text}); Map toJson() => { 'title': title, @@ -173,5 +203,6 @@ class SourcePreferenceStringValue { String? key; String? value; - SourcePreferenceStringValue({this.id = Isar.autoIncrement, this.sourceId, this.key, this.value}); + SourcePreferenceStringValue( + {this.id = Isar.autoIncrement, this.sourceId, this.key, this.value}); } diff --git a/lib/ffi/generated_bindings.dart b/lib/ffi/generated_bindings.dart index 9fa8f51..e75739d 100644 --- a/lib/ffi/generated_bindings.dart +++ b/lib/ffi/generated_bindings.dart @@ -13,13 +13,17 @@ import 'dart:ffi' as ffi; /// Bindings to `lib/ffi/libmtorrentserver.h`. class TorrentLibrary { /// Holds the symbol lookup function. - final ffi.Pointer Function(String symbolName) _lookup; + final ffi.Pointer Function(String symbolName) + _lookup; /// The symbols are looked up in [dynamicLibrary]. - TorrentLibrary(ffi.DynamicLibrary dynamicLibrary) : _lookup = dynamicLibrary.lookup; + TorrentLibrary(ffi.DynamicLibrary dynamicLibrary) + : _lookup = dynamicLibrary.lookup; /// The symbols are looked up with [lookup]. - TorrentLibrary.fromLookup(ffi.Pointer Function(String symbolName) lookup) + TorrentLibrary.fromLookup( + ffi.Pointer Function(String symbolName) + lookup) : _lookup = lookup; void __va_start( @@ -30,15 +34,21 @@ class TorrentLibrary { ); } - late final ___va_startPtr = _lookup)>>('__va_start'); - late final ___va_start = ___va_startPtr.asFunction)>(); + late final ___va_startPtr = + _lookup)>>( + '__va_start'); + late final ___va_start = + ___va_startPtr.asFunction)>(); void __security_init_cookie() { return ___security_init_cookie(); } - late final ___security_init_cookiePtr = _lookup>('__security_init_cookie'); - late final ___security_init_cookie = ___security_init_cookiePtr.asFunction(); + late final ___security_init_cookiePtr = + _lookup>( + '__security_init_cookie'); + late final ___security_init_cookie = + ___security_init_cookiePtr.asFunction(); void __security_check_cookie( int _StackCookie, @@ -49,8 +59,10 @@ class TorrentLibrary { } late final ___security_check_cookiePtr = - _lookup>('__security_check_cookie'); - late final ___security_check_cookie = ___security_check_cookiePtr.asFunction(); + _lookup>( + '__security_check_cookie'); + late final ___security_check_cookie = + ___security_check_cookiePtr.asFunction(); void __report_gsfailure( int _StackCookie, @@ -60,10 +72,14 @@ class TorrentLibrary { ); } - late final ___report_gsfailurePtr = _lookup>('__report_gsfailure'); - late final ___report_gsfailure = ___report_gsfailurePtr.asFunction(); + late final ___report_gsfailurePtr = + _lookup>( + '__report_gsfailure'); + late final ___report_gsfailure = + ___report_gsfailurePtr.asFunction(); - late final ffi.Pointer ___security_cookie = _lookup('__security_cookie'); + late final ffi.Pointer ___security_cookie = + _lookup('__security_cookie'); int get __security_cookie => ___security_cookie.value; @@ -74,16 +90,20 @@ class TorrentLibrary { } late final __invalid_parameter_noinfoPtr = - _lookup>('_invalid_parameter_noinfo'); - late final __invalid_parameter_noinfo = __invalid_parameter_noinfoPtr.asFunction(); + _lookup>( + '_invalid_parameter_noinfo'); + late final __invalid_parameter_noinfo = + __invalid_parameter_noinfoPtr.asFunction(); void _invalid_parameter_noinfo_noreturn() { return __invalid_parameter_noinfo_noreturn(); } late final __invalid_parameter_noinfo_noreturnPtr = - _lookup>('_invalid_parameter_noinfo_noreturn'); - late final __invalid_parameter_noinfo_noreturn = __invalid_parameter_noinfo_noreturnPtr.asFunction(); + _lookup>( + '_invalid_parameter_noinfo_noreturn'); + late final __invalid_parameter_noinfo_noreturn = + __invalid_parameter_noinfo_noreturnPtr.asFunction(); void _invoke_watson( ffi.Pointer _Expression, @@ -103,16 +123,22 @@ class TorrentLibrary { late final __invoke_watsonPtr = _lookup< ffi.NativeFunction< - ffi.Void Function(ffi.Pointer, ffi.Pointer, ffi.Pointer, ffi.UnsignedInt, + ffi.Void Function( + ffi.Pointer, + ffi.Pointer, + ffi.Pointer, + ffi.UnsignedInt, ffi.UintPtr)>>('_invoke_watson'); - late final __invoke_watson = __invoke_watsonPtr - .asFunction, ffi.Pointer, ffi.Pointer, int, int)>(); + late final __invoke_watson = __invoke_watsonPtr.asFunction< + void Function(ffi.Pointer, ffi.Pointer, + ffi.Pointer, int, int)>(); ffi.Pointer _errno() { return __errno(); } - late final __errnoPtr = _lookup Function()>>('_errno'); + late final __errnoPtr = + _lookup Function()>>('_errno'); late final __errno = __errnoPtr.asFunction Function()>(); int _set_errno( @@ -123,7 +149,8 @@ class TorrentLibrary { ); } - late final __set_errnoPtr = _lookup>('_set_errno'); + late final __set_errnoPtr = + _lookup>('_set_errno'); late final __set_errno = __set_errnoPtr.asFunction(); int _get_errno( @@ -134,21 +161,26 @@ class TorrentLibrary { ); } - late final __get_errnoPtr = _lookup)>>('_get_errno'); - late final __get_errno = __get_errnoPtr.asFunction)>(); + late final __get_errnoPtr = + _lookup)>>( + '_get_errno'); + late final __get_errno = + __get_errnoPtr.asFunction)>(); int __threadid() { return ___threadid(); } - late final ___threadidPtr = _lookup>('__threadid'); + late final ___threadidPtr = + _lookup>('__threadid'); late final ___threadid = ___threadidPtr.asFunction(); int __threadhandle() { return ___threadhandle(); } - late final ___threadhandlePtr = _lookup>('__threadhandle'); + late final ___threadhandlePtr = + _lookup>('__threadhandle'); late final ___threadhandle = ___threadhandlePtr.asFunction(); double cabs( @@ -159,7 +191,8 @@ class TorrentLibrary { ); } - late final _cabsPtr = _lookup>('cabs'); + late final _cabsPtr = + _lookup>('cabs'); late final _cabs = _cabsPtr.asFunction(); _Dcomplex cacos( @@ -170,7 +203,8 @@ class TorrentLibrary { ); } - late final _cacosPtr = _lookup>('cacos'); + late final _cacosPtr = + _lookup>('cacos'); late final _cacos = _cacosPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex cacosh( @@ -181,7 +215,8 @@ class TorrentLibrary { ); } - late final _cacoshPtr = _lookup>('cacosh'); + late final _cacoshPtr = + _lookup>('cacosh'); late final _cacosh = _cacoshPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); double carg( @@ -192,7 +227,8 @@ class TorrentLibrary { ); } - late final _cargPtr = _lookup>('carg'); + late final _cargPtr = + _lookup>('carg'); late final _carg = _cargPtr.asFunction(); _Dcomplex casin( @@ -203,7 +239,8 @@ class TorrentLibrary { ); } - late final _casinPtr = _lookup>('casin'); + late final _casinPtr = + _lookup>('casin'); late final _casin = _casinPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex casinh( @@ -214,7 +251,8 @@ class TorrentLibrary { ); } - late final _casinhPtr = _lookup>('casinh'); + late final _casinhPtr = + _lookup>('casinh'); late final _casinh = _casinhPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex catan( @@ -225,7 +263,8 @@ class TorrentLibrary { ); } - late final _catanPtr = _lookup>('catan'); + late final _catanPtr = + _lookup>('catan'); late final _catan = _catanPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex catanh( @@ -236,7 +275,8 @@ class TorrentLibrary { ); } - late final _catanhPtr = _lookup>('catanh'); + late final _catanhPtr = + _lookup>('catanh'); late final _catanh = _catanhPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex ccos( @@ -247,7 +287,8 @@ class TorrentLibrary { ); } - late final _ccosPtr = _lookup>('ccos'); + late final _ccosPtr = + _lookup>('ccos'); late final _ccos = _ccosPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex ccosh( @@ -258,7 +299,8 @@ class TorrentLibrary { ); } - late final _ccoshPtr = _lookup>('ccosh'); + late final _ccoshPtr = + _lookup>('ccosh'); late final _ccosh = _ccoshPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex cexp( @@ -269,7 +311,8 @@ class TorrentLibrary { ); } - late final _cexpPtr = _lookup>('cexp'); + late final _cexpPtr = + _lookup>('cexp'); late final _cexp = _cexpPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); double cimag( @@ -280,7 +323,8 @@ class TorrentLibrary { ); } - late final _cimagPtr = _lookup>('cimag'); + late final _cimagPtr = + _lookup>('cimag'); late final _cimag = _cimagPtr.asFunction(); _Dcomplex clog( @@ -291,7 +335,8 @@ class TorrentLibrary { ); } - late final _clogPtr = _lookup>('clog'); + late final _clogPtr = + _lookup>('clog'); late final _clog = _clogPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex clog10( @@ -302,7 +347,8 @@ class TorrentLibrary { ); } - late final _clog10Ptr = _lookup>('clog10'); + late final _clog10Ptr = + _lookup>('clog10'); late final _clog10 = _clog10Ptr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex conj( @@ -313,7 +359,8 @@ class TorrentLibrary { ); } - late final _conjPtr = _lookup>('conj'); + late final _conjPtr = + _lookup>('conj'); late final _conj = _conjPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex cpow( @@ -326,8 +373,11 @@ class TorrentLibrary { ); } - late final _cpowPtr = _lookup>('cpow'); - late final _cpow = _cpowPtr.asFunction<_Dcomplex Function(_Dcomplex, _Dcomplex)>(); + late final _cpowPtr = + _lookup>( + 'cpow'); + late final _cpow = + _cpowPtr.asFunction<_Dcomplex Function(_Dcomplex, _Dcomplex)>(); _Dcomplex cproj( _Dcomplex _Z, @@ -337,7 +387,8 @@ class TorrentLibrary { ); } - late final _cprojPtr = _lookup>('cproj'); + late final _cprojPtr = + _lookup>('cproj'); late final _cproj = _cprojPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); double creal( @@ -348,7 +399,8 @@ class TorrentLibrary { ); } - late final _crealPtr = _lookup>('creal'); + late final _crealPtr = + _lookup>('creal'); late final _creal = _crealPtr.asFunction(); _Dcomplex csin( @@ -359,7 +411,8 @@ class TorrentLibrary { ); } - late final _csinPtr = _lookup>('csin'); + late final _csinPtr = + _lookup>('csin'); late final _csin = _csinPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex csinh( @@ -370,7 +423,8 @@ class TorrentLibrary { ); } - late final _csinhPtr = _lookup>('csinh'); + late final _csinhPtr = + _lookup>('csinh'); late final _csinh = _csinhPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex csqrt( @@ -381,7 +435,8 @@ class TorrentLibrary { ); } - late final _csqrtPtr = _lookup>('csqrt'); + late final _csqrtPtr = + _lookup>('csqrt'); late final _csqrt = _csqrtPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex ctan( @@ -392,7 +447,8 @@ class TorrentLibrary { ); } - late final _ctanPtr = _lookup>('ctan'); + late final _ctanPtr = + _lookup>('ctan'); late final _ctan = _ctanPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); _Dcomplex ctanh( @@ -403,7 +459,8 @@ class TorrentLibrary { ); } - late final _ctanhPtr = _lookup>('ctanh'); + late final _ctanhPtr = + _lookup>('ctanh'); late final _ctanh = _ctanhPtr.asFunction<_Dcomplex Function(_Dcomplex)>(); double norm( @@ -414,7 +471,8 @@ class TorrentLibrary { ); } - late final _normPtr = _lookup>('norm'); + late final _normPtr = + _lookup>('norm'); late final _norm = _normPtr.asFunction(); double cabsf( @@ -425,7 +483,8 @@ class TorrentLibrary { ); } - late final _cabsfPtr = _lookup>('cabsf'); + late final _cabsfPtr = + _lookup>('cabsf'); late final _cabsf = _cabsfPtr.asFunction(); _Fcomplex cacosf( @@ -436,7 +495,8 @@ class TorrentLibrary { ); } - late final _cacosfPtr = _lookup>('cacosf'); + late final _cacosfPtr = + _lookup>('cacosf'); late final _cacosf = _cacosfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex cacoshf( @@ -447,7 +507,8 @@ class TorrentLibrary { ); } - late final _cacoshfPtr = _lookup>('cacoshf'); + late final _cacoshfPtr = + _lookup>('cacoshf'); late final _cacoshf = _cacoshfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); double cargf( @@ -458,7 +519,8 @@ class TorrentLibrary { ); } - late final _cargfPtr = _lookup>('cargf'); + late final _cargfPtr = + _lookup>('cargf'); late final _cargf = _cargfPtr.asFunction(); _Fcomplex casinf( @@ -469,7 +531,8 @@ class TorrentLibrary { ); } - late final _casinfPtr = _lookup>('casinf'); + late final _casinfPtr = + _lookup>('casinf'); late final _casinf = _casinfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex casinhf( @@ -480,7 +543,8 @@ class TorrentLibrary { ); } - late final _casinhfPtr = _lookup>('casinhf'); + late final _casinhfPtr = + _lookup>('casinhf'); late final _casinhf = _casinhfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex catanf( @@ -491,7 +555,8 @@ class TorrentLibrary { ); } - late final _catanfPtr = _lookup>('catanf'); + late final _catanfPtr = + _lookup>('catanf'); late final _catanf = _catanfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex catanhf( @@ -502,7 +567,8 @@ class TorrentLibrary { ); } - late final _catanhfPtr = _lookup>('catanhf'); + late final _catanhfPtr = + _lookup>('catanhf'); late final _catanhf = _catanhfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex ccosf( @@ -513,7 +579,8 @@ class TorrentLibrary { ); } - late final _ccosfPtr = _lookup>('ccosf'); + late final _ccosfPtr = + _lookup>('ccosf'); late final _ccosf = _ccosfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex ccoshf( @@ -524,7 +591,8 @@ class TorrentLibrary { ); } - late final _ccoshfPtr = _lookup>('ccoshf'); + late final _ccoshfPtr = + _lookup>('ccoshf'); late final _ccoshf = _ccoshfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex cexpf( @@ -535,7 +603,8 @@ class TorrentLibrary { ); } - late final _cexpfPtr = _lookup>('cexpf'); + late final _cexpfPtr = + _lookup>('cexpf'); late final _cexpf = _cexpfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); double cimagf( @@ -546,7 +615,8 @@ class TorrentLibrary { ); } - late final _cimagfPtr = _lookup>('cimagf'); + late final _cimagfPtr = + _lookup>('cimagf'); late final _cimagf = _cimagfPtr.asFunction(); _Fcomplex clogf( @@ -557,7 +627,8 @@ class TorrentLibrary { ); } - late final _clogfPtr = _lookup>('clogf'); + late final _clogfPtr = + _lookup>('clogf'); late final _clogf = _clogfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex clog10f( @@ -568,7 +639,8 @@ class TorrentLibrary { ); } - late final _clog10fPtr = _lookup>('clog10f'); + late final _clog10fPtr = + _lookup>('clog10f'); late final _clog10f = _clog10fPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex conjf( @@ -579,7 +651,8 @@ class TorrentLibrary { ); } - late final _conjfPtr = _lookup>('conjf'); + late final _conjfPtr = + _lookup>('conjf'); late final _conjf = _conjfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex cpowf( @@ -592,8 +665,11 @@ class TorrentLibrary { ); } - late final _cpowfPtr = _lookup>('cpowf'); - late final _cpowf = _cpowfPtr.asFunction<_Fcomplex Function(_Fcomplex, _Fcomplex)>(); + late final _cpowfPtr = + _lookup>( + 'cpowf'); + late final _cpowf = + _cpowfPtr.asFunction<_Fcomplex Function(_Fcomplex, _Fcomplex)>(); _Fcomplex cprojf( _Fcomplex _Z, @@ -603,7 +679,8 @@ class TorrentLibrary { ); } - late final _cprojfPtr = _lookup>('cprojf'); + late final _cprojfPtr = + _lookup>('cprojf'); late final _cprojf = _cprojfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); double crealf( @@ -614,7 +691,8 @@ class TorrentLibrary { ); } - late final _crealfPtr = _lookup>('crealf'); + late final _crealfPtr = + _lookup>('crealf'); late final _crealf = _crealfPtr.asFunction(); _Fcomplex csinf( @@ -625,7 +703,8 @@ class TorrentLibrary { ); } - late final _csinfPtr = _lookup>('csinf'); + late final _csinfPtr = + _lookup>('csinf'); late final _csinf = _csinfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex csinhf( @@ -636,7 +715,8 @@ class TorrentLibrary { ); } - late final _csinhfPtr = _lookup>('csinhf'); + late final _csinhfPtr = + _lookup>('csinhf'); late final _csinhf = _csinhfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex csqrtf( @@ -647,7 +727,8 @@ class TorrentLibrary { ); } - late final _csqrtfPtr = _lookup>('csqrtf'); + late final _csqrtfPtr = + _lookup>('csqrtf'); late final _csqrtf = _csqrtfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex ctanf( @@ -658,7 +739,8 @@ class TorrentLibrary { ); } - late final _ctanfPtr = _lookup>('ctanf'); + late final _ctanfPtr = + _lookup>('ctanf'); late final _ctanf = _ctanfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); _Fcomplex ctanhf( @@ -669,7 +751,8 @@ class TorrentLibrary { ); } - late final _ctanhfPtr = _lookup>('ctanhf'); + late final _ctanhfPtr = + _lookup>('ctanhf'); late final _ctanhf = _ctanhfPtr.asFunction<_Fcomplex Function(_Fcomplex)>(); double normf( @@ -680,7 +763,8 @@ class TorrentLibrary { ); } - late final _normfPtr = _lookup>('normf'); + late final _normfPtr = + _lookup>('normf'); late final _normf = _normfPtr.asFunction(); _Dcomplex _Cbuild( @@ -693,8 +777,11 @@ class TorrentLibrary { ); } - late final __CbuildPtr = _lookup>('_Cbuild'); - late final __Cbuild = __CbuildPtr.asFunction<_Dcomplex Function(double, double)>(); + late final __CbuildPtr = + _lookup>( + '_Cbuild'); + late final __Cbuild = + __CbuildPtr.asFunction<_Dcomplex Function(double, double)>(); _Dcomplex _Cmulcc( _Dcomplex _X, @@ -706,8 +793,11 @@ class TorrentLibrary { ); } - late final __CmulccPtr = _lookup>('_Cmulcc'); - late final __Cmulcc = __CmulccPtr.asFunction<_Dcomplex Function(_Dcomplex, _Dcomplex)>(); + late final __CmulccPtr = + _lookup>( + '_Cmulcc'); + late final __Cmulcc = + __CmulccPtr.asFunction<_Dcomplex Function(_Dcomplex, _Dcomplex)>(); _Dcomplex _Cmulcr( _Dcomplex _X, @@ -719,8 +809,11 @@ class TorrentLibrary { ); } - late final __CmulcrPtr = _lookup>('_Cmulcr'); - late final __Cmulcr = __CmulcrPtr.asFunction<_Dcomplex Function(_Dcomplex, double)>(); + late final __CmulcrPtr = + _lookup>( + '_Cmulcr'); + late final __Cmulcr = + __CmulcrPtr.asFunction<_Dcomplex Function(_Dcomplex, double)>(); _Fcomplex _FCbuild( double _Re, @@ -732,8 +825,11 @@ class TorrentLibrary { ); } - late final __FCbuildPtr = _lookup>('_FCbuild'); - late final __FCbuild = __FCbuildPtr.asFunction<_Fcomplex Function(double, double)>(); + late final __FCbuildPtr = + _lookup>( + '_FCbuild'); + late final __FCbuild = + __FCbuildPtr.asFunction<_Fcomplex Function(double, double)>(); _Fcomplex _FCmulcc( _Fcomplex _X, @@ -745,8 +841,11 @@ class TorrentLibrary { ); } - late final __FCmulccPtr = _lookup>('_FCmulcc'); - late final __FCmulcc = __FCmulccPtr.asFunction<_Fcomplex Function(_Fcomplex, _Fcomplex)>(); + late final __FCmulccPtr = + _lookup>( + '_FCmulcc'); + late final __FCmulcc = + __FCmulccPtr.asFunction<_Fcomplex Function(_Fcomplex, _Fcomplex)>(); _Fcomplex _FCmulcr( _Fcomplex _X, @@ -758,8 +857,11 @@ class TorrentLibrary { ); } - late final __FCmulcrPtr = _lookup>('_FCmulcr'); - late final __FCmulcr = __FCmulcrPtr.asFunction<_Fcomplex Function(_Fcomplex, double)>(); + late final __FCmulcrPtr = + _lookup>( + '_FCmulcr'); + late final __FCmulcr = + __FCmulcrPtr.asFunction<_Fcomplex Function(_Fcomplex, double)>(); Start_return Start( ffi.Pointer mcfg, @@ -769,8 +871,11 @@ class TorrentLibrary { ); } - late final _StartPtr = _lookup)>>('Start'); - late final _Start = _StartPtr.asFunction)>(); + late final _StartPtr = + _lookup)>>( + 'Start'); + late final _Start = + _StartPtr.asFunction)>(); } typedef va_list = ffi.Pointer; diff --git a/lib/main.dart b/lib/main.dart index f0b323b..dcb5051 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -47,7 +47,8 @@ void main(List args) async { 'Failed to find an installed WebView2 runtime or non-stable Microsoft Edge installation.'); final document = await getApplicationDocumentsDirectory(); webViewEnvironment = await WebViewEnvironment.create( - settings: WebViewEnvironmentSettings(userDataFolder: p.join(document.path, 'flutter_inappwebview'))); + settings: WebViewEnvironmentSettings( + userDataFolder: p.join(document.path, 'flutter_inappwebview'))); } isar = await StorageProvider().initDB(null, inspector: kDebugMode); await StorageProvider().requestPermission(); diff --git a/lib/models/category.dart b/lib/models/category.dart index 87693a1..fddee08 100644 --- a/lib/models/category.dart +++ b/lib/models/category.dart @@ -7,7 +7,10 @@ class Category { Id? id; String? name; bool? forManga; - Category({this.id = Isar.autoIncrement, required this.name, required this.forManga}); + Category( + {this.id = Isar.autoIncrement, + required this.name, + required this.forManga}); Category.fromJson(Map json) { id = json['id']; @@ -15,5 +18,6 @@ class Category { forManga = json['forManga']; } - Map toJson() => {'id': id, 'name': name, 'forManga': forManga}; + Map toJson() => + {'id': id, 'name': name, 'forManga': forManga}; } diff --git a/lib/models/changed_items.dart b/lib/models/changed_items.dart index bd0075e..60555df 100644 --- a/lib/models/changed_items.dart +++ b/lib/models/changed_items.dart @@ -48,7 +48,13 @@ class UpdatedChapter { bool? isRead; String? lastPageRead; bool? deleted; - UpdatedChapter({this.chapterId, this.mangaId, this.isBookmarked, this.isRead, this.lastPageRead, this.deleted}); + UpdatedChapter( + {this.chapterId, + this.mangaId, + this.isBookmarked, + this.isRead, + this.lastPageRead, + this.deleted}); UpdatedChapter.fromJson(Map json) { chapterId = json['chapterId']; mangaId = json['mangaId']; diff --git a/lib/models/history.dart b/lib/models/history.dart index a4f68a0..5bf3dc8 100644 --- a/lib/models/history.dart +++ b/lib/models/history.dart @@ -33,6 +33,11 @@ class History { mangaId = json['mangaId']; } - Map toJson() => - {'chapterId': chapterId, 'date': date, 'id': id, 'isManga': isManga, 'mangaId': mangaId}; + Map toJson() => { + 'chapterId': chapterId, + 'date': date, + 'id': id, + 'isManga': isManga, + 'mangaId': mangaId + }; } diff --git a/lib/models/manga.dart b/lib/models/manga.dart index 9228b61..19b0593 100644 --- a/lib/models/manga.dart +++ b/lib/models/manga.dart @@ -118,4 +118,11 @@ class Manga { }; } -enum Status { ongoing, completed, canceled, unknown, onHiatus, publishingFinished } +enum Status { + ongoing, + completed, + canceled, + unknown, + onHiatus, + publishingFinished +} diff --git a/lib/models/settings.dart b/lib/models/settings.dart index 3efe786..22f03e9 100644 --- a/lib/models/settings.dart +++ b/lib/models/settings.dart @@ -280,45 +280,62 @@ class Settings { Settings.fromJson(Map json) { animatePageTransitions = json['animatePageTransitions']; - animeDisplayType = DisplayType.values[json['animeDisplayType'] ?? DisplayType.compactGrid.index]; + animeDisplayType = DisplayType + .values[json['animeDisplayType'] ?? DisplayType.compactGrid.index]; animeLibraryDownloadedChapters = json['animeLibraryDownloadedChapters']; animeLibraryLocalSource = json['animeLibraryLocalSource']; animeLibraryShowCategoryTabs = json['animeLibraryShowCategoryTabs']; - animeLibraryShowContinueReadingButton = json['animeLibraryShowContinueReadingButton']; + animeLibraryShowContinueReadingButton = + json['animeLibraryShowContinueReadingButton']; animeLibraryShowLanguage = json['animeLibraryShowLanguage']; animeLibraryShowNumbersOfItems = json['animeLibraryShowNumbersOfItems']; autoExtensionsUpdates = json['autoExtensionsUpdates']; - backgroundColor = BackgroundColor.values[json['backgroundColor'] ?? BackgroundColor.black.index]; + backgroundColor = BackgroundColor + .values[json['backgroundColor'] ?? BackgroundColor.black.index]; if (json['chapterFilterBookmarkedList'] != null) { chapterFilterBookmarkedList = - (json['chapterFilterBookmarkedList'] as List).map((e) => ChapterFilterBookmarked.fromJson(e)).toList(); + (json['chapterFilterBookmarkedList'] as List) + .map((e) => ChapterFilterBookmarked.fromJson(e)) + .toList(); } if (json['chapterFilterDownloadedList'] != null) { chapterFilterDownloadedList = - (json['chapterFilterDownloadedList'] as List).map((e) => ChapterFilterDownloaded.fromJson(e)).toList(); + (json['chapterFilterDownloadedList'] as List) + .map((e) => ChapterFilterDownloaded.fromJson(e)) + .toList(); } if (json['chapterFilterUnreadList'] != null) { - chapterFilterUnreadList = - (json['chapterFilterUnreadList'] as List).map((e) => ChapterFilterUnread.fromJson(e)).toList(); + chapterFilterUnreadList = (json['chapterFilterUnreadList'] as List) + .map((e) => ChapterFilterUnread.fromJson(e)) + .toList(); } if (json['chapterPageIndexList'] != null) { - chapterPageIndexList = (json['chapterPageIndexList'] as List).map((e) => ChapterPageIndex.fromJson(e)).toList(); + chapterPageIndexList = (json['chapterPageIndexList'] as List) + .map((e) => ChapterPageIndex.fromJson(e)) + .toList(); } if (json['chapterPageUrlsList'] != null) { - chapterPageUrlsList = (json['chapterPageUrlsList'] as List).map((e) => ChapterPageurls.fromJson(e)).toList(); + chapterPageUrlsList = (json['chapterPageUrlsList'] as List) + .map((e) => ChapterPageurls.fromJson(e)) + .toList(); } checkForExtensionUpdates = json['checkForExtensionUpdates']; if (json['cookiesList'] != null) { - cookiesList = (json['cookiesList'] as List).map((e) => MCookie.fromJson(e)).toList(); + cookiesList = (json['cookiesList'] as List) + .map((e) => MCookie.fromJson(e)) + .toList(); } cropBorders = json['cropBorders']; dateFormat = json['dateFormat']; - defaultReaderMode = ReaderMode.values[json['defaultReaderMode'] ?? ReaderMode.vertical.index]; + defaultReaderMode = ReaderMode + .values[json['defaultReaderMode'] ?? ReaderMode.vertical.index]; displayType = DisplayType.values[json['displayType']]; doubleTapAnimationSpeed = json['doubleTapAnimationSpeed']; downloadLocation = json['downloadLocation']; downloadOnlyOnWifi = json['downloadOnlyOnWifi']; - filterScanlatorList = (json['filterScanlatorList'] as List?)?.map((e) => FilterScanlator.fromJson(e)).toList(); + filterScanlatorList = (json['filterScanlatorList'] as List?) + ?.map((e) => FilterScanlator.fromJson(e)) + .toList(); flexColorSchemeBlendLevel = json['flexColorSchemeBlendLevel'] is double ? json['flexColorSchemeBlendLevel'] : (json['flexColorSchemeBlendLevel'] as int).toDouble(); @@ -330,7 +347,8 @@ class Settings { libraryFilterAnimeDownloadType = json['libraryFilterAnimeDownloadType']; libraryFilterAnimeStartedType = json['libraryFilterAnimeStartedType']; libraryFilterAnimeUnreadType = json['libraryFilterAnimeUnreadType']; - libraryFilterMangasBookMarkedType = json['libraryFilterMangasBookMarkedType']; + libraryFilterMangasBookMarkedType = + json['libraryFilterMangasBookMarkedType']; libraryFilterMangasDownloadType = json['libraryFilterMangasDownloadType']; libraryFilterMangasStartedType = json['libraryFilterMangasStartedType']; libraryFilterMangasUnreadType = json['libraryFilterMangasUnreadType']; @@ -339,28 +357,41 @@ class Settings { libraryShowContinueReadingButton = json['libraryShowContinueReadingButton']; libraryShowLanguage = json['libraryShowLanguage']; libraryShowNumbersOfItems = json['libraryShowNumbersOfItems']; - locale = json['locale'] != null ? L10nLocale.fromJson(json['locale']) : null; + locale = + json['locale'] != null ? L10nLocale.fromJson(json['locale']) : null; onlyIncludePinnedSources = json['onlyIncludePinnedSources']; pagePreloadAmount = json['pagePreloadAmount']; if (json['personalPageModeList'] != null) { - personalPageModeList = (json['personalPageModeList'] as List).map((e) => PersonalPageMode.fromJson(e)).toList(); + personalPageModeList = (json['personalPageModeList'] as List) + .map((e) => PersonalPageMode.fromJson(e)) + .toList(); } if (json['personalReaderModeList'] != null) { - personalReaderModeList = - (json['personalReaderModeList'] as List).map((e) => PersonalReaderMode.fromJson(e)).toList(); + personalReaderModeList = (json['personalReaderModeList'] as List) + .map((e) => PersonalReaderMode.fromJson(e)) + .toList(); } pureBlackDarkMode = json['pureBlackDarkMode']; relativeTimesTamps = json['relativeTimesTamps']; saveAsCBZArchive = json['saveAsCBZArchive']; - scaleType = ScaleType.values[json['scaleType'] ?? ScaleType.fitScreen.index]; + scaleType = + ScaleType.values[json['scaleType'] ?? ScaleType.fitScreen.index]; showPagesNumber = json['showPagesNumber']; if (json['sortChapterList'] != null) { - sortChapterList = (json['sortChapterList'] as List).map((e) => SortChapter.fromJson(e)).toList(); + sortChapterList = (json['sortChapterList'] as List) + .map((e) => SortChapter.fromJson(e)) + .toList(); } - sortLibraryAnime = json['sortLibraryAnime'] != null ? SortLibraryManga.fromJson(json['sortLibraryAnime']) : null; - sortLibraryManga = json['sortLibraryManga'] != null ? SortLibraryManga.fromJson(json['sortLibraryManga']) : null; + sortLibraryAnime = json['sortLibraryAnime'] != null + ? SortLibraryManga.fromJson(json['sortLibraryAnime']) + : null; + sortLibraryManga = json['sortLibraryManga'] != null + ? SortLibraryManga.fromJson(json['sortLibraryManga']) + : null; if (json['autoScrollPages'] != null) { - autoScrollPages = (json['autoScrollPages'] as List).map((e) => AutoScrollPages.fromJson(e)).toList(); + autoScrollPages = (json['autoScrollPages'] as List) + .map((e) => AutoScrollPages.fromJson(e)) + .toList(); } themeIsDark = json['themeIsDark']; userAgent = json['userAgent']; @@ -384,17 +415,22 @@ class Settings { aniSkipTimeoutLength = json['aniSkipTimeoutLength']; btServerAddress = json['btServerAddress']; btServerPort = json['btServerPort']; - customColorFilter = - json['customColorFilter'] != null ? CustomColorFilter.fromJson(json['customColorFilter']) : null; + customColorFilter = json['customColorFilter'] != null + ? CustomColorFilter.fromJson(json['customColorFilter']) + : null; enableCustomColorFilter = json['enableCustomColorFilter']; - colorFilterBlendMode = ColorFilterBlendMode.values[json['colorFilterBlendMode'] ?? ColorFilterBlendMode.none]; - playerSubtitleSettings = - json['playerSubtitleSettings'] != null ? PlayerSubtitleSettings.fromJson(json['playerSubtitleSettings']) : null; - mangaHomeDisplayType = DisplayType.values[json['mangaHomeDisplayType'] ?? DisplayType.comfortableGrid.index]; + colorFilterBlendMode = ColorFilterBlendMode + .values[json['colorFilterBlendMode'] ?? ColorFilterBlendMode.none]; + playerSubtitleSettings = json['playerSubtitleSettings'] != null + ? PlayerSubtitleSettings.fromJson(json['playerSubtitleSettings']) + : null; + mangaHomeDisplayType = DisplayType.values[ + json['mangaHomeDisplayType'] ?? DisplayType.comfortableGrid.index]; appFontFamily = json['appFontFamily']; mangaGridSize = json['mangaGridSize']; animeGridSize = json['animeGridSize']; - disableSectionType = SectionType.values[json['disableSectionType'] ?? SectionType.all]; + disableSectionType = + SectionType.values[json['disableSectionType'] ?? SectionType.all]; useLibass = json['useLibass']; } @@ -404,16 +440,22 @@ class Settings { 'animeLibraryDownloadedChapters': animeLibraryDownloadedChapters, 'animeLibraryLocalSource': animeLibraryLocalSource, 'animeLibraryShowCategoryTabs': animeLibraryShowCategoryTabs, - 'animeLibraryShowContinueReadingButton': animeLibraryShowContinueReadingButton, + 'animeLibraryShowContinueReadingButton': + animeLibraryShowContinueReadingButton, 'animeLibraryShowLanguage': animeLibraryShowLanguage, 'animeLibraryShowNumbersOfItems': animeLibraryShowNumbersOfItems, 'autoExtensionsUpdates': autoExtensionsUpdates, 'backgroundColor': backgroundColor.index, - 'chapterFilterBookmarkedList': chapterFilterBookmarkedList?.map((v) => v.toJson()).toList(), - 'chapterFilterDownloadedList': chapterFilterDownloadedList?.map((v) => v.toJson()).toList(), - 'chapterFilterUnreadList': chapterFilterUnreadList?.map((v) => v.toJson()).toList(), - 'chapterPageIndexList': chapterPageIndexList?.map((v) => v.toJson()).toList(), - 'chapterPageUrlsList': chapterPageUrlsList?.map((v) => v.toJson()).toList(), + 'chapterFilterBookmarkedList': + chapterFilterBookmarkedList?.map((v) => v.toJson()).toList(), + 'chapterFilterDownloadedList': + chapterFilterDownloadedList?.map((v) => v.toJson()).toList(), + 'chapterFilterUnreadList': + chapterFilterUnreadList?.map((v) => v.toJson()).toList(), + 'chapterPageIndexList': + chapterPageIndexList?.map((v) => v.toJson()).toList(), + 'chapterPageUrlsList': + chapterPageUrlsList?.map((v) => v.toJson()).toList(), 'checkForExtensionUpdates': checkForExtensionUpdates, 'cookiesList': cookiesList, 'cropBorders': cropBorders, @@ -445,8 +487,10 @@ class Settings { 'locale': locale?.toJson(), 'onlyIncludePinnedSources': onlyIncludePinnedSources, 'pagePreloadAmount': pagePreloadAmount, - 'personalPageModeList': personalPageModeList?.map((v) => v.toJson()).toList(), - 'personalReaderModeList': personalReaderModeList?.map((v) => v.toJson()).toList(), + 'personalPageModeList': + personalPageModeList?.map((v) => v.toJson()).toList(), + 'personalReaderModeList': + personalReaderModeList?.map((v) => v.toJson()).toList(), 'pureBlackDarkMode': pureBlackDarkMode, 'relativeTimesTamps': relativeTimesTamps, 'saveAsCBZArchive': saveAsCBZArchive, @@ -477,10 +521,12 @@ class Settings { 'btServerAddress': btServerAddress, 'btServerPort': btServerPort, 'fullScreenReader': fullScreenReader, - if (customColorFilter != null) 'customColorFilter': customColorFilter!.toJson(), + if (customColorFilter != null) + 'customColorFilter': customColorFilter!.toJson(), 'enableCustomColorFilter': enableCustomColorFilter, 'colorFilterBlendMode': colorFilterBlendMode.index, - if (playerSubtitleSettings != null) 'playerSubtitleSettings': playerSubtitleSettings!.toJson(), + if (playerSubtitleSettings != null) + 'playerSubtitleSettings': playerSubtitleSettings!.toJson(), 'mangaHomeDisplayType': mangaHomeDisplayType.index, 'appFontFamily': appFontFamily, 'mangaGridSize': mangaGridSize, @@ -549,7 +595,8 @@ class SortChapter { reverse = json['reverse']; } - Map toJson() => {'index': index, 'mangaId': mangaId, 'reverse': reverse}; + Map toJson() => + {'index': index, 'mangaId': mangaId, 'reverse': reverse}; } @embedded @@ -604,7 +651,8 @@ class ChapterPageurls { urls = json['headers']?.cast(); } - Map toJson() => {'chapterId': chapterId, 'urls': urls, 'headers': headers}; + Map toJson() => + {'chapterId': chapterId, 'urls': urls, 'headers': headers}; } @embedded @@ -634,7 +682,8 @@ class PersonalReaderMode { readerMode = ReaderMode.values[json['readerMode']]; } - Map toJson() => {'mangaId': mangaId, 'readerMode': readerMode.index}; + Map toJson() => + {'mangaId': mangaId, 'readerMode': readerMode.index}; } @embedded @@ -642,7 +691,8 @@ class AutoScrollPages { int? mangaId; double? pageOffset; bool? autoScroll; - AutoScrollPages({this.mangaId, this.pageOffset = 10, this.autoScroll = false}); + AutoScrollPages( + {this.mangaId, this.pageOffset = 10, this.autoScroll = false}); AutoScrollPages.fromJson(Map json) { mangaId = json['mangaId']; @@ -650,7 +700,8 @@ class AutoScrollPages { autoScroll = json['autoScroll']; } - Map toJson() => {'mangaId': mangaId, 'pageOffset': pageOffset, 'autoScroll': autoScroll}; + Map toJson() => + {'mangaId': mangaId, 'pageOffset': pageOffset, 'autoScroll': autoScroll}; } @embedded @@ -666,10 +717,18 @@ class PersonalPageMode { pageMode = PageMode.values[json['pageMode']]; } - Map toJson() => {'mangaId': mangaId, 'pageMode': pageMode.index}; + Map toJson() => + {'mangaId': mangaId, 'pageMode': pageMode.index}; } -enum ReaderMode { vertical, ltr, rtl, verticalContinuous, webtoon, horizontalContinuous } +enum ReaderMode { + vertical, + ltr, + rtl, + verticalContinuous, + webtoon, + horizontalContinuous +} enum PageMode { onePage, doublePage } @@ -684,7 +743,8 @@ class FilterScanlator { scanlators = json['scanlators']?.cast(); } - Map toJson() => {'mangaId': mangaId, 'scanlators': scanlators}; + Map toJson() => + {'mangaId': mangaId, 'scanlators': scanlators}; } @embedded @@ -698,7 +758,8 @@ class L10nLocale { languageCode = json['languageCode']; } - Map toJson() => {'countryCode': countryCode, 'languageCode': languageCode}; + Map toJson() => + {'countryCode': countryCode, 'languageCode': languageCode}; } @embedded diff --git a/lib/models/source.dart b/lib/models/source.dart index d71f76d..e3cb05a 100644 --- a/lib/models/source.dart +++ b/lib/models/source.dart @@ -115,7 +115,8 @@ class Source { additionalParams = json['additionalParams'] ?? ""; isObsolete = json['isObsolete']; isLocal = json['isLocal']; - sourceCodeLanguage = SourceCodeLanguage.values[json['sourceCodeLanguage'] ?? 0]; + sourceCodeLanguage = + SourceCodeLanguage.values[json['sourceCodeLanguage'] ?? 0]; } Map toJson() => { diff --git a/lib/models/track.dart b/lib/models/track.dart index 7285b2a..49b1dbe 100644 --- a/lib/models/track.dart +++ b/lib/models/track.dart @@ -83,4 +83,14 @@ class Track { }; } -enum TrackStatus { reading, completed, onHold, dropped, planToRead, rereading, watching, planToWatch, reWatching } +enum TrackStatus { + reading, + completed, + onHold, + dropped, + planToRead, + rereading, + watching, + planToWatch, + reWatching +} diff --git a/lib/models/track_preference.dart b/lib/models/track_preference.dart index 969d16c..20ebbfb 100644 --- a/lib/models/track_preference.dart +++ b/lib/models/track_preference.dart @@ -26,5 +26,6 @@ class TrackPreference { prefs = json['prefs']; } - Map toJson() => {'syncId': syncId, 'username': username, 'oAuth': oAuth, 'prefs': prefs}; + Map toJson() => + {'syncId': syncId, 'username': username, 'oAuth': oAuth, 'prefs': prefs}; } diff --git a/lib/models/video.dart b/lib/models/video.dart index e8b78fc..5dc30c1 100644 --- a/lib/models/video.dart +++ b/lib/models/video.dart @@ -8,13 +8,20 @@ class Video { List? subtitles; List? audios; - Video(this.url, this.quality, this.originalUrl, {this.headers, this.subtitles, this.audios}); + Video(this.url, this.quality, this.originalUrl, + {this.headers, this.subtitles, this.audios}); factory Video.fromJson(Map json) { return Video( - json['url'].toString().trim(), json['quality'].toString().trim(), json['originalUrl'].toString().trim(), + json['url'].toString().trim(), + json['quality'].toString().trim(), + json['originalUrl'].toString().trim(), headers: (json['headers'] as Map?)?.toMapStringString, - subtitles: json['subtitles'] != null ? (json['subtitles'] as List).map((e) => Track.fromJson(e)).toList() : [], - audios: json['audios'] != null ? (json['audios'] as List).map((e) => Track.fromJson(e)).toList() : []); + subtitles: json['subtitles'] != null + ? (json['subtitles'] as List).map((e) => Track.fromJson(e)).toList() + : [], + audios: json['audios'] != null + ? (json['audios'] as List).map((e) => Track.fromJson(e)).toList() + : []); } Map toJson() => { 'url': url, diff --git a/lib/modules/anime/anime_player_view.dart b/lib/modules/anime/anime_player_view.dart index 0f30f84..7eb8199 100644 --- a/lib/modules/anime/anime_player_view.dart +++ b/lib/modules/anime/anime_player_view.dart @@ -50,7 +50,8 @@ class _AnimePlayerViewState extends riv.ConsumerState { for (var infoHash in _infoHashList) { MTorrentServer().removeTorrent(infoHash); } - SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values); + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, + overlays: SystemUiOverlay.values); super.dispose(); } @@ -64,13 +65,15 @@ class _AnimePlayerViewState extends riv.ConsumerState { @override Widget build(BuildContext context) { - final serversData = ref.watch(getVideoListProvider(episode: widget.episode)); + final serversData = + ref.watch(getVideoListProvider(episode: widget.episode)); SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive); return serversData.when( data: (data) { final (videos, isLocal, infoHashList) = data; _infoHashList = infoHashList; - if (videos.isEmpty && !(widget.episode.manga.value!.isLocalArchive ?? false)) { + if (videos.isEmpty && + !(widget.episode.manga.value!.isLocalArchive ?? false)) { return Scaffold( backgroundColor: Theme.of(context).scaffoldBackgroundColor, appBar: AppBar( @@ -102,7 +105,8 @@ class _AnimePlayerViewState extends riv.ConsumerState { title: const Text(''), leading: BackButton( onPressed: () { - SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values); + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, + overlays: SystemUiOverlay.values); Navigator.pop(context); }, ), @@ -120,7 +124,8 @@ class _AnimePlayerViewState extends riv.ConsumerState { leading: BackButton( color: Colors.white, onPressed: () { - SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values); + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, + overlays: SystemUiOverlay.values); Navigator.pop(context); }, ), @@ -150,18 +155,24 @@ class AnimeStreamPage extends riv.ConsumerStatefulWidget { riv.ConsumerState createState() => _AnimeStreamPageState(); } -class _AnimeStreamPageState extends riv.ConsumerState with TickerProviderStateMixin { +class _AnimeStreamPageState extends riv.ConsumerState + with TickerProviderStateMixin { late final GlobalKey _key = GlobalKey(); late final useLibass = ref.read(useLibassStateProvider); - late final Player _player = Player(configuration: PlayerConfiguration(libass: useLibass)); + late final Player _player = + Player(configuration: PlayerConfiguration(libass: useLibass)); late final VideoController _controller = VideoController(_player); - late final _streamController = ref.read(animeStreamControllerProvider(episode: widget.episode).notifier); + late final _streamController = + ref.read(animeStreamControllerProvider(episode: widget.episode).notifier); late final _firstVid = widget.videos.first; late final ValueNotifier _video = ValueNotifier(VideoPrefs( - videoTrack: VideoTrack(_firstVid.originalUrl, _firstVid.quality, _firstVid.quality), headers: _firstVid.headers)); + videoTrack: VideoTrack( + _firstVid.originalUrl, _firstVid.quality, _firstVid.quality), + headers: _firstVid.headers)); final ValueNotifier _playbackSpeed = ValueNotifier(1.0); final ValueNotifier _enterFullScreen = ValueNotifier(false); - late final ValueNotifier _currentPosition = ValueNotifier(_streamController.geTCurrentPosition()); + late final ValueNotifier _currentPosition = + ValueNotifier(_streamController.geTCurrentPosition()); final ValueNotifier _currentTotalDuration = ValueNotifier(null); final ValueNotifier _showFitLabel = ValueNotifier(false); final ValueNotifier _isCompleted = ValueNotifier(false); @@ -175,9 +186,12 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick bool _hasEndingSkip = false; bool _initSubtitleAndAudio = true; - late final StreamSubscription _currentPositionSub = _player.stream.position.listen( + late final StreamSubscription _currentPositionSub = + _player.stream.position.listen( (position) async { - _isCompleted.value = _player.state.duration.inSeconds - _currentPosition.value.inSeconds <= 10; + _isCompleted.value = + _player.state.duration.inSeconds - _currentPosition.value.inSeconds <= + 10; _currentPosition.value = position; if (_firstVid.subtitles?.isNotEmpty ?? false) { @@ -191,8 +205,10 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick } catch (_) {} try { if (_firstVid.audios?.isNotEmpty ?? false) { - _player.setAudioTrack(AudioTrack.uri(_firstVid.audios!.first.file ?? "", - title: _firstVid.audios!.first.label, language: _firstVid.audios!.first.label)); + _player.setAudioTrack(AudioTrack.uri( + _firstVid.audios!.first.file ?? "", + title: _firstVid.audios!.first.label, + language: _firstVid.audios!.first.label)); } } catch (_) {} } @@ -201,13 +217,15 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick }, ); - late final StreamSubscription _currentTotalDurationSub = _player.stream.duration.listen( + late final StreamSubscription _currentTotalDurationSub = + _player.stream.duration.listen( (duration) { _currentTotalDuration.value = duration; }, ); - late final StreamSubscription _completed = _player.stream.completed.listen((val) { + late final StreamSubscription _completed = + _player.stream.completed.listen((val) { if (_streamController.getEpisodeIndex().$1 != 0 && val == true) { if (mounted) { pushToNewEpisode(context, _streamController.getNextEpisode()); @@ -231,12 +249,14 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick _loadAndroidFont().then( (_) { _player.open(Media(_video.value!.videoTrack!.id, - httpHeaders: _video.value!.headers, start: _streamController.geTCurrentPosition())); + httpHeaders: _video.value!.headers, + start: _streamController.geTCurrentPosition())); if (widget.isTorrent) { Future.delayed(const Duration(seconds: 10)).then((_) { if (mounted) { _player.open(Media(_video.value!.videoTrack!.id, - httpHeaders: _video.value!.headers, start: _streamController.geTCurrentPosition())); + httpHeaders: _video.value!.headers, + start: _streamController.geTCurrentPosition())); } }); } @@ -253,11 +273,14 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick final subDir = await getApplicationDocumentsDirectory(); final fontPath = path.join(subDir.path, 'subfont.ttf'); final data = await rootBundle.load('assets/fonts/subfont.ttf'); - final bytes = data.buffer.asInt8List(data.offsetInBytes, data.lengthInBytes); + final bytes = + data.buffer.asInt8List(data.offsetInBytes, data.lengthInBytes); final fontFile = await File(fontPath).create(recursive: true); await fontFile.writeAsBytes(bytes); - await (_player.platform as NativePlayer).setProperty('sub-fonts-dir', subDir.path); - await (_player.platform as NativePlayer).setProperty('sub-font', 'Droid Sans Fallback'); + await (_player.platform as NativePlayer) + .setProperty('sub-fonts-dir', subDir.path); + await (_player.platform as NativePlayer) + .setProperty('sub-font', 'Droid Sans Fallback'); } catch (_) {} } } @@ -265,12 +288,14 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick void _initAniSkip() async { await _player.stream.buffer.first; _streamController.getAniSkipResults((result) { - final openingRes = result.where((element) => element.skipType == "op").toList(); + final openingRes = + result.where((element) => element.skipType == "op").toList(); _hasOpeningSkip = openingRes.isNotEmpty; if (_hasOpeningSkip) { _openingResult = openingRes.first; } - final endingRes = result.where((element) => element.skipType == "ed").toList(); + final endingRes = + result.where((element) => element.skipType == "ed").toList(); _hasEndingSkip = endingRes.isNotEmpty; if (_hasEndingSkip) { _endingResult = endingRes.first; @@ -295,14 +320,17 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick } void _setCurrentPosition(bool save) { - _streamController.setCurrentPosition(_currentPosition.value, _currentTotalDuration.value, save: save); + _streamController.setCurrentPosition( + _currentPosition.value, _currentTotalDuration.value, + save: save); _streamController.setAnimeHistoryUpdate(); _streamController.checkAndSyncProgress(); } void _setLandscapeMode(bool state) { if (state) { - SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]); + SystemChrome.setPreferredOrientations( + [DeviceOrientation.landscapeLeft, DeviceOrientation.landscapeRight]); } else { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, @@ -317,7 +345,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick children: [ Flexible( child: Padding( - padding: EdgeInsets.symmetric(horizontal: MediaQuery.of(context).padding.top), + padding: EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).padding.top), child: Text(text, style: Theme.of(context).textTheme.bodyLarge!.copyWith( fontSize: 16, @@ -331,7 +360,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick Widget _videoQualityWidget(BuildContext context) { List videoQuality = _player.state.tracks.video - .where((element) => element.w != null && element.h != null && widget.isLocal) + .where((element) => + element.w != null && element.h != null && widget.isLocal) .toList() .map((e) => VideoPrefs(videoTrack: e, isLocal: true)) .toList(); @@ -339,7 +369,9 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick if (widget.videos.isNotEmpty && !widget.isLocal) { for (var video in widget.videos) { videoQuality.add(VideoPrefs( - videoTrack: VideoTrack(video.url, video.quality, video.quality), headers: video.headers, isLocal: false)); + videoTrack: VideoTrack(video.url, video.quality, video.quality), + headers: video.headers, + isLocal: false)); } } @@ -347,21 +379,27 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 12), child: Column( children: videoQuality.map((quality) { - final selected = _video.value!.videoTrack!.title == quality.videoTrack!.title || widget.isLocal; + final selected = + _video.value!.videoTrack!.title == quality.videoTrack!.title || + widget.isLocal; return GestureDetector( - child: textWidget(widget.isLocal ? _firstVid.quality : quality.videoTrack!.title!, selected), + child: textWidget( + widget.isLocal ? _firstVid.quality : quality.videoTrack!.title!, + selected), onTap: () async { _video.value = quality; if (quality.isLocal) { if (widget.isLocal) { _player.setVideoTrack(quality.videoTrack!); } else { - _player - .open(Media(quality.videoTrack!.id, httpHeaders: quality.headers, start: _currentPosition.value)); + _player.open(Media(quality.videoTrack!.id, + httpHeaders: quality.headers, + start: _currentPosition.value)); } } else { - _player - .open(Media(quality.videoTrack!.id, httpHeaders: quality.headers, start: _currentPosition.value)); + _player.open(Media(quality.videoTrack!.id, + httpHeaders: quality.headers, + start: _currentPosition.value)); } Navigator.pop(context); }, @@ -419,8 +457,10 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick } Widget _videoSubtitle(BuildContext context, Function(bool) hasSubtitleTrack) { - List videoSubtitle = - _player.state.tracks.subtitle.toList().map((e) => VideoPrefs(isLocal: true, subtitle: e)).toList(); + List videoSubtitle = _player.state.tracks.subtitle + .toList() + .map((e) => VideoPrefs(isLocal: true, subtitle: e)) + .toList(); List subs = []; if (widget.videos.isNotEmpty && !widget.isLocal) { @@ -443,7 +483,10 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick videoSubtitle = videoSubtitle .map((e) { VideoPrefs vid = e; - vid.title = vid.subtitle?.title ?? vid.subtitle?.language ?? vid.subtitle?.channels ?? ""; + vid.title = vid.subtitle?.title ?? + vid.subtitle?.language ?? + vid.subtitle?.channels ?? + ""; return vid; }) .toList() @@ -451,11 +494,16 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick .toList(); videoSubtitle.sort((a, b) => a.title!.compareTo(b.title!)); hasSubtitleTrack.call(videoSubtitle.isNotEmpty); - videoSubtitle.insert(0, VideoPrefs(isLocal: false, subtitle: SubtitleTrack.no())); + videoSubtitle.insert( + 0, VideoPrefs(isLocal: false, subtitle: SubtitleTrack.no())); List videoSubtitleLast = []; for (var element in videoSubtitle) { final contains = videoSubtitleLast.any((sub) { - return (sub.title ?? sub.subtitle?.title ?? sub.subtitle?.language ?? sub.subtitle?.channels ?? "None") == + return (sub.title ?? + sub.subtitle?.title ?? + sub.subtitle?.language ?? + sub.subtitle?.channels ?? + "None") == (element.title ?? element.subtitle?.title ?? element.subtitle?.language ?? @@ -470,9 +518,17 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 12), child: Column( children: videoSubtitleLast.toSet().toList().map((sub) { - final title = sub.title ?? sub.subtitle?.title ?? sub.subtitle?.language ?? sub.subtitle?.channels ?? "None"; + final title = sub.title ?? + sub.subtitle?.title ?? + sub.subtitle?.language ?? + sub.subtitle?.channels ?? + "None"; - final selected = (title == (subtitle.title ?? subtitle.language ?? subtitle.channels ?? "None")) || + final selected = (title == + (subtitle.title ?? + subtitle.language ?? + subtitle.channels ?? + "None")) || (subtitle.id == "no" && title == "None"); return GestureDetector( onTap: () { @@ -489,8 +545,10 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick } Widget _videoAudios(BuildContext context) { - List videoAudio = - _player.state.tracks.audio.toList().map((e) => VideoPrefs(isLocal: true, audio: e)).toList(); + List videoAudio = _player.state.tracks.audio + .toList() + .map((e) => VideoPrefs(isLocal: true, audio: e)) + .toList(); List audios = []; if (widget.videos.isNotEmpty && !widget.isLocal) { @@ -498,7 +556,9 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick for (var audio in video.audios ?? []) { if (!audios.contains(audio.file)) { videoAudio.add(VideoPrefs( - isLocal: false, audio: AudioTrack.uri(audio.file!, title: audio.label, language: audio.label))); + isLocal: false, + audio: AudioTrack.uri(audio.file!, + title: audio.label, language: audio.label))); audios.add(audio.file!); } } @@ -508,7 +568,10 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick videoAudio = videoAudio .map((e) { VideoPrefs vid = e; - vid.title = vid.audio?.title ?? vid.audio?.language ?? vid.audio?.channels ?? ""; + vid.title = vid.audio?.title ?? + vid.audio?.language ?? + vid.audio?.channels ?? + ""; return vid; }) .toList() @@ -520,8 +583,13 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick padding: const EdgeInsets.symmetric(vertical: 15, horizontal: 12), child: Column( children: videoAudio.toSet().toList().map((aud) { - final title = aud.title ?? aud.audio?.title ?? aud.audio?.language ?? aud.audio?.channels ?? "None"; - final selected = (aud.audio == audio) || (audio.id == "no" && title == "None"); + final title = aud.title ?? + aud.audio?.title ?? + aud.audio?.language ?? + aud.audio?.channels ?? + "None"; + final selected = + (aud.audio == audio) || (audio.id == "no" && title == "None"); return GestureDetector( onTap: () { Navigator.pop(context); @@ -542,8 +610,10 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick void _togglePlaybackSpeed() { List allowedSpeeds = [0.25, 0.5, 0.75, 1.0, 1.25, 1.50, 1.75, 2.0]; - if (allowedSpeeds.indexOf(_playbackSpeed.value) < allowedSpeeds.length - 1) { - _setPlaybackSpeed(allowedSpeeds[allowedSpeeds.indexOf(_playbackSpeed.value) + 1]); + if (allowedSpeeds.indexOf(_playbackSpeed.value) < + allowedSpeeds.length - 1) { + _setPlaybackSpeed( + allowedSpeeds[allowedSpeeds.indexOf(_playbackSpeed.value) + 1]); } else { _setPlaybackSpeed(allowedSpeeds[0]); } @@ -576,20 +646,26 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick } Widget _seekToWidget() { - final defaultSkipIntroLength = ref.watch(defaultSkipIntroLengthStateProvider); + final defaultSkipIntroLength = + ref.watch(defaultSkipIntroLengthStateProvider); return Padding( padding: const EdgeInsets.symmetric(vertical: 5), child: SizedBox( height: 35, child: ElevatedButton( onPressed: () async { - _tempPosition.value = Duration(seconds: defaultSkipIntroLength + _currentPosition.value.inSeconds); - await _player.seek(Duration(seconds: _currentPosition.value.inSeconds + defaultSkipIntroLength)); + _tempPosition.value = Duration( + seconds: defaultSkipIntroLength + + _currentPosition.value.inSeconds); + await _player.seek(Duration( + seconds: _currentPosition.value.inSeconds + + defaultSkipIntroLength)); _tempPosition.value = null; }, child: Padding( padding: const EdgeInsets.all(8.0), - child: Text("+$defaultSkipIntroLength", style: const TextStyle(fontWeight: FontWeight.w100)), + child: Text("+$defaultSkipIntroLength", + style: const TextStyle(fontWeight: FontWeight.w100)), )), ), ); @@ -631,7 +707,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick _togglePlaybackSpeed(); }), IconButton( - icon: const Icon(Icons.fit_screen_outlined, color: Colors.white), + icon: const Icon(Icons.fit_screen_outlined, + color: Colors.white), onPressed: () async { _changeFitLabel(ref); }, @@ -644,7 +721,9 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick _setLandscapeMode(!snapshot); _enterFullScreen.value = !snapshot; }, - icon: Icon(snapshot ? Icons.fullscreen_exit : Icons.fullscreen), + icon: Icon(snapshot + ? Icons.fullscreen_exit + : Icons.fullscreen), iconSize: 25, color: Colors.white, ); @@ -661,7 +740,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick Widget _desktopBottomButtonBar(BuildContext context) { bool hasPrevEpisode = _streamController.getEpisodeIndex().$1 + 1 != - _streamController.getEpisodesLength(_streamController.getEpisodeIndex().$2); + _streamController + .getEpisodesLength(_streamController.getEpisodeIndex().$2); bool hasNextEpisode = _streamController.getEpisodeIndex().$1 != 0; final skipDuration = ref.watch(defaultDoubleTapToSkipLengthStateProvider); return Column( @@ -675,7 +755,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick if (hasPrevEpisode) IconButton( onPressed: () { - pushToNewEpisode(context, _streamController.getPrevEpisode()); + pushToNewEpisode( + context, _streamController.getPrevEpisode()); }, icon: const Icon( Icons.skip_previous, @@ -688,7 +769,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick if (hasNextEpisode) IconButton( onPressed: () async { - pushToNewEpisode(context, _streamController.getNextEpisode()); + pushToNewEpisode( + context, _streamController.getNextEpisode()); }, icon: const Icon(Icons.skip_next, color: Colors.white), ), @@ -697,8 +779,12 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick width: 50, child: IconButton( onPressed: () async { - _tempPosition.value = Duration(seconds: skipDuration - _currentPosition.value.inSeconds); - await _player.seek(Duration(seconds: _currentPosition.value.inSeconds - skipDuration)); + _tempPosition.value = Duration( + seconds: + skipDuration - _currentPosition.value.inSeconds); + await _player.seek(Duration( + seconds: + _currentPosition.value.inSeconds - skipDuration)); _tempPosition.value = null; }, icon: Stack( @@ -716,7 +802,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick padding: const EdgeInsets.only(top: 2), child: Text( skipDuration.toString(), - style: const TextStyle(fontSize: 9, color: Colors.white), + style: const TextStyle( + fontSize: 9, color: Colors.white), ), )), ), @@ -729,8 +816,12 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick width: 50, child: IconButton( onPressed: () async { - _tempPosition.value = Duration(seconds: skipDuration + _currentPosition.value.inSeconds); - await _player.seek(Duration(seconds: _currentPosition.value.inSeconds + skipDuration)); + _tempPosition.value = Duration( + seconds: + skipDuration + _currentPosition.value.inSeconds); + await _player.seek(Duration( + seconds: + _currentPosition.value.inSeconds + skipDuration)); _tempPosition.value = null; }, icon: Stack( @@ -748,7 +839,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick padding: const EdgeInsets.only(top: 2), child: Text( skipDuration.toString(), - style: const TextStyle(fontSize: 9, color: Colors.white), + style: const TextStyle( + fontSize: 9, color: Colors.white), ), )), ), @@ -762,7 +854,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick ValueListenableBuilder( valueListenable: _tempPosition, builder: (context, value, child) => - CustomMaterialDesktopPositionIndicator(delta: value, controller: _controller), + CustomMaterialDesktopPositionIndicator( + delta: value, controller: _controller), ) ], ), @@ -789,7 +882,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick _togglePlaybackSpeed(); }), IconButton( - icon: const Icon(Icons.fit_screen_outlined, color: Colors.white), + icon: const Icon(Icons.fit_screen_outlined, + color: Colors.white), onPressed: () async { _changeFitLabel(ref); }, @@ -810,7 +904,10 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick valueListenable: _enterFullScreen, builder: (context, fullScreen, _) { return Padding( - padding: EdgeInsets.only(top: !_isDesktop && !fullScreen ? MediaQuery.of(context).padding.top : 0), + padding: EdgeInsets.only( + top: !_isDesktop && !fullScreen + ? MediaQuery.of(context).padding.top + : 0), child: Row( children: [ BackButton( @@ -825,7 +922,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick } } } else { - SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values); + SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, + overlays: SystemUiOverlay.values); if (mounted) { Navigator.pop(context); } @@ -839,7 +937,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick width: context.width(0.8), child: Text( widget.episode.manga.value!.name!, - style: const TextStyle(fontWeight: FontWeight.bold, color: Colors.white), + style: const TextStyle( + fontWeight: FontWeight.bold, color: Colors.white), overflow: TextOverflow.ellipsis, ), ), @@ -848,7 +947,9 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick child: Text( widget.episode.name!, style: TextStyle( - fontSize: 12, fontWeight: FontWeight.w400, color: Colors.white.withValues(alpha: 0.7)), + fontSize: 12, + fontWeight: FontWeight.w400, + color: Colors.white.withValues(alpha: 0.7)), overflow: TextOverflow.ellipsis, ), ), @@ -924,7 +1025,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick void _resize(BoxFit fit) async { await Future.delayed(const Duration(milliseconds: 100)); if (mounted) { - _key.currentState?.update(fit: fit, width: context.width(1), height: context.height(1)); + _key.currentState?.update( + fit: fit, width: context.width(1), height: context.height(1)); } } @@ -934,7 +1036,8 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick return Stack( children: [ Video( - subtitleViewConfiguration: SubtitleViewConfiguration(visible: false, style: subtileTextStyle(ref)), + subtitleViewConfiguration: SubtitleViewConfiguration( + visible: false, style: subtileTextStyle(ref)), fit: fit, key: _key, controls: (state) => _isDesktop @@ -976,8 +1079,10 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick builder: (context, value, child) { if (_hasOpeningSkip || _hasEndingSkip) { if (_hasOpeningSkip) { - if (_openingResult!.interval!.startTime!.ceil() <= value.inSeconds && - _openingResult!.interval!.endTime!.toInt() > value.inSeconds) { + if (_openingResult!.interval!.startTime!.ceil() <= + value.inSeconds && + _openingResult!.interval!.endTime!.toInt() > + value.inSeconds) { _showAniSkipOpeningButton.value = true; _showAniSkipEndingButton.value = false; } else { @@ -985,8 +1090,10 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick } } if (_hasEndingSkip) { - if (_endingResult!.interval!.startTime!.ceil() <= value.inSeconds && - _endingResult!.interval!.endTime!.toInt() > value.inSeconds) { + if (_endingResult!.interval!.startTime!.ceil() <= + value.inSeconds && + _endingResult!.interval!.endTime!.toInt() > + value.inSeconds) { _showAniSkipEndingButton.value = true; _showAniSkipOpeningButton.value = false; } @@ -995,9 +1102,12 @@ class _AnimeStreamPageState extends riv.ConsumerState with Tick } } return Consumer(builder: (context, ref, _) { - late final enableAniSkip = ref.watch(enableAniSkipStateProvider); - late final enableAutoSkip = ref.watch(enableAutoSkipStateProvider); - late final aniSkipTimeoutLength = ref.watch(aniSkipTimeoutLengthStateProvider); + late final enableAniSkip = + ref.watch(enableAniSkipStateProvider); + late final enableAutoSkip = + ref.watch(enableAutoSkipStateProvider); + late final aniSkipTimeoutLength = + ref.watch(aniSkipTimeoutLengthStateProvider); return ValueListenableBuilder( valueListenable: _showAniSkipOpeningButton, builder: (context, showAniSkipOpENINGButton, child) { @@ -1055,11 +1165,13 @@ Widget seekIndicatorTextWidget(Duration duration, Duration currentPosition) { children: [ Text( Duration(seconds: value).label(), - style: const TextStyle(fontSize: 65.0, fontWeight: FontWeight.bold, color: Colors.white), + style: const TextStyle( + fontSize: 65.0, fontWeight: FontWeight.bold, color: Colors.white), ), Text( "[${swipeDuration > 0 ? "+${Duration(seconds: swipeDuration).label()}" : "-${Duration(seconds: swipeDuration).label()}"}]", - style: const TextStyle(fontSize: 40.0, color: Colors.white, fontWeight: FontWeight.bold), + style: const TextStyle( + fontSize: 40.0, color: Colors.white, fontWeight: FontWeight.bold), ), ], ); @@ -1072,5 +1184,11 @@ class VideoPrefs { AudioTrack? audio; bool isLocal; final Map? headers; - VideoPrefs({this.videoTrack, this.isLocal = true, this.headers, this.subtitle, this.audio, this.title}); + VideoPrefs( + {this.videoTrack, + this.isLocal = true, + this.headers, + this.subtitle, + this.audio, + this.title}); } diff --git a/lib/modules/anime/providers/anime_player_controller_provider.dart b/lib/modules/anime/providers/anime_player_controller_provider.dart index 5ee2975..5be1355 100644 --- a/lib/modules/anime/providers/anime_player_controller_provider.dart +++ b/lib/modules/anime/providers/anime_player_controller_provider.dart @@ -104,13 +104,17 @@ class AnimeStreamController extends _$AnimeStreamController { } int getEpisodesLength(bool isInFilterList) { - return isInFilterList ? getAnime().getFilteredChapterList().length : getAnime().chapters.length; + return isInFilterList + ? getAnime().getFilteredChapterList().length + : getAnime().chapters.length; } Duration geTCurrentPosition() { if (incognitoMode) return Duration.zero; String position = episode.lastPageRead ?? "0"; - return Duration(milliseconds: episode.isRead! ? 0 : int.parse(position.isEmpty ? "0" : position)); + return Duration( + milliseconds: + episode.isRead! ? 0 : int.parse(position.isEmpty ? "0" : position)); } void setAnimeHistoryUpdate() { @@ -122,7 +126,8 @@ class AnimeStreamController extends _$AnimeStreamController { }); History? history; - final empty = isar.historys.filter().mangaIdEqualTo(getAnime().id).isEmptySync(); + final empty = + isar.historys.filter().mangaIdEqualTo(getAnime().id).isEmptySync(); if (empty) { history = History( @@ -132,7 +137,10 @@ class AnimeStreamController extends _$AnimeStreamController { chapterId: episode.id) ..chapter.value = episode; } else { - history = (isar.historys.filter().mangaIdEqualTo(getAnime().id).findFirstSync())! + history = (isar.historys + .filter() + .mangaIdEqualTo(getAnime().id) + .findFirstSync())! ..chapterId = episode.id ..chapter.value = episode ..date = DateTime.now().millisecondsSinceEpoch.toString(); @@ -150,19 +158,25 @@ class AnimeStreamController extends _$AnimeStreamController { } } - void setCurrentPosition(Duration duration, Duration? totalDuration, {bool save = false}) { + void setCurrentPosition(Duration duration, Duration? totalDuration, + {bool save = false}) { if (episode.isRead!) return; if (incognitoMode) return; final markEpisodeAsSeenType = ref.watch(markEpisodeAsSeenTypeStateProvider); - final isWatch = totalDuration != null && totalDuration != Duration.zero && duration != Duration.zero - ? duration.inSeconds >= ((totalDuration.inSeconds * markEpisodeAsSeenType) / 100).ceil() + final isWatch = totalDuration != null && + totalDuration != Duration.zero && + duration != Duration.zero + ? duration.inSeconds >= + ((totalDuration.inSeconds * markEpisodeAsSeenType) / 100).ceil() : false; if (isWatch || save) { final ep = episode; isar.writeTxnSync(() { ep.isRead = isWatch; ep.lastPageRead = (duration.inMilliseconds).toString(); - ref.read(changedItemsManagerProvider(managerId: 1).notifier).addUpdatedChapter(ep, false, false); + ref + .read(changedItemsManagerProvider(managerId: 1).notifier) + .addUpdatedChapter(ep, false, false); isar.chapters.putSync(ep); }); if (isWatch) { @@ -172,10 +186,18 @@ class AnimeStreamController extends _$AnimeStreamController { } (int, int)? _getTrackId() { - final malId = - isar.tracks.filter().syncIdEqualTo(1).mangaIdEqualTo(episode.manga.value!.id!).findFirstSync()?.mediaId; - final aniId = - isar.tracks.filter().syncIdEqualTo(2).mangaIdEqualTo(episode.manga.value!.id!).findFirstSync()?.mediaId; + final malId = isar.tracks + .filter() + .syncIdEqualTo(1) + .mangaIdEqualTo(episode.manga.value!.id!) + .findFirstSync() + ?.mediaId; + final aniId = isar.tracks + .filter() + .syncIdEqualTo(2) + .mangaIdEqualTo(episode.manga.value!.id!) + .findFirstSync() + ?.mediaId; return switch (malId) { != null => (malId, 1), == null => switch (aniId) { != null => (aniId, 2), _ => null }, @@ -183,14 +205,17 @@ class AnimeStreamController extends _$AnimeStreamController { }; } - Future?> getAniSkipResults(Function(List) result) async { + Future?> getAniSkipResults( + Function(List) result) async { await Future.delayed(const Duration(milliseconds: 300)); if (ref.watch(enableAniSkipStateProvider)) { final id = _getTrackId(); if (id != null) { - final res = await ref - .read(aniSkipProvider.notifier) - .getResult(id, ChapterRecognition().parseChapterNumber(episode.manga.value!.name!, episode.name!), 0); + final res = await ref.read(aniSkipProvider.notifier).getResult( + id, + ChapterRecognition() + .parseChapterNumber(episode.manga.value!.name!, episode.name!), + 0); result.call(res ?? []); return res; } diff --git a/lib/modules/anime/providers/state_provider.dart b/lib/modules/anime/providers/state_provider.dart index caa6550..2972868 100644 --- a/lib/modules/anime/providers/state_provider.dart +++ b/lib/modules/anime/providers/state_provider.dart @@ -19,15 +19,21 @@ class SubtitleSettingsState extends _$SubtitleSettingsState { final settings = isar.settings.getSync(227); state = value; if (end) { - isar.writeTxnSync(() => isar.settings.putSync(settings!..playerSubtitleSettings = value)); + isar.writeTxnSync(() => + isar.settings.putSync(settings!..playerSubtitleSettings = value)); } } void resetColor() { final settings = isar.settings.getSync(227); - state = PlayerSubtitleSettings(fontSize: state.fontSize, useBold: state.useBold, useItalic: state.useItalic); + state = PlayerSubtitleSettings( + fontSize: state.fontSize, + useBold: state.useBold, + useItalic: state.useItalic); isar.writeTxnSync(() => isar.settings.putSync(settings! - ..playerSubtitleSettings = - PlayerSubtitleSettings(fontSize: state.fontSize, useBold: state.useBold, useItalic: state.useItalic))); + ..playerSubtitleSettings = PlayerSubtitleSettings( + fontSize: state.fontSize, + useBold: state.useBold, + useItalic: state.useItalic))); } } diff --git a/lib/modules/anime/widgets/aniskip_countdown_btn.dart b/lib/modules/anime/widgets/aniskip_countdown_btn.dart index 2b56ca2..7ecdfd6 100644 --- a/lib/modules/anime/widgets/aniskip_countdown_btn.dart +++ b/lib/modules/anime/widgets/aniskip_countdown_btn.dart @@ -20,14 +20,18 @@ class AniSkipCountDownButton extends ConsumerStatefulWidget { required this.timeoutLength}); @override - ConsumerState createState() => _AniSkipCountDownButtonState(); + ConsumerState createState() => + _AniSkipCountDownButtonState(); } -class _AniSkipCountDownButtonState extends ConsumerState with TickerProviderStateMixin { +class _AniSkipCountDownButtonState extends ConsumerState + with TickerProviderStateMixin { late AnimationController _controller; @override void initState() { - _controller = AnimationController(vsync: this, duration: Duration(seconds: widget.timeoutLength))..forward(); + _controller = AnimationController( + vsync: this, duration: Duration(seconds: widget.timeoutLength)) + ..forward(); super.initState(); if (widget.active) { if (widget.autoSkip) { @@ -50,7 +54,8 @@ class _AniSkipCountDownButtonState extends ConsumerState _isCompleted = true; }); _controller.reset(); - widget.player.seek(Duration(seconds: widget.aniSkipResult!.interval!.endTime!.ceil())); + widget.player.seek( + Duration(seconds: widget.aniSkipResult!.interval!.endTime!.ceil())); } bool _isCompleted = false; @@ -72,7 +77,8 @@ class _AniSkipCountDownButtonState extends ConsumerState padding: const EdgeInsets.symmetric(horizontal: 40), child: MaterialButton( padding: const EdgeInsets.all(0), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5)), onPressed: () { _seekTo(); }, @@ -103,15 +109,21 @@ class _AniSkipCountDownButtonState extends ConsumerState ), Positioned.fill( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: + const EdgeInsets.symmetric(horizontal: 10), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + mainAxisAlignment: + MainAxisAlignment.spaceAround, children: [ Text( widget.skipTypeText.toUpperCase(), - style: const TextStyle(fontWeight: FontWeight.bold), + style: const TextStyle( + fontWeight: FontWeight.bold), ), - Text((widget.timeoutLength - (_controller.duration! * _controller.value).inSeconds) + Text((widget.timeoutLength - + (_controller.duration! * + _controller.value) + .inSeconds) .toString()), ], ), diff --git a/lib/modules/anime/widgets/custom_seekbar.dart b/lib/modules/anime/widgets/custom_seekbar.dart index 2948cc1..5cc1a1a 100644 --- a/lib/modules/anime/widgets/custom_seekbar.dart +++ b/lib/modules/anime/widgets/custom_seekbar.dart @@ -10,7 +10,12 @@ class CustomSeekBar extends StatefulWidget { final Function(Duration)? onSeekStart; final Function(Duration)? onSeekEnd; - const CustomSeekBar({super.key, this.onSeekStart, this.onSeekEnd, required this.player, this.delta}); + const CustomSeekBar( + {super.key, + this.onSeekStart, + this.onSeekEnd, + required this.player, + this.delta}); @override CustomSeekBarState createState() => CustomSeekBarState(); @@ -64,7 +69,8 @@ class CustomSeekBarState extends State { width: 70, child: Center( child: Text( - (widget.delta ?? tempPosition ?? position).label(reference: duration), + (widget.delta ?? tempPosition ?? position) + .label(reference: duration), style: const TextStyle( height: 1.0, fontSize: 12.0, @@ -79,10 +85,15 @@ class CustomSeekBarState extends State { ), child: Slider( max: max(duration.inMilliseconds.toDouble(), 0), - value: max((widget.delta ?? tempPosition ?? position).inMilliseconds.toDouble(), 0), + value: max( + (widget.delta ?? tempPosition ?? position) + .inMilliseconds + .toDouble(), + 0), secondaryTrackValue: max(buffer.inMilliseconds.toDouble(), 0), onChanged: (value) { - widget.onSeekStart?.call(Duration(milliseconds: value.toInt() - position.inMilliseconds)); + widget.onSeekStart?.call(Duration( + milliseconds: value.toInt() - position.inMilliseconds)); if (mounted) { setState(() { tempPosition = Duration(milliseconds: value.toInt()); @@ -90,7 +101,8 @@ class CustomSeekBarState extends State { } }, onChangeEnd: (value) async { - widget.onSeekEnd?.call(Duration(milliseconds: value.toInt() - position.inMilliseconds)); + widget.onSeekEnd?.call(Duration( + milliseconds: value.toInt() - position.inMilliseconds)); widget.player.seek(Duration(milliseconds: value.toInt())); }, ), diff --git a/lib/modules/anime/widgets/desktop.dart b/lib/modules/anime/widgets/desktop.dart index 6005140..04faf90 100644 --- a/lib/modules/anime/widgets/desktop.dart +++ b/lib/modules/anime/widgets/desktop.dart @@ -32,7 +32,8 @@ class DesktopControllerWidget extends StatefulWidget { required this.tempDuration}); @override - State createState() => _DesktopControllerWidgetState(); + State createState() => + _DesktopControllerWidgetState(); } class _DesktopControllerWidgetState extends State { @@ -151,26 +152,36 @@ class _DesktopControllerWidgetState extends State { bindings: { // Default key-board shortcuts. // https://support.google.com/youtube/answer/7631406 - const SingleActivator(LogicalKeyboardKey.mediaPlay): () => widget.videoController.player.play(), - const SingleActivator(LogicalKeyboardKey.mediaPause): () => widget.videoController.player.pause(), - const SingleActivator(LogicalKeyboardKey.mediaPlayPause): () => widget.videoController.player.playOrPause(), - const SingleActivator(LogicalKeyboardKey.mediaTrackNext): () => widget.videoController.player.next(), - const SingleActivator(LogicalKeyboardKey.mediaTrackPrevious): () => widget.videoController.player.previous(), - const SingleActivator(LogicalKeyboardKey.space): () => widget.videoController.player.playOrPause(), + const SingleActivator(LogicalKeyboardKey.mediaPlay): () => + widget.videoController.player.play(), + const SingleActivator(LogicalKeyboardKey.mediaPause): () => + widget.videoController.player.pause(), + const SingleActivator(LogicalKeyboardKey.mediaPlayPause): () => + widget.videoController.player.playOrPause(), + const SingleActivator(LogicalKeyboardKey.mediaTrackNext): () => + widget.videoController.player.next(), + const SingleActivator(LogicalKeyboardKey.mediaTrackPrevious): () => + widget.videoController.player.previous(), + const SingleActivator(LogicalKeyboardKey.space): () => + widget.videoController.player.playOrPause(), const SingleActivator(LogicalKeyboardKey.keyJ): () { - final rate = widget.videoController.player.state.position - const Duration(seconds: 10); + final rate = widget.videoController.player.state.position - + const Duration(seconds: 10); widget.videoController.player.seek(rate); }, const SingleActivator(LogicalKeyboardKey.keyL): () { - final rate = widget.videoController.player.state.position + const Duration(seconds: 10); + final rate = widget.videoController.player.state.position + + const Duration(seconds: 10); widget.videoController.player.seek(rate); }, const SingleActivator(LogicalKeyboardKey.arrowLeft): () { - final rate = widget.videoController.player.state.position - const Duration(seconds: 5); + final rate = widget.videoController.player.state.position - + const Duration(seconds: 5); widget.videoController.player.seek(rate); }, const SingleActivator(LogicalKeyboardKey.arrowRight): () { - final rate = widget.videoController.player.state.position + const Duration(seconds: 5); + final rate = widget.videoController.player.state.position + + const Duration(seconds: 5); widget.videoController.player.seek(rate); }, const SingleActivator(LogicalKeyboardKey.arrowUp): () { @@ -182,7 +193,8 @@ class _DesktopControllerWidgetState extends State { widget.videoController.player.setVolume(volume.clamp(0.0, 100.0)); }, const SingleActivator(LogicalKeyboardKey.keyF): () => setFullScreen(), - const SingleActivator(LogicalKeyboardKey.escape): () => setFullScreen(value: false), + const SingleActivator(LogicalKeyboardKey.escape): () => + setFullScreen(value: false), }, child: Stack( children: [ @@ -192,7 +204,8 @@ class _DesktopControllerWidgetState extends State { : Positioned( child: CustomSubtitleView( controller: widget.videoController, - configuration: SubtitleViewConfiguration(style: subtileTextStyle(ref)), + configuration: + SubtitleViewConfiguration(style: subtileTextStyle(ref)), )), ), Focus( @@ -202,12 +215,16 @@ class _DesktopControllerWidgetState extends State { ? (e) { if (e is PointerScrollEvent) { if (e.delta.dy > 0) { - final volume = widget.videoController.player.state.volume - 5.0; - widget.videoController.player.setVolume(volume.clamp(0.0, 100.0)); + final volume = + widget.videoController.player.state.volume - 5.0; + widget.videoController.player + .setVolume(volume.clamp(0.0, 100.0)); } if (e.delta.dy < 0) { - final volume = widget.videoController.player.state.volume + 5.0; - widget.videoController.player.setVolume(volume.clamp(0.0, 100.0)); + final volume = + widget.videoController.player.state.volume + 5.0; + widget.videoController.player + .setVolume(volume.clamp(0.0, 100.0)); } } } @@ -226,12 +243,16 @@ class _DesktopControllerWidgetState extends State { onPanUpdate: modifyVolumeOnScroll ? (e) { if (e.delta.dy > 0) { - final volume = widget.videoController.player.state.volume - 5.0; - widget.videoController.player.setVolume(volume.clamp(0.0, 100.0)); + final volume = + widget.videoController.player.state.volume - 5.0; + widget.videoController.player + .setVolume(volume.clamp(0.0, 100.0)); } if (e.delta.dy < 0) { - final volume = widget.videoController.player.state.volume + 5.0; - widget.videoController.player.setVolume(volume.clamp(0.0, 100.0)); + final volume = + widget.videoController.player.state.volume + 5.0; + widget.videoController.player + .setVolume(volume.clamp(0.0, 100.0)); } } : null, @@ -239,7 +260,9 @@ class _DesktopControllerWidgetState extends State { onHover: (_) => onHover(), onEnter: (_) => onEnter(), onExit: (_) => onExit(), - cursor: cursorVisible ? SystemMouseCursors.basic : SystemMouseCursors.none, + cursor: cursorVisible + ? SystemMouseCursors.basic + : SystemMouseCursors.none, child: Stack( children: [ AnimatedOpacity( @@ -297,7 +320,9 @@ class _DesktopControllerWidgetState extends State { Padding( padding: ( // Add padding in fullscreen! - isFullscreen(context) ? MediaQuery.of(context).padding : EdgeInsets.zero), + isFullscreen(context) + ? MediaQuery.of(context).padding + : EdgeInsets.zero), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, @@ -315,20 +340,29 @@ class _DesktopControllerWidgetState extends State { : 1.0, duration: controlsTransitionDuration, child: Center( - child: seekIndicatorTextWidget(Duration(seconds: swipeDuration), - widget.videoController.player.state.position))), + child: seekIndicatorTextWidget( + Duration( + seconds: swipeDuration), + widget.videoController.player + .state.position))), ), widget.seekToWidget, Transform.translate( offset: Offset.zero, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 5), + padding: const EdgeInsets.symmetric( + horizontal: 5), child: CustomSeekBar( onSeekStart: (value) { setState(() { swipeDuration = value.inSeconds; showSwipeDuration = true; - widget.tempDuration(widget.videoController.player.state.position + value); + widget.tempDuration(widget + .videoController + .player + .state + .position + + value); }); _timer?.cancel(); }, @@ -364,7 +398,9 @@ class _DesktopControllerWidgetState extends State { child: Padding( padding: ( // Add padding in fullscreen! - isFullscreen(context) ? MediaQuery.of(context).padding : EdgeInsets.zero), + isFullscreen(context) + ? MediaQuery.of(context).padding + : EdgeInsets.zero), child: Column( children: [ Container( @@ -430,10 +466,12 @@ class CustomeMaterialDesktopPlayOrPauseButton extends StatefulWidget { }); @override - CustomeMaterialDesktopPlayOrPauseButtonState createState() => CustomeMaterialDesktopPlayOrPauseButtonState(); + CustomeMaterialDesktopPlayOrPauseButtonState createState() => + CustomeMaterialDesktopPlayOrPauseButtonState(); } -class CustomeMaterialDesktopPlayOrPauseButtonState extends State +class CustomeMaterialDesktopPlayOrPauseButtonState + extends State with SingleTickerProviderStateMixin { late final animation = AnimationController( vsync: this, @@ -497,10 +535,12 @@ class CustomMaterialDesktopVolumeButton extends StatefulWidget { }); @override - CustomMaterialDesktopVolumeButtonState createState() => CustomMaterialDesktopVolumeButtonState(); + CustomMaterialDesktopVolumeButtonState createState() => + CustomMaterialDesktopVolumeButtonState(); } -class CustomMaterialDesktopVolumeButtonState extends State +class CustomMaterialDesktopVolumeButtonState + extends State with SingleTickerProviderStateMixin { late double volume = widget.controller.player.state.volume; @@ -663,13 +703,16 @@ class CustomMaterialDesktopPositionIndicator extends StatefulWidget { final VideoController controller; final Duration? delta; - const CustomMaterialDesktopPositionIndicator({super.key, required this.controller, this.delta}); + const CustomMaterialDesktopPositionIndicator( + {super.key, required this.controller, this.delta}); @override - CustomMaterialDesktopPositionIndicatorState createState() => CustomMaterialDesktopPositionIndicatorState(); + CustomMaterialDesktopPositionIndicatorState createState() => + CustomMaterialDesktopPositionIndicatorState(); } -class CustomMaterialDesktopPositionIndicatorState extends State { +class CustomMaterialDesktopPositionIndicatorState + extends State { late Duration position = widget.controller.player.state.position; late Duration duration = widget.controller.player.state.duration; @@ -755,10 +798,12 @@ class CustomMaterialDesktopFullscreenButton extends StatefulWidget { }); @override - State createState() => _CustomMaterialDesktopFullscreenButtonState(); + State createState() => + _CustomMaterialDesktopFullscreenButtonState(); } -class _CustomMaterialDesktopFullscreenButtonState extends State { +class _CustomMaterialDesktopFullscreenButtonState + extends State { bool _isFullscreen = false; @override Widget build(BuildContext context) { @@ -769,7 +814,9 @@ class _CustomMaterialDesktopFullscreenButtonState extends State value; - const MediaIndicatorBuilder({super.key, required this.value, required this.isVolumeIndicator}); + const MediaIndicatorBuilder( + {super.key, required this.value, required this.isVolumeIndicator}); @override Widget build(BuildContext context) { @@ -12,7 +13,9 @@ class MediaIndicatorBuilder extends StatelessWidget { builder: (context, value, child) => Padding( padding: const EdgeInsets.symmetric(horizontal: 40), child: Row( - mainAxisAlignment: isVolumeIndicator ? MainAxisAlignment.start : MainAxisAlignment.end, + mainAxisAlignment: isVolumeIndicator + ? MainAxisAlignment.start + : MainAxisAlignment.end, children: [ Container( clipBehavior: Clip.antiAlias, @@ -42,8 +45,9 @@ class MediaIndicatorBuilder extends StatelessWidget { ), child: SizedBox.fromSize( size: const Size(130, 20), - child: - LinearProgressIndicator(value: value, backgroundColor: Colors.transparent)), + child: LinearProgressIndicator( + value: value, + backgroundColor: Colors.transparent)), ), ), ), diff --git a/lib/modules/anime/widgets/mobile.dart b/lib/modules/anime/widgets/mobile.dart index 7b4c90f..99ddbab 100644 --- a/lib/modules/anime/widgets/mobile.dart +++ b/lib/modules/anime/widgets/mobile.dart @@ -30,16 +30,19 @@ class MobileControllerWidget extends ConsumerStatefulWidget { required this.videoStatekey}); @override - ConsumerState createState() => _MobileControllerWidgetState(); + ConsumerState createState() => + _MobileControllerWidgetState(); } -class _MobileControllerWidgetState extends ConsumerState { +class _MobileControllerWidgetState + extends ConsumerState { bool mount = true; bool visible = true; Duration controlsTransitionDuration = const Duration(milliseconds: 300); Color backdropColor = const Color(0x66000000); Timer? _timer; - late final skipDuration = ref.watch(defaultDoubleTapToSkipLengthStateProvider); + late final skipDuration = + ref.watch(defaultDoubleTapToSkipLengthStateProvider); final ValueNotifier _brightnessValue = ValueNotifier(0.0); final ValueNotifier _brightnessIndicator = ValueNotifier(false); Timer? _brightnessTimer; @@ -50,7 +53,8 @@ class _MobileControllerWidgetState extends ConsumerState // The default event stream in package:volume_controller is buggy. bool _volumeInterceptEventStream = false; - Offset _dragInitialDelta = Offset.zero; // Initial position for horizontal drag + Offset _dragInitialDelta = + Offset.zero; // Initial position for horizontal drag int swipeDuration = 0; // Duration to seek in video bool showSwipeDuration = false; // Whether to show the seek duration overlay @@ -188,15 +192,17 @@ class _MobileControllerWidgetState extends ConsumerState setState(() { swipeDuration = seconds; showSwipeDuration = true; - _seekBarDeltaValueNotifier = - Duration(seconds: widget.videoController.player.state.position.inSeconds + seconds); + _seekBarDeltaValueNotifier = Duration( + seconds: widget.videoController.player.state.position.inSeconds + + seconds); }); } } void onHorizontalDragEnd() { if (swipeDuration != 0) { - Duration newPosition = widget.videoController.player.state.position + Duration(seconds: swipeDuration); + Duration newPosition = widget.videoController.player.state.position + + Duration(seconds: swipeDuration); newPosition = newPosition.clamp( Duration.zero, widget.videoController.player.state.duration, @@ -233,7 +239,8 @@ class _MobileControllerWidgetState extends ConsumerState Future.microtask(() async { try { _brightnessValue.value = await ScreenBrightness.instance.application; - ScreenBrightness.instance.onApplicationScreenBrightnessChanged.listen((value) { + ScreenBrightness.instance.onApplicationScreenBrightnessChanged + .listen((value) { if (mounted) { _brightnessValue.value = value; } @@ -288,7 +295,8 @@ class _MobileControllerWidgetState extends ConsumerState : Positioned( child: CustomSubtitleView( controller: widget.videoController, - configuration: SubtitleViewConfiguration(style: subtileTextStyle(ref)), + configuration: + SubtitleViewConfiguration(style: subtileTextStyle(ref)), )), ), Focus( @@ -329,7 +337,9 @@ class _MobileControllerWidgetState extends ConsumerState onTap: onTap, onDoubleTapDown: _handleTapDown, onDoubleTap: () { - if (_tapPosition != null && _tapPosition!.dx > MediaQuery.of(context).size.width / 2) { + if (_tapPosition != null && + _tapPosition!.dx > + MediaQuery.of(context).size.width / 2) { onDoubleTapSeekForward(); } else { onDoubleTapSeekBackward(); @@ -345,16 +355,19 @@ class _MobileControllerWidgetState extends ConsumerState final delta = e.delta.dy; final Offset position = e.localPosition; - if (position.dx <= MediaQuery.of(context).size.width / 2) { + if (position.dx <= + MediaQuery.of(context).size.width / 2) { // Left side of screen swiped - final brightness = _brightnessValue.value - delta / verticalGestureSensitivity; + final brightness = _brightnessValue.value - + delta / verticalGestureSensitivity; final result = brightness.clamp(0.0, 1.0); setBrightness(result); } else { // Right side of screen swiped - final volume = _volumeValue.value - delta / verticalGestureSensitivity; + final volume = _volumeValue.value - + delta / verticalGestureSensitivity; final result = volume.clamp(0.0, 1.0); setVolume(result); } @@ -368,7 +381,9 @@ class _MobileControllerWidgetState extends ConsumerState Padding( padding: ( // Add padding in fullscreen! - isFullscreen(context) ? MediaQuery.of(context).padding : EdgeInsets.zero), + isFullscreen(context) + ? MediaQuery.of(context).padding + : EdgeInsets.zero), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, @@ -387,8 +402,11 @@ class _MobileControllerWidgetState extends ConsumerState duration: controlsTransitionDuration, child: Center( child: Row( - children: mobilePrimaryButtonBar(context, widget.videoStatekey, - widget.streamController, widget.videoController)), + children: mobilePrimaryButtonBar( + context, + widget.videoStatekey, + widget.streamController, + widget.videoController)), ), ), ), @@ -434,7 +452,9 @@ class _MobileControllerWidgetState extends ConsumerState ), // // Double-Tap Seek Seek-Bar: if (!mount) - if (_mountSeekBackwardButton || _mountSeekForwardButton || showSwipeDuration) + if (_mountSeekBackwardButton || + _mountSeekForwardButton || + showSwipeDuration) Column( children: [ const Spacer(), @@ -443,8 +463,9 @@ class _MobileControllerWidgetState extends ConsumerState children: [ Padding( padding: const EdgeInsets.only(bottom: 10), - child: - CustomSeekBar(delta: _seekBarDeltaValueNotifier, player: widget.videoController.player), + child: CustomSeekBar( + delta: _seekBarDeltaValueNotifier, + player: widget.videoController.player), ), ], ), @@ -455,7 +476,9 @@ class _MobileControllerWidgetState extends ConsumerState child: Padding( padding: ( // Add padding in fullscreen! - isFullscreen(context) ? MediaQuery.of(context).padding : EdgeInsets.zero), + isFullscreen(context) + ? MediaQuery.of(context).padding + : EdgeInsets.zero), child: Column( children: [ Container( @@ -503,7 +526,8 @@ class _MobileControllerWidgetState extends ConsumerState curve: Curves.easeInOut, opacity: value ? 1.0 : 0.0, duration: controlsTransitionDuration, - child: MediaIndicatorBuilder(value: _volumeValue, isVolumeIndicator: true)), + child: MediaIndicatorBuilder( + value: _volumeValue, isVolumeIndicator: true)), ), ), // // Brightness Indicator. @@ -514,7 +538,8 @@ class _MobileControllerWidgetState extends ConsumerState curve: Curves.easeInOut, opacity: value ? 1.0 : 0.0, duration: controlsTransitionDuration, - child: MediaIndicatorBuilder(value: _brightnessValue, isVolumeIndicator: false)), + child: MediaIndicatorBuilder( + value: _brightnessValue, isVolumeIndicator: false)), ), ), // Seek Indicator. @@ -523,7 +548,8 @@ class _MobileControllerWidgetState extends ConsumerState duration: controlsTransitionDuration, opacity: showSwipeDuration ? 1 : 0, child: seekIndicatorTextWidget( - Duration(seconds: swipeDuration), widget.videoController.player.state.position)), + Duration(seconds: swipeDuration), + widget.videoController.player.state.position)), ), // Double-Tap Seek Button(s): @@ -554,20 +580,28 @@ class _MobileControllerWidgetState extends ConsumerState child: _BackwardSeekIndicator( onChanged: (value) { setState(() { - _seekBarDeltaValueNotifier = - widget.videoController.player.state.position - value; + _seekBarDeltaValueNotifier = widget + .videoController + .player + .state + .position - + value; }); }, onSubmitted: (value) { setState(() { _hideSeekBackwardButton = true; }); - var result = widget.videoController.player.state.position - value; + var result = widget.videoController.player + .state.position - + value; result = result.clamp( Duration.zero, - widget.videoController.player.state.duration, + widget.videoController.player.state + .duration, ); - widget.videoController.player.seek(result); + widget.videoController.player + .seek(result); }, skipDuration: skipDuration), ) @@ -596,20 +630,28 @@ class _MobileControllerWidgetState extends ConsumerState child: _ForwardSeekIndicator( onChanged: (value) { setState(() { - _seekBarDeltaValueNotifier = - widget.videoController.player.state.position + value; + _seekBarDeltaValueNotifier = widget + .videoController + .player + .state + .position + + value; }); }, onSubmitted: (value) { setState(() { _hideSeekForwardButton = true; }); - var result = widget.videoController.player.state.position + value; + var result = widget.videoController.player + .state.position + + value; result = result.clamp( Duration.zero, - widget.videoController.player.state.duration, + widget.videoController.player.state + .duration, ); - widget.videoController.player.seek(result); + widget.videoController.player + .seek(result); }, skipDuration: skipDuration), ) @@ -814,10 +856,12 @@ class CustomMaterialPlayOrPauseButton extends StatefulWidget { }); @override - CustomMaterialPlayOrPauseButtonState createState() => CustomMaterialPlayOrPauseButtonState(); + CustomMaterialPlayOrPauseButtonState createState() => + CustomMaterialPlayOrPauseButtonState(); } -class CustomMaterialPlayOrPauseButtonState extends State +class CustomMaterialPlayOrPauseButtonState + extends State with SingleTickerProviderStateMixin { late final animation = AnimationController( vsync: this, @@ -871,8 +915,11 @@ class CustomMaterialPlayOrPauseButtonState extends State mobilePrimaryButtonBar(BuildContext context, GlobalKey key, - AnimeStreamController streamController, VideoController controller) { +List mobilePrimaryButtonBar( + BuildContext context, + GlobalKey key, + AnimeStreamController streamController, + VideoController controller) { bool hasPrevEpisode = streamController.getEpisodeIndex().$1 + 1 != streamController.getEpisodesLength(streamController.getEpisodeIndex().$2); bool hasNextEpisode = streamController.getEpisodeIndex().$1 != 0; @@ -885,7 +932,8 @@ List mobilePrimaryButtonBar(BuildContext context, GlobalKey if (isFullScreen) { key.currentState?.exitFullscreen(); } - pushReplacementMangaReaderView(context: context, chapter: streamController.getPrevEpisode()); + pushReplacementMangaReaderView( + context: context, chapter: streamController.getPrevEpisode()); } : null, icon: Icon( @@ -909,7 +957,8 @@ List mobilePrimaryButtonBar(BuildContext context, GlobalKey ); } : null, - icon: Icon(Icons.skip_next, size: 35, color: hasPrevEpisode ? Colors.white : Colors.grey), + icon: Icon(Icons.skip_next, + size: 35, color: hasPrevEpisode ? Colors.white : Colors.grey), ), const Spacer(flex: 3) ]; diff --git a/lib/modules/anime/widgets/subtitle_setting_widget.dart b/lib/modules/anime/widgets/subtitle_setting_widget.dart index 4c06119..0d907fb 100644 --- a/lib/modules/anime/widgets/subtitle_setting_widget.dart +++ b/lib/modules/anime/widgets/subtitle_setting_widget.dart @@ -43,9 +43,9 @@ class _FontSettingWidgetState extends ConsumerState { mainAxisAlignment: MainAxisAlignment.center, children: [ iconButton(Icons.remove, () { - ref - .read(subtitleSettingsStateProvider.notifier) - .set(subtitleSettings..fontSize = subtitleSettings.fontSize! - 1, true); + ref.read(subtitleSettingsStateProvider.notifier).set( + subtitleSettings..fontSize = subtitleSettings.fontSize! - 1, + true); setState(() {}); }, backgroundColor: context.dynamicWhiteBlackColor, @@ -54,12 +54,15 @@ class _FontSettingWidgetState extends ConsumerState { SizedBox( width: 200, child: TextFormField( - controller: TextEditingController(text: subtitleSettings.fontSize.toString()), + controller: TextEditingController( + text: subtitleSettings.fontSize.toString()), keyboardType: TextInputType.number, onChanged: (v) { final val = int.tryParse(v); if (val != null) { - ref.read(subtitleSettingsStateProvider.notifier).set(subtitleSettings..fontSize = val, true); + ref + .read(subtitleSettingsStateProvider.notifier) + .set(subtitleSettings..fontSize = val, true); } }, decoration: InputDecoration( @@ -67,40 +70,51 @@ class _FontSettingWidgetState extends ConsumerState { isDense: true, filled: true, fillColor: Colors.transparent, - enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: context.dynamicThemeColor)), - focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: context.dynamicThemeColor)), - border: OutlineInputBorder(borderSide: BorderSide(color: context.dynamicThemeColor))), + enabledBorder: OutlineInputBorder( + borderSide: + BorderSide(color: context.dynamicThemeColor)), + focusedBorder: OutlineInputBorder( + borderSide: + BorderSide(color: context.dynamicThemeColor)), + border: OutlineInputBorder( + borderSide: + BorderSide(color: context.dynamicThemeColor))), ), ), iconButton(Icons.add, () { - ref - .read(subtitleSettingsStateProvider.notifier) - .set(subtitleSettings..fontSize = subtitleSettings.fontSize! + 1, true); + ref.read(subtitleSettingsStateProvider.notifier).set( + subtitleSettings..fontSize = subtitleSettings.fontSize! + 1, + true); setState(() {}); }, backgroundColor: context.dynamicWhiteBlackColor, iconColors: context.isLight ? Colors.white : Colors.black, size: 25), iconButton(Icons.format_bold, () { - ref - .read(subtitleSettingsStateProvider.notifier) - .set(subtitleSettings..useBold = !subtitleSettings.useBold!, true); - setState(() {}); - }, iconColors: subtitleSettings.useBold! ? null : context.dynamicWhiteBlackColor.withValues(alpha: 0.5)), - iconButton(Icons.format_italic, () { - ref - .read(subtitleSettingsStateProvider.notifier) - .set(subtitleSettings..useItalic = !subtitleSettings.useItalic!, true); + ref.read(subtitleSettingsStateProvider.notifier).set( + subtitleSettings..useBold = !subtitleSettings.useBold!, + true); setState(() {}); }, - iconColors: - subtitleSettings.useItalic! ? null : context.dynamicWhiteBlackColor.withValues(alpha: 0.5)), + iconColors: subtitleSettings.useBold! + ? null + : context.dynamicWhiteBlackColor.withValues(alpha: 0.5)), + iconButton(Icons.format_italic, () { + ref.read(subtitleSettingsStateProvider.notifier).set( + subtitleSettings..useItalic = !subtitleSettings.useItalic!, + true); + setState(() {}); + }, + iconColors: subtitleSettings.useItalic! + ? null + : context.dynamicWhiteBlackColor.withValues(alpha: 0.5)), ], ), Padding( padding: const EdgeInsets.all(8.0), child: Text("Lorem ipsum dolor sit amet", - style: subtileTextStyle(ref).copyWith(fontSize: 22), textAlign: TextAlign.center), + style: subtileTextStyle(ref).copyWith(fontSize: 22), + textAlign: TextAlign.center), ), TextButton( onPressed: () { @@ -154,7 +168,8 @@ class _ColorSettingWidgetState extends ConsumerState { decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), color: color, - border: Border.all(width: 2, color: context.dynamicWhiteBlackColor)), + border: Border.all( + width: 2, color: context.dynamicWhiteBlackColor)), ), ), Text("#${color.hexCode}", style: TextStyle(color: context.textColor)), @@ -170,12 +185,15 @@ class _ColorSettingWidgetState extends ConsumerState { @override Widget build(BuildContext context) { final subSets = ref.watch(subtitleSettingsStateProvider); - final textColor = - Color.fromARGB(subSets.textColorA!, subSets.textColorR!, subSets.textColorG!, subSets.textColorB!); - final borderColor = - Color.fromARGB(subSets.borderColorA!, subSets.borderColorR!, subSets.borderColorG!, subSets.borderColorB!); + final textColor = Color.fromARGB(subSets.textColorA!, subSets.textColorR!, + subSets.textColorG!, subSets.textColorB!); + final borderColor = Color.fromARGB(subSets.borderColorA!, + subSets.borderColorR!, subSets.borderColorG!, subSets.borderColorB!); final backgroundColor = Color.fromARGB( - subSets.backgroundColorA!, subSets.backgroundColorR!, subSets.backgroundColorG!, subSets.backgroundColorB!); + subSets.backgroundColorA!, + subSets.backgroundColorR!, + subSets.backgroundColorG!, + subSets.backgroundColorB!); return Padding( padding: const EdgeInsets.all(20), child: Column( @@ -198,45 +216,72 @@ class _ColorSettingWidgetState extends ConsumerState { ), Row( children: [ - Expanded(flex: 3, child: button(context.l10n.text, "text", textColor)), - Expanded(flex: 3, child: button(context.l10n.border, "border", borderColor)), - Expanded(flex: 3, child: button(context.l10n.background, "backgroud", backgroundColor)), + Expanded( + flex: 3, child: button(context.l10n.text, "text", textColor)), + Expanded( + flex: 3, + child: button(context.l10n.border, "border", borderColor)), + Expanded( + flex: 3, + child: button( + context.l10n.background, "backgroud", backgroundColor)), ], ), Padding( padding: const EdgeInsets.all(8.0), child: Text("Lorem ipsum dolor sit amet", - style: subtileTextStyle(ref).copyWith(fontSize: 22), textAlign: TextAlign.center), + style: subtileTextStyle(ref).copyWith(fontSize: 22), + textAlign: TextAlign.center), ), if (selector == "text") ...[ - rgbaFilterWidget(subSets.textColorA!, subSets.textColorR!, subSets.textColorG!, subSets.textColorB!, (val) { + rgbaFilterWidget(subSets.textColorA!, subSets.textColorR!, + subSets.textColorG!, subSets.textColorB!, (val) { if (val.$3 == "r") { - ref.read(subtitleSettingsStateProvider.notifier).set(subSets..textColorR = val.$1.toInt(), val.$2); + ref + .read(subtitleSettingsStateProvider.notifier) + .set(subSets..textColorR = val.$1.toInt(), val.$2); } else if (val.$3 == "g") { - ref.read(subtitleSettingsStateProvider.notifier).set(subSets..textColorG = val.$1.toInt(), val.$2); + ref + .read(subtitleSettingsStateProvider.notifier) + .set(subSets..textColorG = val.$1.toInt(), val.$2); } else if (val.$3 == "b") { - ref.read(subtitleSettingsStateProvider.notifier).set(subSets..textColorB = val.$1.toInt(), val.$2); + ref + .read(subtitleSettingsStateProvider.notifier) + .set(subSets..textColorB = val.$1.toInt(), val.$2); } else { - ref.read(subtitleSettingsStateProvider.notifier).set(subSets..textColorA = val.$1.toInt(), val.$2); + ref + .read(subtitleSettingsStateProvider.notifier) + .set(subSets..textColorA = val.$1.toInt(), val.$2); } setState(() {}); }, context), ] else if (selector == "border") ...[ - rgbaFilterWidget(subSets.borderColorA!, subSets.borderColorR!, subSets.borderColorG!, subSets.borderColorB!, - (val) { + rgbaFilterWidget(subSets.borderColorA!, subSets.borderColorR!, + subSets.borderColorG!, subSets.borderColorB!, (val) { if (val.$3 == "r") { - ref.read(subtitleSettingsStateProvider.notifier).set(subSets..borderColorR = val.$1.toInt(), val.$2); + ref + .read(subtitleSettingsStateProvider.notifier) + .set(subSets..borderColorR = val.$1.toInt(), val.$2); } else if (val.$3 == "g") { - ref.read(subtitleSettingsStateProvider.notifier).set(subSets..borderColorG = val.$1.toInt(), val.$2); + ref + .read(subtitleSettingsStateProvider.notifier) + .set(subSets..borderColorG = val.$1.toInt(), val.$2); } else if (val.$3 == "b") { - ref.read(subtitleSettingsStateProvider.notifier).set(subSets..borderColorB = val.$1.toInt(), val.$2); + ref + .read(subtitleSettingsStateProvider.notifier) + .set(subSets..borderColorB = val.$1.toInt(), val.$2); } else { - ref.read(subtitleSettingsStateProvider.notifier).set(subSets..borderColorA = val.$1.toInt(), val.$2); + ref + .read(subtitleSettingsStateProvider.notifier) + .set(subSets..borderColorA = val.$1.toInt(), val.$2); } setState(() {}); }, context), ] else ...[ - rgbaFilterWidget(subSets.backgroundColorA!, subSets.backgroundColorR!, subSets.backgroundColorG!, + rgbaFilterWidget( + subSets.backgroundColorA!, + subSets.backgroundColorR!, + subSets.backgroundColorG!, subSets.backgroundColorB!, (val) { if (val.$3 == "r") { ref @@ -279,7 +324,8 @@ Widget iconButton(IconData icon, void Function()? onPressed, width: size, child: IconButton( iconSize: size * 0.9, - style: ButtonStyle(backgroundColor: WidgetStatePropertyAll(backgroundColor)), + style: ButtonStyle( + backgroundColor: WidgetStatePropertyAll(backgroundColor)), padding: const EdgeInsets.all(1), onPressed: onPressed, icon: Icon(icon, color: iconColors)), diff --git a/lib/modules/anime/widgets/subtitle_view.dart b/lib/modules/anime/widgets/subtitle_view.dart index b21080d..02fd126 100644 --- a/lib/modules/anime/widgets/subtitle_view.dart +++ b/lib/modules/anime/widgets/subtitle_view.dart @@ -77,10 +77,12 @@ class _CustomSubtitleViewState extends ConsumerState { return LayoutBuilder( builder: (context, constraints) { final nr = (constraints.maxWidth * constraints.maxHeight); - const dr = kTextScaleFactorReferenceWidth * kTextScaleFactorReferenceHeight; + const dr = + kTextScaleFactorReferenceWidth * kTextScaleFactorReferenceHeight; final textScaleFactor = sqrt((nr / dr).clamp(0.0, 1.0)); - final textScaler = widget.configuration.textScaler ?? TextScaler.linear(textScaleFactor); + final textScaler = widget.configuration.textScaler ?? + TextScaler.linear(textScaleFactor); return Material( color: Colors.transparent, child: AnimatedContainer( @@ -105,19 +107,35 @@ class _CustomSubtitleViewState extends ConsumerState { TextStyle subtileTextStyle(WidgetRef ref) { final subSets = ref.watch(subtitleSettingsStateProvider); - final borderColor = - Color.fromARGB(subSets.borderColorA!, subSets.borderColorR!, subSets.borderColorG!, subSets.borderColorB!); + final borderColor = Color.fromARGB(subSets.borderColorA!, + subSets.borderColorR!, subSets.borderColorG!, subSets.borderColorB!); return TextStyle( fontSize: subSets.fontSize!.toDouble(), fontWeight: subSets.useBold! ? FontWeight.bold : null, fontStyle: subSets.useItalic! ? FontStyle.italic : null, - color: Color.fromARGB(subSets.textColorA!, subSets.textColorR!, subSets.textColorG!, subSets.textColorB!), + color: Color.fromARGB(subSets.textColorA!, subSets.textColorR!, + subSets.textColorG!, subSets.textColorB!), shadows: [ - Shadow(offset: const Offset(-1.5, -1.5), color: borderColor, blurRadius: 1.4), - Shadow(offset: const Offset(1.5, -1.5), color: borderColor, blurRadius: 1.4), - Shadow(offset: const Offset(1.5, 1.5), color: borderColor, blurRadius: 1.4), - Shadow(offset: const Offset(-1.5, 1.5), color: borderColor, blurRadius: 1.4) + Shadow( + offset: const Offset(-1.5, -1.5), + color: borderColor, + blurRadius: 1.4), + Shadow( + offset: const Offset(1.5, -1.5), + color: borderColor, + blurRadius: 1.4), + Shadow( + offset: const Offset(1.5, 1.5), + color: borderColor, + blurRadius: 1.4), + Shadow( + offset: const Offset(-1.5, 1.5), + color: borderColor, + blurRadius: 1.4) ], backgroundColor: Color.fromARGB( - subSets.backgroundColorA!, subSets.backgroundColorR!, subSets.backgroundColorG!, subSets.backgroundColorB!)); + subSets.backgroundColorA!, + subSets.backgroundColorR!, + subSets.backgroundColorG!, + subSets.backgroundColorB!)); } diff --git a/lib/modules/browse/browse_screen.dart b/lib/modules/browse/browse_screen.dart index 5e90a3c..db77540 100644 --- a/lib/modules/browse/browse_screen.dart +++ b/lib/modules/browse/browse_screen.dart @@ -18,7 +18,8 @@ class BrowseScreen extends ConsumerStatefulWidget { ConsumerState createState() => _BrowseScreenState(); } -class _BrowseScreenState extends ConsumerState with TickerProviderStateMixin { +class _BrowseScreenState extends ConsumerState + with TickerProviderStateMixin { late TabController _tabBarController; @override @@ -74,26 +75,33 @@ class _BrowseScreenState extends ConsumerState with TickerProvider ) : Row( children: [ - if (_tabBarController.index == 2 || _tabBarController.index == 3) + if (_tabBarController.index == 2 || + _tabBarController.index == 3) IconButton( onPressed: () { context.push('/createExtension'); }, - icon: Icon(Icons.add_outlined, color: Theme.of(context).hintColor)), + icon: Icon(Icons.add_outlined, + color: Theme.of(context).hintColor)), _tabBarController.index != 4 ? IconButton( splashRadius: 20, onPressed: () { - if (_tabBarController.index != 1 && _tabBarController.index != 0) { + if (_tabBarController.index != 1 && + _tabBarController.index != 0) { setState(() { _isSearch = true; }); } else { - context.push('/globalSearch', extra: _tabBarController.index == 0 ? true : false); + context.push('/globalSearch', + extra: _tabBarController.index == 0 + ? true + : false); } }, icon: Icon( - _tabBarController.index == 0 || _tabBarController.index == 1 + _tabBarController.index == 0 || + _tabBarController.index == 1 ? Icons.travel_explore_rounded : Icons.search_rounded, color: Theme.of(context).hintColor)) @@ -118,7 +126,8 @@ class _BrowseScreenState extends ConsumerState with TickerProvider icon: Icon( _tabBarController.index == 0 || _tabBarController.index == 1 ? Icons.filter_list_sharp - : _tabBarController.index == 2 || _tabBarController.index == 3 + : _tabBarController.index == 2 || + _tabBarController.index == 3 ? Icons.translate_rounded : Icons.help_outline_outlined, color: Theme.of(context).hintColor)), @@ -132,7 +141,11 @@ class _BrowseScreenState extends ConsumerState with TickerProvider Tab(text: l10n.anime_sources), Tab( child: Row( - children: [Text(l10n.manga_extensions), const SizedBox(width: 8), _extensionUpdateNumbers(ref, true)], + children: [ + Text(l10n.manga_extensions), + const SizedBox(width: 8), + _extensionUpdateNumbers(ref, true) + ], ), ), Tab( @@ -187,18 +200,23 @@ Widget _extensionUpdateNumbers(WidgetRef ref, bool isManga) { .watch(fireImmediately: true), builder: (context, snapshot) { if (snapshot.hasData && snapshot.data!.isNotEmpty) { - final entries = - snapshot.data!.where((element) => compareVersions(element.version!, element.versionLast!) < 0).toList(); + final entries = snapshot.data! + .where((element) => + compareVersions(element.version!, element.versionLast!) < 0) + .toList(); return entries.isEmpty ? Container() : Container( - decoration: - BoxDecoration(borderRadius: BorderRadius.circular(20), color: Theme.of(context).focusColor), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: Theme.of(context).focusColor), child: Padding( padding: const EdgeInsets.all(5), child: Text( entries.length.toString(), - style: TextStyle(fontSize: 12, color: Theme.of(context).textTheme.bodySmall!.color), + style: TextStyle( + fontSize: 12, + color: Theme.of(context).textTheme.bodySmall!.color), ), ), ); diff --git a/lib/modules/browse/extension/edit_code.dart b/lib/modules/browse/extension/edit_code.dart index e9746a2..dcc2f46 100644 --- a/lib/modules/browse/extension/edit_code.dart +++ b/lib/modules/browse/extension/edit_code.dart @@ -37,7 +37,8 @@ Mode getSourceMode(Source? source) { class _CodeEditorState extends ConsumerState { dynamic result; - late final source = widget.sourceId == null ? null : isar.sources.getSync(widget.sourceId!); + late final source = + widget.sourceId == null ? null : isar.sources.getSync(widget.sourceId!); late final controller = CodeController( text: source?.sourceCode ?? "", language: getSourceMode(source), @@ -59,7 +60,8 @@ class _CodeEditorState extends ConsumerState { bool _isLoading = false; String _errorText = ""; bool _error = false; - final _logsNotifier = ValueNotifier>([]); + final _logsNotifier = + ValueNotifier>([]); late final _logStreamController = Logger.logStreamController; final _scrollController = ScrollController(); @override @@ -96,13 +98,15 @@ class _CodeEditorState extends ConsumerState { ), const Spacer(), ElevatedButton( - style: ElevatedButton.styleFrom(backgroundColor: context.primaryColor), + style: ElevatedButton.styleFrom( + backgroundColor: context.primaryColor), onPressed: () { Navigator.pop(context, 'filter'); }, child: Text( context.l10n.filter, - style: TextStyle(color: Theme.of(context).scaffoldBackgroundColor), + style: TextStyle( + color: Theme.of(context).scaffoldBackgroundColor), ), ), ], @@ -156,7 +160,8 @@ class _CodeEditorState extends ConsumerState { gutterStyle: const GutterStyle( textStyle: TextStyle( color: Colors.grey, - height: 1.5, // Issue #307 fix, found in package: flutter-code-editor issue #270 + height: + 1.5, // Issue #307 fix, found in package: flutter-code-editor issue #270 ), showLineNumbers: true, ), @@ -165,7 +170,8 @@ class _CodeEditorState extends ConsumerState { source?.sourceCode = a; }); if (source != null && mounted) { - isar.writeTxnSync(() => isar.sources.putSync(source!)); + isar.writeTxnSync( + () => isar.sources.putSync(source!)); } }, ), @@ -182,11 +188,13 @@ class _CodeEditorState extends ConsumerState { icon: const Icon(Icons.keyboard_arrow_down), isExpanded: true, value: _serviceIndex, - hint: Text(_getServices(context)[_serviceIndex].$1, style: const TextStyle(fontSize: 13)), + hint: Text(_getServices(context)[_serviceIndex].$1, + style: const TextStyle(fontSize: 13)), items: _getServices(context) .map((e) => DropdownMenuItem( value: e.$2, - child: Text(e.$1, style: const TextStyle(fontSize: 13)), + child: Text(e.$1, + style: const TextStyle(fontSize: 13)), )) .toList(), onChanged: (v) { @@ -196,7 +204,9 @@ class _CodeEditorState extends ConsumerState { }, ), ), - if (_serviceIndex == 0 || _serviceIndex == 1 || _serviceIndex == 2) + if (_serviceIndex == 0 || + _serviceIndex == 1 || + _serviceIndex == 2) _textEditing("Page", context, "ex: 1", (v) { _page = int.tryParse(v) ?? 1; }), @@ -204,8 +214,11 @@ class _CodeEditorState extends ConsumerState { _textEditing("Query", context, "ex: one piece", (v) { _query = v; }), - if (_serviceIndex == 3 || _serviceIndex == 4 || _serviceIndex == 5) - _textEditing("Url", context, "ex: url of the entry", (v) { + if (_serviceIndex == 3 || + _serviceIndex == 4 || + _serviceIndex == 5) + _textEditing("Url", context, "ex: url of the entry", + (v) { _url = v; }), Padding( @@ -219,7 +232,8 @@ class _CodeEditorState extends ConsumerState { source?.sourceCode = controller.text; }); if (source != null && mounted) { - isar.writeTxnSync(() => isar.sources.putSync(source!)); + isar.writeTxnSync( + () => isar.sources.putSync(source!)); } setState(() { result = null; @@ -228,36 +242,52 @@ class _CodeEditorState extends ConsumerState { _errorText = ""; }); if (source != null) { - final service = getExtensionService(source!); + final service = + getExtensionService(source!); try { if (_serviceIndex == 0) { - final getManga = - await ref.watch(getPopularProvider(source: source!, page: _page).future); + final getManga = await ref.watch( + getPopularProvider( + source: source!, + page: _page) + .future); result = getManga!.toJson(); } else if (_serviceIndex == 1) { - final getManga = await ref - .watch(getLatestUpdatesProvider(source: source!, page: _page).future); + final getManga = await ref.watch( + getLatestUpdatesProvider( + source: source!, + page: _page) + .future); result = getManga!.toJson(); } else if (_serviceIndex == 2) { - final getManga = await ref.watch(searchProvider( - source: source!, query: _query, page: _page, filterList: filterList) - .future); + final getManga = await ref.watch( + searchProvider( + source: source!, + query: _query, + page: _page, + filterList: filterList) + .future); result = getManga!.toJson(); } else if (_serviceIndex == 3) { - final getManga = - await ref.watch(getDetailProvider(source: source!, url: _url).future); + final getManga = await ref.watch( + getDetailProvider( + source: source!, + url: _url) + .future); result = getManga.toJson(); } else if (_serviceIndex == 4) { result = { - "pages": (await service.getPageList(_url)) + "pages": (await service + .getPageList(_url)) .map((e) => e.toJson()) .toList(), }; } else { - result = (await service.getVideoList(_url)) - .map((e) => e.toJson()) - .toList(); + result = + (await service.getVideoList(_url)) + .map((e) => e.toJson()) + .toList(); } if (mounted) { setState(() { @@ -298,7 +328,8 @@ class _CodeEditorState extends ConsumerState { if (filters.isEmpty) { filters = filterList; } - final res = await filterDialog(context); + final res = + await filterDialog(context); if (res == 'filter' && mounted) { setState(() { result = null; @@ -306,9 +337,13 @@ class _CodeEditorState extends ConsumerState { _error = false; _errorText = ""; }); - final getManga = await ref.watch(searchProvider( - source: source!, query: _query, page: _page, filterList: filters) - .future); + final getManga = await ref.watch( + searchProvider( + source: source!, + query: _query, + page: _page, + filterList: filters) + .future); result = getManga!.toJson(); setState(() { _isLoading = false; @@ -331,22 +366,26 @@ class _CodeEditorState extends ConsumerState { child: _error ? SingleChildScrollView( child: Column( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text(_errorText), ], ), ) : _isLoading - ? const Center(child: CircularProgressIndicator()) + ? const Center( + child: CircularProgressIndicator()) : result != null ? JsonConfig( data: JsonConfigData( gap: 100, style: const JsonStyleScheme( - quotation: JsonQuotation.same('"'), + quotation: + JsonQuotation.same('"'), openAtStart: false, - arrow: Icon(Icons.arrow_forward), + arrow: + Icon(Icons.arrow_forward), depth: 4, ), color: const JsonColorScheme(), @@ -379,7 +418,10 @@ class _CodeEditorState extends ConsumerState { itemBuilder: (context, index) { final value = logs[index]; return SelectableText(value.$2, - style: TextStyle(color: value.$1 == LoggerLevel.info ? Colors.yellow : Colors.blueAccent)); + style: TextStyle( + color: value.$1 == LoggerLevel.info + ? Colors.yellow + : Colors.blueAccent)); }, ), ), @@ -390,7 +432,8 @@ class _CodeEditorState extends ConsumerState { } } -Widget _textEditing(String label, BuildContext context, String hintText, void Function(String)? onChanged) { +Widget _textEditing(String label, BuildContext context, String hintText, + void Function(String)? onChanged) { return Padding( padding: const EdgeInsets.all(4), child: TextFormField( @@ -402,9 +445,12 @@ Widget _textEditing(String label, BuildContext context, String hintText, void Fu isDense: true, filled: true, fillColor: Colors.transparent, - enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: context.dynamicThemeColor)), - focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: context.dynamicThemeColor)), - border: OutlineInputBorder(borderSide: BorderSide(color: context.dynamicThemeColor))), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: context.dynamicThemeColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: context.dynamicThemeColor)), + border: OutlineInputBorder( + borderSide: BorderSide(color: context.dynamicThemeColor))), ), ); } diff --git a/lib/modules/browse/extension/extension_detail.dart b/lib/modules/browse/extension/extension_detail.dart index 5bb1517..f97d089 100644 --- a/lib/modules/browse/extension/extension_detail.dart +++ b/lib/modules/browse/extension/extension_detail.dart @@ -26,14 +26,17 @@ class ExtensionDetail extends ConsumerStatefulWidget { class _ExtensionDetailState extends ConsumerState { late Source source = widget.source; late List sourcePreference = - getSourcePreference(source: source).map((e) => getSourcePreferenceEntry(e.key!, source.id!)).toList(); + getSourcePreference(source: source) + .map((e) => getSourcePreferenceEntry(e.key!, source.id!)) + .toList(); @override Widget build(BuildContext context) { final l10n = l10nLocalizations(context)!; return Scaffold( appBar: AppBar( - title: Text(l10n.extension_detail), leading: BackButton(onPressed: () => Navigator.pop(context, source))), + title: Text(l10n.extension_detail), + leading: BackButton(onPressed: () => Navigator.pop(context, source))), body: SingleChildScrollView( child: Column( children: [ @@ -41,7 +44,9 @@ class _ExtensionDetailState extends ConsumerState { padding: const EdgeInsets.only(top: 20), child: Container( decoration: BoxDecoration( - color: Theme.of(context).secondaryHeaderColor.withValues(alpha: 0.5), + color: Theme.of(context) + .secondaryHeaderColor + .withValues(alpha: 0.5), borderRadius: BorderRadius.circular(10)), child: widget.source.iconUrl!.isEmpty ? const Icon(Icons.source_outlined, size: 140) @@ -65,7 +70,8 @@ class _ExtensionDetailState extends ConsumerState { padding: const EdgeInsets.all(12), child: Text( widget.source.name!, - style: const TextStyle(fontSize: 23, fontWeight: FontWeight.bold), + style: + const TextStyle(fontSize: 23, fontWeight: FontWeight.bold), textAlign: TextAlign.center, ), ), @@ -73,7 +79,8 @@ class _ExtensionDetailState extends ConsumerState { padding: const EdgeInsets.all(8.0), child: Container( decoration: BoxDecoration( - color: context.primaryColor.withValues(alpha: 0.2), borderRadius: BorderRadius.circular(10)), + color: context.primaryColor.withValues(alpha: 0.2), + borderRadius: BorderRadius.circular(10)), child: Padding( padding: const EdgeInsets.all(20), child: Row( @@ -83,7 +90,8 @@ class _ExtensionDetailState extends ConsumerState { children: [ Text( widget.source.version!, - style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: const TextStyle( + fontSize: 16, fontWeight: FontWeight.bold), ), Text( l10n.version, @@ -95,7 +103,8 @@ class _ExtensionDetailState extends ConsumerState { children: [ Text( completeLanguageName(widget.source.lang!), - style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + style: const TextStyle( + fontSize: 16, fontWeight: FontWeight.bold), ), Text( l10n.language, @@ -116,16 +125,19 @@ class _ExtensionDetailState extends ConsumerState { style: ElevatedButton.styleFrom( padding: const EdgeInsets.all(0), backgroundColor: Colors.transparent, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5)), elevation: 0, shadowColor: Colors.transparent), onPressed: () async { - final res = await context.push('/codeEditor', extra: source.id); + final res = + await context.push('/codeEditor', extra: source.id); if (res != null && mounted) { setState(() { source = res as Source; sourcePreference = getSourcePreference(source: source) - .map((e) => getSourcePreferenceEntry(e.key!, source.id!)) + .map((e) => + getSourcePreferenceEntry(e.key!, source.id!)) .toList(); }); } @@ -137,7 +149,8 @@ class _ExtensionDetailState extends ConsumerState { padding: const EdgeInsets.symmetric(horizontal: 10), child: Text( l10n.edit_code, - style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + style: const TextStyle( + fontSize: 20, fontWeight: FontWeight.bold), ), ), const Icon(Icons.code) @@ -153,7 +166,8 @@ class _ExtensionDetailState extends ConsumerState { style: ElevatedButton.styleFrom( padding: const EdgeInsets.all(0), backgroundColor: Colors.transparent, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5)), elevation: 0, shadowColor: Colors.transparent), onPressed: () async { @@ -164,7 +178,8 @@ class _ExtensionDetailState extends ConsumerState { padding: EdgeInsets.symmetric(horizontal: 10), child: Text( "Delete all cookies", - style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + style: TextStyle( + fontSize: 20, fontWeight: FontWeight.bold), ), )), ), @@ -176,9 +191,11 @@ class _ExtensionDetailState extends ConsumerState { child: ElevatedButton( style: ElevatedButton.styleFrom( padding: const EdgeInsets.all(0), - side: BorderSide(color: context.primaryColor, width: 0.3), + side: + BorderSide(color: context.primaryColor, width: 0.3), backgroundColor: Colors.transparent, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5)), elevation: 0, shadowColor: Colors.transparent), onPressed: () { @@ -189,7 +206,8 @@ class _ExtensionDetailState extends ConsumerState { title: Text( widget.source.name!, ), - content: Text(l10n.uninstall_extension(widget.source.name!)), + content: Text(l10n + .uninstall_extension(widget.source.name!)), actions: [ Row( mainAxisAlignment: MainAxisAlignment.end, @@ -204,13 +222,15 @@ class _ExtensionDetailState extends ConsumerState { ), TextButton( onPressed: () { - final sourcePrefsIds = isar.sourcePreferences + final sourcePrefsIds = isar + .sourcePreferences .filter() .sourceIdEqualTo(source.id!) .findAllSync() .map((e) => e.id!) .toList(); - final sourcePrefsStringIds = isar.sourcePreferenceStringValues + final sourcePrefsStringIds = isar + .sourcePreferenceStringValues .filter() .sourceIdEqualTo(source.id!) .findAllSync() @@ -218,15 +238,19 @@ class _ExtensionDetailState extends ConsumerState { .toList(); isar.writeTxnSync(() { if (source.isObsolete ?? false) { - isar.sources.deleteSync(widget.source.id!); + isar.sources.deleteSync( + widget.source.id!); } else { isar.sources.putSync(widget.source ..sourceCode = "" ..isAdded = false ..isPinned = false); } - isar.sourcePreferences.deleteAllSync(sourcePrefsIds); - isar.sourcePreferenceStringValues.deleteAllSync(sourcePrefsStringIds); + isar.sourcePreferences + .deleteAllSync(sourcePrefsIds); + isar.sourcePreferenceStringValues + .deleteAllSync( + sourcePrefsStringIds); }); Navigator.pop(ctx); @@ -241,11 +265,13 @@ class _ExtensionDetailState extends ConsumerState { }, child: Text( l10n.uninstall, - style: const TextStyle(fontSize: 20, fontWeight: FontWeight.bold), + style: const TextStyle( + fontSize: 20, fontWeight: FontWeight.bold), )), ), ), - SourcePreferenceWidget(sourcePreference: sourcePreference, source: source) + SourcePreferenceWidget( + sourcePreference: sourcePreference, source: source) ], ), ), diff --git a/lib/modules/browse/extension/extension_lang.dart b/lib/modules/browse/extension/extension_lang.dart index ffc9b56..20ef4a1 100644 --- a/lib/modules/browse/extension/extension_lang.dart +++ b/lib/modules/browse/extension/extension_lang.dart @@ -39,7 +39,12 @@ class ExtensionsLang extends ConsumerWidget { } else if (value == 1) { enable = false; } - final sources = isar.sources.filter().idIsNotNull().and().isMangaEqualTo(isManga).findAllSync(); + final sources = isar.sources + .filter() + .idIsNotNull() + .and() + .isMangaEqualTo(isManga) + .findAllSync(); for (var source in sources) { isar.sources.putSync(source..isActive = enable); } @@ -48,7 +53,12 @@ class ExtensionsLang extends ConsumerWidget { ], ), body: StreamBuilder( - stream: isar.sources.filter().idIsNotNull().and().isMangaEqualTo(isManga).watch(fireImmediately: true), + stream: isar.sources + .filter() + .idIsNotNull() + .and() + .isMangaEqualTo(isManga) + .watch(fireImmediately: true), builder: (context, snapshot) { List? entries = snapshot.hasData ? snapshot.data : []; final languages = entries!.map((e) => e.lang!).toSet().toList(); @@ -70,7 +80,9 @@ class ExtensionsLang extends ConsumerWidget { }); }, value: entries - .where((element) => element.lang!.toLowerCase() == lang.toLowerCase() && element.isActive!) + .where((element) => + element.lang!.toLowerCase() == lang.toLowerCase() && + element.isActive!) .isNotEmpty, ); }, diff --git a/lib/modules/browse/extension/extension_screen.dart b/lib/modules/browse/extension/extension_screen.dart index 3ca8989..b80b963 100644 --- a/lib/modules/browse/extension/extension_screen.dart +++ b/lib/modules/browse/extension/extension_screen.dart @@ -14,7 +14,8 @@ import 'package:mangayomi/modules/browse/extension/widgets/extension_list_tile_w class ExtensionScreen extends ConsumerStatefulWidget { final bool isManga; final String query; - const ExtensionScreen({required this.query, required this.isManga, super.key}); + const ExtensionScreen( + {required this.query, required this.isManga, super.key}); @override ConsumerState createState() => _ExtensionScreenState(); @@ -24,7 +25,8 @@ class _ExtensionScreenState extends ConsumerState { final controller = ScrollController(); @override Widget build(BuildContext context) { - final streamExtensions = ref.watch(getExtensionsStreamProvider(widget.isManga)); + final streamExtensions = + ref.watch(getExtensionsStreamProvider(widget.isManga)); if (widget.isManga) { ref.watch(fetchMangaSourcesListProvider(id: null, reFresh: false)); } else { @@ -33,15 +35,21 @@ class _ExtensionScreenState extends ConsumerState { final l10n = l10nLocalizations(context)!; return RefreshIndicator( onRefresh: () => widget.isManga - ? ref.refresh(fetchMangaSourcesListProvider(id: null, reFresh: true).future) - : ref.refresh(fetchAnimeSourcesListProvider(id: null, reFresh: true).future), + ? ref.refresh( + fetchMangaSourcesListProvider(id: null, reFresh: true).future) + : ref.refresh( + fetchAnimeSourcesListProvider(id: null, reFresh: true).future), child: Padding( padding: const EdgeInsets.only(top: 10), child: streamExtensions.when( data: (data) { data = widget.query.isEmpty ? data - : data.where((element) => element.name!.toLowerCase().contains(widget.query.toLowerCase())).toList(); + : data + .where((element) => element.name! + .toLowerCase() + .contains(widget.query.toLowerCase())) + .toList(); final notInstalledEntries = data .where((element) => element.version == element.versionLast!) @@ -51,8 +59,10 @@ class _ExtensionScreenState extends ConsumerState { .where((element) => element.version == element.versionLast!) .where((element) => element.isAdded!) .toList(); - final updateEntries = - data.where((element) => compareVersions(element.version!, element.versionLast!) < 0).toList(); + final updateEntries = data + .where((element) => + compareVersions(element.version!, element.versionLast!) < 0) + .toList(); return Scrollbar( interactive: true, controller: controller, @@ -71,16 +81,21 @@ class _ExtensionScreenState extends ConsumerState { children: [ Text( l10n.update_pending, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13), + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), ), ElevatedButton( onPressed: () async { for (var source in updateEntries) { source.isManga! - ? await ref - .watch(fetchMangaSourcesListProvider(id: source.id, reFresh: true).future) - : await ref - .watch(fetchAnimeSourcesListProvider(id: source.id, reFresh: true).future); + ? await ref.watch( + fetchMangaSourcesListProvider( + id: source.id, reFresh: true) + .future) + : await ref.watch( + fetchAnimeSourcesListProvider( + id: source.id, reFresh: true) + .future); } }, child: Text(l10n.update_all)) @@ -92,8 +107,10 @@ class _ExtensionScreenState extends ConsumerState { source: element, ); }, - groupComparator: (group1, group2) => group1.compareTo(group2), - itemComparator: (item1, item2) => item1.name!.compareTo(item2.name!), + groupComparator: (group1, group2) => + group1.compareTo(group2), + itemComparator: (item1, item2) => + item1.name!.compareTo(item2.name!), order: GroupedListOrder.ASC, ), SliverGroupedListView( @@ -103,26 +120,31 @@ class _ExtensionScreenState extends ConsumerState { padding: const EdgeInsets.symmetric(horizontal: 12), child: Text( l10n.installed, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13), + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), ), ), itemBuilder: (context, Source element) { return ExtensionListTileWidget(source: element); }, - groupComparator: (group1, group2) => group1.compareTo(group2), - itemComparator: (item1, item2) => item1.name!.compareTo(item2.name!), + groupComparator: (group1, group2) => + group1.compareTo(group2), + itemComparator: (item1, item2) => + item1.name!.compareTo(item2.name!), order: GroupedListOrder.ASC, ), SliverGroupedListView( elements: notInstalledEntries, - groupBy: (element) => completeLanguageName(element.lang!.toLowerCase()), + groupBy: (element) => + completeLanguageName(element.lang!.toLowerCase()), groupSeparatorBuilder: (String groupByValue) => Padding( padding: const EdgeInsets.only(left: 12), child: Row( children: [ Text( groupByValue, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13), + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), ), ], ), @@ -132,8 +154,10 @@ class _ExtensionScreenState extends ConsumerState { source: element, ); }, - groupComparator: (group1, group2) => group1.compareTo(group2), - itemComparator: (item1, item2) => item1.name!.compareTo(item2.name!), + groupComparator: (group1, group2) => + group1.compareTo(group2), + itemComparator: (item1, item2) => + item1.name!.compareTo(item2.name!), order: GroupedListOrder.ASC, ), ], @@ -144,9 +168,11 @@ class _ExtensionScreenState extends ConsumerState { child: ElevatedButton( onPressed: () { if (widget.isManga) { - ref.invalidate(fetchMangaSourcesListProvider(id: null, reFresh: true)); + ref.invalidate( + fetchMangaSourcesListProvider(id: null, reFresh: true)); } else { - ref.invalidate(fetchAnimeSourcesListProvider(id: null, reFresh: true)); + ref.invalidate( + fetchAnimeSourcesListProvider(id: null, reFresh: true)); } }, child: Text(context.l10n.refresh)), diff --git a/lib/modules/browse/extension/providers/extension_preferences_providers.dart b/lib/modules/browse/extension/providers/extension_preferences_providers.dart index 043619b..df967cd 100644 --- a/lib/modules/browse/extension/providers/extension_preferences_providers.dart +++ b/lib/modules/browse/extension/providers/extension_preferences_providers.dart @@ -5,8 +5,11 @@ import 'package:mangayomi/models/source.dart'; import 'package:mangayomi/services/get_source_preference.dart'; void setPreferenceSetting(SourcePreference sourcePreference, Source source) { - final sourcePref = - isar.sourcePreferences.filter().sourceIdEqualTo(source.id).keyEqualTo(sourcePreference.key).findFirstSync(); + final sourcePref = isar.sourcePreferences + .filter() + .sourceIdEqualTo(source.id) + .keyEqualTo(sourcePreference.key) + .findFirstSync(); isar.writeTxnSync(() { if (sourcePref != null) { isar.sourcePreferences.putSync(sourcePreference); @@ -33,21 +36,30 @@ getPreferenceValue(int sourceId, String key) { } SourcePreference getSourcePreferenceEntry(String key, int sourceId) { - SourcePreference? sourcePreference = - isar.sourcePreferences.filter().sourceIdEqualTo(sourceId).keyEqualTo(key).findFirstSync(); + SourcePreference? sourcePreference = isar.sourcePreferences + .filter() + .sourceIdEqualTo(sourceId) + .keyEqualTo(key) + .findFirstSync(); if (sourcePreference == null) { final source = isar.sources.getSync(sourceId)!; - sourcePreference = getSourcePreference(source: source) - .firstWhere((element) => element.key == key, orElse: () => throw "Error when getting source preference"); + sourcePreference = getSourcePreference(source: source).firstWhere( + (element) => element.key == key, + orElse: () => throw "Error when getting source preference"); setPreferenceSetting(sourcePreference, source); } return sourcePreference; } -String getSourcePreferenceStringValue(int sourceId, String key, String defaultValue) { - SourcePreferenceStringValue? sourcePreferenceStringValue = - isar.sourcePreferenceStringValues.filter().sourceIdEqualTo(sourceId).keyEqualTo(key).findFirstSync(); +String getSourcePreferenceStringValue( + int sourceId, String key, String defaultValue) { + SourcePreferenceStringValue? sourcePreferenceStringValue = isar + .sourcePreferenceStringValues + .filter() + .sourceIdEqualTo(sourceId) + .keyEqualTo(key) + .findFirstSync(); if (sourcePreferenceStringValue == null) { setSourcePreferenceStringValue(sourceId, key, defaultValue); return defaultValue; @@ -57,8 +69,11 @@ String getSourcePreferenceStringValue(int sourceId, String key, String defaultVa } void setSourcePreferenceStringValue(int sourceId, String key, String value) { - final sourcePref = - isar.sourcePreferenceStringValues.filter().sourceIdEqualTo(sourceId).keyEqualTo(key).findFirstSync(); + final sourcePref = isar.sourcePreferenceStringValues + .filter() + .sourceIdEqualTo(sourceId) + .keyEqualTo(key) + .findFirstSync(); isar.writeTxnSync(() { if (sourcePref != null) { isar.sourcePreferenceStringValues.putSync(sourcePref..value = value); diff --git a/lib/modules/browse/extension/widgets/create_extension.dart b/lib/modules/browse/extension/widgets/create_extension.dart index aacd626..6c823d7 100644 --- a/lib/modules/browse/extension/widgets/create_extension.dart +++ b/lib/modules/browse/extension/widgets/create_extension.dart @@ -46,11 +46,13 @@ class _CreateExtensionState extends State { icon: const Icon(Icons.keyboard_arrow_down), isExpanded: true, value: _languageIndex, - hint: Text(_languages[_languageIndex], style: const TextStyle(fontSize: 13)), + hint: Text(_languages[_languageIndex], + style: const TextStyle(fontSize: 13)), items: _languages .map((e) => DropdownMenuItem( value: _languages.indexOf(e), - child: Text(e, style: const TextStyle(fontSize: 13)), + child: Text(e, + style: const TextStyle(fontSize: 13)), )) .toList(), onChanged: (v) { @@ -58,7 +60,8 @@ class _CreateExtensionState extends State { if (v == 0) { _sourceCodeLanguage = SourceCodeLanguage.dart; } else { - _sourceCodeLanguage = SourceCodeLanguage.javascript; + _sourceCodeLanguage = + SourceCodeLanguage.javascript; } _languageIndex = v!; }); @@ -78,12 +81,15 @@ class _CreateExtensionState extends State { _lang = v; }); }), - _textEditing("BaseUrl", context, "ex: https://example.com", (v) { + _textEditing("BaseUrl", context, "ex: https://example.com", + (v) { setState(() { _baseUrl = v; }); }), - _textEditing("ApiUrl (optional)", context, "ex: https://api.example.com", (v) { + _textEditing( + "ApiUrl (optional)", context, "ex: https://api.example.com", + (v) { setState(() { _apiUrl = v; }); @@ -104,11 +110,13 @@ class _CreateExtensionState extends State { icon: const Icon(Icons.keyboard_arrow_down), isExpanded: true, value: _sourceTypeIndex, - hint: Text(_sourceTypes[_sourceTypeIndex], style: const TextStyle(fontSize: 13)), + hint: Text(_sourceTypes[_sourceTypeIndex], + style: const TextStyle(fontSize: 13)), items: _sourceTypes .map((e) => DropdownMenuItem( value: _sourceTypes.indexOf(e), - child: Text(e, style: const TextStyle(fontSize: 13)), + child: Text(e, + style: const TextStyle(fontSize: 13)), )) .toList(), onChanged: (v) { @@ -132,11 +140,15 @@ class _CreateExtensionState extends State { padding: const EdgeInsets.all(8.0), child: ElevatedButton( onPressed: () { - if (_name.isNotEmpty && _lang.isNotEmpty && _baseUrl.isNotEmpty && _iconUrl.isNotEmpty) { + if (_name.isNotEmpty && + _lang.isNotEmpty && + _baseUrl.isNotEmpty && + _iconUrl.isNotEmpty) { try { - final id = _sourceCodeLanguage == SourceCodeLanguage.dart - ? 'mangayomi-$_lang.$_name'.hashCode - : 'mangayomi-js-$_lang.$_name'.hashCode; + final id = + _sourceCodeLanguage == SourceCodeLanguage.dart + ? 'mangayomi-$_lang.$_name'.hashCode + : 'mangayomi-js-$_lang.$_name'.hashCode; final checkIfExist = isar.sources.getSync(id); if (checkIfExist == null) { Source source = Source( @@ -155,9 +167,12 @@ class _CreateExtensionState extends State { ..sourceCodeLanguage = _sourceCodeLanguage; source = source ..isLocal = true - ..sourceCode = - _sourceCodeLanguage == SourceCodeLanguage.dart ? _dartTemplate : _jsSample(source); - isar.writeTxnSync(() => isar.sources.putSync(source)); + ..sourceCode = _sourceCodeLanguage == + SourceCodeLanguage.dart + ? _dartTemplate + : _jsSample(source); + isar.writeTxnSync( + () => isar.sources.putSync(source)); Navigator.pop(context); botToast("Source created successfully"); } else { @@ -177,7 +192,8 @@ class _CreateExtensionState extends State { } } -Widget _textEditing(String label, BuildContext context, String hintText, void Function(String)? onChanged) { +Widget _textEditing(String label, BuildContext context, String hintText, + void Function(String)? onChanged) { return Padding( padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 5), child: TextFormField( @@ -189,9 +205,12 @@ Widget _textEditing(String label, BuildContext context, String hintText, void Fu isDense: true, filled: true, fillColor: Colors.transparent, - enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: context.secondaryColor)), - focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: context.secondaryColor)), - border: OutlineInputBorder(borderSide: BorderSide(color: context.secondaryColor))), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide(color: context.secondaryColor)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide(color: context.secondaryColor)), + border: OutlineInputBorder( + borderSide: BorderSide(color: context.secondaryColor))), ), ); } diff --git a/lib/modules/browse/extension/widgets/extension_lang_list_tile_widget.dart b/lib/modules/browse/extension/widgets/extension_lang_list_tile_widget.dart index 9487ae4..1892453 100644 --- a/lib/modules/browse/extension/widgets/extension_lang_list_tile_widget.dart +++ b/lib/modules/browse/extension/widgets/extension_lang_list_tile_widget.dart @@ -5,7 +5,11 @@ class ExtensionLangListTileWidget extends StatelessWidget { final String lang; final bool value; final Function(bool) onChanged; - const ExtensionLangListTileWidget({super.key, required this.lang, required this.value, required this.onChanged}); + const ExtensionLangListTileWidget( + {super.key, + required this.lang, + required this.value, + required this.onChanged}); @override Widget build(BuildContext context) { diff --git a/lib/modules/browse/extension/widgets/extension_list_tile_widget.dart b/lib/modules/browse/extension/widgets/extension_list_tile_widget.dart index 2ce5823..a680a10 100644 --- a/lib/modules/browse/extension/widgets/extension_list_tile_widget.dart +++ b/lib/modules/browse/extension/widgets/extension_list_tile_widget.dart @@ -14,22 +14,28 @@ import 'package:mangayomi/utils/language.dart'; class ExtensionListTileWidget extends ConsumerStatefulWidget { final Source source; final bool isTestSource; - const ExtensionListTileWidget({super.key, required this.source, this.isTestSource = false}); + const ExtensionListTileWidget( + {super.key, required this.source, this.isTestSource = false}); @override - ConsumerState createState() => _ExtensionListTileWidgetState(); + ConsumerState createState() => + _ExtensionListTileWidgetState(); } -class _ExtensionListTileWidgetState extends ConsumerState { +class _ExtensionListTileWidgetState + extends ConsumerState { bool _isLoading = false; @override Widget build( BuildContext context, ) { final l10n = l10nLocalizations(context)!; - final updateAivalable = - widget.isTestSource ? false : compareVersions(widget.source.version!, widget.source.versionLast!) < 0; - final sourceNotEmpty = widget.source.sourceCode != null && widget.source.sourceCode!.isNotEmpty; + final updateAivalable = widget.isTestSource + ? false + : compareVersions(widget.source.version!, widget.source.versionLast!) < + 0; + final sourceNotEmpty = widget.source.sourceCode != null && + widget.source.sourceCode!.isNotEmpty; return ListTile( onTap: () async { @@ -43,8 +49,12 @@ class _ExtensionListTileWidgetState extends ConsumerState sourcePreference; final Source source; - const SourcePreferenceWidget({super.key, required this.sourcePreference, required this.source}); + const SourcePreferenceWidget( + {super.key, required this.sourcePreference, required this.source}); @override State createState() => _SourcePreferenceWidgetState(); @@ -29,7 +30,9 @@ class _SourcePreferenceWidgetState extends State { final pref = preference.editTextPreference!; w = ListTile( title: Text(pref.title!), - subtitle: Text(pref.summary!, style: TextStyle(fontSize: 11, color: context.secondaryColor)), + subtitle: Text(pref.summary!, + style: TextStyle( + fontSize: 11, color: context.secondaryColor)), onTap: () { showDialog( context: context, @@ -49,7 +52,9 @@ class _SourcePreferenceWidgetState extends State { final pref = preference.checkBoxPreference!; w = CheckboxListTile( title: Text(pref.title!), - subtitle: Text(pref.summary!, style: TextStyle(fontSize: 11, color: context.secondaryColor)), + subtitle: Text(pref.summary!, + style: TextStyle( + fontSize: 11, color: context.secondaryColor)), value: pref.value, onChanged: (value) { setState(() { @@ -63,7 +68,9 @@ class _SourcePreferenceWidgetState extends State { final pref = preference.switchPreferenceCompat!; w = SwitchListTile( title: Text(pref.title!), - subtitle: Text(pref.summary!, style: TextStyle(fontSize: 11, color: context.secondaryColor)), + subtitle: Text(pref.summary!, + style: TextStyle( + fontSize: 11, color: context.secondaryColor)), value: pref.value!, onChanged: (value) { setState(() { @@ -78,7 +85,8 @@ class _SourcePreferenceWidgetState extends State { w = ListTile( title: Text(pref.title!), subtitle: Text(pref.entries![pref.valueIndex!], - style: TextStyle(fontSize: 11, color: context.secondaryColor)), + style: TextStyle( + fontSize: 11, color: context.secondaryColor)), onTap: () async { final res = await showDialog( context: context, @@ -114,7 +122,8 @@ class _SourcePreferenceWidgetState extends State { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), ], ) @@ -132,7 +141,9 @@ class _SourcePreferenceWidgetState extends State { final pref = preference.multiSelectListPreference!; w = ListTile( title: Text(pref.title!), - subtitle: Text(pref.summary!, style: TextStyle(fontSize: 11, color: context.secondaryColor)), + subtitle: Text(pref.summary!, + style: TextStyle( + fontSize: 11, color: context.secondaryColor)), onTap: () { List indexList = []; indexList.addAll(pref.values!); @@ -151,20 +162,27 @@ class _SourcePreferenceWidgetState extends State { itemBuilder: (context, index) { return ListTileChapterFilter( label: pref.entries![index], - type: indexList.contains(pref.entryValues![index]) ? 1 : 0, + type: indexList.contains( + pref.entryValues![index]) + ? 1 + : 0, onTap: () { - if (indexList.contains(pref.entryValues![index])) { + if (indexList.contains( + pref.entryValues![index])) { setState(() { - indexList.remove(pref.entryValues![index]); + indexList.remove(pref + .entryValues![index]); pref.values = indexList; }); } else { setState(() { - indexList.add(pref.entryValues![index]); + indexList.add(pref + .entryValues![index]); pref.values = indexList; }); } - setPreferenceSetting(preference, widget.source); + setPreferenceSetting( + preference, widget.source); }); }, )), @@ -178,7 +196,8 @@ class _SourcePreferenceWidgetState extends State { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), TextButton( onPressed: () async { @@ -186,7 +205,8 @@ class _SourcePreferenceWidgetState extends State { }, child: Text( context.l10n.ok, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), ], ) @@ -211,7 +231,11 @@ class EditTextDialogWidget extends StatefulWidget { final String dialogMessage; final Function(String) onChanged; const EditTextDialogWidget( - {super.key, required this.text, required this.onChanged, required this.dialogTitle, required this.dialogMessage}); + {super.key, + required this.text, + required this.onChanged, + required this.dialogTitle, + required this.dialogMessage}); @override State createState() => _EditTextDialogWidgetState(); @@ -224,7 +248,10 @@ class _EditTextDialogWidgetState extends State { return AlertDialog( title: Column( crossAxisAlignment: CrossAxisAlignment.start, - children: [Text(widget.dialogTitle), Text(widget.dialogMessage, style: const TextStyle(fontSize: 13))], + children: [ + Text(widget.dialogTitle), + Text(widget.dialogMessage, style: const TextStyle(fontSize: 13)) + ], ), content: Padding( padding: const EdgeInsets.only(top: 20), diff --git a/lib/modules/browse/global_search/global_search_screen.dart b/lib/modules/browse/global_search/global_search_screen.dart index 09b1585..a64c1a0 100644 --- a/lib/modules/browse/global_search/global_search_screen.dart +++ b/lib/modules/browse/global_search/global_search_screen.dart @@ -38,7 +38,12 @@ class _GlobalSearchScreenState extends ConsumerState { @override Widget build(BuildContext context) { List sourceList = ref.watch(onlyIncludePinnedSourceStateProvider) - ? isar.sources.filter().isPinnedEqualTo(true).and().isMangaEqualTo(widget.isManga).findAllSync() + ? isar.sources + .filter() + .isPinnedEqualTo(true) + .and() + .isMangaEqualTo(widget.isManga) + .findAllSync() : isar.sources .filter() .idIsNotNull() @@ -123,7 +128,8 @@ class _SourceSearchScreenState extends State { _init() async { try { _errorMessage = ""; - pages = await search(source: widget.source, page: 1, query: widget.query, filterList: []); + pages = await search( + source: widget.source, page: 1, query: widget.query, filterList: []); if (mounted) { setState(() { _isLoading = false; @@ -214,7 +220,8 @@ class MangaGlobalImageCard extends ConsumerStatefulWidget { }); @override - ConsumerState createState() => _MangaGlobalImageCardState(); + ConsumerState createState() => + _MangaGlobalImageCardState(); } class _MangaGlobalImageCardState extends ConsumerState @@ -251,16 +258,20 @@ class _MangaGlobalImageCardState extends ConsumerState child: Column(children: [ Builder( builder: (context) { - if (hasData && snapshot.data!.first.customCoverImage != null) { - return Image.memory(snapshot.data!.first.customCoverImage as Uint8List); + if (hasData && + snapshot.data!.first.customCoverImage != null) { + return Image.memory(snapshot + .data!.first.customCoverImage as Uint8List); } return ClipRRect( borderRadius: BorderRadius.circular(5), child: cachedNetworkImage( - headers: ref - .watch(headersProvider(source: widget.source.name!, lang: widget.source.lang!)), + headers: ref.watch(headersProvider( + source: widget.source.name!, + lang: widget.source.lang!)), imageUrl: toImgUrl(hasData - ? snapshot.data!.first.customCoverFromTracker ?? + ? snapshot.data!.first + .customCoverFromTracker ?? snapshot.data!.first.imageUrl ?? "" : getMangaDetail.imageUrl ?? ""), @@ -281,7 +292,9 @@ class _MangaGlobalImageCardState extends ConsumerState Container( width: 110, height: 150, - color: hasData && snapshot.data!.first.favorite! ? Colors.black.withValues(alpha: 0.7) : null, + color: hasData && snapshot.data!.first.favorite! + ? Colors.black.withValues(alpha: 0.7) + : null, ), if (hasData && snapshot.data!.first.favorite!) Positioned( @@ -289,7 +302,8 @@ class _MangaGlobalImageCardState extends ConsumerState left: 0, child: Padding( padding: const EdgeInsets.all(4), - child: Icon(Icons.collections_bookmark, color: context.primaryColor), + child: Icon(Icons.collections_bookmark, + color: context.primaryColor), )) ], ), diff --git a/lib/modules/browse/sources/sources_filter_screen.dart b/lib/modules/browse/sources/sources_filter_screen.dart index 0cf9e8d..2be30b7 100644 --- a/lib/modules/browse/sources/sources_filter_screen.dart +++ b/lib/modules/browse/sources/sources_filter_screen.dart @@ -38,7 +38,8 @@ class SourcesFilterScreen extends ConsumerWidget { SliverGroupedListView( elements: entries, groupBy: (element) => element.lang!, - groupSeparatorBuilder: (String groupByValue) => SwitchListTile( + groupSeparatorBuilder: (String groupByValue) => + SwitchListTile( value: entries .where((element) => element.lang!.toLowerCase() == groupByValue && @@ -49,19 +50,24 @@ class SourcesFilterScreen extends ConsumerWidget { isar.writeTxnSync(() { for (var source in entries) { if (source.lang!.toLowerCase() == groupByValue) { - isar.sources.putSync(source..isActive = val == true); + isar.sources + .putSync(source..isActive = val == true); } } }); }, title: Text( completeLanguageName(groupByValue), - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13), + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), ), ), itemBuilder: (context, Source element) { if (entries - .where((s) => s.lang!.toLowerCase() == element.lang && s.isActive! && s.isManga == isManga) + .where((s) => + s.lang!.toLowerCase() == element.lang && + s.isActive! && + s.isManga == isManga) .isEmpty) { return Container(); } @@ -70,7 +76,9 @@ class SourcesFilterScreen extends ConsumerWidget { height: 37, width: 37, decoration: BoxDecoration( - color: Theme.of(context).secondaryHeaderColor.withValues(alpha: 0.5), + color: Theme.of(context) + .secondaryHeaderColor + .withValues(alpha: 0.5), borderRadius: BorderRadius.circular(5)), child: element.iconUrl!.isEmpty ? const Icon(Icons.source_outlined) @@ -97,8 +105,10 @@ class SourcesFilterScreen extends ConsumerWidget { title: Text(element.name!), ); }, - groupComparator: (group1, group2) => group1.compareTo(group2), - itemComparator: (item1, item2) => item1.name!.compareTo(item2.name!), + groupComparator: (group1, group2) => + group1.compareTo(group2), + itemComparator: (item1, item2) => + item1.name!.compareTo(item2.name!), order: GroupedListOrder.ASC, ), ], diff --git a/lib/modules/browse/sources/sources_screen.dart b/lib/modules/browse/sources/sources_screen.dart index f23cd66..15a8295 100644 --- a/lib/modules/browse/sources/sources_screen.dart +++ b/lib/modules/browse/sources/sources_screen.dart @@ -11,7 +11,8 @@ import 'package:mangayomi/utils/language.dart'; class SourcesScreen extends ConsumerStatefulWidget { final Function(int) tabIndex; final bool isManga; - const SourcesScreen({required this.tabIndex, required this.isManga, super.key}); + const SourcesScreen( + {required this.tabIndex, required this.isManga, super.key}); @override ConsumerState createState() => _SourcesScreenState(); @@ -50,16 +51,20 @@ class _SourcesScreenState extends ConsumerState { Padding( padding: const EdgeInsets.all(8.0), child: ElevatedButton.icon( - onPressed: () => widget.tabIndex(widget.isManga ? 2 : 3), + onPressed: () => + widget.tabIndex(widget.isManga ? 2 : 3), icon: const Icon(Icons.extension_rounded), label: Text(context.l10n.show_extensions)), ) ], ); } - final lastUsedEntries = sources.where((element) => element.lastUsed!).toList(); - final isPinnedEntries = sources.where((element) => element.isPinned!).toList(); - final allEntriesWithoutIspinned = sources.where((element) => !element.isPinned!).toList(); + final lastUsedEntries = + sources.where((element) => element.lastUsed!).toList(); + final isPinnedEntries = + sources.where((element) => element.isPinned!).toList(); + final allEntriesWithoutIspinned = + sources.where((element) => !element.isPinned!).toList(); return Scrollbar( interactive: true, controller: controller, @@ -77,7 +82,8 @@ class _SourcesScreenState extends ConsumerState { children: [ Text( l10n.last_used, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13), + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), ), ], ), @@ -88,8 +94,10 @@ class _SourcesScreenState extends ConsumerState { isManga: widget.isManga, ); }, - groupComparator: (group1, group2) => group1.compareTo(group2), - itemComparator: (item1, item2) => item1.name!.compareTo(item2.name!), + groupComparator: (group1, group2) => + group1.compareTo(group2), + itemComparator: (item1, item2) => + item1.name!.compareTo(item2.name!), order: GroupedListOrder.ASC, ), SliverGroupedListView( @@ -101,7 +109,8 @@ class _SourcesScreenState extends ConsumerState { children: [ Text( l10n.pinned, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13), + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), ), ], ), @@ -112,20 +121,24 @@ class _SourcesScreenState extends ConsumerState { isManga: widget.isManga, ); }, - groupComparator: (group1, group2) => group1.compareTo(group2), - itemComparator: (item1, item2) => item1.name!.compareTo(item2.name!), + groupComparator: (group1, group2) => + group1.compareTo(group2), + itemComparator: (item1, item2) => + item1.name!.compareTo(item2.name!), order: GroupedListOrder.ASC, ), SliverGroupedListView( elements: allEntriesWithoutIspinned, - groupBy: (element) => completeLanguageName(element.lang!.toLowerCase()), + groupBy: (element) => + completeLanguageName(element.lang!.toLowerCase()), groupSeparatorBuilder: (String groupByValue) => Padding( padding: const EdgeInsets.only(left: 12), child: Row( children: [ Text( groupByValue, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 13), + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 13), ), ], ), @@ -136,8 +149,10 @@ class _SourcesScreenState extends ConsumerState { isManga: widget.isManga, ); }, - groupComparator: (group1, group2) => group1.compareTo(group2), - itemComparator: (item1, item2) => item1.name!.compareTo(item2.name!), + groupComparator: (group1, group2) => + group1.compareTo(group2), + itemComparator: (item1, item2) => + item1.name!.compareTo(item2.name!), order: GroupedListOrder.ASC, ), ], diff --git a/lib/modules/browse/sources/widgets/source_list_tile.dart b/lib/modules/browse/sources/widgets/source_list_tile.dart index 749ec00..089de6f 100644 --- a/lib/modules/browse/sources/widgets/source_list_tile.dart +++ b/lib/modules/browse/sources/widgets/source_list_tile.dart @@ -12,16 +12,23 @@ import 'package:mangayomi/utils/language.dart'; class SourceListTile extends StatelessWidget { final bool isManga; final Source source; - const SourceListTile({super.key, required this.source, required this.isManga}); + const SourceListTile( + {super.key, required this.source, required this.isManga}); @override Widget build(BuildContext context) { return ListTile( onTap: () { - final sources = isar.sources.filter().idIsNotNull().and().isMangaEqualTo(isManga).findAllSync(); + final sources = isar.sources + .filter() + .idIsNotNull() + .and() + .isMangaEqualTo(isManga) + .findAllSync(); isar.writeTxnSync(() { for (var src in sources) { - isar.sources.putSync(src..lastUsed = src.id == source.id ? true : false); + isar.sources + .putSync(src..lastUsed = src.id == source.id ? true : false); } }); @@ -31,7 +38,8 @@ class SourceListTile extends StatelessWidget { height: 37, width: 37, decoration: BoxDecoration( - color: Theme.of(context).secondaryHeaderColor.withValues(alpha: 0.5), + color: + Theme.of(context).secondaryHeaderColor.withValues(alpha: 0.5), borderRadius: BorderRadius.circular(5)), child: source.iconUrl!.isEmpty ? const Icon(Icons.extension_rounded) @@ -68,8 +76,10 @@ class SourceListTile extends StatelessWidget { // final supportsLatest = ref.watch(supportsLatestProvider(source: source)); // if (supportsLatest) { return TextButton( - style: const ButtonStyle(padding: WidgetStatePropertyAll(EdgeInsets.all(10))), - onPressed: () => context.push('/mangaHome', extra: (source, true)), + style: const ButtonStyle( + padding: WidgetStatePropertyAll(EdgeInsets.all(10))), + onPressed: () => + context.push('/mangaHome', extra: (source, true)), child: Text(context.l10n.latest)); // } // return const SizedBox.shrink(); @@ -79,7 +89,8 @@ class SourceListTile extends StatelessWidget { IconButton( padding: const EdgeInsets.all(0), onPressed: () { - isar.writeTxnSync(() => isar.sources.putSync(source..isPinned = !source.isPinned!)); + isar.writeTxnSync(() => isar.sources + .putSync(source..isPinned = !source.isPinned!)); }, icon: Icon( Icons.push_pin_outlined, diff --git a/lib/modules/history/history_screen.dart b/lib/modules/history/history_screen.dart index 3136e1c..20fc747 100644 --- a/lib/modules/history/history_screen.dart +++ b/lib/modules/history/history_screen.dart @@ -28,7 +28,8 @@ class HistoryScreen extends ConsumerStatefulWidget { ConsumerState createState() => _HistoryScreenState(); } -class _HistoryScreenState extends ConsumerState with TickerProviderStateMixin { +class _HistoryScreenState extends ConsumerState + with TickerProviderStateMixin { late TabController _tabBarController; @override @@ -88,7 +89,8 @@ class _HistoryScreenState extends ConsumerState with TickerProvid _isSearch = true; }); }, - icon: Icon(Icons.search, color: Theme.of(context).hintColor)), + icon: + Icon(Icons.search, color: Theme.of(context).hintColor)), IconButton( splashRadius: 20, onPressed: () { @@ -117,8 +119,10 @@ class _HistoryScreenState extends ConsumerState with TickerProvid List histories = isar.historys .filter() .idIsNotNull() - .chapter( - (q) => q.manga((q) => q.isMangaEqualTo(_tabBarController.index == 0))) + .chapter((q) => q.manga((q) => + q.isMangaEqualTo( + _tabBarController.index == + 0))) .findAllSync() .toList(); isar.writeTxnSync(() { @@ -137,7 +141,8 @@ class _HistoryScreenState extends ConsumerState with TickerProvid ); }); }, - icon: Icon(Icons.delete_sweep_outlined, color: Theme.of(context).hintColor)), + icon: Icon(Icons.delete_sweep_outlined, + color: Theme.of(context).hintColor)), ], bottom: TabBar( indicatorSize: TabBarIndicatorSize.tab, @@ -179,13 +184,16 @@ class _HistoryTabState extends ConsumerState { @override Widget build(BuildContext context) { final l10n = l10nLocalizations(context)!; - final history = ref.watch(getAllHistoryStreamProvider(isManga: widget.isManga)); + final history = + ref.watch(getAllHistoryStreamProvider(isManga: widget.isManga)); return Scaffold( body: history.when( data: (data) { final entries = data .where((element) => widget.query.isNotEmpty - ? element.chapter.value!.manga.value!.name!.toLowerCase().contains(widget.query.toLowerCase()) + ? element.chapter.value!.manga.value!.name! + .toLowerCase() + .contains(widget.query.toLowerCase()) : true) .toList(); @@ -195,7 +203,10 @@ class _HistoryTabState extends ConsumerState { SliverGroupedListView( elements: entries, groupBy: (element) => dateFormat(element.date!, - context: context, ref: ref, forHistoryValue: true, useRelativeTimesTamps: false), + context: context, + ref: ref, + forHistoryValue: true, + useRelativeTimesTamps: false), groupSeparatorBuilder: (String groupByValue) => Padding( padding: const EdgeInsets.only(bottom: 8, left: 12), child: Row( @@ -216,7 +227,8 @@ class _HistoryTabState extends ConsumerState { style: ElevatedButton.styleFrom( padding: const EdgeInsets.all(0), backgroundColor: Colors.transparent, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(0)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(0)), elevation: 0, shadowColor: Colors.transparent), onPressed: () { @@ -235,18 +247,26 @@ class _HistoryTabState extends ConsumerState { child: ElevatedButton( style: ElevatedButton.styleFrom( padding: const EdgeInsets.all(0), - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(7)), ), onPressed: () { - context.push('/manga-reader/detail', extra: manga.id); + context.push('/manga-reader/detail', + extra: manga.id); }, child: ClipRRect( borderRadius: BorderRadius.circular(7), child: manga.customCoverImage != null - ? Image.memory(manga.customCoverImage as Uint8List) + ? Image.memory( + manga.customCoverImage as Uint8List) : cachedNetworkImage( - headers: ref.watch(headersProvider(source: manga.source!, lang: manga.lang!)), - imageUrl: toImgUrl(manga.customCoverFromTracker ?? manga.imageUrl ?? ""), + headers: ref.watch(headersProvider( + source: manga.source!, + lang: manga.lang!)), + imageUrl: toImgUrl( + manga.customCoverFromTracker ?? + manga.imageUrl ?? + ""), width: 60, height: 90, fit: BoxFit.cover), @@ -262,33 +282,46 @@ class _HistoryTabState extends ConsumerState { child: Padding( padding: const EdgeInsets.all(8.0), child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Text( manga.name!, style: TextStyle( fontSize: 14, - color: Theme.of(context).textTheme.bodyLarge!.color, + color: Theme.of(context) + .textTheme + .bodyLarge! + .color, fontWeight: FontWeight.bold), textAlign: TextAlign.start, ), Wrap( - crossAxisAlignment: WrapCrossAlignment.end, + crossAxisAlignment: + WrapCrossAlignment.end, children: [ Text( chapter.name!, style: TextStyle( fontSize: 11, - color: Theme.of(context).textTheme.bodyLarge!.color, + color: Theme.of(context) + .textTheme + .bodyLarge! + .color, ), ), Text( " - ${dateFormatHour(element.date!, context)}", style: TextStyle( fontSize: 11, - color: Theme.of(context).textTheme.bodyLarge!.color, - fontWeight: FontWeight.w400), + color: Theme.of(context) + .textTheme + .bodyLarge! + .color, + fontWeight: + FontWeight.w400), ), ], ), @@ -306,43 +339,73 @@ class _HistoryTabState extends ConsumerState { title: Text( l10n.remove, ), - content: Text(l10n.remove_history_msg), + content: Text( + l10n.remove_history_msg), actions: [ Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.end, children: [ TextButton( onPressed: () { - Navigator.pop(context); + Navigator.pop( + context); }, - child: Text(l10n.cancel)), + child: Text( + l10n.cancel)), const SizedBox( width: 15, ), TextButton( onPressed: () async { - await manga.chapters.load(); - final chapters = manga.chapters; - await isar.writeTxn(() async { - await isar.historys.delete(element.id!); - for (var chapter in chapters) { + await manga.chapters + .load(); + final chapters = + manga.chapters; + await isar.writeTxn( + () async { + await isar + .historys + .delete( + element + .id!); + for (var chapter + in chapters) { await ref - .read(changedItemsManagerProvider(managerId: 1) + .read(changedItemsManagerProvider( + managerId: + 1) .notifier) - .addUpdatedChapterAsync(chapter, true, false); - await isar.chapters.delete(chapter.id!); + .addUpdatedChapterAsync( + chapter, + true, + false); + await isar + .chapters + .delete( + chapter + .id!); } await ref - .read(changedItemsManagerProvider(managerId: 1) + .read(changedItemsManagerProvider( + managerId: + 1) .notifier) - .addDeletedMangaAsync(manga, false); - await isar.mangas.delete(manga.id!); + .addDeletedMangaAsync( + manga, + false); + await isar.mangas + .delete(manga + .id!); }); - if (context.mounted) { - Navigator.pop(context); + if (context + .mounted) { + Navigator.pop( + context); } }, - child: Text(l10n.remove)), + child: Text( + l10n.remove)), ], ) ], @@ -352,7 +415,10 @@ class _HistoryTabState extends ConsumerState { icon: Icon( Icons.delete_outline, size: 25, - color: Theme.of(context).textTheme.bodyLarge!.color, + color: Theme.of(context) + .textTheme + .bodyLarge! + .color, )), ], ), @@ -363,7 +429,8 @@ class _HistoryTabState extends ConsumerState { ), ); }, - itemComparator: (item1, item2) => item1.date!.compareTo(item2.date!), + itemComparator: (item1, item2) => + item1.date!.compareTo(item2.date!), order: GroupedListOrder.DESC, ), ], diff --git a/lib/modules/history/providers/isar_providers.dart b/lib/modules/history/providers/isar_providers.dart index 08ce7c5..c800f60 100644 --- a/lib/modules/history/providers/isar_providers.dart +++ b/lib/modules/history/providers/isar_providers.dart @@ -9,7 +9,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; part 'isar_providers.g.dart'; @riverpod -Stream> getAllHistoryStream(Ref ref, {required bool isManga}) async* { +Stream> getAllHistoryStream(Ref ref, + {required bool isManga}) async* { yield* isar.historys .filter() .idIsNotNull() @@ -19,7 +20,8 @@ Stream> getAllHistoryStream(Ref ref, {required bool isManga}) asyn } @riverpod -Stream> getAllUpdateStream(Ref ref, {required bool isManga}) async* { +Stream> getAllUpdateStream(Ref ref, + {required bool isManga}) async* { yield* isar.updates .filter() .idIsNotNull() diff --git a/lib/modules/library/library_screen.dart b/lib/modules/library/library_screen.dart index e933d9d..ad8b031 100644 --- a/lib/modules/library/library_screen.dart +++ b/lib/modules/library/library_screen.dart @@ -8,7 +8,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:isar/isar.dart'; -import 'package:mangayomi/eval/dart/model/m_bridge.dart'; +import 'package:mangayomi/eval/model/m_bridge.dart'; import 'package:mangayomi/main.dart'; import 'package:mangayomi/models/category.dart'; import 'package:mangayomi/models/chapter.dart'; @@ -1115,7 +1115,9 @@ class _LibraryScreenState extends ConsumerState type: fromLibList.isNotEmpty ? 1 : 0, ), ListTileChapterFilter( - label: widget.isManga ? l10n.downloaded_chapters : l10n.downloaded_episodes, + label: widget.isManga + ? l10n.downloaded_chapters + : l10n.downloaded_episodes, onTap: () { setState(() { if (downloadedChapsList == mangaIdsList) { @@ -1516,7 +1518,9 @@ class _LibraryScreenState extends ConsumerState child: Column( children: [ ListTileChapterFilter( - label: widget.isManga ? l10n.downloaded_chapters : l10n.downloaded_episodes, + label: widget.isManga + ? l10n.downloaded_chapters + : l10n.downloaded_episodes, type: downloadedChapter ? 1 : 0, onTap: () { ref @@ -1549,7 +1553,9 @@ class _LibraryScreenState extends ConsumerState .set(!localSource); }), ListTileChapterFilter( - label: widget.isManga ? l10n.show_continue_reading_buttons : l10n.show_continue_watching_buttons, + label: widget.isManga + ? l10n.show_continue_reading_buttons + : l10n.show_continue_watching_buttons, type: continueReaderBtn ? 1 : 0, onTap: () { ref @@ -1648,7 +1654,8 @@ class _LibraryScreenState extends ConsumerState color: Theme.of(context).scaffoldBackgroundColor, child: AppBar( title: Text(mangaIdsList.length.toString()), - backgroundColor: context.primaryColor.withValues(alpha: 0.2), + backgroundColor: + context.primaryColor.withValues(alpha: 0.2), leading: IconButton( onPressed: () { ref.read(mangasListStateProvider.notifier).clear(); diff --git a/lib/modules/library/providers/add_torrent.dart b/lib/modules/library/providers/add_torrent.dart index b39bcd6..f49b677 100644 --- a/lib/modules/library/providers/add_torrent.dart +++ b/lib/modules/library/providers/add_torrent.dart @@ -8,17 +8,23 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; part 'add_torrent.g.dart'; @riverpod -Future addTorrentFromUrlOrFromFile(Ref ref, Manga? mManga, {required bool init, String? url}) async { +Future addTorrentFromUrlOrFromFile(Ref ref, Manga? mManga, + {required bool init, String? url}) async { FilePickerResult? result; if (url == null) { - result = - await FilePicker.platform.pickFiles(allowMultiple: true, type: FileType.custom, allowedExtensions: ['torrent']); + result = await FilePicker.platform.pickFiles( + allowMultiple: true, + type: FileType.custom, + allowedExtensions: ['torrent']); } if (result != null || url != null) { String torrentName = ""; if (url != null) { - torrentName = (await MTorrentServer().getTorrentPlaylist(url, null)).$1.first.quality; + torrentName = (await MTorrentServer().getTorrentPlaylist(url, null)) + .$1 + .first + .quality; } final dateNow = DateTime.now().millisecondsSinceEpoch; final manga = mManga ?? @@ -43,7 +49,8 @@ Future addTorrentFromUrlOrFromFile(Ref ref, Manga? mManga, {required bool init, manga.customCoverImage = null; isar.writeTxnSync(() { isar.mangas.putSync(manga); - final chapters = Chapter(name: torrentName, url: url, mangaId: manga.id)..manga.value = manga; + final chapters = Chapter(name: torrentName, url: url, mangaId: manga.id) + ..manga.value = manga; isar.chapters.putSync(chapters); chapters.manga.saveSync(); }); @@ -57,7 +64,9 @@ Future addTorrentFromUrlOrFromFile(Ref ref, Manga? mManga, {required bool init, isar.writeTxnSync(() { isar.mangas.putSync(manga); - final chapters = Chapter(name: name, archivePath: file.path, mangaId: manga.id)..manga.value = manga; + final chapters = + Chapter(name: name, archivePath: file.path, mangaId: manga.id) + ..manga.value = manga; isar.chapters.putSync(chapters); chapters.manga.saveSync(); }); @@ -68,10 +77,6 @@ Future addTorrentFromUrlOrFromFile(Ref ref, Manga? mManga, {required bool init, } String _getName(String path) { - return path - .split('/') - .last - .split("\\") - .last - .replaceAll(RegExp(r'\.(mp4|mov|avi|flv|wmv|mpeg|mkv|cbz|zip|cbt|tar|torrent)'), ''); + return path.split('/').last.split("\\").last.replaceAll( + RegExp(r'\.(mp4|mov|avi|flv|wmv|mpeg|mkv|cbz|zip|cbt|tar|torrent)'), ''); } diff --git a/lib/modules/library/providers/isar_providers.dart b/lib/modules/library/providers/isar_providers.dart index 87db5ff..d87d127 100644 --- a/lib/modules/library/providers/isar_providers.dart +++ b/lib/modules/library/providers/isar_providers.dart @@ -7,7 +7,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; part 'isar_providers.g.dart'; @riverpod -Stream> getAllMangaStream(Ref ref, {required int? categoryId, required bool? isManga}) async* { +Stream> getAllMangaStream(Ref ref, + {required int? categoryId, required bool? isManga}) async* { yield* categoryId == null ? isar.mangas .filter() @@ -28,7 +29,8 @@ Stream> getAllMangaStream(Ref ref, {required int? categoryId, requir } @riverpod -Stream> getAllMangaWithoutCategoriesStream(Ref ref, {required bool? isManga}) async* { +Stream> getAllMangaWithoutCategoriesStream(Ref ref, + {required bool? isManga}) async* { yield* isar.mangas .filter() .idIsNotNull() @@ -47,5 +49,10 @@ Stream> getAllMangaWithoutCategoriesStream(Ref ref, {required bool? @riverpod Stream> getSettingsStream(Ref ref) async* { - yield* isar.settings.filter().idIsNotNull().and().idEqualTo(227).watch(fireImmediately: true); + yield* isar.settings + .filter() + .idIsNotNull() + .and() + .idEqualTo(227) + .watch(fireImmediately: true); } diff --git a/lib/modules/library/providers/library_state_provider.dart b/lib/modules/library/providers/library_state_provider.dart index fd02ba2..5e22641 100644 --- a/lib/modules/library/providers/library_state_provider.dart +++ b/lib/modules/library/providers/library_state_provider.dart @@ -16,7 +16,8 @@ class LibraryDisplayTypeState extends _$LibraryDisplayTypeState { return isManga ? settings.displayType : settings.animeDisplayType; } - String getLibraryDisplayTypeName(DisplayType displayType, BuildContext context) { + String getLibraryDisplayTypeName( + DisplayType displayType, BuildContext context) { final l10n = context.l10n; return switch (displayType) { DisplayType.compactGrid => l10n.compact_grid, @@ -74,13 +75,18 @@ class LibraryGridSizeState extends _$LibraryGridSizeState { @riverpod class MangaFilterDownloadedState extends _$MangaFilterDownloadedState { @override - int build({required List mangaList, required bool isManga, required Settings settings}) { + int build( + {required List mangaList, + required bool isManga, + required Settings settings}) { state = getType(); return getType(); } int getType() { - return isManga ? settings.libraryFilterMangasDownloadType! : settings.libraryFilterAnimeDownloadType ?? 0; + return isManga + ? settings.libraryFilterMangasDownloadType! + : settings.libraryFilterAnimeDownloadType ?? 0; } void setType(int type) { @@ -110,13 +116,18 @@ class MangaFilterDownloadedState extends _$MangaFilterDownloadedState { @riverpod class MangaFilterUnreadState extends _$MangaFilterUnreadState { @override - int build({required List mangaList, required bool isManga, required Settings settings}) { + int build( + {required List mangaList, + required bool isManga, + required Settings settings}) { state = getType(); return getType(); } int getType() { - return isManga ? settings.libraryFilterMangasUnreadType! : settings.libraryFilterAnimeUnreadType ?? 0; + return isManga + ? settings.libraryFilterMangasUnreadType! + : settings.libraryFilterAnimeUnreadType ?? 0; } void setType(int type) { @@ -195,13 +206,18 @@ class MangaFilterUnreadState extends _$MangaFilterUnreadState { @riverpod class MangaFilterStartedState extends _$MangaFilterStartedState { @override - int build({required List mangaList, required bool isManga, required Settings settings}) { + int build( + {required List mangaList, + required bool isManga, + required Settings settings}) { state = getType(); return getType(); } int getType() { - return isManga ? settings.libraryFilterMangasStartedType! : settings.libraryFilterAnimeStartedType ?? 0; + return isManga + ? settings.libraryFilterMangasStartedType! + : settings.libraryFilterAnimeStartedType ?? 0; } void setType(int type) { @@ -280,13 +296,18 @@ class MangaFilterStartedState extends _$MangaFilterStartedState { @riverpod class MangaFilterBookmarkedState extends _$MangaFilterBookmarkedState { @override - int build({required List mangaList, required bool isManga, required Settings settings}) { + int build( + {required List mangaList, + required bool isManga, + required Settings settings}) { state = getType(); return getType(); } int getType() { - return isManga ? settings.libraryFilterMangasBookMarkedType! : settings.libraryFilterAnimeBookMarkedType ?? 0; + return isManga + ? settings.libraryFilterMangasBookMarkedType! + : settings.libraryFilterAnimeBookMarkedType ?? 0; } void setType(int type) { @@ -365,16 +386,22 @@ class MangaFilterBookmarkedState extends _$MangaFilterBookmarkedState { @riverpod class MangasFilterResultState extends _$MangasFilterResultState { @override - bool build({required List mangaList, required bool isManga, required Settings settings}) { - final downloadFilterType = - ref.watch(mangaFilterDownloadedStateProvider(mangaList: mangaList, isManga: isManga, settings: settings)); - final unreadFilterType = - ref.watch(mangaFilterUnreadStateProvider(mangaList: mangaList, isManga: isManga, settings: settings)); - final startedFilterType = - ref.watch(mangaFilterStartedStateProvider(mangaList: mangaList, isManga: isManga, settings: settings)); - final bookmarkedFilterType = - ref.watch(mangaFilterBookmarkedStateProvider(mangaList: mangaList, isManga: isManga, settings: settings)); - return downloadFilterType == 0 && unreadFilterType == 0 && startedFilterType == 0 && bookmarkedFilterType == 0; + bool build( + {required List mangaList, + required bool isManga, + required Settings settings}) { + final downloadFilterType = ref.watch(mangaFilterDownloadedStateProvider( + mangaList: mangaList, isManga: isManga, settings: settings)); + final unreadFilterType = ref.watch(mangaFilterUnreadStateProvider( + mangaList: mangaList, isManga: isManga, settings: settings)); + final startedFilterType = ref.watch(mangaFilterStartedStateProvider( + mangaList: mangaList, isManga: isManga, settings: settings)); + final bookmarkedFilterType = ref.watch(mangaFilterBookmarkedStateProvider( + mangaList: mangaList, isManga: isManga, settings: settings)); + return downloadFilterType == 0 && + unreadFilterType == 0 && + startedFilterType == 0 && + bookmarkedFilterType == 0; } } @@ -382,7 +409,9 @@ class MangasFilterResultState extends _$MangasFilterResultState { class LibraryShowCategoryTabsState extends _$LibraryShowCategoryTabsState { @override bool build({required bool isManga, required Settings settings}) { - return isManga ? settings.libraryShowCategoryTabs! : settings.animeLibraryShowCategoryTabs ?? false; + return isManga + ? settings.libraryShowCategoryTabs! + : settings.animeLibraryShowCategoryTabs ?? false; } void set(bool value) { @@ -403,7 +432,9 @@ class LibraryShowCategoryTabsState extends _$LibraryShowCategoryTabsState { class LibraryDownloadedChaptersState extends _$LibraryDownloadedChaptersState { @override bool build({required bool isManga, required Settings settings}) { - return isManga ? settings.libraryDownloadedChapters! : settings.animeLibraryDownloadedChapters ?? false; + return isManga + ? settings.libraryDownloadedChapters! + : settings.animeLibraryDownloadedChapters ?? false; } void set(bool value) { @@ -424,7 +455,9 @@ class LibraryDownloadedChaptersState extends _$LibraryDownloadedChaptersState { class LibraryLanguageState extends _$LibraryLanguageState { @override bool build({required bool isManga, required Settings settings}) { - return isManga ? settings.libraryShowLanguage! : settings.animeLibraryShowLanguage ?? false; + return isManga + ? settings.libraryShowLanguage! + : settings.animeLibraryShowLanguage ?? false; } void set(bool value) { @@ -445,7 +478,9 @@ class LibraryLanguageState extends _$LibraryLanguageState { class LibraryLocalSourceState extends _$LibraryLocalSourceState { @override bool build({required bool isManga, required Settings settings}) { - return isManga ? settings.libraryLocalSource ?? false : settings.animeLibraryLocalSource ?? false; + return isManga + ? settings.libraryLocalSource ?? false + : settings.animeLibraryLocalSource ?? false; } void set(bool value) { @@ -466,7 +501,9 @@ class LibraryLocalSourceState extends _$LibraryLocalSourceState { class LibraryShowNumbersOfItemsState extends _$LibraryShowNumbersOfItemsState { @override bool build({required bool isManga, required Settings settings}) { - return isManga ? settings.libraryShowNumbersOfItems! : settings.animeLibraryShowNumbersOfItems ?? false; + return isManga + ? settings.libraryShowNumbersOfItems! + : settings.animeLibraryShowNumbersOfItems ?? false; } void set(bool value) { @@ -484,7 +521,8 @@ class LibraryShowNumbersOfItemsState extends _$LibraryShowNumbersOfItemsState { } @riverpod -class LibraryShowContinueReadingButtonState extends _$LibraryShowContinueReadingButtonState { +class LibraryShowContinueReadingButtonState + extends _$LibraryShowContinueReadingButtonState { @override bool build({required bool isManga, required Settings settings}) { return isManga @@ -510,7 +548,9 @@ class LibraryShowContinueReadingButtonState extends _$LibraryShowContinueReading class SortLibraryMangaState extends _$SortLibraryMangaState { @override SortLibraryManga build({required bool isManga, required Settings settings}) { - return isManga ? settings.sortLibraryManga ?? SortLibraryManga() : settings.sortLibraryAnime ?? SortLibraryManga(); + return isManga + ? settings.sortLibraryManga ?? SortLibraryManga() + : settings.sortLibraryAnime ?? SortLibraryManga(); } void update(bool reverse, int index) { @@ -611,7 +651,9 @@ class MangasSetIsReadState extends _$MangasSetIsReadState { for (var chapter in chapters) { chapter.isRead = true; chapter.lastPageRead = "1"; - ref.read(changedItemsManagerProvider(managerId: 1).notifier).addUpdatedChapter(chapter, false, false); + ref + .read(changedItemsManagerProvider(managerId: 1).notifier) + .addUpdatedChapter(chapter, false, false); isar.chapters.putSync(chapter..manga.value = manga); chapter.manga.saveSync(); } @@ -636,7 +678,9 @@ class MangasSetUnReadState extends _$MangasSetUnReadState { isar.writeTxnSync(() { for (var chapter in chapters) { chapter.isRead = false; - ref.read(changedItemsManagerProvider(managerId: 1).notifier).addUpdatedChapter(chapter, false, false); + ref + .read(changedItemsManagerProvider(managerId: 1).notifier) + .addUpdatedChapter(chapter, false, false); isar.chapters.putSync(chapter..manga.value = manga); chapter.manga.saveSync(); } diff --git a/lib/modules/library/providers/local_archive.dart b/lib/modules/library/providers/local_archive.dart index 7db062e..98b57e6 100644 --- a/lib/modules/library/providers/local_archive.dart +++ b/lib/modules/library/providers/local_archive.dart @@ -10,11 +10,14 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; part 'local_archive.g.dart'; @riverpod -Future importArchivesFromFile(Ref ref, Manga? mManga, {required bool isManga, required bool init}) async { +Future importArchivesFromFile(Ref ref, Manga? mManga, + {required bool isManga, required bool init}) async { FilePickerResult? result = await FilePicker.platform.pickFiles( allowMultiple: true, type: FileType.custom, - allowedExtensions: isManga ? ['cbz', 'zip'] : ['mp4', 'mov', 'avi', 'flv', 'wmv', 'mpeg', 'mkv']); + allowedExtensions: isManga + ? ['cbz', 'zip'] + : ['mp4', 'mov', 'avi', 'flv', 'wmv', 'mpeg', 'mkv']); if (result != null) { final dateNow = DateTime.now().millisecondsSinceEpoch; final manga = mManga ?? @@ -36,8 +39,9 @@ Future importArchivesFromFile(Ref ref, Manga? mManga, {required bool isManga, re artist: '', ); for (var file in result.files.reversed.toList()) { - (String, LocalExtensionType, Uint8List, String)? data = - isManga ? await ref.watch(getArchivesDataFromFileProvider(file.path!).future) : null; + (String, LocalExtensionType, Uint8List, String)? data = isManga + ? await ref.watch(getArchivesDataFromFileProvider(file.path!).future) + : null; String name = _getName(file.path!); if (init) { @@ -46,9 +50,11 @@ Future importArchivesFromFile(Ref ref, Manga? mManga, {required bool isManga, re isar.writeTxnSync(() { isar.mangas.putSync(manga); - final chapters = - Chapter(name: isManga ? data!.$1 : name, archivePath: isManga ? data!.$4 : file.path, mangaId: manga.id) - ..manga.value = manga; + final chapters = Chapter( + name: isManga ? data!.$1 : name, + archivePath: isManga ? data!.$4 : file.path, + mangaId: manga.id) + ..manga.value = manga; isar.chapters.putSync(chapters); chapters.manga.saveSync(); }); @@ -58,10 +64,6 @@ Future importArchivesFromFile(Ref ref, Manga? mManga, {required bool isManga, re } String _getName(String path) { - return path - .split('/') - .last - .split("\\") - .last - .replaceAll(RegExp(r'\.(mp4|mov|avi|flv|wmv|mpeg|mkv|cbz|zip|cbt|tar)'), ''); + return path.split('/').last.split("\\").last.replaceAll( + RegExp(r'\.(mp4|mov|avi|flv|wmv|mpeg|mkv|cbz|zip|cbt|tar)'), ''); } diff --git a/lib/modules/library/widgets/library_gridview_widget.dart b/lib/modules/library/widgets/library_gridview_widget.dart index 570de2f..13854d8 100644 --- a/lib/modules/library/widgets/library_gridview_widget.dart +++ b/lib/modules/library/widgets/library_gridview_widget.dart @@ -53,7 +53,8 @@ class _LibraryGridViewWidgetState extends State { final isLongPressed = ref.watch(isLongPressedMangaStateProvider); final isManga = widget.isManga; - final gridSize = ref.watch(libraryGridSizeStateProvider(isManga: isManga)); + final gridSize = + ref.watch(libraryGridSizeStateProvider(isManga: isManga)); return GridViewWidget( gridSize: gridSize, childAspectRatio: widget.isComfortableGrid ? 0.642 : 0.69, @@ -74,12 +75,16 @@ class _LibraryGridViewWidgetState extends State { ), isComfortableGrid: widget.isComfortableGrid, image: entry.customCoverImage != null - ? MemoryImage(entry.customCoverImage as Uint8List) as ImageProvider + ? MemoryImage(entry.customCoverImage as Uint8List) + as ImageProvider : CustomExtendedNetworkImageProvider( - toImgUrl(entry.customCoverFromTracker ?? entry.imageUrl ?? ""), + toImgUrl(entry.customCoverFromTracker ?? + entry.imageUrl ?? + ""), headers: entry.isLocalArchive! ? null - : ref.watch(headersProvider(source: entry.source!, lang: entry.lang!)), + : ref.watch(headersProvider( + source: entry.source!, lang: entry.lang!)), ), onTap: () async { if (isLongPressed) { @@ -91,15 +96,19 @@ class _LibraryGridViewWidgetState extends State { lang: entry.lang!, mangaM: entry, source: entry.source!); - ref.invalidate(getAllMangaWithoutCategoriesStreamProvider(isManga: widget.isManga)); - ref.invalidate(getAllMangaStreamProvider(categoryId: null, isManga: widget.isManga)); + ref.invalidate(getAllMangaWithoutCategoriesStreamProvider( + isManga: widget.isManga)); + ref.invalidate(getAllMangaStreamProvider( + categoryId: null, isManga: widget.isManga)); } }, onLongPress: () { if (!isLongPressed) { ref.read(mangasListStateProvider.notifier).update(entry); - ref.read(isLongPressedMangaStateProvider.notifier).update(!isLongPressed); + ref + .read(isLongPressedMangaStateProvider.notifier) + .update(!isLongPressed); } else { ref.read(mangasListStateProvider.notifier).update(entry); } @@ -108,7 +117,9 @@ class _LibraryGridViewWidgetState extends State { if (!isLongPressed) { ref.read(mangasListStateProvider.notifier).update(entry); - ref.read(isLongPressedMangaStateProvider.notifier).update(!isLongPressed); + ref + .read(isLongPressedMangaStateProvider.notifier) + .update(!isLongPressed); } else { ref.read(mangasListStateProvider.notifier).update(entry); } @@ -132,14 +143,18 @@ class _LibraryGridViewWidgetState extends State { Container( decoration: BoxDecoration( borderRadius: const BorderRadius.only( - topLeft: Radius.circular(3), bottomLeft: Radius.circular(3)), + topLeft: Radius.circular(3), + bottomLeft: Radius.circular(3)), color: Theme.of(context).hintColor, ), child: Padding( - padding: const EdgeInsets.only(left: 3, right: 3), + padding: const EdgeInsets.only( + left: 3, right: 3), child: Text( "Local", - style: TextStyle(color: context.dynamicBlackWhiteColor), + style: TextStyle( + color: context + .dynamicBlackWhiteColor), ), ), ), @@ -150,14 +165,20 @@ class _LibraryGridViewWidgetState extends State { List nbrDown = []; if (widget.downloadedChapter) { isar.txnSync(() { - for (var i = 0; i < entry.chapters.length; i++) { + for (var i = 0; + i < entry.chapters.length; + i++) { final entries = isar.downloads .filter() .idIsNotNull() - .chapterIdEqualTo(entry.chapters.toList()[i].id) + .chapterIdEqualTo(entry + .chapters + .toList()[i] + .id) .findAllSync(); - if (entries.isNotEmpty && entries.first.isDownload!) { + if (entries.isNotEmpty && + entries.first.isDownload!) { nbrDown.add(1); } } @@ -166,25 +187,42 @@ class _LibraryGridViewWidgetState extends State { return Row( children: [ - if (nbrDown.isNotEmpty && widget.downloadedChapter) + if (nbrDown.isNotEmpty && + widget.downloadedChapter) Container( decoration: BoxDecoration( - borderRadius: const BorderRadius.only( - topLeft: Radius.circular(3), bottomLeft: Radius.circular(3)), - color: Theme.of(context).secondaryHeaderColor, + borderRadius: + const BorderRadius.only( + topLeft: + Radius.circular( + 3), + bottomLeft: + Radius.circular( + 3)), + color: Theme.of(context) + .secondaryHeaderColor, ), child: Padding( - padding: const EdgeInsets.only(left: 3, right: 3), + padding: + const EdgeInsets.only( + left: 3, right: 3), child: Text( nbrDown.length.toString(), ), ), ), Padding( - padding: const EdgeInsets.only(left: 3), + padding: const EdgeInsets.only( + left: 3), child: Text( - entry.chapters.where((element) => !element.isRead!).length.toString(), - style: TextStyle(color: context.dynamicBlackWhiteColor), + entry.chapters + .where((element) => + !element.isRead!) + .length + .toString(), + style: TextStyle( + color: context + .dynamicBlackWhiteColor), ), ), ], @@ -207,14 +245,17 @@ class _LibraryGridViewWidgetState extends State { child: Container( decoration: BoxDecoration( borderRadius: const BorderRadius.only( - topLeft: Radius.circular(3), bottomLeft: Radius.circular(3)), + topLeft: Radius.circular(3), + bottomLeft: Radius.circular(3)), color: Theme.of(context).hintColor, ), child: Padding( - padding: const EdgeInsets.only(left: 3, right: 3), + padding: const EdgeInsets.only( + left: 3, right: 3), child: Text( entry.lang!.toUpperCase(), - style: const TextStyle(color: Colors.white), + style: + const TextStyle(color: Colors.white), ), ), ), @@ -222,7 +263,8 @@ class _LibraryGridViewWidgetState extends State { )), ], ), - if (!widget.isComfortableGrid && !widget.isCoverOnlyGrid) BottomTextWidget(text: entry.name!), + if (!widget.isComfortableGrid && !widget.isCoverOnlyGrid) + BottomTextWidget(text: entry.name!), if (widget.continueReaderBtn) Positioned( bottom: 0, @@ -236,22 +278,31 @@ class _LibraryGridViewWidgetState extends State { .filter() .idIsNotNull() .and() - .chapter((q) => q.manga((q) => q.isMangaEqualTo(entry.isManga!))) + .chapter((q) => q.manga((q) => + q.isMangaEqualTo(entry.isManga!))) .watch(fireImmediately: true), builder: (context, snapshot) { - if (snapshot.hasData && snapshot.data!.isNotEmpty) { - final incognitoMode = ref.watch(incognitoModeStateProvider); - final entries = - snapshot.data!.where((element) => element.mangaId == entry.id).toList(); - if (entries.isNotEmpty && !incognitoMode) { + if (snapshot.hasData && + snapshot.data!.isNotEmpty) { + final incognitoMode = + ref.watch(incognitoModeStateProvider); + final entries = snapshot.data! + .where((element) => + element.mangaId == entry.id) + .toList(); + if (entries.isNotEmpty && + !incognitoMode) { return GestureDetector( onTap: () { - entries.first.chapter.value!.pushToReaderView(context); + entries.first.chapter.value! + .pushToReaderView(context); }, child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - color: context.primaryColor.withValues(alpha: 0.9), + borderRadius: + BorderRadius.circular(5), + color: context.primaryColor + .withValues(alpha: 0.9), ), child: const Padding( padding: EdgeInsets.all(7), @@ -265,12 +316,19 @@ class _LibraryGridViewWidgetState extends State { } return GestureDetector( onTap: () { - entry.chapters.toList().reversed.toList().last.pushToReaderView(context); + entry.chapters + .toList() + .reversed + .toList() + .last + .pushToReaderView(context); }, child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - color: context.primaryColor.withValues(alpha: 0.9), + borderRadius: + BorderRadius.circular(5), + color: context.primaryColor + .withValues(alpha: 0.9), ), child: const Padding( padding: EdgeInsets.all(7), @@ -284,12 +342,19 @@ class _LibraryGridViewWidgetState extends State { } return GestureDetector( onTap: () { - entry.chapters.toList().reversed.toList().last.pushToReaderView(context); + entry.chapters + .toList() + .reversed + .toList() + .last + .pushToReaderView(context); }, child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - color: context.primaryColor.withValues(alpha: 0.9), + borderRadius: + BorderRadius.circular(5), + color: context.primaryColor + .withValues(alpha: 0.9), ), child: const Padding( padding: EdgeInsets.all(7), diff --git a/lib/modules/library/widgets/library_listview_widget.dart b/lib/modules/library/widgets/library_listview_widget.dart index 88afc82..0b816ed 100644 --- a/lib/modules/library/widgets/library_listview_widget.dart +++ b/lib/modules/library/widgets/library_listview_widget.dart @@ -58,15 +58,19 @@ class LibraryListViewWidget extends StatelessWidget { lang: entry.lang!, mangaM: entry, source: entry.source!); - ref.invalidate(getAllMangaWithoutCategoriesStreamProvider(isManga: entry.isManga)); - ref.invalidate(getAllMangaStreamProvider(categoryId: null, isManga: entry.isManga)); + ref.invalidate(getAllMangaWithoutCategoriesStreamProvider( + isManga: entry.isManga)); + ref.invalidate(getAllMangaStreamProvider( + categoryId: null, isManga: entry.isManga)); } }, onLongPress: () { if (!isLongPressed) { ref.read(mangasListStateProvider.notifier).update(entry); - ref.read(isLongPressedMangaStateProvider.notifier).update(!isLongPressed); + ref + .read(isLongPressedMangaStateProvider.notifier) + .update(!isLongPressed); } else { ref.read(mangasListStateProvider.notifier).update(entry); } @@ -75,19 +79,24 @@ class LibraryListViewWidget extends StatelessWidget { if (!isLongPressed) { ref.read(mangasListStateProvider.notifier).update(entry); - ref.read(isLongPressedMangaStateProvider.notifier).update(!isLongPressed); + ref + .read(isLongPressedMangaStateProvider.notifier) + .update(!isLongPressed); } else { ref.read(mangasListStateProvider.notifier).update(entry); } }, child: Container( - color: - mangaIdsList.contains(entry.id) ? context.primaryColor.withValues(alpha: 0.4) : Colors.transparent, + color: mangaIdsList.contains(entry.id) + ? context.primaryColor.withValues(alpha: 0.4) + : Colors.transparent, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3), + padding: + const EdgeInsets.symmetric(horizontal: 8, vertical: 3), child: Container( height: 45, - decoration: BoxDecoration(borderRadius: BorderRadius.circular(5)), + decoration: + BoxDecoration(borderRadius: BorderRadius.circular(5)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -102,16 +111,21 @@ class LibraryListViewWidget extends StatelessWidget { width: 40, height: 45, image: entry.customCoverImage != null - ? MemoryImage(entry.customCoverImage as Uint8List) as ImageProvider + ? MemoryImage(entry.customCoverImage + as Uint8List) as ImageProvider : CustomExtendedNetworkImageProvider( - toImgUrl(entry.customCoverFromTracker ?? entry.imageUrl!), - headers: - ref.watch(headersProvider(source: entry.source!, lang: entry.lang!)), + toImgUrl( + entry.customCoverFromTracker ?? + entry.imageUrl!), + headers: ref.watch(headersProvider( + source: entry.source!, + lang: entry.lang!)), ), child: InkWell( child: Container( color: mangaIdsList.contains(entry.id) - ? context.primaryColor.withValues(alpha: 0.4) + ? context.primaryColor + .withValues(alpha: 0.4) : Colors.transparent, )), ), @@ -119,7 +133,8 @@ class LibraryListViewWidget extends StatelessWidget { ), Expanded( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 10), + padding: const EdgeInsets.symmetric( + horizontal: 10), child: Text(entry.name!), ), ) @@ -129,8 +144,9 @@ class LibraryListViewWidget extends StatelessWidget { Padding( padding: const EdgeInsets.all(5), child: Container( - decoration: - BoxDecoration(borderRadius: BorderRadius.circular(3), color: context.primaryColor), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(3), + color: context.primaryColor), child: SizedBox( height: 22, child: Row( @@ -139,11 +155,13 @@ class LibraryListViewWidget extends StatelessWidget { Container( decoration: BoxDecoration( borderRadius: const BorderRadius.only( - topLeft: Radius.circular(3), bottomLeft: Radius.circular(3)), + topLeft: Radius.circular(3), + bottomLeft: Radius.circular(3)), color: Theme.of(context).hintColor, ), child: const Padding( - padding: EdgeInsets.only(left: 3, right: 3), + padding: + EdgeInsets.only(left: 3, right: 3), child: Text( "Local", style: TextStyle(color: Colors.white), @@ -157,14 +175,20 @@ class LibraryListViewWidget extends StatelessWidget { builder: (context, ref, child) { List nbrDown = []; isar.txnSync(() { - for (var i = 0; i < entry.chapters.length; i++) { + for (var i = 0; + i < entry.chapters.length; + i++) { final entries = isar.downloads .filter() .idIsNotNull() - .chapterIdEqualTo(entry.chapters.toList()[i].id) + .chapterIdEqualTo(entry + .chapters + .toList()[i] + .id) .findAllSync(); - if (entries.isNotEmpty && entries.first.isDownload!) { + if (entries.isNotEmpty && + entries.first.isDownload!) { nbrDown.add(entries.first); } } @@ -172,15 +196,22 @@ class LibraryListViewWidget extends StatelessWidget { if (nbrDown.isNotEmpty) { return Container( decoration: BoxDecoration( - borderRadius: const BorderRadius.only( - topLeft: Radius.circular(3), bottomLeft: Radius.circular(3)), - color: Theme.of(context).hintColor, + 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), + padding: const EdgeInsets.only( + left: 3, right: 3), child: Text( nbrDown.length.toString(), - style: const TextStyle(color: Colors.white), + style: const TextStyle( + color: Colors.white), ), ), ); @@ -194,7 +225,8 @@ class LibraryListViewWidget extends StatelessWidget { padding: const EdgeInsets.only(right: 3), child: Text( entry.chapters.length.toString(), - style: const TextStyle(color: Colors.white), + style: + const TextStyle(color: Colors.white), ), ), if (language && entry.lang!.isNotEmpty) @@ -203,14 +235,17 @@ class LibraryListViewWidget extends StatelessWidget { child: Container( decoration: BoxDecoration( borderRadius: const BorderRadius.only( - topRight: Radius.circular(3), bottomRight: Radius.circular(3)), + topRight: Radius.circular(3), + bottomRight: Radius.circular(3)), color: Theme.of(context).hintColor, ), child: Padding( - padding: const EdgeInsets.only(left: 3, right: 3), + padding: const EdgeInsets.only( + left: 3, right: 3), child: Text( entry.lang!.toUpperCase(), - style: const TextStyle(color: Colors.white), + style: const TextStyle( + color: Colors.white), ), ), ), @@ -228,13 +263,18 @@ class LibraryListViewWidget extends StatelessWidget { .filter() .idIsNotNull() .and() - .chapter((q) => q.manga((q) => q.isMangaEqualTo(entry.isManga!))) + .chapter((q) => q.manga((q) => + q.isMangaEqualTo(entry.isManga!))) .watch(fireImmediately: true), builder: (context, snapshot) { - if (snapshot.hasData && snapshot.data!.isNotEmpty) { - final incognitoMode = ref.watch(incognitoModeStateProvider); - final entries = - snapshot.data!.where((element) => element.mangaId == entry.id).toList(); + if (snapshot.hasData && + snapshot.data!.isNotEmpty) { + final incognitoMode = + ref.watch(incognitoModeStateProvider); + final entries = snapshot.data! + .where((element) => + element.mangaId == entry.id) + .toList(); if (entries.isNotEmpty && !incognitoMode) { final chap = entries.first.chapter.value!; return GestureDetector( @@ -243,8 +283,10 @@ class LibraryListViewWidget extends StatelessWidget { }, child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - color: context.primaryColor.withValues(alpha: 0.9), + borderRadius: + BorderRadius.circular(5), + color: context.primaryColor + .withValues(alpha: 0.9), ), child: const Padding( padding: EdgeInsets.all(7), @@ -258,12 +300,19 @@ class LibraryListViewWidget extends StatelessWidget { } return GestureDetector( onTap: () { - entry.chapters.toList().reversed.toList().last.pushToReaderView(context); + entry.chapters + .toList() + .reversed + .toList() + .last + .pushToReaderView(context); }, child: Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(5), - color: context.primaryColor.withValues(alpha: 0.9), + borderRadius: + BorderRadius.circular(5), + color: context.primaryColor + .withValues(alpha: 0.9), ), child: const Padding( padding: EdgeInsets.all(7), @@ -277,12 +326,18 @@ class LibraryListViewWidget extends StatelessWidget { } return GestureDetector( onTap: () { - entry.chapters.toList().reversed.toList().last.pushToReaderView(context); + entry.chapters + .toList() + .reversed + .toList() + .last + .pushToReaderView(context); }, child: Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), - color: context.primaryColor.withValues(alpha: 0.9), + color: context.primaryColor + .withValues(alpha: 0.9), ), child: const Padding( padding: EdgeInsets.all(7), diff --git a/lib/modules/library/widgets/list_tile_manga_category.dart b/lib/modules/library/widgets/list_tile_manga_category.dart index c3aa2e9..3abab1f 100644 --- a/lib/modules/library/widgets/list_tile_manga_category.dart +++ b/lib/modules/library/widgets/list_tile_manga_category.dart @@ -26,7 +26,9 @@ class _ListTileMangaCategoryState extends State { void initState() { final res = widget.mangasList.where( (element) { - return element.categories == null ? false : element.categories!.contains(widget.category.id); + return element.categories == null + ? false + : element.categories!.contains(widget.category.id); }, ).toList(); widget.res(res); diff --git a/lib/modules/library/widgets/search_text_form_field.dart b/lib/modules/library/widgets/search_text_form_field.dart index 25d67aa..cf6a286 100644 --- a/lib/modules/library/widgets/search_text_form_field.dart +++ b/lib/modules/library/widgets/search_text_form_field.dart @@ -35,8 +35,10 @@ class SeachFormTextField extends StatelessWidget { icon: const Icon( Icons.arrow_back, )), - suffixIcon: - controller.text.isEmpty ? null : IconButton(onPressed: onSuffixPressed, icon: const Icon(Icons.clear)), + suffixIcon: controller.text.isEmpty + ? null + : IconButton( + onPressed: onSuffixPressed, icon: const Icon(Icons.clear)), enabledBorder: const OutlineInputBorder( borderSide: BorderSide.none, ), diff --git a/lib/modules/main_view/main_screen.dart b/lib/modules/main_view/main_screen.dart index 249a947..923a685 100644 --- a/lib/modules/main_view/main_screen.dart +++ b/lib/modules/main_view/main_screen.dart @@ -54,7 +54,8 @@ class MainScreen extends ConsumerWidget { final location = ref.watch( routerCurrentLocationStateProvider(context), ); - bool isReadingScreen = location == '/mangareaderview' || location == '/animePlayerView'; + bool isReadingScreen = + location == '/mangareaderview' || location == '/animePlayerView'; int currentIndex = switch (location) { null || '/MangaLibrary' => 0, '/AnimeLibrary' => 1, @@ -122,7 +123,9 @@ class MainScreen extends ConsumerWidget { children: [ NavigationRailTheme( data: NavigationRailThemeData( - indicatorShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)), + indicatorShape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(30)), ), child: Builder(builder: (context) { return NavigationRail( @@ -130,46 +133,73 @@ class MainScreen extends ConsumerWidget { useIndicator: true, destinations: [ NavigationRailDestination( - selectedIcon: const Icon(Icons.collections_bookmark), - icon: const Icon(Icons.collections_bookmark_outlined), + selectedIcon: const Icon( + Icons.collections_bookmark), + icon: const Icon(Icons + .collections_bookmark_outlined), label: Padding( - padding: const EdgeInsets.only(top: 5), child: Text(l10n.manga))), + padding: const EdgeInsets.only( + top: 5), + child: Text(l10n.manga))), NavigationRailDestination( - selectedIcon: const Icon(Icons.video_collection), - icon: const Icon(Icons.video_collection_outlined), + selectedIcon: const Icon( + Icons.video_collection), + icon: const Icon(Icons + .video_collection_outlined), label: Padding( - padding: const EdgeInsets.only(top: 5), child: Text(l10n.anime))), + padding: const EdgeInsets.only( + top: 5), + child: Text(l10n.anime))), NavigationRailDestination( - selectedIcon: const Icon(Icons.new_releases), - icon: const Icon(Icons.new_releases_outlined), + selectedIcon: + const Icon(Icons.new_releases), + icon: const Icon( + Icons.new_releases_outlined), label: Padding( - padding: const EdgeInsets.only(top: 5), + padding: const EdgeInsets.only( + top: 5), child: Stack( children: [ Text( getHyphenatedUpdatesLabel( - ref.watch(l10nLocaleStateProvider).languageCode, + ref + .watch( + l10nLocaleStateProvider) + .languageCode, l10n.updates, ), - textAlign: TextAlign.center, + textAlign: + TextAlign.center, ), ], ))), NavigationRailDestination( - selectedIcon: const Icon(Icons.history), - icon: const Icon(Icons.history_outlined), + selectedIcon: + const Icon(Icons.history), + icon: const Icon( + Icons.history_outlined), label: Padding( - padding: const EdgeInsets.only(top: 5), child: Text(l10n.history))), + padding: const EdgeInsets.only( + top: 5), + child: Text(l10n.history))), NavigationRailDestination( - selectedIcon: const Icon(Icons.explore), - icon: const Icon(Icons.explore_outlined), + selectedIcon: + const Icon(Icons.explore), + icon: const Icon( + Icons.explore_outlined), label: Padding( - padding: const EdgeInsets.only(top: 5), child: Text(l10n.browse))), + padding: const EdgeInsets.only( + top: 5), + child: Text(l10n.browse))), NavigationRailDestination( - selectedIcon: const Icon(Icons.more_horiz), - icon: const Icon(Icons.more_horiz_outlined), + selectedIcon: + const Icon(Icons.more_horiz), + icon: const Icon( + Icons.more_horiz_outlined), label: Padding( - padding: const EdgeInsets.only(top: 5), child: Text(l10n.more))), + padding: const EdgeInsets.only( + top: 5), + child: Text(l10n.more))), ], selectedIndex: currentIndex, onDestinationSelected: (newIndex) { @@ -186,8 +216,14 @@ class MainScreen extends ConsumerWidget { ); }), ), - Positioned(right: 18, top: 140, child: _updatesTotalNumbers(ref)), - Positioned(right: 18, top: 275, child: _extensionUpdateTotalNumbers(ref)), + Positioned( + right: 18, + top: 140, + child: _updatesTotalNumbers(ref)), + Positioned( + right: 18, + top: 275, + child: _extensionUpdateTotalNumbers(ref)), ], ), ), @@ -216,27 +252,38 @@ class MainScreen extends ConsumerWidget { }, child: NavigationBarTheme( data: NavigationBarThemeData( - indicatorShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30)), + indicatorShape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(30)), ), child: NavigationBar( - animationDuration: const Duration(milliseconds: 500), + animationDuration: + const Duration(milliseconds: 500), selectedIndex: currentIndex, destinations: [ NavigationDestination( - selectedIcon: const Icon(Icons.collections_bookmark), - icon: const Icon(Icons.collections_bookmark_outlined), + selectedIcon: + const Icon(Icons.collections_bookmark), + icon: const Icon( + Icons.collections_bookmark_outlined), label: l10n.manga), NavigationDestination( - selectedIcon: const Icon(Icons.video_collection), - icon: const Icon(Icons.video_collection_outlined), + selectedIcon: + const Icon(Icons.video_collection), + icon: const Icon( + Icons.video_collection_outlined), label: l10n.anime), Stack( children: [ NavigationDestination( - selectedIcon: const Icon(Icons.new_releases), - icon: const Icon(Icons.new_releases_outlined), + selectedIcon: + const Icon(Icons.new_releases), + icon: const Icon( + Icons.new_releases_outlined), label: l10n.updates), - Positioned(right: 14, top: 3, child: _updatesTotalNumbers(ref)), + Positioned( + right: 14, + top: 3, + child: _updatesTotalNumbers(ref)), ], ), NavigationDestination( @@ -249,7 +296,10 @@ class MainScreen extends ConsumerWidget { selectedIcon: const Icon(Icons.explore), icon: const Icon(Icons.explore_outlined), label: l10n.browse), - Positioned(right: 14, top: 3, child: _extensionUpdateTotalNumbers(ref)), + Positioned( + right: 14, + top: 3, + child: _extensionUpdateTotalNumbers(ref)), ], ), NavigationDestination( @@ -286,21 +336,32 @@ class MainScreen extends ConsumerWidget { Widget _extensionUpdateTotalNumbers(WidgetRef ref) { return StreamBuilder( - stream: isar.sources.filter().idIsNotNull().and().isActiveEqualTo(true).watch(fireImmediately: true), + stream: isar.sources + .filter() + .idIsNotNull() + .and() + .isActiveEqualTo(true) + .watch(fireImmediately: true), builder: (context, snapshot) { if (snapshot.hasData && snapshot.data!.isNotEmpty) { - final entries = - snapshot.data!.where((element) => compareVersions(element.version!, element.versionLast!) < 0).toList(); + final entries = snapshot.data! + .where((element) => + compareVersions(element.version!, element.versionLast!) < 0) + .toList(); return entries.isEmpty ? Container() : Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), color: const Color.fromARGB(255, 176, 46, 37)), + borderRadius: BorderRadius.circular(10), + color: const Color.fromARGB(255, 176, 46, 37)), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 3), + padding: + const EdgeInsets.symmetric(horizontal: 5, vertical: 3), child: Text( entries.length.toString(), - style: TextStyle(fontSize: 10, color: Theme.of(context).textTheme.bodySmall!.color), + style: TextStyle( + fontSize: 10, + color: Theme.of(context).textTheme.bodySmall!.color), ), ), ); @@ -324,12 +385,16 @@ Widget _updatesTotalNumbers(WidgetRef ref) { ? Container() : Container( decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), color: const Color.fromARGB(255, 176, 46, 37)), + borderRadius: BorderRadius.circular(10), + color: const Color.fromARGB(255, 176, 46, 37)), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 3), + padding: + const EdgeInsets.symmetric(horizontal: 5, vertical: 3), child: Text( entries.length.toString(), - style: TextStyle(fontSize: 10, color: Theme.of(context).textTheme.bodySmall!.color), + style: TextStyle( + fontSize: 10, + color: Theme.of(context).textTheme.bodySmall!.color), ), ), ); diff --git a/lib/modules/main_view/providers/migration.dart b/lib/modules/main_view/providers/migration.dart index ad9563f..ced3bdc 100644 --- a/lib/modules/main_view/providers/migration.dart +++ b/lib/modules/main_view/providers/migration.dart @@ -11,11 +11,20 @@ part 'migration.g.dart'; @riverpod Future migration(Ref ref) async { - final chapters = isar.chapters.filter().idIsNotNull().mangaIdIsNull().findAllSync(); - final downloads = isar.downloads.filter().idIsNotNull().mangaIdIsNull().findAllSync(); - final histories = - isar.historys.filter().idIsNotNull().chapterIdIsNull().or().idIsNotNull().isMangaIsNull().findAllSync(); - final tracks = isar.tracks.filter().idIsNotNull().isMangaIsNull().findAllSync(); + final chapters = + isar.chapters.filter().idIsNotNull().mangaIdIsNull().findAllSync(); + final downloads = + isar.downloads.filter().idIsNotNull().mangaIdIsNull().findAllSync(); + final histories = isar.historys + .filter() + .idIsNotNull() + .chapterIdIsNull() + .or() + .idIsNotNull() + .isMangaIsNull() + .findAllSync(); + final tracks = + isar.tracks.filter().idIsNotNull().isMangaIsNull().findAllSync(); isar.writeTxnSync(() { //mangaId in chapter diff --git a/lib/modules/manga/archive_reader/providers/archive_reader_providers.dart b/lib/modules/manga/archive_reader/providers/archive_reader_providers.dart index 8c6378a..81def86 100644 --- a/lib/modules/manga/archive_reader/providers/archive_reader_providers.dart +++ b/lib/modules/manga/archive_reader/providers/archive_reader_providers.dart @@ -8,17 +8,20 @@ import 'package:path/path.dart' as p; part 'archive_reader_providers.g.dart'; @riverpod -Future> getArchivesDataFromDirectory(Ref ref, String path) async { +Future> + getArchivesDataFromDirectory(Ref ref, String path) async { return compute(_extractOnly, path); } @riverpod -Future> getArchiveDataFromDirectory(Ref ref, String path) async { +Future> getArchiveDataFromDirectory( + Ref ref, String path) async { return compute(_extract, path); } @riverpod -Future<(String, LocalExtensionType, Uint8List, String)> getArchivesDataFromFile(Ref ref, String path) async { +Future<(String, LocalExtensionType, Uint8List, String)> getArchivesDataFromFile( + Ref ref, String path) async { return compute(_extractArchiveOnly, path); } @@ -31,7 +34,8 @@ Future> _extract(String data) async { return await _searchForArchive(Directory(data)); } -Future> _extractOnly(String data) async { +Future> _extractOnly( + String data) async { return await _searchForArchiveOnly(Directory(data)); } @@ -53,7 +57,8 @@ Future> _searchForArchive(Directory dir) async { return _list; } -Future> _searchForArchiveOnly(Directory dir) async { +Future> + _searchForArchiveOnly(Directory dir) async { List entities = dir.listSync(); for (FileSystemEntity entity in entities) { if (entity is Directory) { @@ -99,7 +104,8 @@ LocalArchive _extractArchive(String path) { Archive? archive; final inputStream = InputFileStream(path); final extensionType = localArchive.extensionType; - if (extensionType == LocalExtensionType.cbt || extensionType == LocalExtensionType.tar) { + if (extensionType == LocalExtensionType.cbt || + extensionType == LocalExtensionType.tar) { archive = TarDecoder().decodeStream(inputStream); } else { archive = ZipDecoder().decodeStream(inputStream); @@ -125,27 +131,35 @@ LocalArchive _extractArchive(String path) { return localArchive; } -(String, LocalExtensionType, Uint8List, String) _extractArchiveOnly(String path) { - final extensionType = setTypeExtension(p.extension(path).replaceFirst('.', '')); +(String, LocalExtensionType, Uint8List, String) _extractArchiveOnly( + String path) { + final extensionType = + setTypeExtension(p.extension(path).replaceFirst('.', '')); final name = p.basenameWithoutExtension(path); Uint8List? coverImage; Archive? archive; final inputStream = InputFileStream(path); - if (extensionType == LocalExtensionType.cbt || extensionType == LocalExtensionType.tar) { + if (extensionType == LocalExtensionType.cbt || + extensionType == LocalExtensionType.tar) { archive = TarDecoder().decodeStream(inputStream); } else { archive = ZipDecoder().decodeStream(inputStream); } - final cover = archive.files.where((file) => file.isFile && _isImageFile(file.name) && file.name.contains("cover")); + final cover = archive.files.where((file) => + file.isFile && _isImageFile(file.name) && file.name.contains("cover")); if (cover.isNotEmpty) { coverImage = cover.first.content; } else { - List lArchive = - archive.files.where((file) => file.isFile && _isImageFile(file.name) && !file.name.contains("cover")).toList(); + List lArchive = archive.files + .where((file) => + file.isFile && + _isImageFile(file.name) && + !file.name.contains("cover")) + .toList(); lArchive.sort( (a, b) => a.name.compareTo(b.name), ); diff --git a/lib/modules/manga/detail/manga_detail_main.dart b/lib/modules/manga/detail/manga_detail_main.dart index ab3d2c5..4670d2b 100644 --- a/lib/modules/manga/detail/manga_detail_main.dart +++ b/lib/modules/manga/detail/manga_detail_main.dart @@ -26,7 +26,9 @@ class _MangaReaderDetailState extends ConsumerState { _init() async { await Future.delayed(const Duration(milliseconds: 100)); - await ref.read(updateMangaDetailProvider(mangaId: widget.mangaId, isInit: true).future); + await ref.read( + updateMangaDetailProvider(mangaId: widget.mangaId, isInit: true) + .future); if (mounted) { setState(() { _isLoading = false; @@ -37,7 +39,8 @@ class _MangaReaderDetailState extends ConsumerState { bool _isLoading = true; @override Widget build(BuildContext context) { - final manga = ref.watch(getMangaDetailStreamProvider(mangaId: widget.mangaId)); + final manga = + ref.watch(getMangaDetailStreamProvider(mangaId: widget.mangaId)); return Scaffold( body: manga.when( data: (manga) { @@ -59,7 +62,9 @@ class _MangaReaderDetailState extends ConsumerState { return RefreshIndicator( onRefresh: () async { if (sourceExist && !_isLoading) { - await ref.read(updateMangaDetailProvider(mangaId: manga.id, isInit: false).future); + await ref.read(updateMangaDetailProvider( + mangaId: manga.id, isInit: false) + .future); } }, child: Stack( @@ -73,7 +78,9 @@ class _MangaReaderDetailState extends ConsumerState { _isLoading = true; }); if (sourceExist) { - await ref.read(updateMangaDetailProvider(mangaId: manga.id, isInit: false).future); + await ref.read(updateMangaDetailProvider( + mangaId: manga.id, isInit: false) + .future); } if (mounted) { setState(() { diff --git a/lib/modules/manga/detail/manga_detail_view.dart b/lib/modules/manga/detail/manga_detail_view.dart index f729fb6..dd39529 100644 --- a/lib/modules/manga/detail/manga_detail_view.dart +++ b/lib/modules/manga/detail/manga_detail_view.dart @@ -7,7 +7,7 @@ import 'package:flutter/rendering.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:go_router/go_router.dart'; import 'package:isar/isar.dart'; -import 'package:mangayomi/eval/dart/model/m_bridge.dart'; +import 'package:mangayomi/eval/model/m_bridge.dart'; import 'package:mangayomi/main.dart'; import 'package:mangayomi/models/chapter.dart'; import 'package:mangayomi/models/download.dart'; diff --git a/lib/modules/manga/detail/manga_details_view.dart b/lib/modules/manga/detail/manga_details_view.dart index df62bfe..8302967 100644 --- a/lib/modules/manga/detail/manga_details_view.dart +++ b/lib/modules/manga/detail/manga_details_view.dart @@ -41,7 +41,8 @@ class _MangaDetailsViewState extends ConsumerState { return textPainter.size; } - double calculateDynamicButtonWidth(String text, TextStyle textStyle, double padding) { + double calculateDynamicButtonWidth( + String text, TextStyle textStyle, double padding) { final textSize = measureText(text, textStyle); return textSize.width + padding; } @@ -57,20 +58,28 @@ class _MangaDetailsViewState extends ConsumerState { final isExtended = ref.watch(isExtendedStateProvider); return ref.watch(isLongPressedStateProvider) == true ? Container() - : chaptersList.isNotEmpty && chaptersList.where((element) => !element.isRead!).toList().isNotEmpty + : chaptersList.isNotEmpty && + chaptersList + .where((element) => !element.isRead!) + .toList() + .isNotEmpty ? StreamBuilder( stream: isar.historys .filter() .idIsNotNull() .and() - .chapter((q) => q.manga((q) => q.isMangaEqualTo(widget.manga.isManga!))) + .chapter((q) => q.manga( + (q) => q.isMangaEqualTo(widget.manga.isManga!))) .watch(fireImmediately: true), builder: (context, snapshot) { - String buttonLabel = widget.manga.isManga! ? l10n.read : l10n.watch; + String buttonLabel = + widget.manga.isManga! ? l10n.read : l10n.watch; if (snapshot.hasData && snapshot.data!.isNotEmpty) { - final incognitoMode = ref.watch(incognitoModeStateProvider); + final incognitoMode = + ref.watch(incognitoModeStateProvider); final entries = snapshot.data! - .where((element) => element.mangaId == widget.manga.id) + .where((element) => + element.mangaId == widget.manga.id) .toList() .reversed .toList(); @@ -83,8 +92,12 @@ class _MangaDetailsViewState extends ConsumerState { onPressed: () { chap.pushToReaderView(context); }, - textWidth: measureText(l10n.resume, Theme.of(context).textTheme.labelLarge!).width, - width: calculateDynamicButtonWidth(l10n.resume, Theme.of(context).textTheme.labelLarge!, + textWidth: measureText(l10n.resume, + Theme.of(context).textTheme.labelLarge!) + .width, + width: calculateDynamicButtonWidth( + l10n.resume, + Theme.of(context).textTheme.labelLarge!, 50), // 50 Padding, else RenderFlex overflow Exception ); } @@ -92,10 +105,19 @@ class _MangaDetailsViewState extends ConsumerState { isExtended: !isExtended, label: buttonLabel, onPressed: () { - widget.manga.chapters.toList().reversed.toList().last.pushToReaderView(context); + widget.manga.chapters + .toList() + .reversed + .toList() + .last + .pushToReaderView(context); }, - textWidth: measureText(buttonLabel, Theme.of(context).textTheme.labelLarge!).width, - width: calculateDynamicButtonWidth(buttonLabel, Theme.of(context).textTheme.labelLarge!, + textWidth: measureText(buttonLabel, + Theme.of(context).textTheme.labelLarge!) + .width, + width: calculateDynamicButtonWidth( + buttonLabel, + Theme.of(context).textTheme.labelLarge!, 50), // 50 Padding, else RenderFlex overflow Exception ); } @@ -103,10 +125,19 @@ class _MangaDetailsViewState extends ConsumerState { isExtended: !isExtended, label: buttonLabel, onPressed: () { - widget.manga.chapters.toList().reversed.toList().last.pushToReaderView(context); + widget.manga.chapters + .toList() + .reversed + .toList() + .last + .pushToReaderView(context); }, - textWidth: measureText(buttonLabel, Theme.of(context).textTheme.labelLarge!).width, - width: calculateDynamicButtonWidth(buttonLabel, Theme.of(context).textTheme.labelLarge!, + textWidth: measureText(buttonLabel, + Theme.of(context).textTheme.labelLarge!) + .width, + width: calculateDynamicButtonWidth( + buttonLabel, + Theme.of(context).textTheme.labelLarge!, 50), // 50 Padding, else RenderFlex overflow Exception ); }, @@ -155,7 +186,9 @@ class _MangaDetailsViewState extends ConsumerState { ? SizedBox( child: ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: Theme.of(context).scaffoldBackgroundColor, elevation: 0), + backgroundColor: + Theme.of(context).scaffoldBackgroundColor, + elevation: 0), onPressed: () { final model = widget.manga; isar.writeTxnSync(() { @@ -183,8 +216,9 @@ class _MangaDetailsViewState extends ConsumerState { ), ) : ElevatedButton( - style: - ElevatedButton.styleFrom(backgroundColor: Theme.of(context).scaffoldBackgroundColor, elevation: 0), + style: ElevatedButton.styleFrom( + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + elevation: 0), onPressed: () { final checkCategoryList = isar.categorys .filter() @@ -215,7 +249,8 @@ class _MangaDetailsViewState extends ConsumerState { ), Text( l10n.add_to_library, - style: TextStyle(color: context.secondaryColor, fontSize: 11), + style: TextStyle( + color: context.secondaryColor, fontSize: 11), textAlign: TextAlign.center, ) ], @@ -264,14 +299,17 @@ class _MangaDetailsViewState extends ConsumerState { label: entries[index].name!, onTap: () { setState(() { - if (categoryIds.contains(entries[index].id)) { + if (categoryIds + .contains(entries[index].id)) { categoryIds.remove(entries[index].id); } else { categoryIds.add(entries[index].id!); } }); }, - type: categoryIds.contains(entries[index].id) ? 1 : 0, + type: categoryIds.contains(entries[index].id) + ? 1 + : 0, ); }, ); @@ -285,7 +323,8 @@ class _MangaDetailsViewState extends ConsumerState { children: [ TextButton( onPressed: () { - context.push("/categories", extra: (true, widget.manga.isManga! ? 0 : 1)); + context.push("/categories", + extra: (true, widget.manga.isManga! ? 0 : 1)); Navigator.pop(context); }, child: Text(l10n.edit)), @@ -305,7 +344,8 @@ class _MangaDetailsViewState extends ConsumerState { isar.writeTxnSync(() { model.favorite = true; model.categories = categoryIds; - model.dateAdded = DateTime.now().millisecondsSinceEpoch; + model.dateAdded = + DateTime.now().millisecondsSinceEpoch; isar.mangas.putSync(model); }); if (mounted) { diff --git a/lib/modules/manga/detail/providers/isar_providers.dart b/lib/modules/manga/detail/providers/isar_providers.dart index f292677..2e5e7d4 100644 --- a/lib/modules/manga/detail/providers/isar_providers.dart +++ b/lib/modules/manga/detail/providers/isar_providers.dart @@ -16,5 +16,8 @@ Stream> getChaptersStream( Ref ref, { required int mangaId, }) async* { - yield* isar.chapters.filter().manga((q) => q.idEqualTo(mangaId)).watch(fireImmediately: true); + yield* isar.chapters + .filter() + .manga((q) => q.idEqualTo(mangaId)) + .watch(fireImmediately: true); } diff --git a/lib/modules/manga/detail/providers/state_providers.dart b/lib/modules/manga/detail/providers/state_providers.dart index 4df02d9..017ccb7 100644 --- a/lib/modules/manga/detail/providers/state_providers.dart +++ b/lib/modules/manga/detail/providers/state_providers.dart @@ -159,7 +159,8 @@ class ChapterFilterDownloadedState extends _$ChapterFilterDownloadedState { } chapterFilterDownloadedList.add(value); isar.writeTxnSync(() { - isar.settings.putSync(settings..chapterFilterDownloadedList = chapterFilterDownloadedList); + isar.settings.putSync( + settings..chapterFilterDownloadedList = chapterFilterDownloadedList); }); state = type; @@ -211,7 +212,8 @@ class ChapterFilterUnreadState extends _$ChapterFilterUnreadState { } chapterFilterUnreadList.add(value); isar.writeTxnSync(() { - isar.settings.putSync(settings..chapterFilterUnreadList = chapterFilterUnreadList); + isar.settings + .putSync(settings..chapterFilterUnreadList = chapterFilterUnreadList); }); state = type; } @@ -262,7 +264,8 @@ class ChapterFilterBookmarkedState extends _$ChapterFilterBookmarkedState { } chapterFilterBookmarkedList.add(value); isar.writeTxnSync(() { - isar.settings.putSync(settings..chapterFilterBookmarkedList = chapterFilterBookmarkedList); + isar.settings.putSync( + settings..chapterFilterBookmarkedList = chapterFilterBookmarkedList); }); state = type; } @@ -282,12 +285,18 @@ class ChapterFilterBookmarkedState extends _$ChapterFilterBookmarkedState { class ChapterFilterResultState extends _$ChapterFilterResultState { @override bool build({required Manga manga}) { - final downloadFilterType = ref.watch(chapterFilterDownloadedStateProvider(mangaId: manga.id!)); - final unreadFilterType = ref.watch(chapterFilterUnreadStateProvider(mangaId: manga.id!)); + final downloadFilterType = + ref.watch(chapterFilterDownloadedStateProvider(mangaId: manga.id!)); + final unreadFilterType = + ref.watch(chapterFilterUnreadStateProvider(mangaId: manga.id!)); - final bookmarkedFilterType = ref.watch(chapterFilterBookmarkedStateProvider(mangaId: manga.id!)); + final bookmarkedFilterType = + ref.watch(chapterFilterBookmarkedStateProvider(mangaId: manga.id!)); final scanlators = ref.watch(scanlatorsFilterStateProvider(manga)); - return downloadFilterType == 0 && unreadFilterType == 0 && bookmarkedFilterType == 0 && scanlators.$2.isEmpty; + return downloadFilterType == 0 && + unreadFilterType == 0 && + bookmarkedFilterType == 0 && + scanlators.$2.isEmpty; } } @@ -301,7 +310,9 @@ class ChapterSetIsBookmarkState extends _$ChapterSetIsBookmarkState { isar.writeTxnSync(() { for (var chapter in chapters) { chapter.isBookmarked = !chapter.isBookmarked!; - ref.read(changedItemsManagerProvider(managerId: 1).notifier).addUpdatedChapter(chapter, false, false); + ref + .read(changedItemsManagerProvider(managerId: 1).notifier) + .addUpdatedChapter(chapter, false, false); isar.chapters.putSync(chapter..manga.value = manga); chapter.manga.saveSync(); } @@ -321,7 +332,9 @@ class ChapterSetIsReadState extends _$ChapterSetIsReadState { isar.writeTxnSync(() { for (var chapter in chapters) { chapter.isRead = !chapter.isRead!; - ref.read(changedItemsManagerProvider(managerId: 1).notifier).addUpdatedChapter(chapter, false, false); + ref + .read(changedItemsManagerProvider(managerId: 1).notifier) + .addUpdatedChapter(chapter, false, false); isar.chapters.putSync(chapter..manga.value = manga); chapter.manga.saveSync(); } @@ -340,7 +353,11 @@ class ChapterSetDownloadState extends _$ChapterSetDownloadState { ref.read(isLongPressedStateProvider.notifier).update(false); isar.txnSync(() { for (var chapter in ref.watch(chaptersListStateProvider)) { - final entries = isar.downloads.filter().idIsNotNull().chapterIdEqualTo(chapter.id).findAllSync(); + final entries = isar.downloads + .filter() + .idIsNotNull() + .chapterIdEqualTo(chapter.id) + .findAllSync(); if (entries.isEmpty || !entries.first.isDownload!) { ref.watch(downloadChapterProvider(chapter: chapter)); } @@ -378,7 +395,8 @@ class ScanlatorsFilterState extends _$ScanlatorsFilterState { List _getScanlators() { List scanlators = []; for (var a in manga.chapters.toList()) { - if ((a.scanlator?.isNotEmpty ?? false) && !scanlators.contains(a.scanlator)) { + if ((a.scanlator?.isNotEmpty ?? false) && + !scanlators.contains(a.scanlator)) { scanlators.add(a.scanlator!); } } @@ -399,14 +417,16 @@ class ScanlatorsFilterState extends _$ScanlatorsFilterState { } filterScanlatorList.add(value); isar.writeTxnSync(() { - isar.settings.putSync(settings..filterScanlatorList = filterScanlatorList); + isar.settings + .putSync(settings..filterScanlatorList = filterScanlatorList); }); state = (_getScanlators(), _getFilterScanlator()!, filterScanlators); } List? _getFilterScanlator() { final scanlators = isar.settings.getSync(227)!.filterScanlatorList ?? []; - final filter = scanlators.where((element) => element.mangaId == manga.id).toList(); + final filter = + scanlators.where((element) => element.mangaId == manga.id).toList(); return filter.isEmpty ? null : filter.first.scanlators; } @@ -421,6 +441,7 @@ class ScanlatorsFilterState extends _$ScanlatorsFilterState { } else { scanlatorFilteredList.add(scanlator); } - state = (_getScanlators(), _getFilterScanlator() ?? [], scanlatorFilteredList); + state = + (_getScanlators(), _getFilterScanlator() ?? [], scanlatorFilteredList); } } diff --git a/lib/modules/manga/detail/providers/track_state_providers.dart b/lib/modules/manga/detail/providers/track_state_providers.dart index a4c2aa6..c0b89ae 100644 --- a/lib/modules/manga/detail/providers/track_state_providers.dart +++ b/lib/modules/manga/detail/providers/track_state_providers.dart @@ -18,19 +18,41 @@ class TrackState extends _$TrackState { Track? updateTrack; if (track!.syncId == 1) { updateTrack = isManga! - ? await ref.read(myAnimeListProvider(syncId: track!.syncId!, isManga: isManga).notifier).updateManga(track!) - : await ref.read(myAnimeListProvider(syncId: track!.syncId!, isManga: isManga).notifier).updateAnime(track!); + ? await ref + .read( + myAnimeListProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .updateManga(track!) + : await ref + .read( + myAnimeListProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .updateAnime(track!); } else if (track!.syncId == 2) { updateTrack = isManga! - ? await ref.read(anilistProvider(syncId: track!.syncId!, isManga: isManga).notifier).updateLibManga(track!) - : await ref.read(anilistProvider(syncId: track!.syncId!, isManga: isManga).notifier).updateLibAnime(track!); + ? await ref + .read(anilistProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .updateLibManga(track!) + : await ref + .read(anilistProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .updateLibAnime(track!); } else if (track!.syncId == 3) { updateTrack = isManga! - ? await ref.read(kitsuProvider(syncId: track!.syncId!, isManga: isManga).notifier).updateLibManga(track!) - : await ref.read(kitsuProvider(syncId: track!.syncId!, isManga: isManga).notifier).updateLibAnime(track!); + ? await ref + .read(kitsuProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .updateLibManga(track!) + : await ref + .read(kitsuProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .updateLibAnime(track!); } - ref.read(tracksProvider(syncId: track!.syncId!).notifier).updateTrackManga(updateTrack!, isManga); + ref + .read(tracksProvider(syncId: track!.syncId!).notifier) + .updateTrackManga(updateTrack!, isManga); } int getScoreMaxValue() { @@ -38,7 +60,11 @@ class TrackState extends _$TrackState { if (track!.syncId == 1 || track!.syncId == 3) { maxValue = 10; } else if (track!.syncId == 2) { - maxValue = ref.read(anilistProvider(syncId: track!.syncId!, isManga: isManga).notifier).getScoreValue().$1; + maxValue = ref + .read(anilistProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .getScoreValue() + .$1; } return maxValue!; } @@ -46,7 +72,9 @@ class TrackState extends _$TrackState { String getTextMapper(String numberText) { if (track!.syncId == 1 || track!.syncId == 3) { } else if (track!.syncId == 2) { - numberText = ref.read(anilistProvider(syncId: 2, isManga: isManga).notifier).displayScore(int.parse(numberText)); + numberText = ref + .read(anilistProvider(syncId: 2, isManga: isManga).notifier) + .displayScore(int.parse(numberText)); } return numberText; } @@ -56,7 +84,11 @@ class TrackState extends _$TrackState { if (track!.syncId == 1 || track!.syncId == 3) { step = 1; } else if (track!.syncId == 2) { - step = ref.read(anilistProvider(syncId: track!.syncId!, isManga: isManga).notifier).getScoreValue().$2; + step = ref + .read(anilistProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .getScoreValue() + .$2; } return step!; } @@ -66,12 +98,15 @@ class TrackState extends _$TrackState { if (track!.syncId == 1 || track!.syncId == 3) { result = score.toString(); } else if (track!.syncId == 2) { - result = ref.read(anilistProvider(syncId: 2, isManga: isManga).notifier).displayScore(score); + result = ref + .read(anilistProvider(syncId: 2, isManga: isManga).notifier) + .displayScore(score); } return result!; } - Future setTrackSearch(TrackSearch trackSearch, int mangaId, int syncId) async { + Future setTrackSearch( + TrackSearch trackSearch, int mangaId, int syncId) async { Track? findManga; final track = Track( mangaId: mangaId, @@ -86,20 +121,36 @@ class TrackState extends _$TrackState { startedReadingDate: 0, finishedReadingDate: 0); if (syncId == 1) { - findManga = await ref.read(myAnimeListProvider(syncId: syncId, isManga: isManga).notifier).findManga(track); + findManga = await ref + .read(myAnimeListProvider(syncId: syncId, isManga: isManga).notifier) + .findManga(track); } else if (syncId == 2) { findManga = isManga! - ? await ref.read(anilistProvider(syncId: syncId, isManga: isManga).notifier).findLibManga(track) - : await ref.read(anilistProvider(syncId: syncId, isManga: isManga).notifier).findLibAnime(track); + ? await ref + .read(anilistProvider(syncId: syncId, isManga: isManga).notifier) + .findLibManga(track) + : await ref + .read(anilistProvider(syncId: syncId, isManga: isManga).notifier) + .findLibAnime(track); findManga ??= isManga! - ? await ref.read(anilistProvider(syncId: syncId, isManga: isManga).notifier).addLibManga(track) - : await ref.read(anilistProvider(syncId: syncId, isManga: isManga).notifier).addLibAnime(track); + ? await ref + .read(anilistProvider(syncId: syncId, isManga: isManga).notifier) + .addLibManga(track) + : await ref + .read(anilistProvider(syncId: syncId, isManga: isManga).notifier) + .addLibAnime(track); } else if (syncId == 3) { findManga = isManga! - ? await ref.read(kitsuProvider(syncId: syncId, isManga: isManga).notifier).addLibManga(track) - : await ref.read(kitsuProvider(syncId: syncId, isManga: isManga).notifier).addLibAnime(track); + ? await ref + .read(kitsuProvider(syncId: syncId, isManga: isManga).notifier) + .addLibManga(track) + : await ref + .read(kitsuProvider(syncId: syncId, isManga: isManga).notifier) + .addLibAnime(track); } - ref.read(tracksProvider(syncId: syncId).notifier).updateTrackManga(findManga!, isManga); + ref + .read(tracksProvider(syncId: syncId).notifier) + .updateTrackManga(findManga!, isManga); } List getStatusList() { @@ -107,16 +158,36 @@ class TrackState extends _$TrackState { List list = []; if (track!.syncId == 1) { statusList = isManga! - ? ref.read(myAnimeListProvider(syncId: track!.syncId!, isManga: isManga).notifier).myAnimeListStatusListManga - : ref.read(myAnimeListProvider(syncId: track!.syncId!, isManga: isManga).notifier).myAnimeListStatusListAnime; + ? ref + .read( + myAnimeListProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .myAnimeListStatusListManga + : ref + .read( + myAnimeListProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .myAnimeListStatusListAnime; } else if (track!.syncId == 2) { statusList = isManga! - ? ref.read(anilistProvider(syncId: track!.syncId!, isManga: isManga).notifier).aniListStatusListManga - : ref.read(anilistProvider(syncId: track!.syncId!, isManga: isManga).notifier).aniListStatusListAnime; + ? ref + .read(anilistProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .aniListStatusListManga + : ref + .read(anilistProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .aniListStatusListAnime; } else if (track!.syncId == 3) { statusList = isManga! - ? ref.read(kitsuProvider(syncId: track!.syncId!, isManga: isManga).notifier).kitsuStatusListManga - : ref.read(kitsuProvider(syncId: track!.syncId!, isManga: isManga).notifier).kitsuStatusListAnime; + ? ref + .read(kitsuProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .kitsuStatusListManga + : ref + .read(kitsuProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .kitsuStatusListAnime; } for (var element in TrackStatus.values) { if (statusList.contains(element)) { @@ -129,16 +200,30 @@ class TrackState extends _$TrackState { Future findManga() async { Track? findManga; if (track!.syncId == 1) { - findManga = - await ref.read(myAnimeListProvider(syncId: track!.syncId!, isManga: isManga).notifier).findManga(track!); + findManga = await ref + .read(myAnimeListProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .findManga(track!); } else if (track!.syncId == 2) { findManga = isManga! - ? await ref.read(anilistProvider(syncId: track!.syncId!, isManga: isManga).notifier).findLibManga(track!) - : await ref.read(anilistProvider(syncId: track!.syncId!, isManga: isManga).notifier).findLibAnime(track!); + ? await ref + .read(anilistProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .findLibManga(track!) + : await ref + .read(anilistProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .findLibAnime(track!); } else if (track!.syncId == 3) { findManga = isManga! - ? await ref.read(kitsuProvider(syncId: track!.syncId!, isManga: isManga).notifier).findLibManga(track!) - : await ref.read(kitsuProvider(syncId: track!.syncId!, isManga: isManga).notifier).findLibAnime(track!); + ? await ref + .read(kitsuProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .findLibManga(track!) + : await ref + .read(kitsuProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .findLibAnime(track!); } return findManga; } @@ -146,15 +231,30 @@ class TrackState extends _$TrackState { Future?> search(String query) async { List? tracks; if (track!.syncId == 1) { - tracks = await ref.read(myAnimeListProvider(syncId: track!.syncId!, isManga: isManga).notifier).search(query); + tracks = await ref + .read(myAnimeListProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .search(query); } else if (track!.syncId == 2) { tracks = isManga! - ? await ref.read(anilistProvider(syncId: track!.syncId!, isManga: isManga).notifier).search(query) - : await ref.read(anilistProvider(syncId: track!.syncId!, isManga: isManga).notifier).searchAnime(query); + ? await ref + .read(anilistProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .search(query) + : await ref + .read(anilistProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .searchAnime(query); } else if (track!.syncId == 3) { tracks = isManga! - ? await ref.read(kitsuProvider(syncId: track!.syncId!, isManga: isManga).notifier).search(query) - : await ref.read(kitsuProvider(syncId: track!.syncId!, isManga: isManga).notifier).searchAnime(query); + ? await ref + .read(kitsuProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .search(query) + : await ref + .read(kitsuProvider(syncId: track!.syncId!, isManga: isManga) + .notifier) + .searchAnime(query); } return tracks; } diff --git a/lib/modules/manga/detail/providers/update_manga_detail_providers.dart b/lib/modules/manga/detail/providers/update_manga_detail_providers.dart index 3943c0b..6d2267a 100644 --- a/lib/modules/manga/detail/providers/update_manga_detail_providers.dart +++ b/lib/modules/manga/detail/providers/update_manga_detail_providers.dart @@ -12,7 +12,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; part 'update_manga_detail_providers.g.dart'; @riverpod -Future updateMangaDetail(Ref ref, {required int? mangaId, required bool isInit}) async { +Future updateMangaDetail(Ref ref, + {required int? mangaId, required bool isInit}) async { final manga = isar.mangas.getSync(mangaId!); if (manga!.chapters.isNotEmpty && isInit) { return; @@ -20,20 +21,31 @@ Future updateMangaDetail(Ref ref, {required int? mangaId, required bool final source = getSource(manga.lang!, manga.source!); MManga getManga; try { - getManga = await ref.watch(getDetailProvider(url: manga.link!, source: source!).future); + getManga = await ref + .watch(getDetailProvider(url: manga.link!, source: source!).future); } catch (e) { botToast(e.toString()); return; } - final genre = getManga.genre?.map((e) => e.toString().trim().trimLeft().trimRight()).toList().toSet().toList() ?? []; + final genre = getManga.genre + ?.map((e) => e.toString().trim().trimLeft().trimRight()) + .toList() + .toSet() + .toList() ?? + []; manga ..imageUrl = getManga.imageUrl ?? manga.imageUrl ..name = getManga.name?.trim().trimLeft().trimRight() ?? 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 ?? "" - ..status = getManga.status == Status.unknown ? manga.status : getManga.status! - ..description = getManga.description?.trim().trimLeft().trimRight() ?? manga.description ?? "" + ..author = + getManga.author?.trim().trimLeft().trimRight() ?? manga.author ?? "" + ..artist = + getManga.artist?.trim().trimLeft().trimRight() ?? manga.artist ?? "" + ..status = + getManga.status == Status.unknown ? manga.status : getManga.status! + ..description = getManga.description?.trim().trimLeft().trimRight() ?? + manga.description ?? + "" ..link = getManga.link?.trim().trimLeft().trimRight() ?? manga.link ..source = manga.source ..lang = manga.lang @@ -68,19 +80,24 @@ Future updateMangaDetail(Ref ref, {required int? mangaId, required bool } if (chapters.isNotEmpty) { for (var chap in chapters.reversed.toList()) { - ref.read(changedItemsManagerProvider(managerId: 1).notifier).addUpdatedChapter(chap, false, false); + ref + .read(changedItemsManagerProvider(managerId: 1).notifier) + .addUpdatedChapter(chap, false, false); isar.chapters.putSync(chap); chap.manga.saveSync(); if (manga.chapters.isNotEmpty) { - final update = - Update(mangaId: mangaId, chapterName: chap.name, date: DateTime.now().millisecondsSinceEpoch.toString()) - ..chapter.value = chap; + final update = Update( + mangaId: mangaId, + chapterName: chap.name, + date: DateTime.now().millisecondsSinceEpoch.toString()) + ..chapter.value = chap; isar.updates.putSync(update); update.chapter.saveSync(); } } } - final oldChapers = isar.mangas.getSync(mangaId)!.chapters.toList().reversed.toList(); + final oldChapers = + isar.mangas.getSync(mangaId)!.chapters.toList().reversed.toList(); if (oldChapers.length == chaps.length) { for (var i = 0; i < oldChapers.length; i++) { final oldChap = oldChapers[i]; @@ -91,7 +108,9 @@ Future updateMangaDetail(Ref ref, {required int? mangaId, required bool newChap.name == oldChap.name) { oldChap.url = newChap.url; oldChap.scanlator = newChap.scanlator; - ref.read(changedItemsManagerProvider(managerId: 1).notifier).addUpdatedChapter(oldChap, false, false); + ref + .read(changedItemsManagerProvider(managerId: 1).notifier) + .addUpdatedChapter(oldChap, false, false); isar.chapters.putSync(oldChap); oldChap.manga.saveSync(); } diff --git a/lib/modules/manga/detail/widgets/chapter_filter_list_tile_widget.dart b/lib/modules/manga/detail/widgets/chapter_filter_list_tile_widget.dart index 5b51bea..2bbbfac 100644 --- a/lib/modules/manga/detail/widgets/chapter_filter_list_tile_widget.dart +++ b/lib/modules/manga/detail/widgets/chapter_filter_list_tile_widget.dart @@ -4,7 +4,11 @@ class ListTileChapterFilter extends StatelessWidget { final String label; final int type; final VoidCallback onTap; - const ListTileChapterFilter({super.key, required this.label, required this.type, required this.onTap}); + const ListTileChapterFilter( + {super.key, + required this.label, + required this.type, + required this.onTap}); @override Widget build(BuildContext context) { diff --git a/lib/modules/manga/detail/widgets/chapter_list_tile_widget.dart b/lib/modules/manga/detail/widgets/chapter_list_tile_widget.dart index 007549e..8a45aac 100644 --- a/lib/modules/manga/detail/widgets/chapter_list_tile_widget.dart +++ b/lib/modules/manga/detail/widgets/chapter_list_tile_widget.dart @@ -25,19 +25,25 @@ class ChapterListTileWidget extends ConsumerWidget { final isLongPressed = ref.watch(isLongPressedStateProvider); final l10n = l10nLocalizations(context)!; return Container( - color: chapterList.contains(chapter) ? context.primaryColor.withValues(alpha: 0.4) : null, + 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, + 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); + ref + .read(isLongPressedStateProvider.notifier) + .update(!isLongPressed); } else { ref.read(chaptersListStateProvider.notifier).update(chapter); } @@ -73,18 +79,23 @@ class ChapterListTileWidget extends ConsumerWidget { Text( chapter.dateUpload == null || chapter.dateUpload!.isEmpty ? "" - : dateFormat(chapter.dateUpload!, ref: ref, context: context), + : dateFormat(chapter.dateUpload!, + ref: ref, context: context), style: const TextStyle(fontSize: 11), ), if (!chapter.isRead!) - if (chapter.lastPageRead!.isNotEmpty && chapter.lastPageRead != "1") + if (chapter.lastPageRead!.isNotEmpty && + chapter.lastPageRead != "1") Row( children: [ const Text(' • '), Text( !chapter.manga.value!.isManga! - ? l10n.episode_progress( - Duration(milliseconds: int.parse(chapter.lastPageRead!)).toString().substringBefore(".")) + ? l10n.episode_progress(Duration( + milliseconds: + int.parse(chapter.lastPageRead!)) + .toString() + .substringBefore(".")) : l10n.page(chapter.lastPageRead!), style: TextStyle( fontSize: 11, diff --git a/lib/modules/manga/detail/widgets/chapter_sort_list_tile_widget.dart b/lib/modules/manga/detail/widgets/chapter_sort_list_tile_widget.dart index 671b4f3..45ead0e 100644 --- a/lib/modules/manga/detail/widgets/chapter_sort_list_tile_widget.dart +++ b/lib/modules/manga/detail/widgets/chapter_sort_list_tile_widget.dart @@ -6,15 +6,22 @@ class ListTileChapterSort extends StatelessWidget { final VoidCallback onTap; final bool showLeading; const ListTileChapterSort( - {super.key, required this.label, required this.reverse, required this.onTap, required this.showLeading}); + {super.key, + required this.label, + required this.reverse, + required this.onTap, + required this.showLeading}); @override Widget build(BuildContext context) { return ListTile( iconColor: Theme.of(context).primaryColor, dense: true, - leading: Icon(reverse ? Icons.arrow_downward_sharp : Icons.arrow_upward_sharp, - color: showLeading ? Theme.of(context).primaryColor : Colors.transparent), + leading: Icon( + reverse ? Icons.arrow_downward_sharp : Icons.arrow_upward_sharp, + color: showLeading + ? Theme.of(context).primaryColor + : Colors.transparent), title: Text( label, style: const TextStyle(fontSize: 14), diff --git a/lib/modules/manga/detail/widgets/readmore.dart b/lib/modules/manga/detail/widgets/readmore.dart index 2a2eab6..4fdad4e 100644 --- a/lib/modules/manga/detail/widgets/readmore.dart +++ b/lib/modules/manga/detail/widgets/readmore.dart @@ -4,7 +4,8 @@ import 'package:mangayomi/providers/l10n_providers.dart'; import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class ReadMoreWidget extends StatefulWidget { - const ReadMoreWidget({super.key, required this.text, required this.onChanged}); + const ReadMoreWidget( + {super.key, required this.text, required this.onChanged}); final Function(bool) onChanged; final String text; @@ -12,7 +13,8 @@ class ReadMoreWidget extends StatefulWidget { ReadMoreWidgetState createState() => ReadMoreWidgetState(); } -class ReadMoreWidgetState extends State with TickerProviderStateMixin { +class ReadMoreWidgetState extends State + with TickerProviderStateMixin { late bool expanded = true; @override Widget build(BuildContext context) { @@ -61,7 +63,9 @@ class ReadMoreWidgetState extends State with TickerProviderState begin: Alignment.topCenter, end: Alignment.bottomCenter, colors: [ - Theme.of(context).scaffoldBackgroundColor.withValues(alpha: 0.2), + Theme.of(context) + .scaffoldBackgroundColor + .withValues(alpha: 0.2), Theme.of(context).scaffoldBackgroundColor ], stops: const [0, .9], diff --git a/lib/modules/manga/detail/widgets/tracker_search_widget.dart b/lib/modules/manga/detail/widgets/tracker_search_widget.dart index f02e11f..e885b76 100644 --- a/lib/modules/manga/detail/widgets/tracker_search_widget.dart +++ b/lib/modules/manga/detail/widgets/tracker_search_widget.dart @@ -11,10 +11,12 @@ import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class TrackerWidgetSearch extends ConsumerStatefulWidget { final bool isManga; final Track track; - const TrackerWidgetSearch({required this.isManga, required this.track, super.key}); + const TrackerWidgetSearch( + {required this.isManga, required this.track, super.key}); @override - ConsumerState createState() => _TrackerWidgetSearchState(); + ConsumerState createState() => + _TrackerWidgetSearchState(); } class _TrackerWidgetSearchState extends ConsumerState { @@ -28,7 +30,10 @@ class _TrackerWidgetSearchState extends ConsumerState { late List? tracks = []; _init() async { await Future.delayed(const Duration(microseconds: 100)); - tracks = await ref.read(trackStateProvider(track: widget.track, isManga: widget.isManga).notifier).search(query); + tracks = await ref + .read(trackStateProvider(track: widget.track, isManga: widget.isManga) + .notifier) + .search(query); if (mounted) { setState(() { _isLoading = false; @@ -42,7 +47,8 @@ class _TrackerWidgetSearchState extends ConsumerState { Widget build(BuildContext context) { return Material( color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20)), + borderRadius: const BorderRadius.only( + bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20)), clipBehavior: Clip.antiAliasWithSaveLayer, child: _isLoading ? const ProgressCenter() @@ -66,41 +72,50 @@ class _TrackerWidgetSearchState extends ConsumerState { child: Column( children: [ Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Material( borderRadius: BorderRadius.circular(5), color: Colors.transparent, - clipBehavior: Clip.antiAliasWithSaveLayer, + clipBehavior: + Clip.antiAliasWithSaveLayer, child: Ink.image( height: 120, width: 80, fit: BoxFit.cover, - image: CustomExtendedNetworkImageProvider(tracks![index].coverUrl!), + image: + CustomExtendedNetworkImageProvider( + tracks![index].coverUrl!), ), ), const SizedBox( width: 10, ), Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ SizedBox( width: context.width(0.6), child: Text( tracks![index].title!, - style: const TextStyle(fontWeight: FontWeight.bold), + style: const TextStyle( + fontWeight: FontWeight.bold), ), ), Row( children: [ const Text( "Type : ", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 12), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 12), ), Text( tracks![index].publishingType!, - style: const TextStyle(fontSize: 12), + style: const TextStyle( + fontSize: 12), ), ], ), @@ -108,11 +123,15 @@ class _TrackerWidgetSearchState extends ConsumerState { children: [ const Text( "Status : ", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 12), + style: TextStyle( + fontWeight: FontWeight.bold, + fontSize: 12), ), Text( - tracks![index].publishingStatus!, - style: const TextStyle(fontSize: 12), + tracks![index] + .publishingStatus!, + style: const TextStyle( + fontSize: 12), ), ], ), @@ -153,7 +172,10 @@ class _TrackerWidgetSearchState extends ConsumerState { _isLoading = true; }); tracks = await ref - .read(trackStateProvider(track: widget.track, isManga: widget.isManga).notifier) + .read(trackStateProvider( + track: widget.track, + isManga: widget.isManga) + .notifier) .search(d.trim()); if (mounted) { setState(() { @@ -173,12 +195,16 @@ class _TrackerWidgetSearchState extends ConsumerState { }, icon: const Icon(Icons.clear)), enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: context.primaryColor), + borderSide: + BorderSide(color: context.primaryColor), ), focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: context.primaryColor), + borderSide: + BorderSide(color: context.primaryColor), ), - border: OutlineInputBorder(borderSide: BorderSide(color: context.primaryColor))), + border: OutlineInputBorder( + borderSide: + BorderSide(color: context.primaryColor))), ), ), ], @@ -189,7 +215,8 @@ class _TrackerWidgetSearchState extends ConsumerState { } } -trackersSearchraggableMenu(BuildContext context, {required Track track, required bool isManga}) async { +trackersSearchraggableMenu(BuildContext context, + {required Track track, required bool isManga}) async { return await DraggableMenu.open( context, DraggableMenu( @@ -199,7 +226,9 @@ trackersSearchraggableMenu(BuildContext context, {required Track track, required barItem: Container( decoration: BoxDecoration( color: Theme.of(context).scaffoldBackgroundColor, - borderRadius: const BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20))), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(20), + topRight: Radius.circular(20))), child: Column( children: [ Row( diff --git a/lib/modules/manga/detail/widgets/tracker_widget.dart b/lib/modules/manga/detail/widgets/tracker_widget.dart index bf72baf..be286a3 100644 --- a/lib/modules/manga/detail/widgets/tracker_widget.dart +++ b/lib/modules/manga/detail/widgets/tracker_widget.dart @@ -38,10 +38,15 @@ class _TrackerWidgetState extends ConsumerState { _init() async { await Future.delayed(const Duration(microseconds: 100)); - final findManga = - await ref.read(trackStateProvider(track: widget.trackRes, isManga: widget.isManga).notifier).findManga(); + final findManga = await ref + .read( + trackStateProvider(track: widget.trackRes, isManga: widget.isManga) + .notifier) + .findManga(); if (mounted) { - ref.read(tracksProvider(syncId: widget.syncId).notifier).updateTrackManga(findManga!, widget.isManga); + ref + .read(tracksProvider(syncId: widget.syncId).notifier) + .updateTrackManga(findManga!, widget.isManga); } } @@ -51,7 +56,9 @@ class _TrackerWidgetState extends ConsumerState { final l10nLocale = ref.watch(l10nLocaleStateProvider); return Container( decoration: BoxDecoration( - color: context.isLight ? Theme.of(context).scaffoldBackgroundColor : Colors.black, + color: context.isLight + ? Theme.of(context).scaffoldBackgroundColor + : Colors.black, borderRadius: BorderRadius.circular(20)), child: Column( children: [ @@ -59,10 +66,12 @@ class _TrackerWidgetState extends ConsumerState { children: [ if (!widget.hide) Padding( - padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 5), + padding: + const EdgeInsets.symmetric(horizontal: 12, vertical: 5), child: Container( - decoration: - BoxDecoration(borderRadius: BorderRadius.circular(10), color: trackInfos(widget.syncId).$3), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: trackInfos(widget.syncId).$3), width: 50, height: 45, child: Image.asset( @@ -74,16 +83,22 @@ class _TrackerWidgetState extends ConsumerState { Expanded( child: _elevatedButton( context, - borderRadius: const BorderRadius.only(topRight: Radius.circular(20), topLeft: Radius.circular(20)), + borderRadius: const BorderRadius.only( + topRight: Radius.circular(20), + topLeft: Radius.circular(20)), onPressed: !widget.hide ? () async { - final trackSearch = - await trackersSearchraggableMenu(context, isManga: widget.isManga, track: widget.trackRes) - as TrackSearch?; + final trackSearch = await trackersSearchraggableMenu( + context, + isManga: widget.isManga, + track: widget.trackRes) as TrackSearch?; if (trackSearch != null) { await ref - .read(trackStateProvider(track: null, isManga: widget.isManga).notifier) - .setTrackSearch(trackSearch, widget.mangaId, widget.syncId); + .read(trackStateProvider( + track: null, isManga: widget.isManga) + .notifier) + .setTrackSearch( + trackSearch, widget.mangaId, widget.syncId); } } : null, @@ -95,7 +110,10 @@ class _TrackerWidgetState extends ConsumerState { child: Text( widget.trackRes.title!, style: TextStyle( - color: Theme.of(context).textTheme.bodyMedium!.color, + color: Theme.of(context) + .textTheme + .bodyMedium! + .color, overflow: TextOverflow.ellipsis, fontSize: 16, fontWeight: FontWeight.bold), @@ -105,7 +123,10 @@ class _TrackerWidgetState extends ConsumerState { ), IconButton( onPressed: () { - ref.read(tracksProvider(syncId: widget.syncId).notifier).deleteTrackManga(widget.trackRes); + ref + .read(tracksProvider(syncId: widget.syncId) + .notifier) + .deleteTrackManga(widget.trackRes); }, icon: const Icon(Icons.cancel_outlined)) ], @@ -130,29 +151,39 @@ class _TrackerWidgetState extends ConsumerState { child: ListView.builder( shrinkWrap: true, itemCount: ref - .read(trackStateProvider(track: widget.trackRes, isManga: widget.isManga).notifier) + .read(trackStateProvider( + track: widget.trackRes, + isManga: widget.isManga) + .notifier) .getStatusList() .length, itemBuilder: (context, index) { final status = ref - .read( - trackStateProvider(track: widget.trackRes, isManga: widget.isManga).notifier) + .read(trackStateProvider( + track: widget.trackRes, + isManga: widget.isManga) + .notifier) .getStatusList()[index]; return RadioListTile( dense: true, contentPadding: const EdgeInsets.all(0), value: status, - groupValue: - toTrackStatus(widget.trackRes.status, widget.isManga, widget.trackRes.syncId!), + groupValue: toTrackStatus( + widget.trackRes.status, + widget.isManga, + widget.trackRes.syncId!), onChanged: (value) { ref .read(trackStateProvider( - track: widget.trackRes..status = status, isManga: widget.isManga) + track: widget.trackRes + ..status = status, + isManga: widget.isManga) .notifier) .updateManga(); Navigator.pop(context); }, - title: Text(getTrackStatus(status, context)), + title: + Text(getTrackStatus(status, context)), ); }, )), @@ -166,7 +197,8 @@ class _TrackerWidgetState extends ConsumerState { }, child: Text( l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), ], ) @@ -175,7 +207,9 @@ class _TrackerWidgetState extends ConsumerState { }); }, text: getTrackStatus( - toTrackStatus(widget.trackRes.status, widget.isManga, widget.trackRes.syncId!), context)), + toTrackStatus(widget.trackRes.status, widget.isManga, + widget.trackRes.syncId!), + context)), ), Expanded( child: _elevatedButton(context, onPressed: () { @@ -196,10 +230,13 @@ class _TrackerWidgetState extends ConsumerState { NumberPicker( value: currentIntValue, minValue: 0, - maxValue: widget.trackRes.totalChapter != 0 ? widget.trackRes.totalChapter! : 10000, + maxValue: widget.trackRes.totalChapter != 0 + ? widget.trackRes.totalChapter! + : 10000, step: 1, haptics: true, - onChanged: (value) => setState(() => currentIntValue = value), + onChanged: (value) => + setState(() => currentIntValue = value), ), ], ), @@ -215,13 +252,16 @@ class _TrackerWidgetState extends ConsumerState { }, child: Text( l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), TextButton( onPressed: () async { ref .read(trackStateProvider( - track: widget.trackRes..lastChapterRead = currentIntValue, + track: widget.trackRes + ..lastChapterRead = + currentIntValue, isManga: widget.isManga) .notifier) .updateManga(); @@ -229,7 +269,8 @@ class _TrackerWidgetState extends ConsumerState { }, child: Text( l10n.ok, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), ], ) @@ -261,21 +302,28 @@ class _TrackerWidgetState extends ConsumerState { value: currentIntValue, minValue: 0, maxValue: ref - .read(trackStateProvider(track: widget.trackRes, isManga: widget.isManga) + .read(trackStateProvider( + track: widget.trackRes, + isManga: widget.isManga) .notifier) .getScoreMaxValue(), textMapper: (numberText) { return ref - .read(trackStateProvider(track: widget.trackRes, isManga: widget.isManga) + .read(trackStateProvider( + track: widget.trackRes, + isManga: widget.isManga) .notifier) .getTextMapper(numberText); }, step: ref - .read(trackStateProvider(track: widget.trackRes, isManga: widget.isManga) + .read(trackStateProvider( + track: widget.trackRes, + isManga: widget.isManga) .notifier) .getScoreStep(), haptics: true, - onChanged: (value) => setState(() => currentIntValue = value), + onChanged: (value) => + setState(() => currentIntValue = value), ), ], ), @@ -291,13 +339,15 @@ class _TrackerWidgetState extends ConsumerState { }, child: Text( l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), TextButton( onPressed: () async { ref .read(trackStateProvider( - track: widget.trackRes..score = currentIntValue, + track: widget.trackRes + ..score = currentIntValue, isManga: widget.isManga) .notifier) .updateManga(); @@ -305,7 +355,8 @@ class _TrackerWidgetState extends ConsumerState { }, child: Text( l10n.ok, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), ], ) @@ -315,7 +366,10 @@ class _TrackerWidgetState extends ConsumerState { }, text: widget.trackRes.score != 0 ? ref - .read(trackStateProvider(track: widget.trackRes, isManga: widget.isManga).notifier) + .read(trackStateProvider( + track: widget.trackRes, + isManga: widget.isManga) + .notifier) .displayScore(widget.trackRes.score!) : l10n!.score), ) @@ -324,8 +378,9 @@ class _TrackerWidgetState extends ConsumerState { Row( children: [ Expanded( - child: _elevatedButton(context, borderRadius: const BorderRadius.only(bottomLeft: Radius.circular(20)), - onPressed: () async { + child: _elevatedButton(context, + borderRadius: const BorderRadius.only( + bottomLeft: Radius.circular(20)), onPressed: () async { DateTime? newDate = await showDatePicker( helpText: l10n!.start_date, locale: l10nLocale, @@ -336,20 +391,27 @@ class _TrackerWidgetState extends ConsumerState { if (newDate == null) return; ref .read(trackStateProvider( - track: widget.trackRes..startedReadingDate = newDate.millisecondsSinceEpoch, + track: widget.trackRes + ..startedReadingDate = + newDate.millisecondsSinceEpoch, isManga: widget.isManga) .notifier) .updateManga(); }, text: widget.trackRes.startedReadingDate != null && - widget.trackRes.startedReadingDate! > DateTime(1970).millisecondsSinceEpoch - ? dateFormat(widget.trackRes.startedReadingDate.toString(), - ref: ref, useRelativeTimesTamps: false, context: context) + widget.trackRes.startedReadingDate! > + DateTime(1970).millisecondsSinceEpoch + ? dateFormat( + widget.trackRes.startedReadingDate.toString(), + ref: ref, + useRelativeTimesTamps: false, + context: context) : l10n!.start_date), ), Expanded( - child: _elevatedButton(context, borderRadius: const BorderRadius.only(bottomRight: Radius.circular(20)), - onPressed: () async { + child: _elevatedButton(context, + borderRadius: const BorderRadius.only( + bottomRight: Radius.circular(20)), onPressed: () async { DateTime? newDate = await showDatePicker( helpText: l10n!.finish_date, locale: l10nLocale, @@ -360,15 +422,21 @@ class _TrackerWidgetState extends ConsumerState { if (newDate == null) return; ref .read(trackStateProvider( - track: widget.trackRes..finishedReadingDate = newDate.millisecondsSinceEpoch, + track: widget.trackRes + ..finishedReadingDate = + newDate.millisecondsSinceEpoch, isManga: widget.isManga) .notifier) .updateManga(); }, text: widget.trackRes.finishedReadingDate != null && - widget.trackRes.finishedReadingDate! > DateTime(1970).millisecondsSinceEpoch - ? dateFormat(widget.trackRes.finishedReadingDate.toString(), - ref: ref, useRelativeTimesTamps: false, context: context) + widget.trackRes.finishedReadingDate! > + DateTime(1970).millisecondsSinceEpoch + ? dateFormat( + widget.trackRes.finishedReadingDate.toString(), + ref: ref, + useRelativeTimesTamps: false, + context: context) : l10n!.finish_date), ) ], @@ -380,20 +448,32 @@ class _TrackerWidgetState extends ConsumerState { } Widget _elevatedButton(BuildContext context, - {required Function()? onPressed, String text = "", Widget? child, BorderRadiusGeometry? borderRadius}) { + {required Function()? onPressed, + String text = "", + Widget? child, + BorderRadiusGeometry? borderRadius}) { return ElevatedButton( style: ElevatedButton.styleFrom( padding: const EdgeInsets.all(0), - backgroundColor: context.isLight ? Theme.of(context).scaffoldBackgroundColor : Colors.black, + backgroundColor: context.isLight + ? Theme.of(context).scaffoldBackgroundColor + : Colors.black, elevation: 0, shadowColor: Colors.transparent, shape: RoundedRectangleBorder( - side: BorderSide(width: 0, color: context.secondaryColor.withValues(alpha: 0.1)), + side: BorderSide( + width: 0, + color: context.secondaryColor.withValues(alpha: 0.1)), borderRadius: borderRadius ?? BorderRadius.circular(0))), onPressed: onPressed, child: child ?? Text( text, - style: TextStyle(color: Theme.of(context).textTheme.bodyMedium!.color!.withValues(alpha: 0.9)), + style: TextStyle( + color: Theme.of(context) + .textTheme + .bodyMedium! + .color! + .withValues(alpha: 0.9)), )); } diff --git a/lib/modules/manga/download/download_page_widget.dart b/lib/modules/manga/download/download_page_widget.dart index d168285..fa63ecc 100644 --- a/lib/modules/manga/download/download_page_widget.dart +++ b/lib/modules/manga/download/download_page_widget.dart @@ -35,19 +35,24 @@ class _ChapterPageDownloadState extends ConsumerState final StorageProvider _storageProvider = StorageProvider(); void _startDownload(bool? useWifi) async { - await ref.watch(downloadChapterProvider(chapter: widget.chapter, useWifi: useWifi).future); + await ref.watch( + downloadChapterProvider(chapter: widget.chapter, useWifi: useWifi) + .future); } late final manga = widget.chapter.manga.value!; void _sendFile() async { - final mangaDir = await _storageProvider.getMangaMainDirectory(widget.chapter); - final path = await _storageProvider.getMangaChapterDirectory(widget.chapter); + final mangaDir = + await _storageProvider.getMangaMainDirectory(widget.chapter); + final path = + await _storageProvider.getMangaChapterDirectory(widget.chapter); List files = []; final cbzFile = File(p.join(mangaDir!.path, "${widget.chapter.name}.cbz")); - final mp4File = File(p.join(mangaDir.path, "${widget.chapter.name!.replaceForbiddenCharacters(' ')}.mp4")); + final mp4File = File(p.join(mangaDir.path, + "${widget.chapter.name!.replaceForbiddenCharacters(' ')}.mp4")); if (cbzFile.existsSync()) { files = [XFile(cbzFile.path)]; } else if (mp4File.existsSync()) { @@ -61,18 +66,22 @@ class _ChapterPageDownloadState extends ConsumerState } void _deleteFile() async { - final mangaDir = await _storageProvider.getMangaMainDirectory(widget.chapter); - final path = await _storageProvider.getMangaChapterDirectory(widget.chapter); + final mangaDir = + await _storageProvider.getMangaMainDirectory(widget.chapter); + final path = + await _storageProvider.getMangaChapterDirectory(widget.chapter); try { try { - final cbzFile = File(p.join(mangaDir!.path, "${widget.chapter.name}.cbz")); + final cbzFile = + File(p.join(mangaDir!.path, "${widget.chapter.name}.cbz")); if (cbzFile.existsSync()) { cbzFile.deleteSync(); } } catch (_) {} try { - final mp4File = File(p.join(mangaDir!.path, "${widget.chapter.name!.replaceForbiddenCharacters(' ')}.mp4")); + final mp4File = File(p.join(mangaDir!.path, + "${widget.chapter.name!.replaceForbiddenCharacters(' ')}.mp4")); if (mp4File.existsSync()) { mp4File.deleteSync(); } @@ -80,7 +89,11 @@ class _ChapterPageDownloadState extends ConsumerState path!.deleteSync(recursive: true); } catch (_) {} isar.writeTxnSync(() { - int id = isar.downloads.filter().chapterIdEqualTo(widget.chapter.id!).findFirstSync()!.id!; + int id = isar.downloads + .filter() + .chapterIdEqualTo(widget.chapter.id!) + .findFirstSync()! + .id!; isar.downloads.deleteSync(id); }); } @@ -111,7 +124,10 @@ class _ChapterPageDownloadState extends ConsumerState child: Icon( size: 25, Icons.check_circle, - color: Theme.of(context).iconTheme.color!.withValues(alpha: 0.7), + color: Theme.of(context) + .iconTheme + .color! + .withValues(alpha: 0.7), ), onSelected: (value) { if (value == 0) { @@ -125,7 +141,8 @@ class _ChapterPageDownloadState extends ConsumerState PopupMenuItem(value: 1, child: Text(l10n.delete)), ], ) - : entries.first.isStartDownload! && entries.first.succeeded == 0 + : entries.first.isStartDownload! && + entries.first.succeeded == 0 ? SizedBox( height: 41, width: 35, @@ -144,7 +161,9 @@ class _ChapterPageDownloadState extends ConsumerState } }, itemBuilder: (context) => [ - PopupMenuItem(value: 1, child: Text(l10n.start_downloading)), + PopupMenuItem( + value: 1, + child: Text(l10n.start_downloading)), PopupMenuItem(value: 0, child: Text(l10n.cancel)), ], )) @@ -159,19 +178,25 @@ class _ChapterPageDownloadState extends ConsumerState Align( alignment: Alignment.center, child: TweenAnimationBuilder( - duration: const Duration(milliseconds: 250), + duration: + const Duration(milliseconds: 250), curve: Curves.easeInOut, tween: Tween( begin: 0, - end: (entries.first.succeeded! / entries.first.total!), + end: (entries.first.succeeded! / + entries.first.total!), ), - builder: (context, value, _) => SizedBox( + builder: (context, value, _) => + SizedBox( height: 2, width: 2, child: CircularProgressIndicator( strokeWidth: 19, value: value, - color: Theme.of(context).iconTheme.color!.withValues(alpha: 0.7), + color: Theme.of(context) + .iconTheme + .color! + .withValues(alpha: 0.7), ), ), ), @@ -180,9 +205,15 @@ class _ChapterPageDownloadState extends ConsumerState alignment: Alignment.center, child: Icon( Icons.arrow_downward_sharp, - color: (entries.first.succeeded! / entries.first.total!) > 0.5 - ? Theme.of(context).scaffoldBackgroundColor - : Theme.of(context).iconTheme.color!.withValues(alpha: 0.7), + color: (entries.first.succeeded! / + entries.first.total!) > + 0.5 + ? Theme.of(context) + .scaffoldBackgroundColor + : Theme.of(context) + .iconTheme + .color! + .withValues(alpha: 0.7), )), ], ), @@ -198,8 +229,11 @@ class _ChapterPageDownloadState extends ConsumerState } }, itemBuilder: (context) => [ - PopupMenuItem(value: 1, child: Text(l10n.start_downloading)), - PopupMenuItem(value: 0, child: Text(l10n.cancel)), + PopupMenuItem( + value: 1, + child: Text(l10n.start_downloading)), + PopupMenuItem( + value: 0, child: Text(l10n.cancel)), ], )) : entries.first.succeeded == 0 @@ -212,7 +246,10 @@ class _ChapterPageDownloadState extends ConsumerState }, icon: Icon( FontAwesomeIcons.circleDown, - color: Theme.of(context).iconTheme.color!.withValues(alpha: 0.7), + color: Theme.of(context) + .iconTheme + .color! + .withValues(alpha: 0.7), size: 25, )) : SizedBox( @@ -235,7 +272,8 @@ class _ChapterPageDownloadState extends ConsumerState } }, itemBuilder: (context) => [ - PopupMenuItem(value: 0, child: Text(l10n.retry)), + PopupMenuItem( + value: 0, child: Text(l10n.retry)), ], )); } @@ -255,7 +293,8 @@ class _ChapterPageDownloadState extends ConsumerState } }, itemBuilder: (context) => [ - PopupMenuItem(value: 1, child: Text(l10n.start_downloading)), + PopupMenuItem( + value: 1, child: Text(l10n.start_downloading)), PopupMenuItem(value: 0, child: Text(l10n.cancel)), ], )) @@ -287,7 +326,10 @@ class _ChapterPageDownloadState extends ConsumerState []; await FileDownloader().cancelTasksWithIds(_pageUrls); await Future.delayed(const Duration(seconds: 2)); - final chapterD = isar.downloads.filter().chapterIdEqualTo(widget.chapter.id!).findFirstSync(); + final chapterD = isar.downloads + .filter() + .chapterIdEqualTo(widget.chapter.id!) + .findFirstSync(); if (chapterD != null) { final verifyId = isar.downloads.getSync(chapterD.id!); isar.writeTxnSync(() { diff --git a/lib/modules/manga/download/providers/convert_to_cbz.dart b/lib/modules/manga/download/providers/convert_to_cbz.dart index 26636d1..60c4696 100644 --- a/lib/modules/manga/download/providers/convert_to_cbz.dart +++ b/lib/modules/manga/download/providers/convert_to_cbz.dart @@ -7,8 +7,8 @@ import 'package:path/path.dart' as path; part 'convert_to_cbz.g.dart'; @riverpod -Future> convertToCBZ( - Ref ref, String chapterDir, String mangaDir, String chapterName, List pageList) async { +Future> convertToCBZ(Ref ref, String chapterDir, String mangaDir, + String chapterName, List pageList) async { return compute(_convertToCBZ, (chapterDir, mangaDir, chapterName, pageList)); } diff --git a/lib/modules/manga/download/providers/download_provider.dart b/lib/modules/manga/download/providers/download_provider.dart index c793115..fd9f055 100644 --- a/lib/modules/manga/download/providers/download_provider.dart +++ b/lib/modules/manga/download/providers/download_provider.dart @@ -41,8 +41,9 @@ Future> downloadChapter( bool isOk = false; final manga = chapter.manga.value!; final path1 = await storageProvider.getDirectory(); - String scanlator = - (chapter.scanlator?.isNotEmpty ?? false) ? "${chapter.scanlator!.replaceForbiddenCharacters('_')}_" : ""; + String scanlator = (chapter.scanlator?.isNotEmpty ?? false) + ? "${chapter.scanlator!.replaceForbiddenCharacters('_')}_" + : ""; final chapterName = chapter.name!.replaceForbiddenCharacters(' '); final isManga = manga.isManga!; @@ -68,12 +69,13 @@ Future> downloadChapter( Future processConvert() async { if (hasM3U8File) { - await m3u8Downloader?.mergeTsToMp4(p.join(path!.path, "$chapterName.mp4"), p.join(path.path, chapterName)); + await m3u8Downloader?.mergeTsToMp4(p.join(path!.path, "$chapterName.mp4"), + p.join(path.path, chapterName)); } else { if (ref.watch(saveAsCBZArchiveStateProvider)) { - await ref.watch( - convertToCBZProvider(path!.path, mangaDir!.path, chapter.name!, pageUrls.map((e) => e.url).toList()) - .future); + await ref.watch(convertToCBZProvider(path!.path, mangaDir!.path, + chapter.name!, pageUrls.map((e) => e.url).toList()) + .future); } } } @@ -86,12 +88,17 @@ Future> downloadChapter( chapterPageUrls.add(chapterPageUrl); } } - final chapterPageHeaders = pageUrls.map((e) => e.headers == null ? null : jsonEncode(e.headers)).toList(); + final chapterPageHeaders = pageUrls + .map((e) => e.headers == null ? null : jsonEncode(e.headers)) + .toList(); chapterPageUrls.add(ChapterPageurls() ..chapterId = chapter.id ..urls = pageUrls.map((e) => e.url).toList() - ..headers = chapterPageHeaders.first != null ? chapterPageHeaders.map((e) => e.toString()).toList() : null); - isar.writeTxnSync(() => isar.settings.putSync(settings..chapterPageUrlsList = chapterPageUrls)); + ..headers = chapterPageHeaders.first != null + ? chapterPageHeaders.map((e) => e.toString()).toList() + : null); + isar.writeTxnSync(() => + isar.settings.putSync(settings..chapterPageUrlsList = chapterPageUrls)); } if (isManga) { @@ -108,9 +115,13 @@ Future> downloadChapter( } else { ref.read(getVideoListProvider(episode: chapter).future).then((value) async { final m3u8Urls = value.$1 - .where((element) => element.originalUrl.endsWith(".m3u8") || element.originalUrl.endsWith(".m3u")) + .where((element) => + element.originalUrl.endsWith(".m3u8") || + element.originalUrl.endsWith(".m3u")) + .toList(); + final nonM3u8Urls = value.$1 + .where((element) => element.originalUrl.isMediaVideo()) .toList(); - final nonM3u8Urls = value.$1.where((element) => element.originalUrl.isMediaVideo()).toList(); nonM3U8File = nonM3u8Urls.isNotEmpty; hasM3U8File = nonM3U8File ? false : m3u8Urls.isNotEmpty; final videosUrls = nonM3U8File ? nonM3u8Urls : m3u8Urls; @@ -121,9 +132,12 @@ Future> downloadChapter( m3u8Url: videosUrls.first.url, downloadDir: p.join(path!.path, chapterName), headers: videosUrls.first.headers ?? {}); - (tsList, tsKey, tsIv, m3u8MediaSequence) = await m3u8Downloader!.getTsList(); + (tsList, tsKey, tsIv, m3u8MediaSequence) = + await m3u8Downloader!.getTsList(); } - pageUrls = hasM3U8File ? [...tsList.map((e) => PageUrl(e.url))] : [PageUrl(videosUrls.first.url)]; + pageUrls = hasM3U8File + ? [...tsList.map((e) => PageUrl(e.url))] + : [PageUrl(videosUrls.first.url)]; videoHeader.addAll(videosUrls.first.headers ?? {}); isOk = true; } @@ -140,12 +154,18 @@ Future> downloadChapter( if (pageUrls.isNotEmpty) { bool cbzFileExist = - await File(p.join(mangaDir!.path, "${chapter.name}.cbz")).exists() && ref.watch(saveAsCBZArchiveStateProvider); - bool mp4FileExist = await File(p.join(mangaDir.path, "$chapterName.mp4")).exists(); + await File(p.join(mangaDir!.path, "${chapter.name}.cbz")).exists() && + ref.watch(saveAsCBZArchiveStateProvider); + bool mp4FileExist = + await File(p.join(mangaDir.path, "$chapterName.mp4")).exists(); if (!cbzFileExist && isManga || !mp4FileExist && !isManga) { for (var index = 0; index < pageUrls.length; index++) { - final path2 = Directory(p.join(path1.path, "downloads", isManga ? "Manga" : "Anime", - "${manga.source} (${manga.lang!.toUpperCase()})", manga.name!.replaceForbiddenCharacters('_'))); + final path2 = Directory(p.join( + path1.path, + "downloads", + isManga ? "Manga" : "Anime", + "${manga.source} (${manga.lang!.toUpperCase()})", + manga.name!.replaceForbiddenCharacters('_'))); if (!(await path2.exists())) { await path2.create(recursive: true); } @@ -156,7 +176,10 @@ Future> downloadChapter( } final page = pageUrls[index]; final cookie = MClient.getCookiesPref(page.url); - final headers = isManga ? ref.watch(headersProvider(source: manga.source!, lang: manga.lang!)) : videoHeader; + final headers = isManga + ? ref.watch( + headersProvider(source: manga.source!, lang: manga.lang!)) + : videoHeader; if (cookie.isNotEmpty) { final userAgent = isar.settings.getSync(227)!.userAgent!; headers.addAll(cookie); @@ -166,7 +189,8 @@ Future> downloadChapter( pageHeaders.addAll(page.headers ?? {}); if (isManga) { - final file = File(p.join(tempDir.path, "Mangayomi", finalPath, "${padIndex(index + 1)}.jpg")); + final file = File(p.join(tempDir.path, "Mangayomi", finalPath, + "${padIndex(index + 1)}.jpg")); if (file.existsSync()) { Directory(path.path).createSync(recursive: true); await file.copy(p.join(path.path, "${padIndex(index + 1)}.jpg")); @@ -175,7 +199,8 @@ Future> downloadChapter( if (!(await path.exists())) { await path.create(); } - if (!(await File(p.join(path.path, "${padIndex(index + 1)}.jpg")).exists())) { + if (!(await File(p.join(path.path, "${padIndex(index + 1)}.jpg")) + .exists())) { tasks.add(DownloadTask( taskId: page.url, headers: pageHeaders, @@ -190,16 +215,21 @@ Future> downloadChapter( } } } else { - final file = File(p.join(tempDir.path, "Mangayomi", finalPath, "$chapterName.mp4")); + final file = File( + p.join(tempDir.path, "Mangayomi", finalPath, "$chapterName.mp4")); if (file.existsSync()) { await file.copy(p.join(path.path, "$chapterName.mp4")); await file.delete(); } else if (hasM3U8File) { - final tempFile = File(p.join(tempDir.path, "Mangayomi", finalPath, chapterName, "TS_${index + 1}.ts")); - final file = File(p.join(path.path, chapterName, "TS_${index + 1}.ts")); + final tempFile = File(p.join(tempDir.path, "Mangayomi", finalPath, + chapterName, "TS_${index + 1}.ts")); + final file = + File(p.join(path.path, chapterName, "TS_${index + 1}.ts")); if (tempFile.existsSync()) { - Directory(p.join(path.path, chapterName)).createSync(recursive: true); - await tempFile.copy(p.join(path.path, chapterName, "TS_${index + 1}.ts")); + Directory(p.join(path.path, chapterName)) + .createSync(recursive: true); + await tempFile + .copy(p.join(path.path, chapterName, "TS_${index + 1}.ts")); await tempFile.delete(); } else if (!(file.existsSync())) { tasks.add(DownloadTask( @@ -264,7 +294,10 @@ Future> downloadChapter( if (succeeded == tasks.length) { await processConvert(); } - bool isEmpty = isar.downloads.filter().chapterIdEqualTo(chapter.id!).isEmptySync(); + bool isEmpty = isar.downloads + .filter() + .chapterIdEqualTo(chapter.id!) + .isEmptySync(); if (isEmpty) { final download = Download( succeeded: succeeded, @@ -279,7 +312,10 @@ Future> downloadChapter( isar.downloads.putSync(download..chapter.value = chapter); }); } else { - final download = isar.downloads.filter().chapterIdEqualTo(chapter.id!).findFirstSync()!; + final download = isar.downloads + .filter() + .chapterIdEqualTo(chapter.id!) + .findFirstSync()!; isar.writeTxnSync(() { isar.downloads.putSync(download ..succeeded = succeeded @@ -292,7 +328,10 @@ Future> downloadChapter( taskProgressCallback: (taskProgress) async { final progress = taskProgress.progress; if (!isManga && !hasM3U8File) { - bool isEmpty = isar.downloads.filter().chapterIdEqualTo(chapter.id!).isEmptySync(); + bool isEmpty = isar.downloads + .filter() + .chapterIdEqualTo(chapter.id!) + .isEmptySync(); if (isEmpty) { final download = Download( succeeded: (progress * 100).toInt(), @@ -307,7 +346,10 @@ Future> downloadChapter( isar.downloads.putSync(download..chapter.value = chapter); }); } else { - final download = isar.downloads.filter().chapterIdEqualTo(chapter.id!).findFirstSync()!; + final download = isar.downloads + .filter() + .chapterIdEqualTo(chapter.id!) + .findFirstSync()!; isar.writeTxnSync(() { isar.downloads.putSync(download ..succeeded = (progress * 100).toInt() @@ -317,11 +359,14 @@ Future> downloadChapter( } } if (progress == 1.0) { - final file = File(p.join(tempDir.path, taskProgress.task.directory, taskProgress.task.filename)); + final file = File(p.join(tempDir.path, taskProgress.task.directory, + taskProgress.task.filename)); if (hasM3U8File) { - final newFile = await file.copy(p.join(path!.path, chapterName, taskProgress.task.filename)); + final newFile = await file.copy( + p.join(path!.path, chapterName, taskProgress.task.filename)); await file.delete(); - await m3u8Downloader?.processBytes(newFile, tsKey, tsIv, m3u8MediaSequence); + await m3u8Downloader?.processBytes( + newFile, tsKey, tsIv, m3u8MediaSequence); } else { await file.copy(p.join(path!.path, taskProgress.task.filename)); await file.delete(); diff --git a/lib/modules/manga/home/manga_home_screen.dart b/lib/modules/manga/home/manga_home_screen.dart index 43fbcd8..49362ff 100644 --- a/lib/modules/manga/home/manga_home_screen.dart +++ b/lib/modules/manga/home/manga_home_screen.dart @@ -31,7 +31,11 @@ class MangaHomeScreen extends ConsumerStatefulWidget { final bool isLatest; final String query; const MangaHomeScreen( - {required this.source, this.query = "", this.isSearch = false, this.isLatest = false, super.key}); + {required this.source, + this.query = "", + this.isSearch = false, + this.isLatest = false, + super.key}); @override ConsumerState createState() => _MangaHomeScreenState(); @@ -86,9 +90,14 @@ class _MangaHomeScreenState extends ConsumerState { source: source, page: _page + 1, ).future); - } else if (_selectedIndex == 2 && (_isSearch && _query.isNotEmpty) || _isFiltering) { - mangaRes = await ref - .watch(searchProvider(source: source, query: _query, page: _page + 1, filterList: filters).future); + } else if (_selectedIndex == 2 && (_isSearch && _query.isNotEmpty) || + _isFiltering) { + mangaRes = await ref.watch(searchProvider( + source: source, + query: _query, + page: _page + 1, + filterList: filters) + .future); } } if (mangaRes!.list.isNotEmpty) { @@ -115,8 +124,10 @@ class _MangaHomeScreenState extends ConsumerState { Widget build(BuildContext context) { final supportsLatest = ref.watch(supportsLatestProvider(source: source)); final filterList = getFilterList(source: source); - if (_selectedIndex == 2 && (_isSearch && _query.isNotEmpty) || _isFiltering) { - _getManga = ref.watch(searchProvider(source: source, query: _query, page: 1, filterList: filters)); + if (_selectedIndex == 2 && (_isSearch && _query.isNotEmpty) || + _isFiltering) { + _getManga = ref.watch(searchProvider( + source: source, query: _query, page: 1, filterList: filters)); } else if (_selectedIndex == 1 && !_isSearch && _query.isEmpty) { _getManga = ref.watch(getLatestUpdatesProvider(source: source, page: 1)); } else if (_selectedIndex == 0 && !_isSearch && _query.isEmpty) { @@ -125,7 +136,9 @@ class _MangaHomeScreenState extends ConsumerState { final l10n = context.l10n; final displayType = ref.watch(mangaHomeDisplayTypeStateProvider); final displayTypeIcon = switch (displayType) { - DisplayType.comfortableGrid || DisplayType.compactGrid => Icons.view_module, + DisplayType.comfortableGrid || + DisplayType.compactGrid => + Icons.view_module, _ => Icons.view_list, }; return Scaffold( @@ -179,13 +192,16 @@ class _MangaHomeScreenState extends ConsumerState { _isSearch = true; }); }, - icon: Icon(Icons.search, color: Theme.of(context).hintColor)), + icon: + Icon(Icons.search, color: Theme.of(context).hintColor)), PopupMenuButton( popUpAnimationStyle: popupAnimationStyle, icon: Icon(displayTypeIcon), itemBuilder: (context) { - final displayType = ref.watch(mangaHomeDisplayTypeStateProvider); - final displayTypeNotifier = ref.read(mangaHomeDisplayTypeStateProvider.notifier); + final displayType = + ref.watch(mangaHomeDisplayTypeStateProvider); + final displayTypeNotifier = + ref.read(mangaHomeDisplayTypeStateProvider.notifier); return [ PopupMenuItem( value: 0, @@ -242,11 +258,17 @@ class _MangaHomeScreenState extends ConsumerState { }, onSelected: (value) async { if (value == 0) { - final baseUrl = ref.watch(sourceBaseUrlProvider(source: source)); - Map data = {'url': baseUrl, 'sourceId': source.id.toString(), 'title': ''}; + final baseUrl = + ref.watch(sourceBaseUrlProvider(source: source)); + Map data = { + 'url': baseUrl, + 'sourceId': source.id.toString(), + 'title': '' + }; context.push("/mangawebview", extra: data); } else { - final res = await context.push('/extension_detail', extra: source); + final res = + await context.push('/extension_detail', extra: source); if (res != null && mounted) { setState(() { source = res as Source; @@ -284,7 +306,8 @@ class _MangaHomeScreenState extends ConsumerState { if (index == 2) { final result = await showModalBottomSheet( context: context, - builder: (context) => StatefulBuilder(builder: (context, setState) { + builder: (context) => + StatefulBuilder(builder: (context, setState) { return Column( children: [ Padding( @@ -294,20 +317,25 @@ class _MangaHomeScreenState extends ConsumerState { TextButton( onPressed: () { setState(() { - filters = getFilterList(source: source); + filters = getFilterList( + source: source); }); }, child: Text(l10n.reset), ), const Spacer(), ElevatedButton( - style: ElevatedButton.styleFrom(backgroundColor: context.primaryColor), + style: ElevatedButton.styleFrom( + backgroundColor: + context.primaryColor), onPressed: () { Navigator.pop(context, 'filter'); }, child: Text( l10n.filter, - style: TextStyle(color: Theme.of(context).scaffoldBackgroundColor), + style: TextStyle( + color: Theme.of(context) + .scaffoldBackgroundColor), ), ), ], @@ -339,8 +367,11 @@ class _MangaHomeScreenState extends ConsumerState { }); } - _getManga = ref - .refresh(searchProvider(source: source, query: _query, page: 1, filterList: filters)); + _getManga = ref.refresh(searchProvider( + source: source, + query: _query, + page: 1, + filterList: filters)); } } else { _mangaList.clear(); @@ -385,7 +416,8 @@ class _MangaHomeScreenState extends ConsumerState { _mangaList.addAll(data.list); } Widget buildProgressIndicator() { - return !(data!.list.isNotEmpty && (data.hasNextPage || _hasNextPage)) + return !(data!.list.isNotEmpty && + (data.hasNextPage || _hasNextPage)) ? Container() : _isLoading ? const Center( @@ -401,7 +433,9 @@ class _MangaHomeScreenState extends ConsumerState { padding: const EdgeInsets.all(4), child: ElevatedButton( style: ElevatedButton.styleFrom( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(5))), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(5))), onPressed: () { if (!_getManga!.isLoading) { if (mounted) { @@ -420,15 +454,19 @@ class _MangaHomeScreenState extends ConsumerState { } }, child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: + CrossAxisAlignment.center, + mainAxisAlignment: + MainAxisAlignment.center, children: [ Text( l10n.load_more, - style: const TextStyle(overflow: TextOverflow.ellipsis), + style: const TextStyle( + overflow: TextOverflow.ellipsis), maxLines: 2, ), - const Icon(Icons.arrow_forward_outlined), + const Icon( + Icons.arrow_forward_outlined), ], )), ); @@ -438,8 +476,12 @@ class _MangaHomeScreenState extends ConsumerState { return Center(child: Text(l10n.no_result)); } _scrollController.addListener(() { - if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) { - if (_mangaList.isNotEmpty && (_hasNextPage) && !_isLoading && !_getManga!.isLoading) { + if (_scrollController.position.pixels == + _scrollController.position.maxScrollExtent) { + if (_mangaList.isNotEmpty && + (_hasNextPage) && + !_isLoading && + !_getManga!.isLoading) { if (mounted) { setState(() { _isLoading = true; @@ -457,9 +499,13 @@ class _MangaHomeScreenState extends ConsumerState { } }); - _length = source.isFullData! ? _fullDataLength : _mangaList.length; - _length = (_mangaList.length < _length ? _mangaList.length : _length); - final isComfortableGrid = displayType == DisplayType.comfortableGrid; + _length = + source.isFullData! ? _fullDataLength : _mangaList.length; + _length = (_mangaList.length < _length + ? _mangaList.length + : _length); + final isComfortableGrid = + displayType == DisplayType.comfortableGrid; return Padding( padding: const EdgeInsets.only(top: 10), child: Column( @@ -474,16 +520,21 @@ class _MangaHomeScreenState extends ConsumerState { return buildProgressIndicator(); } return MangaHomeImageCardListTile( - isManga: source.isManga ?? true, manga: _mangaList[index], source: source); + isManga: source.isManga ?? true, + manga: _mangaList[index], + source: source); }) : Consumer(builder: (context, ref, child) { - final gridSize = ref.watch(libraryGridSizeStateProvider(isManga: source.isManga!)); + final gridSize = ref.watch( + libraryGridSizeStateProvider( + isManga: source.isManga!)); return GridViewWidget( gridSize: gridSize, controller: _scrollController, itemCount: _length + 1, - childAspectRatio: isComfortableGrid ? 0.642 : 0.69, + childAspectRatio: + isComfortableGrid ? 0.642 : 0.69, itemBuilder: (context, index) { if (index == _length) { return buildProgressIndicator(); @@ -514,12 +565,22 @@ class _MangaHomeScreenState extends ConsumerState { children: [ IconButton( onPressed: () { - if (_selectedIndex == 2 && (_isSearch && _query.isNotEmpty) || _isFiltering) { - ref.invalidate( - searchProvider(source: source, query: _query, page: 1, filterList: filters)); - } else if (_selectedIndex == 1 && !_isSearch && _query.isEmpty) { - ref.invalidate(getLatestUpdatesProvider(source: source, page: 1)); - } else if (_selectedIndex == 0 && !_isSearch && _query.isEmpty) { + if (_selectedIndex == 2 && + (_isSearch && _query.isNotEmpty) || + _isFiltering) { + ref.invalidate(searchProvider( + source: source, + query: _query, + page: 1, + filterList: filters)); + } else if (_selectedIndex == 1 && + !_isSearch && + _query.isEmpty) { + ref.invalidate(getLatestUpdatesProvider( + source: source, page: 1)); + } else if (_selectedIndex == 0 && + !_isSearch && + _query.isEmpty) { ref.invalidate(getPopularProvider( source: source, page: 1, @@ -537,12 +598,14 @@ class _MangaHomeScreenState extends ConsumerState { children: [ IconButton( onPressed: () async { - final baseUrl = ref.watch(sourceBaseUrlProvider(source: source)); + final baseUrl = ref.watch( + sourceBaseUrlProvider(source: source)); Map data = { 'url': baseUrl, 'sourceId': source.id.toString(), 'title': '', - "hasCloudFlare": source.hasCloudflare ?? false + "hasCloudFlare": + source.hasCloudflare ?? false }; context.push("/mangawebview", extra: data); }, @@ -580,7 +643,11 @@ class MangaHomeImageCard extends ConsumerStatefulWidget { final Source source; final bool isComfortableGrid; const MangaHomeImageCard( - {super.key, required this.manga, required this.source, required this.isManga, required this.isComfortableGrid}); + {super.key, + required this.manga, + required this.source, + required this.isManga, + required this.isComfortableGrid}); @override ConsumerState createState() => _MangaHomeImageCardState(); @@ -607,19 +674,28 @@ class MangaHomeImageCardListTile extends ConsumerStatefulWidget { final MManga manga; final bool isManga; final Source source; - const MangaHomeImageCardListTile({super.key, required this.manga, required this.source, required this.isManga}); + const MangaHomeImageCardListTile( + {super.key, + required this.manga, + required this.source, + required this.isManga}); @override - ConsumerState createState() => _MangaHomeImageCardListTileState(); + ConsumerState createState() => + _MangaHomeImageCardListTileState(); } -class _MangaHomeImageCardListTileState extends ConsumerState +class _MangaHomeImageCardListTileState + extends ConsumerState with AutomaticKeepAliveClientMixin { @override Widget build(BuildContext context) { super.build(context); - return MangaImageCardListTileWidget(getMangaDetail: widget.manga, source: widget.source, isManga: widget.isManga); + return MangaImageCardListTileWidget( + getMangaDetail: widget.manga, + source: widget.source, + isManga: widget.isManga); } @override diff --git a/lib/modules/manga/home/widget/filter_widget.dart b/lib/modules/manga/home/widget/filter_widget.dart index 3575df2..6af9e6d 100644 --- a/lib/modules/manga/home/widget/filter_widget.dart +++ b/lib/modules/manga/home/widget/filter_widget.dart @@ -5,7 +5,8 @@ import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; class FilterWidget extends StatelessWidget { final List filterList; final Function(List) onChanged; - const FilterWidget({super.key, required this.onChanged, required this.filterList}); + const FilterWidget( + {super.key, required this.onChanged, required this.filterList}); @override Widget build(BuildContext context) { @@ -83,14 +84,18 @@ class FilterWidget extends StatelessWidget { final selected = filterState.values[filterState.state.index] == e; return ListTile( dense: true, - leading: Icon(ascending ? Icons.arrow_upward_rounded : Icons.arrow_downward_rounded, + leading: Icon( + ascending + ? Icons.arrow_upward_rounded + : Icons.arrow_downward_rounded, color: selected ? null : Colors.transparent), title: Text(e.name), onTap: () { if (selected) { filterState.state.ascending = !ascending; } else { - filterState.state.index = filterState.values.indexWhere((element) => element == e); + filterState.state.index = filterState.values + .indexWhere((element) => element == e); } filterList[idx] = filterState; onChanged(filterList); @@ -113,20 +118,24 @@ class FilterWidget extends StatelessWidget { Expanded( child: DropdownButtonHideUnderline( child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 25), + padding: const EdgeInsets.symmetric( + vertical: 8, horizontal: 25), child: DropdownButton( icon: const Icon(Icons.keyboard_arrow_down), isExpanded: true, value: filterState.values[filterState.state], - hint: Text(filterState.name, style: const TextStyle(fontSize: 13)), + hint: Text(filterState.name, + style: const TextStyle(fontSize: 13)), items: filterState.values .map((e) => DropdownMenuItem( value: e, - child: Text(e.name, style: const TextStyle(fontSize: 13)), + child: Text(e.name, + style: const TextStyle(fontSize: 13)), )) .toList(), onChanged: (value) { - filterState.state = filterState.values.indexWhere((element) => element == value); + filterState.state = filterState.values + .indexWhere((element) => element == value); onChanged(filterList); }, ), @@ -147,10 +156,15 @@ class SeachFormTextFieldWidget extends StatefulWidget { final String labelText; final String text; final Function(String) onChanged; - const SeachFormTextFieldWidget({super.key, required this.text, required this.onChanged, required this.labelText}); + const SeachFormTextFieldWidget( + {super.key, + required this.text, + required this.onChanged, + required this.labelText}); @override - State createState() => _SeachFormTextFieldWidgetState(); + State createState() => + _SeachFormTextFieldWidgetState(); } class _SeachFormTextFieldWidgetState extends State { diff --git a/lib/modules/manga/home/widget/mangas_card_selector.dart b/lib/modules/manga/home/widget/mangas_card_selector.dart index 5184128..eb09206 100644 --- a/lib/modules/manga/home/widget/mangas_card_selector.dart +++ b/lib/modules/manga/home/widget/mangas_card_selector.dart @@ -7,7 +7,11 @@ class MangasCardSelector extends StatelessWidget { final bool selected; final VoidCallback onPressed; const MangasCardSelector( - {super.key, required this.text, required this.icon, required this.selected, required this.onPressed}); + {super.key, + required this.text, + required this.icon, + required this.selected, + required this.onPressed}); @override Widget build(BuildContext context) { @@ -18,7 +22,8 @@ class MangasCardSelector extends StatelessWidget { padding: const EdgeInsets.all(0), side: BorderSide(width: 0.6, color: context.primaryColor), backgroundColor: selected ? context.primaryColor : null, - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)), + shape: + RoundedRectangleBorder(borderRadius: BorderRadius.circular(7)), ), onPressed: onPressed, child: Padding( diff --git a/lib/modules/manga/reader/double_columm_view_center.dart b/lib/modules/manga/reader/double_columm_view_center.dart index dc9cde0..9bbb1e4 100644 --- a/lib/modules/manga/reader/double_columm_view_center.dart +++ b/lib/modules/manga/reader/double_columm_view_center.dart @@ -27,14 +27,17 @@ class DoubleColummView extends StatefulWidget { State createState() => _DoubleColummViewState(); } -class _DoubleColummViewState extends State with TickerProviderStateMixin { +class _DoubleColummViewState extends State + with TickerProviderStateMixin { late AnimationController _scaleAnimationController; late Animation _animation; Alignment _scalePosition = Alignment.center; final PhotoViewController _photoViewController = PhotoViewController(); - final PhotoViewScaleStateController _photoViewScaleStateController = PhotoViewScaleStateController(); + final PhotoViewScaleStateController _photoViewScaleStateController = + PhotoViewScaleStateController(); Duration? _doubleTapAnimationDuration() { - int doubleTapAnimationValue = isar.settings.getSync(227)!.doubleTapAnimationSpeed!; + int doubleTapAnimationValue = + isar.settings.getSync(227)!.doubleTapAnimationSpeed!; if (doubleTapAnimationValue == 0) { return const Duration(milliseconds: 10); } else if (doubleTapAnimationValue == 1) { @@ -43,7 +46,8 @@ class _DoubleColummViewState extends State with TickerProvider return const Duration(milliseconds: 200); } - void _onScaleEnd(BuildContext context, ScaleEndDetails details, PhotoViewControllerValue controllerValue) { + void _onScaleEnd(BuildContext context, ScaleEndDetails details, + PhotoViewControllerValue controllerValue) { if (controllerValue.scale! < 1) { _photoViewScaleStateController.reset(); } @@ -52,15 +56,16 @@ class _DoubleColummViewState extends State with TickerProvider double get pixelRatio => View.of(context).devicePixelRatio; Size get size => View.of(context).physicalSize / pixelRatio; Alignment _computeAlignmentByTapOffset(Offset offset) { - return Alignment( - (offset.dx - size.width / 2) / (size.width / 2), (offset.dy - size.height / 2) / (size.height / 2)); + return Alignment((offset.dx - size.width / 2) / (size.width / 2), + (offset.dy - size.height / 2) / (size.height / 2)); } @override void initState() { - _scaleAnimationController = AnimationController(duration: _doubleTapAnimationDuration(), vsync: this); - _animation = - Tween(begin: 1.0, end: 2.0).animate(CurvedAnimation(curve: Curves.ease, parent: _scaleAnimationController)); + _scaleAnimationController = AnimationController( + duration: _doubleTapAnimationDuration(), vsync: this); + _animation = Tween(begin: 1.0, end: 2.0).animate( + CurvedAnimation(curve: Curves.ease, parent: _scaleAnimationController)); _animation.addListener(() { _photoViewController.scale = _animation.value; }); @@ -122,32 +127,42 @@ class _DoubleColummViewState extends State with TickerProvider child: ImageViewPaged( data: widget.datas[0]!, loadStateChanged: (state) { - if (state.extendedImageLoadState == LoadState.loading) { - final ImageChunkEvent? loadingProgress = state.loadingProgress; - final double progress = loadingProgress?.expectedTotalBytes != null - ? loadingProgress!.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! - : 0; + if (state.extendedImageLoadState == + LoadState.loading) { + final ImageChunkEvent? loadingProgress = + state.loadingProgress; + final double progress = + loadingProgress?.expectedTotalBytes != null + ? loadingProgress!.cumulativeBytesLoaded / + loadingProgress.expectedTotalBytes! + : 0; return Container( color: getBackgroundColor(widget.backgroundColor), height: context.height(0.8), - child: CircularProgressIndicatorAnimateRotate(progress: progress), + child: CircularProgressIndicatorAnimateRotate( + progress: progress), ); } - if (state.extendedImageLoadState == LoadState.completed) { + if (state.extendedImageLoadState == + LoadState.completed) { widget.isFailedToLoadImage(false); return Image(image: state.imageProvider); } - if (state.extendedImageLoadState == LoadState.failed) { + if (state.extendedImageLoadState == + LoadState.failed) { widget.isFailedToLoadImage(true); return Container( - color: getBackgroundColor(widget.backgroundColor), + color: + getBackgroundColor(widget.backgroundColor), height: context.height(0.8), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( l10n.image_loading_error, - style: TextStyle(color: Colors.white.withValues(alpha: 0.7)), + style: TextStyle( + color: Colors.white + .withValues(alpha: 0.7)), ), Padding( padding: const EdgeInsets.all(8.0), @@ -162,9 +177,14 @@ class _DoubleColummViewState extends State with TickerProvider }, child: Container( decoration: BoxDecoration( - color: context.primaryColor, borderRadius: BorderRadius.circular(30)), + color: context.primaryColor, + borderRadius: + BorderRadius.circular(30)), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), + padding: + const EdgeInsets.symmetric( + vertical: 8, + horizontal: 16), child: Text( l10n.retry, ), @@ -176,7 +196,8 @@ class _DoubleColummViewState extends State with TickerProvider } return null; }, - onLongPressData: (datas) => widget.onLongPressData.call(datas), + onLongPressData: (datas) => + widget.onLongPressData.call(datas), ), ), // if (widget.datas[1] != null) const SizedBox(width: 10), @@ -185,32 +206,42 @@ class _DoubleColummViewState extends State with TickerProvider child: ImageViewPaged( data: widget.datas[1]!, loadStateChanged: (state) { - if (state.extendedImageLoadState == LoadState.loading) { - final ImageChunkEvent? loadingProgress = state.loadingProgress; - final double progress = loadingProgress?.expectedTotalBytes != null - ? loadingProgress!.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! - : 0; + if (state.extendedImageLoadState == + LoadState.loading) { + final ImageChunkEvent? loadingProgress = + state.loadingProgress; + final double progress = + loadingProgress?.expectedTotalBytes != null + ? loadingProgress!.cumulativeBytesLoaded / + loadingProgress.expectedTotalBytes! + : 0; return Container( color: getBackgroundColor(widget.backgroundColor), height: context.height(0.8), - child: CircularProgressIndicatorAnimateRotate(progress: progress), + child: CircularProgressIndicatorAnimateRotate( + progress: progress), ); } - if (state.extendedImageLoadState == LoadState.completed) { + if (state.extendedImageLoadState == + LoadState.completed) { widget.isFailedToLoadImage(false); return Image(image: state.imageProvider); } - if (state.extendedImageLoadState == LoadState.failed) { + if (state.extendedImageLoadState == + LoadState.failed) { widget.isFailedToLoadImage(true); return Container( - color: getBackgroundColor(widget.backgroundColor), + color: + getBackgroundColor(widget.backgroundColor), height: context.height(0.8), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( l10n.image_loading_error, - style: TextStyle(color: Colors.white.withValues(alpha: 0.7)), + style: TextStyle( + color: Colors.white + .withValues(alpha: 0.7)), ), Padding( padding: const EdgeInsets.all(8.0), @@ -225,9 +256,14 @@ class _DoubleColummViewState extends State with TickerProvider }, child: Container( decoration: BoxDecoration( - color: context.primaryColor, borderRadius: BorderRadius.circular(30)), + color: context.primaryColor, + borderRadius: + BorderRadius.circular(30)), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), + padding: + const EdgeInsets.symmetric( + vertical: 8, + horizontal: 16), child: Text( l10n.retry, ), @@ -239,7 +275,8 @@ class _DoubleColummViewState extends State with TickerProvider } return null; }, - onLongPressData: (datas) => widget.onLongPressData.call(datas), + onLongPressData: (datas) => + widget.onLongPressData.call(datas), ), ), ], diff --git a/lib/modules/manga/reader/double_columm_view_vertical.dart b/lib/modules/manga/reader/double_columm_view_vertical.dart index 8356e22..9a3e118 100644 --- a/lib/modules/manga/reader/double_columm_view_vertical.dart +++ b/lib/modules/manga/reader/double_columm_view_vertical.dart @@ -39,14 +39,18 @@ class DoubleColummVerticalView extends StatelessWidget { data: datas[0]!, loadStateChanged: (state) { if (state.extendedImageLoadState == LoadState.loading) { - final ImageChunkEvent? loadingProgress = state.loadingProgress; - final double progress = loadingProgress?.expectedTotalBytes != null - ? loadingProgress!.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! - : 0; + final ImageChunkEvent? loadingProgress = + state.loadingProgress; + final double progress = + loadingProgress?.expectedTotalBytes != null + ? loadingProgress!.cumulativeBytesLoaded / + loadingProgress.expectedTotalBytes! + : 0; return Container( color: getBackgroundColor(backgroundColor), height: context.height(0.8), - child: CircularProgressIndicatorAnimateRotate(progress: progress), + child: CircularProgressIndicatorAnimateRotate( + progress: progress), ); } if (state.extendedImageLoadState == LoadState.completed) { @@ -63,7 +67,8 @@ class DoubleColummVerticalView extends StatelessWidget { children: [ Text( l10n.image_loading_error, - style: TextStyle(color: Colors.white.withValues(alpha: 0.7)), + style: TextStyle( + color: Colors.white.withValues(alpha: 0.7)), ), Padding( padding: const EdgeInsets.all(8.0), @@ -78,9 +83,12 @@ class DoubleColummVerticalView extends StatelessWidget { }, child: Container( decoration: BoxDecoration( - color: context.primaryColor, borderRadius: BorderRadius.circular(30)), + color: context.primaryColor, + borderRadius: + BorderRadius.circular(30)), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), + padding: const EdgeInsets.symmetric( + vertical: 8, horizontal: 16), child: Text( l10n.retry, ), @@ -102,14 +110,18 @@ class DoubleColummVerticalView extends StatelessWidget { data: datas[1]!, loadStateChanged: (state) { if (state.extendedImageLoadState == LoadState.loading) { - final ImageChunkEvent? loadingProgress = state.loadingProgress; - final double progress = loadingProgress?.expectedTotalBytes != null - ? loadingProgress!.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! - : 0; + final ImageChunkEvent? loadingProgress = + state.loadingProgress; + final double progress = + loadingProgress?.expectedTotalBytes != null + ? loadingProgress!.cumulativeBytesLoaded / + loadingProgress.expectedTotalBytes! + : 0; return Container( color: getBackgroundColor(backgroundColor), height: context.height(0.8), - child: CircularProgressIndicatorAnimateRotate(progress: progress), + child: CircularProgressIndicatorAnimateRotate( + progress: progress), ); } if (state.extendedImageLoadState == LoadState.completed) { @@ -126,7 +138,8 @@ class DoubleColummVerticalView extends StatelessWidget { children: [ Text( l10n.image_loading_error, - style: TextStyle(color: Colors.white.withValues(alpha: 0.7)), + style: TextStyle( + color: Colors.white.withValues(alpha: 0.7)), ), Padding( padding: const EdgeInsets.all(8.0), @@ -141,9 +154,12 @@ class DoubleColummVerticalView extends StatelessWidget { }, child: Container( decoration: BoxDecoration( - color: context.primaryColor, borderRadius: BorderRadius.circular(30)), + color: context.primaryColor, + borderRadius: + BorderRadius.circular(30)), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), + padding: const EdgeInsets.symmetric( + vertical: 8, horizontal: 16), child: Text( l10n.retry, ), diff --git a/lib/modules/manga/reader/image_view_paged.dart b/lib/modules/manga/reader/image_view_paged.dart index 49deb17..788a558 100644 --- a/lib/modules/manga/reader/image_view_paged.dart +++ b/lib/modules/manga/reader/image_view_paged.dart @@ -12,7 +12,8 @@ class ImageViewPaged extends ConsumerWidget { final Function(UChapDataPreload data) onLongPressData; final Widget? Function(ExtendedImageState state) loadStateChanged; final Function(ExtendedImageGestureState state)? onDoubleTap; - final GestureConfig Function(ExtendedImageState state)? initGestureConfigHandler; + final GestureConfig Function(ExtendedImageState state)? + initGestureConfigHandler; const ImageViewPaged({ super.key, required this.data, diff --git a/lib/modules/manga/reader/image_view_vertical.dart b/lib/modules/manga/reader/image_view_vertical.dart index 4949abd..e7eb1e3 100644 --- a/lib/modules/manga/reader/image_view_vertical.dart +++ b/lib/modules/manga/reader/image_view_vertical.dart @@ -40,7 +40,8 @@ class ImageViewVertical extends ConsumerWidget { if (state.extendedImageLoadState == LoadState.loading) { final ImageChunkEvent? loadingProgress = state.loadingProgress; final double progress = loadingProgress?.expectedTotalBytes != null - ? loadingProgress!.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! + ? loadingProgress!.cumulativeBytesLoaded / + loadingProgress.expectedTotalBytes! : 0; return Container( color: Colors.black, @@ -59,7 +60,8 @@ class ImageViewVertical extends ConsumerWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Text(context.l10n.image_loading_error, - style: TextStyle(color: Colors.white.withValues(alpha: 0.7))), + style: TextStyle( + color: Colors.white.withValues(alpha: 0.7))), Padding( padding: const EdgeInsets.all(8.0), child: GestureDetector( @@ -72,10 +74,12 @@ class ImageViewVertical extends ConsumerWidget { failedToLoadImage(false); }, child: Container( - decoration: - BoxDecoration(color: context.primaryColor, borderRadius: BorderRadius.circular(30)), + decoration: BoxDecoration( + color: context.primaryColor, + borderRadius: BorderRadius.circular(30)), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 16), + padding: const EdgeInsets.symmetric( + vertical: 8, horizontal: 16), child: Text( context.l10n.retry, ), diff --git a/lib/modules/manga/reader/providers/color_filter_provider.dart b/lib/modules/manga/reader/providers/color_filter_provider.dart index 5cf14ed..980661b 100644 --- a/lib/modules/manga/reader/providers/color_filter_provider.dart +++ b/lib/modules/manga/reader/providers/color_filter_provider.dart @@ -19,7 +19,8 @@ class CustomColorFilterState extends _$CustomColorFilterState { ..g = g ..b = b; if (end) { - isar.writeTxnSync(() => isar.settings.putSync(settings!..customColorFilter = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..customColorFilter = value)); } state = value; } @@ -35,7 +36,8 @@ class EnableCustomColorFilterState extends _$EnableCustomColorFilterState { void set(bool value) { final settings = isar.settings.getSync(227); - isar.writeTxnSync(() => isar.settings.putSync(settings!..enableCustomColorFilter = value)); + isar.writeTxnSync(() => + isar.settings.putSync(settings!..enableCustomColorFilter = value)); state = value; } } @@ -50,7 +52,8 @@ class ColorFilterBlendModeState extends _$ColorFilterBlendModeState { void set(ColorFilterBlendMode value) { final settings = isar.settings.getSync(227); - isar.writeTxnSync(() => isar.settings.putSync(settings!..colorFilterBlendMode = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..colorFilterBlendMode = value)); state = value; } } diff --git a/lib/modules/manga/reader/providers/crop_borders_provider.dart b/lib/modules/manga/reader/providers/crop_borders_provider.dart index 317f12b..7a312d7 100644 --- a/lib/modules/manga/reader/providers/crop_borders_provider.dart +++ b/lib/modules/manga/reader/providers/crop_borders_provider.dart @@ -10,7 +10,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; part 'crop_borders_provider.g.dart'; @Riverpod(keepAlive: true) -Future cropBorders(Ref ref, {required UChapDataPreload data, required bool cropBorder}) async { +Future cropBorders(Ref ref, + {required UChapDataPreload data, required bool cropBorder}) async { Uint8List? imageBytes; if (cropBorder) { diff --git a/lib/modules/manga/reader/providers/push_router.dart b/lib/modules/manga/reader/providers/push_router.dart index 53a3a66..abde10c 100644 --- a/lib/modules/manga/reader/providers/push_router.dart +++ b/lib/modules/manga/reader/providers/push_router.dart @@ -31,7 +31,8 @@ Future pushMangaReaderView({ } } -void pushReplacementMangaReaderView({required BuildContext context, required Chapter chapter}) { +void pushReplacementMangaReaderView( + {required BuildContext context, required Chapter chapter}) { if (chapter.manga.value!.isManga!) { context.pushReplacement('/mangareaderview', extra: chapter); } else { diff --git a/lib/modules/manga/reader/providers/reader_controller_provider.dart b/lib/modules/manga/reader/providers/reader_controller_provider.dart index 5942a5e..db7fd59 100644 --- a/lib/modules/manga/reader/providers/reader_controller_provider.dart +++ b/lib/modules/manga/reader/providers/reader_controller_provider.dart @@ -24,7 +24,9 @@ class CurrentIndex extends _$CurrentIndex { int build(Chapter chapter) { final incognitoMode = ref.watch(incognitoModeStateProvider); if (incognitoMode) return 0; - return ref.read(readerControllerProvider(chapter: chapter).notifier).getPageIndex(); + return ref + .read(readerControllerProvider(chapter: chapter).notifier) + .getPageIndex(); } setCurrentIndex(int currentIndex) { @@ -58,8 +60,10 @@ class ReaderController extends _$ReaderController { final incognitoMode = isar.settings.getSync(227)!.incognitoMode!; ReaderMode getReaderMode() { - final personalReaderModeList = getIsarSetting().personalReaderModeList ?? []; - final personalReaderMode = personalReaderModeList.where((element) => element.mangaId == getManga().id); + final personalReaderModeList = + getIsarSetting().personalReaderModeList ?? []; + final personalReaderMode = personalReaderModeList + .where((element) => element.mangaId == getManga().id); if (personalReaderMode.isNotEmpty) { return personalReaderMode.first.readerMode; } @@ -68,9 +72,13 @@ class ReaderController extends _$ReaderController { (bool, double) autoScrollValues() { final autoScrollPagesList = getIsarSetting().autoScrollPages ?? []; - final autoScrollPages = autoScrollPagesList.where((element) => element.mangaId == getManga().id); + final autoScrollPages = autoScrollPagesList + .where((element) => element.mangaId == getManga().id); if (autoScrollPages.isNotEmpty) { - return (autoScrollPages.first.autoScroll ?? false, autoScrollPages.first.pageOffset ?? 10); + return ( + autoScrollPages.first.autoScroll ?? false, + autoScrollPages.first.pageOffset ?? 10 + ); } return (false, 10); } @@ -86,12 +94,14 @@ class ReaderController extends _$ReaderController { ..mangaId = getManga().id ..pageOffset = offset ..autoScroll = value); - isar.writeTxnSync(() => isar.settings.putSync(getIsarSetting()..autoScrollPages = autoScrollPagesList)); + isar.writeTxnSync(() => isar.settings + .putSync(getIsarSetting()..autoScrollPages = autoScrollPagesList)); } PageMode getPageMode() { final personalPageModeList = getIsarSetting().personalPageModeList ?? []; - final personalPageMode = personalPageModeList.where((element) => element.mangaId == getManga().id); + final personalPageMode = personalPageModeList + .where((element) => element.mangaId == getManga().id); if (personalPageMode.isNotEmpty) { return personalPageMode.first.pageMode; } @@ -100,7 +110,8 @@ class ReaderController extends _$ReaderController { void setReaderMode(ReaderMode newReaderMode) { List? personalReaderModeLists = []; - for (var personalReaderMode in getIsarSetting().personalReaderModeList ?? []) { + for (var personalReaderMode + in getIsarSetting().personalReaderModeList ?? []) { if (personalReaderMode.mangaId != getManga().id) { personalReaderModeLists.add(personalReaderMode); } @@ -108,7 +119,8 @@ class ReaderController extends _$ReaderController { personalReaderModeLists.add(PersonalReaderMode() ..mangaId = getManga().id ..readerMode = newReaderMode); - isar.writeTxnSync(() => isar.settings.putSync(getIsarSetting()..personalReaderModeList = personalReaderModeLists)); + isar.writeTxnSync(() => isar.settings.putSync( + getIsarSetting()..personalReaderModeList = personalReaderModeLists)); } void setPageMode(PageMode newPageMode) { @@ -121,12 +133,14 @@ class ReaderController extends _$ReaderController { personalPageModeLists.add(PersonalPageMode() ..mangaId = getManga().id ..pageMode = newPageMode); - isar.writeTxnSync(() => isar.settings.putSync(getIsarSetting()..personalPageModeList = personalPageModeLists)); + isar.writeTxnSync(() => isar.settings.putSync( + getIsarSetting()..personalPageModeList = personalPageModeLists)); } void setShowPageNumber(bool value) { if (!incognitoMode) { - isar.writeTxnSync(() => isar.settings.putSync(getIsarSetting()..showPagesNumber = value)); + isar.writeTxnSync(() => + isar.settings.putSync(getIsarSetting()..showPagesNumber = value)); } } @@ -150,7 +164,8 @@ class ReaderController extends _$ReaderController { }); History? history; - final empty = isar.historys.filter().mangaIdEqualTo(getManga().id).isEmptySync(); + final empty = + isar.historys.filter().mangaIdEqualTo(getManga().id).isEmptySync(); if (empty) { history = History( @@ -160,7 +175,10 @@ class ReaderController extends _$ReaderController { chapterId: chapter.id) ..chapter.value = chapter; } else { - history = (isar.historys.filter().mangaIdEqualTo(getManga().id).findFirstSync())! + history = (isar.historys + .filter() + .mangaIdEqualTo(getManga().id) + .findFirstSync())! ..chapterId = chapter.id ..chapter.value = chapter ..date = DateTime.now().millisecondsSinceEpoch.toString(); @@ -184,7 +202,9 @@ class ReaderController extends _$ReaderController { final chap = chapter; isar.writeTxnSync(() { chap.isBookmarked = !isBookmarked; - ref.read(changedItemsManagerProvider(managerId: 1).notifier).addUpdatedChapter(chap, false, false); + ref + .read(changedItemsManagerProvider(managerId: 1).notifier) + .addUpdatedChapter(chap, false, false); isar.chapters.putSync(chap); }); } @@ -268,13 +288,16 @@ class ReaderController extends _$ReaderController { } int getChaptersLength(bool isInFilterList) { - return isInFilterList ? getManga().getFilteredChapterList().length : getManga().chapters.length; + return isInFilterList + ? getManga().getFilteredChapterList().length + : getManga().chapters.length; } int getPageIndex() { if (incognitoMode) return 0; final chapterPageIndexList = getIsarSetting().chapterPageIndexList ?? []; - final index = chapterPageIndexList.where((element) => element.chapterId == chapter.id); + final index = chapterPageIndexList + .where((element) => element.chapterId == chapter.id); return chapter.isRead! ? 0 : index.isNotEmpty @@ -284,13 +307,19 @@ class ReaderController extends _$ReaderController { int getPageLength(List incognitoPageLength) { if (incognitoMode) return incognitoPageLength.length; - return getIsarSetting().chapterPageUrlsList!.where((element) => element.chapterId == chapter.id).first.urls!.length; + return getIsarSetting() + .chapterPageUrlsList! + .where((element) => element.chapterId == chapter.id) + .first + .urls! + .length; } void setPageIndex(int newIndex, bool save) { if (chapter.isRead!) return; if (incognitoMode) return; - final isRead = (getReaderMode() == ReaderMode.verticalContinuous || getReaderMode() == ReaderMode.webtoon) + final isRead = (getReaderMode() == ReaderMode.verticalContinuous || + getReaderMode() == ReaderMode.webtoon) ? ((newIndex + 1) == getPageLength([]) - 1) ? ((newIndex + 1) == getPageLength([]) - 1) : (newIndex + 1) == getPageLength([]) @@ -298,7 +327,8 @@ class ReaderController extends _$ReaderController { if (isRead || save) { List? chapterPageIndexs = []; - for (var chapterPageIndex in getIsarSetting().chapterPageIndexList ?? []) { + for (var chapterPageIndex + in getIsarSetting().chapterPageIndexList ?? []) { if (chapterPageIndex.chapterId != chapter.id) { chapterPageIndexs.add(chapterPageIndex); } @@ -308,10 +338,13 @@ class ReaderController extends _$ReaderController { ..index = isRead ? 0 : newIndex); final chap = chapter; isar.writeTxnSync(() { - isar.settings.putSync(getIsarSetting()..chapterPageIndexList = chapterPageIndexs); + isar.settings.putSync( + getIsarSetting()..chapterPageIndexList = chapterPageIndexs); chap.isRead = isRead; chap.lastPageRead = isRead ? '1' : (newIndex + 1).toString(); - ref.read(changedItemsManagerProvider(managerId: 1).notifier).addUpdatedChapter(chap, false, false); + ref + .read(changedItemsManagerProvider(managerId: 1).notifier) + .addUpdatedChapter(chap, false, false); isar.chapters.putSync(chap); }); if (isRead) { @@ -336,31 +369,46 @@ class ReaderController extends _$ReaderController { extension ChapterExtensions on Chapter { void updateTrackChapterRead(dynamic ref) { if (!(ref is WidgetRef || ref is Ref)) return; - final updateProgressAfterReading = ref.watch(updateProgressAfterReadingStateProvider); + final updateProgressAfterReading = + ref.watch(updateProgressAfterReadingStateProvider); if (!updateProgressAfterReading) return; final manga = this.manga.value!; - final chapterNumber = ChapterRecognition().parseChapterNumber(manga.name!, name!); + final chapterNumber = + ChapterRecognition().parseChapterNumber(manga.name!, name!); - final tracks = - isar.tracks.filter().idIsNotNull().isMangaEqualTo(manga.isManga).mangaIdEqualTo(manga.id!).findAllSync(); + final tracks = isar.tracks + .filter() + .idIsNotNull() + .isMangaEqualTo(manga.isManga) + .mangaIdEqualTo(manga.id!) + .findAllSync(); if (tracks.isEmpty) return; for (var track in tracks) { - final service = isar.trackPreferences.filter().syncIdIsNotNull().syncIdEqualTo(track.syncId).findFirstSync(); + final service = isar.trackPreferences + .filter() + .syncIdIsNotNull() + .syncIdEqualTo(track.syncId) + .findFirstSync(); if (!(service == null || chapterNumber <= (track.lastChapterRead ?? 0))) { if (track.status != TrackStatus.completed) { track.lastChapterRead = chapterNumber; - if (track.lastChapterRead == track.totalChapter && (track.totalChapter ?? 0) > 0) { + if (track.lastChapterRead == track.totalChapter && + (track.totalChapter ?? 0) > 0) { track.status = TrackStatus.completed; track.finishedReadingDate = DateTime.now().millisecondsSinceEpoch; } else { - track.status = manga.isManga! ? TrackStatus.reading : TrackStatus.watching; + track.status = + manga.isManga! ? TrackStatus.reading : TrackStatus.watching; if (track.lastChapterRead == 1) { track.startedReadingDate = DateTime.now().millisecondsSinceEpoch; } } } - ref.read(trackStateProvider(track: track, isManga: manga.isManga).notifier).updateManga(); + ref + .read(trackStateProvider(track: track, isManga: manga.isManga) + .notifier) + .updateManga(); } } } @@ -404,14 +452,18 @@ extension MangaExtensions on Manga { )) .type!; - final sortChapter = - (isar.settings.getSync(227)!.sortChapterList!.where((element) => element.mangaId == id).toList().firstOrNull ?? - SortChapter( - mangaId: id, - index: 1, - reverse: false, - )) - .index; + final sortChapter = (isar.settings + .getSync(227)! + .sortChapterList! + .where((element) => element.mangaId == id) + .toList() + .firstOrNull ?? + SortChapter( + mangaId: id, + index: 1, + reverse: false, + )) + .index; final filterScanlator = _getFilterScanlator(this) ?? []; List? chapterList; chapterList = data @@ -426,22 +478,33 @@ extension MangaExtensions on Manga { ? element.isBookmarked == false : true) .where((element) { - final modelChapDownload = isar.downloads.filter().idIsNotNull().chapterIdEqualTo(element.id).findAllSync(); + final modelChapDownload = isar.downloads + .filter() + .idIsNotNull() + .chapterIdEqualTo(element.id) + .findAllSync(); return filterDownloaded == 1 - ? modelChapDownload.isNotEmpty && modelChapDownload.first.isDownload == true + ? modelChapDownload.isNotEmpty && + modelChapDownload.first.isDownload == true : filterDownloaded == 2 - ? !(modelChapDownload.isNotEmpty && modelChapDownload.first.isDownload == true) + ? !(modelChapDownload.isNotEmpty && + modelChapDownload.first.isDownload == true) : true; }) .where((element) => !filterScanlator.contains(element.scanlator)) .toList(); - List chapters = sortChapter == 1 ? chapterList.reversed.toList() : chapterList; + List chapters = + sortChapter == 1 ? chapterList.reversed.toList() : chapterList; if (sortChapter == 0) { chapters.sort( (a, b) { - return (a.scanlator == null || b.scanlator == null || a.dateUpload == null || b.dateUpload == null) + return (a.scanlator == null || + b.scanlator == null || + a.dateUpload == null || + b.dateUpload == null) ? 0 - : a.scanlator!.compareTo(b.scanlator!) | a.dateUpload!.compareTo(b.dateUpload!); + : a.scanlator!.compareTo(b.scanlator!) | + a.dateUpload!.compareTo(b.dateUpload!); }, ); } else if (sortChapter == 2) { @@ -455,7 +518,9 @@ extension MangaExtensions on Manga { } else if (sortChapter == 3) { chapters.sort( (a, b) { - return (a.name == null || b.name == null) ? 0 : a.name!.compareTo(b.name!); + return (a.name == null || b.name == null) + ? 0 + : a.name!.compareTo(b.name!); }, ); } @@ -465,6 +530,7 @@ extension MangaExtensions on Manga { List? _getFilterScanlator(Manga manga) { final scanlators = isar.settings.getSync(227)!.filterScanlatorList ?? []; - final filter = scanlators.where((element) => element.mangaId == manga.id).toList(); + final filter = + scanlators.where((element) => element.mangaId == manga.id).toList(); return filter.firstOrNull?.scanlators; } diff --git a/lib/modules/manga/reader/reader_view.dart b/lib/modules/manga/reader/reader_view.dart index 9034024..b7f5e71 100644 --- a/lib/modules/manga/reader/reader_view.dart +++ b/lib/modules/manga/reader/reader_view.dart @@ -8,7 +8,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; -import 'package:mangayomi/eval/dart/model/m_bridge.dart'; +import 'package:mangayomi/eval/model/m_bridge.dart'; import 'package:mangayomi/main.dart'; import 'package:mangayomi/models/chapter.dart'; import 'package:mangayomi/models/manga.dart'; diff --git a/lib/modules/manga/reader/widgets/btn_chapter_list_dialog.dart b/lib/modules/manga/reader/widgets/btn_chapter_list_dialog.dart index 6f7beb4..d1dd431 100644 --- a/lib/modules/manga/reader/widgets/btn_chapter_list_dialog.dart +++ b/lib/modules/manga/reader/widgets/btn_chapter_list_dialog.dart @@ -9,7 +9,8 @@ import 'package:mangayomi/utils/date.dart'; import 'package:mangayomi/utils/extensions/build_context_extensions.dart'; import 'package:super_sliver_list/super_sliver_list.dart'; -Widget btnToShowChapterListDialog(BuildContext context, String title, Chapter chapter, +Widget btnToShowChapterListDialog( + BuildContext context, String title, Chapter chapter, {void Function(bool)? onChanged}) { return IconButton( onPressed: () async { @@ -19,7 +20,9 @@ Widget btnToShowChapterListDialog(BuildContext context, String title, Chapter ch builder: (context) { return AlertDialog( title: Text(title), - content: SizedBox(width: context.width(0.8), child: ChapterListWidget(chapter: chapter)), + content: SizedBox( + width: context.width(0.8), + child: ChapterListWidget(chapter: chapter)), ); }); onChanged?.call(true); @@ -51,7 +54,9 @@ class _ChapterListWidgetState extends State { Future _jumpTo() async { await Future.delayed(const Duration(milliseconds: 5)); - controller.jumpTo(controller.position.maxScrollExtent / chapterList.length * currentChapIndex); + controller.jumpTo(controller.position.maxScrollExtent / + chapterList.length * + currentChapIndex); } @override @@ -70,8 +75,10 @@ class _ChapterListWidgetState extends State { itemCount: chapterList.length, itemBuilder: (context, index) { final chapter = chapterList[index]; - final currentChap = chapter == chapterList[currentChapIndex]; - return ChapterListTile(chapter: chapter, currentChap: currentChap); + final currentChap = + chapter == chapterList[currentChapIndex]; + return ChapterListTile( + chapter: chapter, currentChap: currentChap); }), ), ], @@ -82,7 +89,8 @@ class _ChapterListWidgetState extends State { class ChapterListTile extends StatefulWidget { final Chapter chapter; final bool currentChap; - const ChapterListTile({super.key, required this.chapter, required this.currentChap}); + const ChapterListTile( + {super.key, required this.chapter, required this.currentChap}); @override State createState() => _ChapterListTileState(); @@ -94,14 +102,18 @@ class _ChapterListTileState extends State { @override Widget build(BuildContext context) { return Container( - color: widget.currentChap ? context.primaryColor.withValues(alpha: 0.3) : null, + color: widget.currentChap + ? context.primaryColor.withValues(alpha: 0.3) + : 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, + selectedColor: chapter.isRead! + ? Colors.white.withValues(alpha: 0.3) + : Colors.white, onTap: () async { if (!widget.currentChap) { Navigator.pop(context); @@ -120,10 +132,12 @@ class _ChapterListTileState extends State { builder: (context, ref, child) => Text( chapter.dateUpload == null || chapter.dateUpload!.isEmpty ? "" - : dateFormat(chapter.dateUpload!, ref: ref, context: context), + : dateFormat(chapter.dateUpload!, + ref: ref, context: context), style: const TextStyle(fontSize: 11))), if (!chapter.isRead!) - if (chapter.lastPageRead!.isNotEmpty && chapter.lastPageRead != "1") + if (chapter.lastPageRead!.isNotEmpty && + chapter.lastPageRead != "1") if (chapter.scanlator!.isNotEmpty) Row( children: [ @@ -146,11 +160,13 @@ class _ChapterListTileState extends State { isBookmarked = !isBookmarked; }); isar.writeTxnSync(() => { - addUpdatedChapterIndependentProvider.call(chapter, false, false), + addUpdatedChapterIndependentProvider.call( + chapter, false, false), isar.chapters.putSync(chapter..isBookmarked = isBookmarked), }); }, - icon: Icon(isBookmarked ? Icons.bookmark : Icons.bookmark_outline, color: context.primaryColor), + icon: Icon(isBookmarked ? Icons.bookmark : Icons.bookmark_outline, + color: context.primaryColor), ), ), ); diff --git a/lib/modules/manga/reader/widgets/circular_progress_indicator_animate_rotate.dart b/lib/modules/manga/reader/widgets/circular_progress_indicator_animate_rotate.dart index 40c29eb..ed59012 100644 --- a/lib/modules/manga/reader/widgets/circular_progress_indicator_animate_rotate.dart +++ b/lib/modules/manga/reader/widgets/circular_progress_indicator_animate_rotate.dart @@ -3,20 +3,25 @@ import 'package:flutter/material.dart'; class CircularProgressIndicatorAnimateRotate extends StatefulWidget { final double progress; - const CircularProgressIndicatorAnimateRotate({super.key, required this.progress}); + const CircularProgressIndicatorAnimateRotate( + {super.key, required this.progress}); @override - State createState() => _CircularProgressIndicatorAnimateRotateState(); + State createState() => + _CircularProgressIndicatorAnimateRotateState(); } -class _CircularProgressIndicatorAnimateRotateState extends State +class _CircularProgressIndicatorAnimateRotateState + extends State with SingleTickerProviderStateMixin { late final AnimationController _controller; @override void initState() { super.initState(); - _controller = AnimationController(vsync: this, duration: const Duration(seconds: 10))..repeat(); + _controller = + AnimationController(vsync: this, duration: const Duration(seconds: 10)) + ..repeat(); } @override diff --git a/lib/modules/manga/reader/widgets/color_filter_widget.dart b/lib/modules/manga/reader/widgets/color_filter_widget.dart index 5f6ff6a..7cd6a3d 100644 --- a/lib/modules/manga/reader/widgets/color_filter_widget.dart +++ b/lib/modules/manga/reader/widgets/color_filter_widget.dart @@ -16,19 +16,20 @@ class ColorFilterWidget extends ConsumerWidget { final colorFilterBlendMode = ref.watch(colorFilterBlendModeStateProvider); return Container( foregroundDecoration: BoxDecoration( - backgroundBlendMode: getColorFilterBlendMode(colorFilterBlendMode, context), + backgroundBlendMode: + getColorFilterBlendMode(colorFilterBlendMode, context), color: customColorFilter == null ? Colors.transparent - : Color.fromARGB( - customColorFilter.a ?? 0, customColorFilter.r ?? 0, customColorFilter.g ?? 0, customColorFilter.b ?? 0), + : Color.fromARGB(customColorFilter.a ?? 0, customColorFilter.r ?? 0, + customColorFilter.g ?? 0, customColorFilter.b ?? 0), ), child: child, ); } } -Widget customColorFilterListTile( - String label, int value, void Function((double, bool, String))? onChanged, BuildContext context) { +Widget customColorFilterListTile(String label, int value, + void Function((double, bool, String))? onChanged, BuildContext context) { final color = switch (label) { "a" => Color.fromARGB(value, 255, 255, 255), "r" => Color.fromARGB(255, value, 0, 0), @@ -47,14 +48,17 @@ Widget customColorFilterListTile( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text(label.toUpperCase(), style: const TextStyle(fontSize: 17, fontWeight: FontWeight.bold)), + Text(label.toUpperCase(), + style: const TextStyle( + fontSize: 17, fontWeight: FontWeight.bold)), Container( height: 25, width: 25, decoration: BoxDecoration( borderRadius: BorderRadius.circular(5), color: color, - border: Border.all(width: 2, color: context.dynamicWhiteBlackColor)), + border: Border.all( + width: 2, color: context.dynamicWhiteBlackColor)), ) ], ), @@ -64,7 +68,8 @@ Widget customColorFilterListTile( child: SliderTheme( data: SliderTheme.of(context).copyWith( trackHeight: context.isDesktop ? null : 3, - overlayShape: const RoundSliderOverlayShape(overlayRadius: 5.0)), + overlayShape: + const RoundSliderOverlayShape(overlayRadius: 5.0)), child: Slider( min: 0.0, max: 255, @@ -83,8 +88,8 @@ Widget customColorFilterListTile( ); } -Widget rgbaFilterWidget( - int a, int r, int g, int b, void Function((double, bool, String))? onChanged, BuildContext context) { +Widget rgbaFilterWidget(int a, int r, int g, int b, + void Function((double, bool, String))? onChanged, BuildContext context) { return Column(children: [ customColorFilterListTile("r", r, onChanged, context), customColorFilterListTile("g", g, onChanged, context), diff --git a/lib/modules/more/about/about_screen.dart b/lib/modules/more/about/about_screen.dart index 1aa5730..bdbd8f4 100644 --- a/lib/modules/more/about/about_screen.dart +++ b/lib/modules/more/about/about_screen.dart @@ -25,7 +25,9 @@ class AboutScreen extends ConsumerWidget { padding: const EdgeInsets.symmetric(vertical: 40), child: Image.asset( "assets/app_icons/icon.png", - color: Theme.of(context).brightness == Brightness.light ? Colors.black : Colors.white, + color: Theme.of(context).brightness == Brightness.light + ? Colors.black + : Colors.white, fit: BoxFit.cover, height: 100, ), @@ -45,7 +47,8 @@ class AboutScreen extends ConsumerWidget { ), ListTile( onTap: () { - ref.read(checkForUpdateProvider(context: context, manualUpdate: true)); + ref.read(checkForUpdateProvider( + context: context, manualUpdate: true)); }, title: Text(l10n.check_for_update), ), @@ -66,12 +69,14 @@ class AboutScreen extends ConsumerWidget { children: [ IconButton( onPressed: () { - _launchInBrowser(Uri.parse('https://github.com/kodjodevf/mangayomi')); + _launchInBrowser(Uri.parse( + 'https://github.com/kodjodevf/mangayomi')); }, icon: const Icon(FontAwesomeIcons.github)), IconButton( onPressed: () { - _launchInBrowser(Uri.parse('https://discord.com/invite/EjfBuYahsP')); + _launchInBrowser(Uri.parse( + 'https://discord.com/invite/EjfBuYahsP')); }, icon: const Icon(FontAwesomeIcons.discord)) ], diff --git a/lib/modules/more/about/providers/check_for_update.dart b/lib/modules/more/about/providers/check_for_update.dart index 37bf86f..78c8c06 100644 --- a/lib/modules/more/about/providers/check_for_update.dart +++ b/lib/modules/more/about/providers/check_for_update.dart @@ -14,7 +14,8 @@ import 'package:url_launcher/url_launcher.dart'; part 'check_for_update.g.dart'; @riverpod -Future checkForUpdate(Ref ref, {BuildContext? context, bool? manualUpdate}) async { +Future checkForUpdate(Ref ref, + {BuildContext? context, bool? manualUpdate}) async { manualUpdate = manualUpdate ?? false; final l10n = l10nLocalizations(context!)!; if (manualUpdate) { @@ -37,7 +38,8 @@ Future checkForUpdate(Ref ref, {BuildContext? context, bool? manualUpdate} builder: (context) { return AlertDialog( title: Text(l10n.new_update_available), - content: Text("${l10n.app_version(updateAvailable.$1)}\n\n${updateAvailable.$2}"), + content: Text( + "${l10n.app_version(updateAvailable.$1)}\n\n${updateAvailable.$2}"), actions: [ Row( mainAxisAlignment: MainAxisAlignment.end, @@ -81,11 +83,14 @@ Future _launchInBrowser(Uri url) async { Future<(String, String, String)> _checkUpdate() async { final http = MClient.init(reqcopyWith: {'useDartHttpClient': true}); try { - final res = - await http.get(Uri.parse("https://api.github.com/repos/kodjodevf/Mangayomi/releases?page=1&per_page=10")); + final res = await http.get(Uri.parse( + "https://api.github.com/repos/kodjodevf/Mangayomi/releases?page=1&per_page=10")); List resListJson = jsonDecode(res.body) as List; return ( - resListJson.first["name"].toString().substringAfter('v').substringBefore('-'), + resListJson.first["name"] + .toString() + .substringAfter('v') + .substringBefore('-'), resListJson.first["body"].toString(), resListJson.first["html_url"].toString() ); diff --git a/lib/modules/more/backup_and_restore/backup_and_restore.dart b/lib/modules/more/backup_and_restore/backup_and_restore.dart index 55995dc..71aef1c 100644 --- a/lib/modules/more/backup_and_restore/backup_and_restore.dart +++ b/lib/modules/more/backup_and_restore/backup_and_restore.dart @@ -2,7 +2,7 @@ import 'dart:io'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:mangayomi/eval/dart/model/m_bridge.dart'; +import 'package:mangayomi/eval/model/m_bridge.dart'; import 'package:mangayomi/modules/manga/detail/widgets/chapter_filter_list_tile_widget.dart'; import 'package:mangayomi/modules/more/backup_and_restore/providers/auto_backup.dart'; import 'package:mangayomi/modules/more/backup_and_restore/providers/backup.dart'; @@ -158,10 +158,10 @@ class BackupAndRestore extends ConsumerWidget { onPressed: () async { try { FilePickerResult? result = - await FilePicker.platform - .pickFiles(allowMultiple: false, - type: FileType.custom, - allowedExtensions: ["backup"]); + await FilePicker.platform.pickFiles( + allowMultiple: false, + type: FileType.custom, + allowedExtensions: ["backup"]); if (result != null && context.mounted) { ref.watch(doRestoreProvider( diff --git a/lib/modules/more/backup_and_restore/providers/auto_backup.dart b/lib/modules/more/backup_and_restore/providers/auto_backup.dart index ca08308..f0d729a 100644 --- a/lib/modules/more/backup_and_restore/providers/auto_backup.dart +++ b/lib/modules/more/backup_and_restore/providers/auto_backup.dart @@ -31,7 +31,8 @@ class BackupFrequencyOptionsState extends _$BackupFrequencyOptionsState { void set(List values) { final settings = isar.settings.getSync(227); state = values; - isar.writeTxnSync(() => isar.settings.putSync(settings!..backupFrequencyOptions = values)); + isar.writeTxnSync(() => + isar.settings.putSync(settings!..backupFrequencyOptions = values)); } } @@ -45,7 +46,8 @@ class AutoBackupLocationState extends _$AutoBackupLocationState { void set(String location) { final settings = isar.settings.getSync(227); state = (p.join(_storageProvider!.path, "backup"), location); - isar.writeTxnSync(() => isar.settings.putSync(settings!..autoBackupLocation = location)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..autoBackupLocation = location)); } Directory? _storageProvider; @@ -56,7 +58,9 @@ class AutoBackupLocationState extends _$AutoBackupLocationState { : await StorageProvider().getDefaultDirectory(); final settings = isar.settings.getSync(227); state = ( - Platform.isIOS ? _storageProvider!.path : p.join(_storageProvider!.path, "backup"), + Platform.isIOS + ? _storageProvider!.path + : p.join(_storageProvider!.path, "backup"), settings!.autoBackupLocation ?? "" ); } @@ -69,7 +73,8 @@ Future checkAndBackup(Ref ref) async { final backupFrequency = _duration(settings.backupFrequency); if (backupFrequency != null) { if (settings.startDatebackup != null) { - final startDatebackup = DateTime.fromMillisecondsSinceEpoch(settings.startDatebackup!); + final startDatebackup = + DateTime.fromMillisecondsSinceEpoch(settings.startDatebackup!); if (DateTime.now().isAfter(startDatebackup)) { _setBackupFrequency(settings.backupFrequency!); final storageProvider = StorageProvider(); @@ -77,8 +82,9 @@ Future checkAndBackup(Ref ref) async { final defaulteDirectory = await storageProvider.getDefaultDirectory(); final backupLocation = ref.watch(autoBackupLocationStateProvider).$2; Directory? backupDirectory; - backupDirectory = - Directory(backupLocation.isEmpty ? p.join(defaulteDirectory!.path, "backup") : backupLocation); + backupDirectory = Directory(backupLocation.isEmpty + ? p.join(defaulteDirectory!.path, "backup") + : backupLocation); if (Platform.isIOS) { backupDirectory = await (storageProvider.getIosBackupDirectory()); } @@ -86,7 +92,9 @@ Future checkAndBackup(Ref ref) async { backupDirectory.create(); } ref.watch(doBackUpProvider( - list: ref.watch(backupFrequencyOptionsStateProvider), path: backupDirectory.path, context: null)); + list: ref.watch(backupFrequencyOptionsStateProvider), + path: backupDirectory.path, + context: null)); } } } diff --git a/lib/modules/more/backup_and_restore/providers/backup.dart b/lib/modules/more/backup_and_restore/providers/backup.dart index 7fde7f6..a973f0b 100644 --- a/lib/modules/more/backup_and_restore/providers/backup.dart +++ b/lib/modules/more/backup_and_restore/providers/backup.dart @@ -23,7 +23,10 @@ import 'package:path/path.dart' as p; part 'backup.g.dart'; @riverpod -void doBackUp(Ref ref, {required List list, required String path, required BuildContext? context}) { +void doBackUp(Ref ref, + {required List list, + required String path, + required BuildContext? context}) { Map datas = {}; datas.addAll({"version": "1"}); if (list.contains(0)) { @@ -38,38 +41,84 @@ void doBackUp(Ref ref, {required List list, required String path, required datas.addAll({"manga": res}); } if (list.contains(1)) { - final res = isar.categorys.filter().idIsNotNull().findAllSync().map((e) => e.toJson()).toList(); + final res = isar.categorys + .filter() + .idIsNotNull() + .findAllSync() + .map((e) => e.toJson()) + .toList(); datas.addAll({"categories": res}); } if (list.contains(2)) { - final res = isar.chapters.filter().idIsNotNull().findAllSync().map((e) => e.toJson()).toList(); + final res = isar.chapters + .filter() + .idIsNotNull() + .findAllSync() + .map((e) => e.toJson()) + .toList(); datas.addAll({"chapters": res}); - final res_ = isar.downloads.filter().idIsNotNull().findAllSync().map((e) => e.toJson()).toList(); + final res_ = isar.downloads + .filter() + .idIsNotNull() + .findAllSync() + .map((e) => e.toJson()) + .toList(); datas.addAll({"downloads": res_}); } if (list.contains(3)) { - final res = isar.tracks.filter().idIsNotNull().findAllSync().map((e) => e.toJson()).toList(); + final res = isar.tracks + .filter() + .idIsNotNull() + .findAllSync() + .map((e) => e.toJson()) + .toList(); datas.addAll({"tracks": res}); - final res_ = isar.trackPreferences.filter().syncIdIsNotNull().findAllSync().map((e) => e.toJson()).toList(); + final res_ = isar.trackPreferences + .filter() + .syncIdIsNotNull() + .findAllSync() + .map((e) => e.toJson()) + .toList(); datas.addAll({"trackPreferences": res_}); } if (list.contains(4)) { - final res = isar.historys.filter().idIsNotNull().findAllSync().map((e) => e.toJson()).toList(); + final res = isar.historys + .filter() + .idIsNotNull() + .findAllSync() + .map((e) => e.toJson()) + .toList(); datas.addAll({"history": res}); } if (list.contains(5)) { - final res = isar.settings.filter().idIsNotNull().findAllSync().map((e) => e.toJson()).toList(); + final res = isar.settings + .filter() + .idIsNotNull() + .findAllSync() + .map((e) => e.toJson()) + .toList(); datas.addAll({"settings": res}); } if (list.contains(6)) { - final res = isar.sources.filter().idIsNotNull().findAllSync().map((e) => e.toJson()).toList(); + final res = isar.sources + .filter() + .idIsNotNull() + .findAllSync() + .map((e) => e.toJson()) + .toList(); datas.addAll({"extensions": res}); - final resSourePref = - isar.sourcePreferences.filter().idIsNotNull().keyIsNotNull().findAllSync().map((e) => e.toJson()).toList(); + final resSourePref = isar.sourcePreferences + .filter() + .idIsNotNull() + .keyIsNotNull() + .findAllSync() + .map((e) => e.toJson()) + .toList(); datas.addAll({"extensions_preferences": resSourePref}); } final regExp = RegExp(r'[^a-zA-Z0-9 .()\-\s]'); - final name = 'mangayomi_${DateTime.now().toString().replaceAll(regExp, '_').replaceAll(' ', '_')}'; + final name = + 'mangayomi_${DateTime.now().toString().replaceAll(regExp, '_').replaceAll(' ', '_')}'; final backupFilePath = p.join(path, "$name.backup.db"); final file = File(backupFilePath); @@ -79,7 +128,10 @@ void doBackUp(Ref ref, {required List list, required String path, required encoder.addFile(File(backupFilePath)); encoder.close(); Directory(backupFilePath).deleteSync(recursive: true); - final assets = ['assets/app_icons/icon-black.png', 'assets/app_icons/icon-red.png']; + final assets = [ + 'assets/app_icons/icon-black.png', + 'assets/app_icons/icon-red.png' + ]; if (context != null) { Navigator.pop(context); BotToast.showNotification( @@ -99,7 +151,8 @@ void doBackUp(Ref ref, {required List list, required String path, required alignment: Alignment.topLeft, child: ElevatedButton( onPressed: () { - Share.shareXFiles([XFile(p.join(path, "$name.backup"))], text: "$name.backup"); + Share.shareXFiles([XFile(p.join(path, "$name.backup"))], + text: "$name.backup"); }, child: Text(context.l10n.share)), ), diff --git a/lib/modules/more/backup_and_restore/providers/restore.dart b/lib/modules/more/backup_and_restore/providers/restore.dart index 493b27c..cd6c9b9 100644 --- a/lib/modules/more/backup_and_restore/providers/restore.dart +++ b/lib/modules/more/backup_and_restore/providers/restore.dart @@ -29,21 +29,40 @@ part 'restore.g.dart'; void doRestore(Ref ref, {required String path, required BuildContext context}) { final inputStream = InputFileStream(path); final archive = ZipDecoder().decodeStream(inputStream); - final backup = jsonDecode(utf8.decode(archive.files.first.content)) as Map; + final backup = jsonDecode(utf8.decode(archive.files.first.content)) + as Map; if (backup['version'] == "1") { try { - final manga = (backup["manga"] as List?)?.map((e) => Manga.fromJson(e)).toList(); - final chapters = (backup["chapters"] as List?)?.map((e) => Chapter.fromJson(e)).toList(); - final categories = (backup["categories"] as List?)?.map((e) => Category.fromJson(e)).toList(); - final track = (backup["tracks"] as List?)?.map((e) => Track.fromJson(e)).toList(); - final trackPreferences = (backup["trackPreferences"] as List?)?.map((e) => TrackPreference.fromJson(e)).toList(); - final history = (backup["history"] as List?)?.map((e) => History.fromJson(e)).toList(); - final downloads = (backup["downloads"] as List?)?.map((e) => Download.fromJson(e)).toList(); - final settings = (backup["settings"] as List?)?.map((e) => Settings.fromJson(e)).toList(); - final extensions = (backup["extensions"] as List?)?.map((e) => Source.fromJson(e)).toList(); - final extensionsPref = - (backup["extensions_preferences"] as List?)?.map((e) => SourcePreference.fromJson(e)).toList(); - final updates = (backup["updates"] as List?)?.map((e) => Update.fromJson(e)).toList(); + final manga = + (backup["manga"] as List?)?.map((e) => Manga.fromJson(e)).toList(); + final chapters = (backup["chapters"] as List?) + ?.map((e) => Chapter.fromJson(e)) + .toList(); + final categories = (backup["categories"] as List?) + ?.map((e) => Category.fromJson(e)) + .toList(); + final track = + (backup["tracks"] as List?)?.map((e) => Track.fromJson(e)).toList(); + final trackPreferences = (backup["trackPreferences"] as List?) + ?.map((e) => TrackPreference.fromJson(e)) + .toList(); + final history = (backup["history"] as List?) + ?.map((e) => History.fromJson(e)) + .toList(); + final downloads = (backup["downloads"] as List?) + ?.map((e) => Download.fromJson(e)) + .toList(); + final settings = (backup["settings"] as List?) + ?.map((e) => Settings.fromJson(e)) + .toList(); + final extensions = (backup["extensions"] as List?) + ?.map((e) => Source.fromJson(e)) + .toList(); + final extensionsPref = (backup["extensions_preferences"] as List?) + ?.map((e) => SourcePreference.fromJson(e)) + .toList(); + final updates = + (backup["updates"] as List?)?.map((e) => Update.fromJson(e)).toList(); isar.writeTxnSync(() { isar.mangas.clearSync(); @@ -83,10 +102,13 @@ void doRestore(Ref ref, {required String path, required BuildContext context}) { isar.updates.clearSync(); if (updates != null) { - final tempChapters = isar.chapters.filter().idIsNotNull().findAllSync().toList(); + final tempChapters = + isar.chapters.filter().idIsNotNull().findAllSync().toList(); for (var update in updates) { final matchingChapter = tempChapters - .where((chapter) => chapter.mangaId == update.mangaId && chapter.name == update.chapterName) + .where((chapter) => + chapter.mangaId == update.mangaId && + chapter.name == update.chapterName) .firstOrNull; if (matchingChapter != null) { isar.updates.putSync(update..chapter.value = matchingChapter); @@ -139,7 +161,8 @@ void doRestore(Ref ref, {required String path, required BuildContext context}) { animationReverseDuration: const Duration(milliseconds: 200), duration: const Duration(seconds: 5), backButtonBehavior: BackButtonBehavior.none, - leading: (_) => Image.asset('assets/app_icons/icon-red.png', height: 40), + leading: (_) => + Image.asset('assets/app_icons/icon-red.png', height: 40), title: (_) => const Text( "Backup restored!", style: TextStyle(fontWeight: FontWeight.bold), diff --git a/lib/modules/more/categories/categories_screen.dart b/lib/modules/more/categories/categories_screen.dart index 849b53d..372f759 100644 --- a/lib/modules/more/categories/categories_screen.dart +++ b/lib/modules/more/categories/categories_screen.dart @@ -16,7 +16,8 @@ class CategoriesScreen extends ConsumerStatefulWidget { ConsumerState createState() => _CategoriesScreenState(); } -class _CategoriesScreenState extends ConsumerState with TickerProviderStateMixin { +class _CategoriesScreenState extends ConsumerState + with TickerProviderStateMixin { late TabController _tabBarController; @override void initState() { @@ -75,7 +76,8 @@ class _CategoriesTabState extends ConsumerState { @override Widget build(BuildContext context) { final l10n = l10nLocalizations(context)!; - final categories = ref.watch(getMangaCategorieStreamProvider(isManga: widget.isManga)); + final categories = + ref.watch(getMangaCategorieStreamProvider(isManga: widget.isManga)); return Scaffold( body: categories.when( data: (data) { @@ -141,7 +143,8 @@ class _CategoriesTabState extends ConsumerState { onPressed: () { _renameCategory(_entries[index]); }, - icon: const Icon(Icons.mode_edit_outline_outlined)), + icon: const Icon( + Icons.mode_edit_outline_outlined)), IconButton( onPressed: () { showDialog( @@ -153,30 +156,47 @@ class _CategoriesTabState extends ConsumerState { title: Text( l10n.delete_category, ), - content: Text(l10n.delete_category_msg(_entries[index].name!)), + content: Text( + l10n.delete_category_msg( + _entries[index].name!)), actions: [ Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.end, children: [ TextButton( onPressed: () { - Navigator.pop(context); + Navigator.pop( + context); }, - child: Text(l10n.cancel)), + child: Text( + l10n.cancel)), const SizedBox( width: 15, ), TextButton( onPressed: () async { - await isar.writeTxn(() async { + await isar.writeTxn( + () async { await ref - .read(changedItemsManagerProvider(managerId: 1) + .read(changedItemsManagerProvider( + managerId: + 1) .notifier) - .addDeletedCategoryAsync(_entries[index], false); - await isar.categorys.delete(_entries[index].id!); + .addDeletedCategoryAsync( + _entries[ + index], + false); + await isar + .categorys + .delete(_entries[ + index] + .id!); }); - if (context.mounted) { - Navigator.pop(context); + if (context + .mounted) { + Navigator.pop( + context); } }, child: Text( @@ -254,7 +274,8 @@ class _CategoriesTabState extends ConsumerState { width: 15, ), TextButton( - onPressed: controller.text.isEmpty || isExist + onPressed: controller.text.isEmpty || + isExist ? null : () async { await isar.writeTxn(() async { @@ -270,9 +291,12 @@ class _CategoriesTabState extends ConsumerState { child: Text( l10n.add, style: TextStyle( - color: controller.text.isEmpty || isExist - ? Theme.of(context).primaryColor.withValues(alpha: 0.2) - : null), + color: + controller.text.isEmpty || isExist + ? Theme.of(context) + .primaryColor + .withValues(alpha: 0.2) + : null), )), ], ) @@ -338,22 +362,27 @@ class _CategoriesTabState extends ConsumerState { width: 15, ), TextButton( - onPressed: controller.text.isEmpty || isExist || isSameName - ? null - : () async { - await isar.writeTxn(() async { - category.name = controller.text; - await isar.categorys.put(category); - }); - if (context.mounted) { - Navigator.pop(context); - } - }, + onPressed: + controller.text.isEmpty || isExist || isSameName + ? null + : () async { + await isar.writeTxn(() async { + category.name = controller.text; + await isar.categorys.put(category); + }); + if (context.mounted) { + Navigator.pop(context); + } + }, child: Text( l10n.ok, style: TextStyle( - color: controller.text.isEmpty || isExist || isSameName - ? Theme.of(context).primaryColor.withValues(alpha: 0.2) + color: controller.text.isEmpty || + isExist || + isSameName + ? Theme.of(context) + .primaryColor + .withValues(alpha: 0.2) : null), )), ], diff --git a/lib/modules/more/categories/providers/isar_providers.dart b/lib/modules/more/categories/providers/isar_providers.dart index 09c5593..1b4c714 100644 --- a/lib/modules/more/categories/providers/isar_providers.dart +++ b/lib/modules/more/categories/providers/isar_providers.dart @@ -6,6 +6,12 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; part 'isar_providers.g.dart'; @riverpod -Stream> getMangaCategorieStream(Ref ref, {required bool isManga}) async* { - yield* isar.categorys.filter().idIsNotNull().and().forMangaEqualTo(isManga).watch(fireImmediately: true); +Stream> getMangaCategorieStream(Ref ref, + {required bool isManga}) async* { + yield* isar.categorys + .filter() + .idIsNotNull() + .and() + .forMangaEqualTo(isManga) + .watch(fireImmediately: true); } diff --git a/lib/modules/more/categories/widgets/custom_textfield.dart b/lib/modules/more/categories/widgets/custom_textfield.dart index 17277ad..b9b50cc 100644 --- a/lib/modules/more/categories/widgets/custom_textfield.dart +++ b/lib/modules/more/categories/widgets/custom_textfield.dart @@ -30,24 +30,39 @@ class CustomTextFormField extends StatelessWidget { keyboardType: TextInputType.text, onChanged: (value) { if (name != controller.text) { - exist(entries.where((element) => element.name == controller.text).toList().isNotEmpty); + exist(entries + .where((element) => element.name == controller.text) + .toList() + .isNotEmpty); } val(value); }, onFieldSubmitted: (s) {}, decoration: InputDecoration( - helperText: isExist == true ? l10n!.add_category_error_exist : l10n!.category_name_required, + helperText: isExist == true + ? l10n!.add_category_error_exist + : l10n!.category_name_required, helperStyle: TextStyle(color: isExist == true ? Colors.red : null), isDense: true, - label: Text(l10n.name, style: TextStyle(color: isExist == true ? Colors.red : null)), + label: Text(l10n.name, + style: TextStyle(color: isExist == true ? Colors.red : null)), filled: true, fillColor: Colors.transparent, enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: isExist == true ? Colors.red : Theme.of(context).primaryColor)), + borderSide: BorderSide( + color: isExist == true + ? Colors.red + : Theme.of(context).primaryColor)), focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: isExist == true ? Colors.red : Theme.of(context).primaryColor)), + borderSide: BorderSide( + color: isExist == true + ? Colors.red + : Theme.of(context).primaryColor)), border: OutlineInputBorder( - borderSide: BorderSide(color: isExist == true ? Colors.red : Theme.of(context).primaryColor))), + borderSide: BorderSide( + color: isExist == true + ? Colors.red + : Theme.of(context).primaryColor))), ); } } diff --git a/lib/modules/more/download_queue/download_queue_screen.dart b/lib/modules/more/download_queue/download_queue_screen.dart index 0d81d56..7699096 100644 --- a/lib/modules/more/download_queue/download_queue_screen.dart +++ b/lib/modules/more/download_queue/download_queue_screen.dart @@ -16,7 +16,8 @@ class DownloadQueueScreen extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final l10n = l10nLocalizations(context); return StreamBuilder( - stream: isar.downloads.filter().idIsNotNull().watch(fireImmediately: true), + stream: + isar.downloads.filter().idIsNotNull().watch(fireImmediately: true), builder: (context, snapshot) { if (snapshot.hasData && snapshot.data!.isNotEmpty) { final entries = snapshot.data! @@ -37,11 +38,15 @@ class DownloadQueueScreen extends ConsumerWidget { Padding( padding: const EdgeInsets.only(bottom: 3), child: Container( - decoration: - BoxDecoration(borderRadius: BorderRadius.circular(20), color: Theme.of(context).focusColor), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(20), + color: Theme.of(context).focusColor), child: Text( allQueueLength.toString(), - style: TextStyle(fontSize: 12, color: Theme.of(context).textTheme.bodySmall!.color), + style: TextStyle( + fontSize: 12, + color: + Theme.of(context).textTheme.bodySmall!.color), ), ), ), @@ -50,10 +55,13 @@ class DownloadQueueScreen extends ConsumerWidget { ), body: GroupedListView( elements: entries, - groupBy: (element) => element.chapter.value?.manga.value?.source ?? "", + groupBy: (element) => + element.chapter.value?.manga.value?.source ?? "", groupSeparatorBuilder: (String groupByValue) { final sourceQueueLength = entries - .where((element) => (element.chapter.value?.manga.value?.source ?? "") == groupByValue) + .where((element) => + (element.chapter.value?.manga.value?.source ?? "") == + groupByValue) .toList() .length; return Padding( @@ -79,7 +87,8 @@ class DownloadQueueScreen extends ConsumerWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - element.chapter.value?.manga.value?.name ?? "", + element.chapter.value?.manga.value?.name ?? + "", style: const TextStyle(fontSize: 16), ), Text( @@ -102,7 +111,8 @@ class DownloadQueueScreen extends ConsumerWidget { begin: 0, end: element.succeeded! / element.total!, ), - builder: (context, value, _) => LinearProgressIndicator( + builder: (context, value, _) => + LinearProgressIndicator( value: value, )), ], @@ -115,17 +125,25 @@ class DownloadQueueScreen extends ConsumerWidget { child: const Icon(Icons.more_vert), onSelected: (value) async { if (value.toString() == 'Cancel') { - final taskIds = (isar.settings.getSync(227)!.chapterPageUrlsList ?? []) - .where((e) => e.chapterId == element.chapterId!) + final taskIds = (isar.settings + .getSync(227)! + .chapterPageUrlsList ?? + []) + .where((e) => + e.chapterId == element.chapterId!) .map((e) => e.urls) .firstOrNull ?? []; - FileDownloader().cancelTasksWithIds(taskIds).then((value) async { - await Future.delayed(const Duration(seconds: 1)); + FileDownloader() + .cancelTasksWithIds(taskIds) + .then((value) async { + await Future.delayed( + const Duration(seconds: 1)); isar.writeTxnSync(() { int id = isar.downloads .filter() - .chapterIdEqualTo(element.chapter.value!.id) + .chapterIdEqualTo( + element.chapter.value!.id) .findFirstSync()! .id!; isar.downloads.deleteSync(id); @@ -134,27 +152,38 @@ class DownloadQueueScreen extends ConsumerWidget { } else if (value.toString() == 'CancelAll') { final chapterIds = entries .where((e) => - e.chapter.value?.manga.value?.name == element.chapter.value?.manga.value?.name && + e.chapter.value?.manga.value?.name == + element.chapter.value?.manga.value + ?.name && e.chapter.value?.manga.value?.source == - element.chapter.value?.manga.value?.source) + element.chapter.value?.manga.value + ?.source) .map((e) => e.chapterId) .toList(); for (var chapterId in chapterIds) { - final taskIds = (isar.settings.getSync(227)!.chapterPageUrlsList ?? []) + final taskIds = (isar.settings + .getSync(227)! + .chapterPageUrlsList ?? + []) .where((e) => e.chapterId == chapterId!) .map((e) => e.urls) .firstOrNull ?? []; - await FileDownloader().cancelTasksWithIds(taskIds); + await FileDownloader() + .cancelTasksWithIds(taskIds); Future.delayed(const Duration(seconds: 2)).then( (value) { - final chapterD = - isar.downloads.filter().chapterIdEqualTo(chapterId).findFirstSync(); + final chapterD = isar.downloads + .filter() + .chapterIdEqualTo(chapterId) + .findFirstSync(); if (chapterD != null) { - final verifyId = isar.downloads.getSync(chapterD.id!); + final verifyId = + isar.downloads.getSync(chapterD.id!); isar.writeTxnSync(() { if (verifyId != null) { - isar.downloads.deleteSync(chapterD.id!); + isar.downloads + .deleteSync(chapterD.id!); } }); } @@ -164,8 +193,11 @@ class DownloadQueueScreen extends ConsumerWidget { } }, itemBuilder: (context) => [ - PopupMenuItem(value: 'Cancel', child: Text(l10n.cancel)), - PopupMenuItem(value: 'CancelAll', child: Text(l10n.cancel_all_for_this_series)), + PopupMenuItem( + value: 'Cancel', child: Text(l10n.cancel)), + PopupMenuItem( + value: 'CancelAll', + child: Text(l10n.cancel_all_for_this_series)), ], ), ) @@ -173,8 +205,9 @@ class DownloadQueueScreen extends ConsumerWidget { ), ); }, - itemComparator: (item1, item2) => (item1.chapter.value?.manga.value?.source ?? "") - .compareTo(item2.chapter.value?.manga.value?.source ?? ""), + itemComparator: (item1, item2) => + (item1.chapter.value?.manga.value?.source ?? "").compareTo( + item2.chapter.value?.manga.value?.source ?? ""), order: GroupedListOrder.DESC, ), ); diff --git a/lib/modules/more/more_screen.dart b/lib/modules/more/more_screen.dart index b8a6005..1b35bf5 100644 --- a/lib/modules/more/more_screen.dart +++ b/lib/modules/more/more_screen.dart @@ -21,7 +21,9 @@ class MoreScreen extends StatelessWidget { padding: const EdgeInsets.symmetric(vertical: 40), child: Image.asset( "assets/app_icons/icon.png", - color: Theme.of(context).brightness == Brightness.light ? Colors.black : Colors.white, + color: Theme.of(context).brightness == Brightness.light + ? Colors.black + : Colors.white, fit: BoxFit.cover, height: 100, ), diff --git a/lib/modules/more/providers/incognito_mode_state_provider.dart b/lib/modules/more/providers/incognito_mode_state_provider.dart index 40d2876..7b21f8c 100644 --- a/lib/modules/more/providers/incognito_mode_state_provider.dart +++ b/lib/modules/more/providers/incognito_mode_state_provider.dart @@ -13,6 +13,7 @@ class IncognitoModeState extends _$IncognitoModeState { void setIncognitoMode(bool value) { final settings = isar.settings.getSync(227)!; state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings..incognitoMode = state)); + isar.writeTxnSync( + () => isar.settings.putSync(settings..incognitoMode = state)); } } diff --git a/lib/modules/more/settings/appearance/appearance_screen.dart b/lib/modules/more/settings/appearance/appearance_screen.dart index 0eb040c..bf19ca4 100644 --- a/lib/modules/more/settings/appearance/appearance_screen.dart +++ b/lib/modules/more/settings/appearance/appearance_screen.dart @@ -32,7 +32,8 @@ class AppearanceScreen extends ConsumerWidget { : GoogleFonts.asMap() .entries .toList() - .firstWhere((element) => element.value().fontFamily! == appFontFamily) + .firstWhere( + (element) => element.value().fontFamily! == appFontFamily) .key; return Scaffold( appBar: AppBar( @@ -49,7 +50,9 @@ class AppearanceScreen extends ConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 15), child: Row( children: [ - Text(l10n.theme, style: TextStyle(fontSize: 13, color: context.primaryColor)), + Text(l10n.theme, + style: TextStyle( + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -62,10 +65,13 @@ class AppearanceScreen extends ConsumerWidget { title: Text(l10n.pure_black_dark_mode), value: pureBlackDarkMode, onChanged: (value) { - ref.read(pureBlackDarkModeStateProvider.notifier).set(value); + ref + .read(pureBlackDarkModeStateProvider.notifier) + .set(value); }), ), - if (!pureBlackDarkMode || !isDarkTheme) const BlendLevelSlider() + if (!pureBlackDarkMode || !isDarkTheme) + const BlendLevelSlider() ], ), ), @@ -77,7 +83,9 @@ class AppearanceScreen extends ConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 15), child: Row( children: [ - Text(l10n.appearance, style: TextStyle(fontSize: 13, color: context.primaryColor)), + Text(l10n.appearance, + style: TextStyle( + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -94,19 +102,25 @@ class AppearanceScreen extends ConsumerWidget { width: context.width(0.8), child: ListView.builder( shrinkWrap: true, - itemCount: AppLocalizations.supportedLocales.length, + itemCount: AppLocalizations + .supportedLocales.length, itemBuilder: (context, index) { - final locale = AppLocalizations.supportedLocales[index]; + final locale = AppLocalizations + .supportedLocales[index]; return RadioListTile( dense: true, contentPadding: const EdgeInsets.all(0), value: locale, groupValue: l10nLocale, onChanged: (value) { - ref.read(l10nLocaleStateProvider.notifier).setLocale(locale); + ref + .read(l10nLocaleStateProvider + .notifier) + .setLocale(locale); Navigator.pop(context); }, - title: Text(completeLanguageName(locale.toLanguageTag())), + title: Text(completeLanguageName( + locale.toLanguageTag())), ); }, )), @@ -120,7 +134,8 @@ class AppearanceScreen extends ConsumerWidget { }, child: Text( l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), ], ) @@ -131,7 +146,8 @@ class AppearanceScreen extends ConsumerWidget { title: Text(l10n.app_language), subtitle: Text( completeLanguageName(l10nLocale.toLanguageTag()), - style: TextStyle(fontSize: 11, color: context.secondaryColor), + style: TextStyle( + fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -143,13 +159,15 @@ class AppearanceScreen extends ConsumerWidget { builder: (context) { return AlertDialog( title: Text(context.l10n.font), - content: StatefulBuilder(builder: (context, setState) { + content: + StatefulBuilder(builder: (context, setState) { return SizedBox( width: context.width(0.8), child: Column( children: [ Padding( - padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8), + padding: const EdgeInsets.symmetric( + vertical: 12, horizontal: 8), child: TextField( onChanged: (v) { setState(() { @@ -159,20 +177,33 @@ class AppearanceScreen extends ConsumerWidget { decoration: InputDecoration( isDense: true, filled: false, - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: context.secondaryColor), + enabledBorder: + OutlineInputBorder( + borderSide: BorderSide( + color: context + .secondaryColor), ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: context.primaryColor), + focusedBorder: + OutlineInputBorder( + borderSide: BorderSide( + color: context + .primaryColor), ), - border: const OutlineInputBorder(borderSide: BorderSide()), + border: + const OutlineInputBorder( + borderSide: + BorderSide()), hintText: l10n.search)), ), Builder(builder: (context) { - List values = GoogleFonts.asMap().entries.toList(); + List values = GoogleFonts.asMap() + .entries + .toList(); values = values - .where((values) => - values.key.toLowerCase().contains(textValue.toLowerCase())) + .where((values) => values.key + .toLowerCase() + .contains( + textValue.toLowerCase())) .toList(); return Flexible( child: Scrollbar( @@ -184,21 +215,35 @@ class AppearanceScreen extends ConsumerWidget { controller: controller, slivers: [ SliverPadding( - padding: const EdgeInsets.all(0), - sliver: SuperSliverList.builder( + padding: + const EdgeInsets.all(0), + sliver: + SuperSliverList.builder( itemCount: values.length, - itemBuilder: (context, index) { - final value = values[index]; + itemBuilder: + (context, index) { + final value = + values[index]; return RadioListTile( dense: true, - contentPadding: const EdgeInsets.all(0), - value: value.value().fontFamily, - groupValue: appFontFamily, + contentPadding: + const EdgeInsets + .all(0), + value: value + .value() + .fontFamily, + groupValue: + appFontFamily, onChanged: (value) { - ref.read(appFontFamilyProvider.notifier).set(value); - Navigator.pop(context); + ref + .read(appFontFamilyProvider + .notifier) + .set(value); + Navigator.pop( + context); }, - title: Text(value.key), + title: + Text(value.key), ); }, ), @@ -217,12 +262,16 @@ class AppearanceScreen extends ConsumerWidget { children: [ TextButton( onPressed: () async { - ref.read(appFontFamilyProvider.notifier).set(null); + ref + .read(appFontFamilyProvider + .notifier) + .set(null); Navigator.pop(context); }, child: Text( l10n.default0, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), TextButton( onPressed: () async { @@ -230,7 +279,8 @@ class AppearanceScreen extends ConsumerWidget { }, child: Text( l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), ], ) @@ -241,7 +291,8 @@ class AppearanceScreen extends ConsumerWidget { title: Text(context.l10n.font), subtitle: Text( appFontFamilySub, - style: TextStyle(fontSize: 11, color: context.secondaryColor), + style: TextStyle( + fontSize: 11, color: context.secondaryColor), ), ), ], @@ -255,7 +306,9 @@ class AppearanceScreen extends ConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 15), child: Row( children: [ - Text(l10n.timestamp, style: TextStyle(fontSize: 13, color: context.primaryColor)), + Text(l10n.timestamp, + style: TextStyle( + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -272,7 +325,8 @@ class AppearanceScreen extends ConsumerWidget { width: context.width(0.8), child: ListView.builder( shrinkWrap: true, - itemCount: relativeTimestampsList(context).length, + itemCount: + relativeTimestampsList(context).length, itemBuilder: (context, index) { return RadioListTile( dense: true, @@ -280,11 +334,18 @@ class AppearanceScreen extends ConsumerWidget { value: index, groupValue: relativeTimestamps, onChanged: (value) { - ref.read(relativeTimesTampsStateProvider.notifier).set(value!); + ref + .read( + relativeTimesTampsStateProvider + .notifier) + .set(value!); Navigator.pop(context); }, title: Row( - children: [Text(relativeTimestampsList(context)[index])], + children: [ + Text(relativeTimestampsList( + context)[index]) + ], ), ); }, @@ -299,7 +360,8 @@ class AppearanceScreen extends ConsumerWidget { }, child: Text( l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), ], ) @@ -310,7 +372,8 @@ class AppearanceScreen extends ConsumerWidget { title: Text(l10n.relative_timestamp), subtitle: Text( relativeTimestampsList(context)[relativeTimestamps], - style: TextStyle(fontSize: 11, color: context.secondaryColor), + style: TextStyle( + fontSize: 11, color: context.secondaryColor), ), ), ListTile( @@ -334,7 +397,10 @@ class AppearanceScreen extends ConsumerWidget { value: dateFormatsList[index], groupValue: dateFormatState, onChanged: (value) { - ref.read(dateFormatStateProvider.notifier).set(value!); + ref + .read(dateFormatStateProvider + .notifier) + .set(value!); Navigator.pop(context); }, title: Row( @@ -356,7 +422,8 @@ class AppearanceScreen extends ConsumerWidget { }, child: Text( l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), ], ) @@ -367,7 +434,8 @@ class AppearanceScreen extends ConsumerWidget { title: Text(l10n.date_format), subtitle: Text( "$dateFormatState (${dateFormat(context: context, DateTime.now().millisecondsSinceEpoch.toString(), useRelativeTimesTamps: false, dateFormat: dateFormatState, ref: ref)})", - style: TextStyle(fontSize: 11, color: context.secondaryColor), + style: TextStyle( + fontSize: 11, color: context.secondaryColor), ), ), ], diff --git a/lib/modules/more/settings/appearance/providers/app_font_family.dart b/lib/modules/more/settings/appearance/providers/app_font_family.dart index 6121680..b95f2d2 100644 --- a/lib/modules/more/settings/appearance/providers/app_font_family.dart +++ b/lib/modules/more/settings/appearance/providers/app_font_family.dart @@ -22,6 +22,7 @@ class AppFontFamily extends _$AppFontFamily { void set(String? fontFamily) { final settings = isar.settings.getSync(227); state = fontFamily; - isar.writeTxnSync(() => isar.settings.putSync(settings!..appFontFamily = fontFamily)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..appFontFamily = fontFamily)); } } diff --git a/lib/modules/more/settings/appearance/providers/blend_level_state_provider.dart b/lib/modules/more/settings/appearance/providers/blend_level_state_provider.dart index 6a25ad1..04e8d0e 100644 --- a/lib/modules/more/settings/appearance/providers/blend_level_state_provider.dart +++ b/lib/modules/more/settings/appearance/providers/blend_level_state_provider.dart @@ -14,7 +14,8 @@ class BlendLevelState extends _$BlendLevelState { final settings = isar.settings.getSync(227); state = blendLevelValue; if (end) { - isar.writeTxnSync(() => isar.settings.putSync(settings!..flexColorSchemeBlendLevel = state)); + isar.writeTxnSync(() => + isar.settings.putSync(settings!..flexColorSchemeBlendLevel = state)); } } } diff --git a/lib/modules/more/settings/appearance/providers/date_format_state_provider.dart b/lib/modules/more/settings/appearance/providers/date_format_state_provider.dart index 90b98fe..6c2d268 100644 --- a/lib/modules/more/settings/appearance/providers/date_format_state_provider.dart +++ b/lib/modules/more/settings/appearance/providers/date_format_state_provider.dart @@ -13,7 +13,8 @@ class DateFormatState extends _$DateFormatState { void set(String dateFormat) { final settings = isar.settings.getSync(227); state = dateFormat; - isar.writeTxnSync(() => isar.settings.putSync(settings!..dateFormat = state)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..dateFormat = state)); } } @@ -27,6 +28,7 @@ class RelativeTimesTampsState extends _$RelativeTimesTampsState { void set(int type) { final settings = isar.settings.getSync(227); state = type; - isar.writeTxnSync(() => isar.settings.putSync(settings!..relativeTimesTamps = state)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..relativeTimesTamps = state)); } } diff --git a/lib/modules/more/settings/appearance/providers/flex_scheme_color_state_provider.dart b/lib/modules/more/settings/appearance/providers/flex_scheme_color_state_provider.dart index 499726c..47ab8fc 100644 --- a/lib/modules/more/settings/appearance/providers/flex_scheme_color_state_provider.dart +++ b/lib/modules/more/settings/appearance/providers/flex_scheme_color_state_provider.dart @@ -9,7 +9,8 @@ part 'flex_scheme_color_state_provider.g.dart'; class FlexSchemeColorState extends _$FlexSchemeColorState { @override FlexSchemeColor build() { - final flexSchemeColorIndex = isar.settings.getSync(227)!.flexSchemeColorIndex!; + final flexSchemeColorIndex = + isar.settings.getSync(227)!.flexSchemeColorIndex!; return ref.read(themeModeStateProvider) ? ThemeAA.schemes[flexSchemeColorIndex].dark : ThemeAA.schemes[flexSchemeColorIndex].light; @@ -18,7 +19,8 @@ class FlexSchemeColorState extends _$FlexSchemeColorState { void setTheme(FlexSchemeColor color, int index) { final settings = isar.settings.getSync(227); state = color; - isar.writeTxnSync(() => isar.settings.putSync(settings!..flexSchemeColorIndex = index)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..flexSchemeColorIndex = index)); } } diff --git a/lib/modules/more/settings/appearance/providers/pure_black_dark_mode_state_provider.dart b/lib/modules/more/settings/appearance/providers/pure_black_dark_mode_state_provider.dart index efe3627..5ad074a 100644 --- a/lib/modules/more/settings/appearance/providers/pure_black_dark_mode_state_provider.dart +++ b/lib/modules/more/settings/appearance/providers/pure_black_dark_mode_state_provider.dart @@ -13,6 +13,7 @@ class PureBlackDarkModeState extends _$PureBlackDarkModeState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..pureBlackDarkMode = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..pureBlackDarkMode = value)); } } diff --git a/lib/modules/more/settings/appearance/providers/theme_mode_state_provider.dart b/lib/modules/more/settings/appearance/providers/theme_mode_state_provider.dart index 76d86bc..71aa2d9 100644 --- a/lib/modules/more/settings/appearance/providers/theme_mode_state_provider.dart +++ b/lib/modules/more/settings/appearance/providers/theme_mode_state_provider.dart @@ -14,18 +14,20 @@ class ThemeModeState extends _$ThemeModeState { void setLightTheme() { final settings = isar.settings.getSync(227); state = false; - ref - .read(flexSchemeColorStateProvider.notifier) - .setTheme(ThemeAA.schemes[settings!.flexSchemeColorIndex!].light, settings.flexSchemeColorIndex!); - isar.writeTxnSync(() => isar.settings.putSync(settings..themeIsDark = state)); + ref.read(flexSchemeColorStateProvider.notifier).setTheme( + ThemeAA.schemes[settings!.flexSchemeColorIndex!].light, + settings.flexSchemeColorIndex!); + isar.writeTxnSync( + () => isar.settings.putSync(settings..themeIsDark = state)); } void setDarkTheme() { final settings = isar.settings.getSync(227); state = true; - ref - .read(flexSchemeColorStateProvider.notifier) - .setTheme(ThemeAA.schemes[settings!.flexSchemeColorIndex!].dark, settings.flexSchemeColorIndex!); - isar.writeTxnSync(() => isar.settings.putSync(settings..themeIsDark = state)); + ref.read(flexSchemeColorStateProvider.notifier).setTheme( + ThemeAA.schemes[settings!.flexSchemeColorIndex!].dark, + settings.flexSchemeColorIndex!); + isar.writeTxnSync( + () => isar.settings.putSync(settings..themeIsDark = state)); } } diff --git a/lib/modules/more/settings/appearance/widgets/blend_level_slider.dart b/lib/modules/more/settings/appearance/widgets/blend_level_slider.dart index 5a042ed..c3df4cf 100644 --- a/lib/modules/more/settings/appearance/widgets/blend_level_slider.dart +++ b/lib/modules/more/settings/appearance/widgets/blend_level_slider.dart @@ -26,8 +26,11 @@ class BlendLevelSlider extends ConsumerWidget { max: 40.0, divisions: max(39, 1), value: blendLevel, - onChanged: (value) => ref.read(blendLevelStateProvider.notifier).setBlendLevel(value), - onChangeEnd: (value) => ref.read(blendLevelStateProvider.notifier).setBlendLevel(value, end: true), + onChanged: (value) => + ref.read(blendLevelStateProvider.notifier).setBlendLevel(value), + onChangeEnd: (value) => ref + .read(blendLevelStateProvider.notifier) + .setBlendLevel(value, end: true), ), ], ); diff --git a/lib/modules/more/settings/appearance/widgets/theme_selector.dart b/lib/modules/more/settings/appearance/widgets/theme_selector.dart index 3d8f6ad..1b2f2bb 100644 --- a/lib/modules/more/settings/appearance/widgets/theme_selector.dart +++ b/lib/modules/more/settings/appearance/widgets/theme_selector.dart @@ -45,7 +45,9 @@ class _ThemeSelectorState extends ConsumerState { Column( children: [ FlexThemeModeOptionButton( - flexSchemeColor: isLight ? ThemeAA.schemes[index].light : ThemeAA.schemes[index].dark, + flexSchemeColor: isLight + ? ThemeAA.schemes[index].light + : ThemeAA.schemes[index].dark, selected: selected == index, selectedBorder: BorderSide( color: theme.primaryColorLight, @@ -63,11 +65,15 @@ class _ThemeSelectorState extends ConsumerState { }); isLight ? ref - .read(flexSchemeColorStateProvider.notifier) - .setTheme(ThemeAA.schemes[selected].light, selected) + .read( + flexSchemeColorStateProvider.notifier) + .setTheme(ThemeAA.schemes[selected].light, + selected) : ref - .read(flexSchemeColorStateProvider.notifier) - .setTheme(ThemeAA.schemes[selected].dark, selected); + .read( + flexSchemeColorStateProvider.notifier) + .setTheme(ThemeAA.schemes[selected].dark, + selected); }, optionButtonPadding: EdgeInsets.zero, optionButtonMargin: EdgeInsets.zero, @@ -77,7 +83,8 @@ class _ThemeSelectorState extends ConsumerState { ), Text( ThemeAA.schemes[index].name, - style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w300), + style: const TextStyle( + fontSize: 12, fontWeight: FontWeight.w300), ) ], ), diff --git a/lib/modules/more/settings/browse/browse_screen.dart b/lib/modules/more/settings/browse/browse_screen.dart index 11cfb06..fc82c02 100644 --- a/lib/modules/more/settings/browse/browse_screen.dart +++ b/lib/modules/more/settings/browse/browse_screen.dart @@ -9,8 +9,10 @@ class BrowseSScreen extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final onlyIncludePinnedSource = ref.watch(onlyIncludePinnedSourceStateProvider); - final checkForExtensionUpdates = ref.watch(checkForExtensionsUpdateStateProvider); + final onlyIncludePinnedSource = + ref.watch(onlyIncludePinnedSourceStateProvider); + final checkForExtensionUpdates = + ref.watch(checkForExtensionsUpdateStateProvider); final autoUpdateExtensions = ref.watch(autoUpdateExtensionsStateProvider); final l10n = l10nLocalizations(context); return Scaffold( @@ -28,7 +30,9 @@ class BrowseSScreen extends ConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 15), child: Row( children: [ - Text(l10n.extensions, style: TextStyle(fontSize: 13, color: context.primaryColor)), + Text(l10n.extensions, + style: TextStyle( + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -36,16 +40,22 @@ class BrowseSScreen extends ConsumerWidget { value: checkForExtensionUpdates, title: Text(l10n.check_for_extension_updates), onChanged: (value) { - ref.read(checkForExtensionsUpdateStateProvider.notifier).set(value); + ref + .read( + checkForExtensionsUpdateStateProvider.notifier) + .set(value); }), if (checkForExtensionUpdates) SwitchListTile( value: autoUpdateExtensions, title: Text(l10n.auto_extensions_updates), subtitle: Text(l10n.auto_extensions_updates_subtitle, - style: TextStyle(fontSize: 11, color: context.secondaryColor)), + style: TextStyle( + fontSize: 11, color: context.secondaryColor)), onChanged: (value) { - ref.read(autoUpdateExtensionsStateProvider.notifier).set(value); + ref + .read(autoUpdateExtensionsStateProvider.notifier) + .set(value); }), ], ), @@ -58,7 +68,9 @@ class BrowseSScreen extends ConsumerWidget { padding: const EdgeInsets.symmetric(horizontal: 15), child: Row( children: [ - Text(l10n.global_search, style: TextStyle(fontSize: 13, color: context.primaryColor)), + Text(l10n.global_search, + style: TextStyle( + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -66,7 +78,9 @@ class BrowseSScreen extends ConsumerWidget { value: onlyIncludePinnedSource, title: Text(l10n.only_include_pinned_sources), onChanged: (value) { - ref.read(onlyIncludePinnedSourceStateProvider.notifier).set(value); + ref + .read(onlyIncludePinnedSourceStateProvider.notifier) + .set(value); }), ], ), diff --git a/lib/modules/more/settings/browse/providers/browse_state_provider.dart b/lib/modules/more/settings/browse/providers/browse_state_provider.dart index f16593d..de1fdc9 100644 --- a/lib/modules/more/settings/browse/providers/browse_state_provider.dart +++ b/lib/modules/more/settings/browse/providers/browse_state_provider.dart @@ -13,7 +13,8 @@ class OnlyIncludePinnedSourceState extends _$OnlyIncludePinnedSourceState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..onlyIncludePinnedSources = value)); + isar.writeTxnSync(() => + isar.settings.putSync(settings!..onlyIncludePinnedSources = value)); } } @@ -27,7 +28,8 @@ class AutoUpdateExtensionsState extends _$AutoUpdateExtensionsState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..autoExtensionsUpdates = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..autoExtensionsUpdates = value)); } } @@ -41,6 +43,7 @@ class CheckForExtensionsUpdateState extends _$CheckForExtensionsUpdateState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..checkForExtensionUpdates = value)); + isar.writeTxnSync(() => + isar.settings.putSync(settings!..checkForExtensionUpdates = value)); } } diff --git a/lib/modules/more/settings/downloads/downloads_screen.dart b/lib/modules/more/settings/downloads/downloads_screen.dart index f9d8c5d..e94887e 100644 --- a/lib/modules/more/settings/downloads/downloads_screen.dart +++ b/lib/modules/more/settings/downloads/downloads_screen.dart @@ -49,7 +49,10 @@ class _DownloadsScreenState extends ConsumerState { : downloadLocationState.$2, groupValue: downloadLocationState.$1, onChanged: (value) { - ref.read(downloadLocationStateProvider.notifier).set(""); + ref + .read(downloadLocationStateProvider + .notifier) + .set(""); Navigator.pop(context); }, title: Text(downloadLocationState.$1)), @@ -61,10 +64,14 @@ class _DownloadsScreenState extends ConsumerState { : downloadLocationState.$2, groupValue: downloadLocationState.$2, onChanged: (value) async { - String? result = await FilePicker.platform.getDirectoryPath(); + String? result = await FilePicker.platform + .getDirectoryPath(); if (result != null) { - ref.read(downloadLocationStateProvider.notifier).set(result); + ref + .read(downloadLocationStateProvider + .notifier) + .set(result); } else {} if (!context.mounted) return; Navigator.pop(context); @@ -82,7 +89,8 @@ class _DownloadsScreenState extends ConsumerState { }, child: Text( l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), ], ) @@ -92,7 +100,9 @@ class _DownloadsScreenState extends ConsumerState { }, title: Text(l10n.download_location), subtitle: Text( - downloadLocationState.$2.isEmpty ? downloadLocationState.$1 : downloadLocationState.$2, + downloadLocationState.$2.isEmpty + ? downloadLocationState.$1 + : downloadLocationState.$2, style: TextStyle(fontSize: 11, color: context.secondaryColor), ), ), diff --git a/lib/modules/more/settings/downloads/providers/downloads_state_provider.dart b/lib/modules/more/settings/downloads/providers/downloads_state_provider.dart index 3801aca..c376b76 100644 --- a/lib/modules/more/settings/downloads/providers/downloads_state_provider.dart +++ b/lib/modules/more/settings/downloads/providers/downloads_state_provider.dart @@ -16,7 +16,8 @@ class OnlyOnWifiState extends _$OnlyOnWifiState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..downloadOnlyOnWifi = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..downloadOnlyOnWifi = value)); } } @@ -30,7 +31,8 @@ class SaveAsCBZArchiveState extends _$SaveAsCBZArchiveState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..saveAsCBZArchive = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..saveAsCBZArchive = value)); } } @@ -44,7 +46,8 @@ class DownloadLocationState extends _$DownloadLocationState { void set(String location) { final settings = isar.settings.getSync(227); state = (path.join(_storageProvider!.path, 'downloads'), location); - isar.writeTxnSync(() => isar.settings.putSync(settings!..downloadLocation = location)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..downloadLocation = location)); } Directory? _storageProvider; @@ -52,6 +55,9 @@ class DownloadLocationState extends _$DownloadLocationState { Future refresh() async { _storageProvider = await StorageProvider().getDefaultDirectory(); final settings = isar.settings.getSync(227); - state = (path.join(_storageProvider!.path, 'downloads'), settings!.downloadLocation ?? ""); + state = ( + path.join(_storageProvider!.path, 'downloads'), + settings!.downloadLocation ?? "" + ); } } diff --git a/lib/modules/more/settings/general/general_screen.dart b/lib/modules/more/settings/general/general_screen.dart index 3a998da..acd1b33 100644 --- a/lib/modules/more/settings/general/general_screen.dart +++ b/lib/modules/more/settings/general/general_screen.dart @@ -32,19 +32,24 @@ class GeneralScreen extends ConsumerWidget { width: context.width(0.8), child: ListView.builder( shrinkWrap: true, - itemCount: AppLocalizations.supportedLocales.length, + itemCount: + AppLocalizations.supportedLocales.length, itemBuilder: (context, index) { - final locale = AppLocalizations.supportedLocales[index]; + final locale = + AppLocalizations.supportedLocales[index]; return RadioListTile( dense: true, contentPadding: const EdgeInsets.all(0), value: locale, groupValue: l10nLocale, onChanged: (value) { - ref.read(l10nLocaleStateProvider.notifier).setLocale(locale); + ref + .read(l10nLocaleStateProvider.notifier) + .setLocale(locale); Navigator.pop(context); }, - title: Text(completeLanguageName(locale.toLanguageTag())), + title: Text(completeLanguageName( + locale.toLanguageTag())), ); }, )), @@ -58,7 +63,8 @@ class GeneralScreen extends ConsumerWidget { }, child: Text( l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), ], ) diff --git a/lib/modules/more/settings/player/player_screen.dart b/lib/modules/more/settings/player/player_screen.dart index c87f36c..625eb6b 100644 --- a/lib/modules/more/settings/player/player_screen.dart +++ b/lib/modules/more/settings/player/player_screen.dart @@ -11,8 +11,10 @@ class PlayerScreen extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final markEpisodeAsSeenType = ref.watch(markEpisodeAsSeenTypeStateProvider); - final defaultSkipIntroLength = ref.watch(defaultSkipIntroLengthStateProvider); - final defaultDoubleTapToSkipLength = ref.watch(defaultDoubleTapToSkipLengthStateProvider); + final defaultSkipIntroLength = + ref.watch(defaultSkipIntroLengthStateProvider); + final defaultDoubleTapToSkipLength = + ref.watch(defaultDoubleTapToSkipLengthStateProvider); final defaultPlayBackSpeed = ref.watch(defaultPlayBackSpeedStateProvider); final enableAniSkip = ref.watch(enableAniSkipStateProvider); final enableAutoSkip = ref.watch(enableAutoSkipStateProvider); @@ -46,7 +48,10 @@ class PlayerScreen extends ConsumerWidget { value: values[index], groupValue: markEpisodeAsSeenType, onChanged: (value) { - ref.read(markEpisodeAsSeenTypeStateProvider.notifier).set(value!); + ref + .read(markEpisodeAsSeenTypeStateProvider + .notifier) + .set(value!); Navigator.pop(context); }, title: Row( @@ -65,7 +70,8 @@ class PlayerScreen extends ConsumerWidget { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), ], ) @@ -100,7 +106,8 @@ class PlayerScreen extends ConsumerWidget { step: 1, haptics: true, textMapper: (numberText) => "${numberText}s", - onChanged: (value) => setState(() => currentIntValue = value), + onChanged: (value) => + setState(() => currentIntValue = value), ), ], ), @@ -116,16 +123,22 @@ class PlayerScreen extends ConsumerWidget { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), TextButton( onPressed: () async { - ref.read(defaultSkipIntroLengthStateProvider.notifier).set(currentIntValue); + ref + .read( + defaultSkipIntroLengthStateProvider + .notifier) + .set(currentIntValue); Navigator.pop(context); }, child: Text( context.l10n.ok, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), ], ) @@ -146,7 +159,8 @@ class PlayerScreen extends ConsumerWidget { context: context, builder: (context) { return AlertDialog( - title: Text(context.l10n.default_skip_forward_skip_length), + title: + Text(context.l10n.default_skip_forward_skip_length), content: SizedBox( width: context.width(0.8), child: ListView.builder( @@ -159,7 +173,11 @@ class PlayerScreen extends ConsumerWidget { value: values[index], groupValue: defaultDoubleTapToSkipLength, onChanged: (value) { - ref.read(defaultDoubleTapToSkipLengthStateProvider.notifier).set(value!); + ref + .read( + defaultDoubleTapToSkipLengthStateProvider + .notifier) + .set(value!); Navigator.pop(context); }, title: Row( @@ -178,7 +196,8 @@ class PlayerScreen extends ConsumerWidget { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), ], ) @@ -212,7 +231,10 @@ class PlayerScreen extends ConsumerWidget { value: values[index], groupValue: defaultPlayBackSpeed, onChanged: (value) { - ref.read(defaultPlayBackSpeedStateProvider.notifier).set(value!); + ref + .read(defaultPlayBackSpeedStateProvider + .notifier) + .set(value!); Navigator.pop(context); }, title: Row( @@ -231,7 +253,8 @@ class PlayerScreen extends ConsumerWidget { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), ], ) @@ -258,13 +281,15 @@ class PlayerScreen extends ConsumerWidget { ), ), subtitle: Text(context.l10n.aniskip_requires_info, - style: TextStyle(fontSize: 11, color: context.secondaryColor)), + style: + TextStyle(fontSize: 11, color: context.secondaryColor)), ), SwitchListTile( value: useLibass, title: Text(context.l10n.use_libass), - subtitle: - Text(context.l10n.use_libass_info, style: TextStyle(fontSize: 11, color: context.secondaryColor)), + subtitle: Text(context.l10n.use_libass_info, + style: + TextStyle(fontSize: 11, color: context.secondaryColor)), onChanged: (value) { ref.read(useLibassStateProvider.notifier).set(value); }), @@ -277,7 +302,8 @@ class PlayerScreen extends ConsumerWidget { onChanged: (_) {}, ), ), - onExpansionChanged: (value) => ref.read(enableAniSkipStateProvider.notifier).set(value), + onExpansionChanged: (value) => + ref.read(enableAniSkipStateProvider.notifier).set(value), children: [ SwitchListTile( value: enableAutoSkip, @@ -292,7 +318,8 @@ class PlayerScreen extends ConsumerWidget { context: context, builder: (context) { return AlertDialog( - title: Text(context.l10n.default_playback_speed_length), + title: Text( + context.l10n.default_playback_speed_length), content: SizedBox( width: context.width(0.8), child: ListView.builder( @@ -305,7 +332,11 @@ class PlayerScreen extends ConsumerWidget { value: values[index], groupValue: aniSkipTimeoutLength, onChanged: (value) { - ref.read(aniSkipTimeoutLengthStateProvider.notifier).set(value!); + ref + .read( + aniSkipTimeoutLengthStateProvider + .notifier) + .set(value!); Navigator.pop(context); }, title: Row( @@ -324,7 +355,8 @@ class PlayerScreen extends ConsumerWidget { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: TextStyle( + color: context.primaryColor), )), ], ) @@ -335,7 +367,8 @@ class PlayerScreen extends ConsumerWidget { title: Text(context.l10n.aniskip_button_timeout), subtitle: Text( "${aniSkipTimeoutLength}s", - style: TextStyle(fontSize: 11, color: context.secondaryColor), + style: + TextStyle(fontSize: 11, color: context.secondaryColor), ), ), ], @@ -344,7 +377,8 @@ class PlayerScreen extends ConsumerWidget { value: fullScreenPlayer, title: Text(context.l10n.full_screen_player), subtitle: Text(context.l10n.full_screen_player_info, - style: TextStyle(fontSize: 11, color: context.secondaryColor)), + style: + TextStyle(fontSize: 11, color: context.secondaryColor)), onChanged: (value) { ref.read(fullScreenPlayerStateProvider.notifier).set(value); }), diff --git a/lib/modules/more/settings/player/providers/player_state_provider.dart b/lib/modules/more/settings/player/providers/player_state_provider.dart index 1ebf1cf..858d99d 100644 --- a/lib/modules/more/settings/player/providers/player_state_provider.dart +++ b/lib/modules/more/settings/player/providers/player_state_provider.dart @@ -13,7 +13,8 @@ class MarkEpisodeAsSeenTypeState extends _$MarkEpisodeAsSeenTypeState { void set(int value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..markEpisodeAsSeenType = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..markEpisodeAsSeenType = value)); } } @@ -27,12 +28,14 @@ class DefaultSkipIntroLengthState extends _$DefaultSkipIntroLengthState { void set(int value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..defaultSkipIntroLength = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..defaultSkipIntroLength = value)); } } @riverpod -class DefaultDoubleTapToSkipLengthState extends _$DefaultDoubleTapToSkipLengthState { +class DefaultDoubleTapToSkipLengthState + extends _$DefaultDoubleTapToSkipLengthState { @override int build() { return isar.settings.getSync(227)!.defaultDoubleTapToSkipLength ?? 10; @@ -41,7 +44,8 @@ class DefaultDoubleTapToSkipLengthState extends _$DefaultDoubleTapToSkipLengthSt void set(int value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..defaultDoubleTapToSkipLength = value)); + isar.writeTxnSync(() => + isar.settings.putSync(settings!..defaultDoubleTapToSkipLength = value)); } } @@ -55,7 +59,8 @@ class DefaultPlayBackSpeedState extends _$DefaultPlayBackSpeedState { void set(double value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..defaultPlayBackSpeed = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..defaultPlayBackSpeed = value)); } } @@ -69,7 +74,8 @@ class FullScreenPlayerState extends _$FullScreenPlayerState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..fullScreenPlayer = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..fullScreenPlayer = value)); } } @@ -83,7 +89,8 @@ class EnableAniSkipState extends _$EnableAniSkipState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..enableAniSkip = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..enableAniSkip = value)); } } @@ -97,7 +104,8 @@ class EnableAutoSkipState extends _$EnableAutoSkipState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..enableAutoSkip = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..enableAutoSkip = value)); } } @@ -111,7 +119,8 @@ class AniSkipTimeoutLengthState extends _$AniSkipTimeoutLengthState { void set(int value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..aniSkipTimeoutLength = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..aniSkipTimeoutLength = value)); } } @@ -125,6 +134,7 @@ class UseLibassState extends _$UseLibassState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..useLibass = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..useLibass = value)); } } diff --git a/lib/modules/more/settings/reader/providers/reader_state_provider.dart b/lib/modules/more/settings/reader/providers/reader_state_provider.dart index 060e50f..8f3dbcd 100644 --- a/lib/modules/more/settings/reader/providers/reader_state_provider.dart +++ b/lib/modules/more/settings/reader/providers/reader_state_provider.dart @@ -13,7 +13,8 @@ class DefaultReadingModeState extends _$DefaultReadingModeState { void set(ReaderMode value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..defaultReaderMode = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..defaultReaderMode = value)); } } @@ -27,7 +28,8 @@ class AnimatePageTransitionsState extends _$AnimatePageTransitionsState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..animatePageTransitions = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..animatePageTransitions = value)); } } @@ -41,7 +43,8 @@ class DoubleTapAnimationSpeedState extends _$DoubleTapAnimationSpeedState { void set(int value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..doubleTapAnimationSpeed = value)); + isar.writeTxnSync(() => + isar.settings.putSync(settings!..doubleTapAnimationSpeed = value)); } } @@ -55,7 +58,8 @@ class CropBordersState extends _$CropBordersState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..cropBorders = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..cropBorders = value)); } } @@ -69,7 +73,8 @@ class ScaleTypeState extends _$ScaleTypeState { void set(ScaleType value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..scaleType = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..scaleType = value)); } } @@ -83,7 +88,8 @@ class PagePreloadAmountState extends _$PagePreloadAmountState { void set(int value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..pagePreloadAmount = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..pagePreloadAmount = value)); } } @@ -97,7 +103,8 @@ class BackgroundColorState extends _$BackgroundColorState { void set(BackgroundColor value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..backgroundColor = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..backgroundColor = value)); } } @@ -111,7 +118,8 @@ class UsePageTapZonesState extends _$UsePageTapZonesState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..usePageTapZones = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..usePageTapZones = value)); } } @@ -125,6 +133,7 @@ class FullScreenReaderState extends _$FullScreenReaderState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..fullScreenReader = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..fullScreenReader = value)); } } diff --git a/lib/modules/more/settings/reader/reader_screen.dart b/lib/modules/more/settings/reader/reader_screen.dart index 8f6599a..f7a1a6d 100644 --- a/lib/modules/more/settings/reader/reader_screen.dart +++ b/lib/modules/more/settings/reader/reader_screen.dart @@ -11,8 +11,10 @@ class ReaderScreen extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final defaultReadingMode = ref.watch(defaultReadingModeStateProvider); - final animatePageTransitions = ref.watch(animatePageTransitionsStateProvider); - final doubleTapAnimationSpeed = ref.watch(doubleTapAnimationSpeedStateProvider); + final animatePageTransitions = + ref.watch(animatePageTransitionsStateProvider); + final doubleTapAnimationSpeed = + ref.watch(doubleTapAnimationSpeedStateProvider); final pagePreloadAmount = ref.watch(pagePreloadAmountStateProvider); final scaleType = ref.watch(scaleTypeStateProvider); final backgroundColor = ref.watch(backgroundColorStateProvider); @@ -45,11 +47,17 @@ class ReaderScreen extends ConsumerWidget { value: ReaderMode.values[index], groupValue: defaultReadingMode, onChanged: (value) { - ref.read(defaultReadingModeStateProvider.notifier).set(value!); + ref + .read(defaultReadingModeStateProvider + .notifier) + .set(value!); Navigator.pop(context); }, title: Row( - children: [Text(getReaderModeName(ReaderMode.values[index], context))], + children: [ + Text(getReaderModeName( + ReaderMode.values[index], context)) + ], ), ); }, @@ -64,7 +72,8 @@ class ReaderScreen extends ConsumerWidget { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), ], ) @@ -99,11 +108,18 @@ class ReaderScreen extends ConsumerWidget { value: index, groupValue: doubleTapAnimationSpeed, onChanged: (value) { - ref.read(doubleTapAnimationSpeedStateProvider.notifier).set(value!); + ref + .read( + doubleTapAnimationSpeedStateProvider + .notifier) + .set(value!); Navigator.pop(context); }, title: Row( - children: [Text(getAnimationSpeedName(index, context))], + children: [ + Text( + getAnimationSpeedName(index, context)) + ], ), ); }, @@ -118,7 +134,8 @@ class ReaderScreen extends ConsumerWidget { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), ], ) @@ -151,11 +168,18 @@ class ReaderScreen extends ConsumerWidget { value: BackgroundColor.values[index], groupValue: backgroundColor, onChanged: (value) { - ref.read(backgroundColorStateProvider.notifier).set(value!); + ref + .read(backgroundColorStateProvider + .notifier) + .set(value!); Navigator.pop(context); }, title: Row( - children: [Text(getBackgroundColorName(BackgroundColor.values[index], context))], + children: [ + Text(getBackgroundColorName( + BackgroundColor.values[index], + context)) + ], ), ); }, @@ -170,7 +194,8 @@ class ReaderScreen extends ConsumerWidget { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), ], ) @@ -206,7 +231,10 @@ class ReaderScreen extends ConsumerWidget { value: numbers[index], groupValue: pagePreloadAmount, onChanged: (value) { - ref.read(pagePreloadAmountStateProvider.notifier).set(value!); + ref + .read(pagePreloadAmountStateProvider + .notifier) + .set(value!); Navigator.pop(context); }, title: Row( @@ -225,7 +253,8 @@ class ReaderScreen extends ConsumerWidget { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), ], ) @@ -260,11 +289,16 @@ class ReaderScreen extends ConsumerWidget { value: index, groupValue: scaleType.index, onChanged: (value) { - ref.read(scaleTypeStateProvider.notifier).set(ScaleType.values[value!]); + ref + .read(scaleTypeStateProvider.notifier) + .set(ScaleType.values[value!]); Navigator.pop(context); }, title: Row( - children: [Text(getScaleTypeNames(context)[index].toString())], + children: [ + Text(getScaleTypeNames(context)[index] + .toString()) + ], ), ); }, @@ -279,7 +313,8 @@ class ReaderScreen extends ConsumerWidget { }, child: Text( context.l10n.cancel, - style: TextStyle(color: context.primaryColor), + style: + TextStyle(color: context.primaryColor), )), ], ) @@ -303,7 +338,9 @@ class ReaderScreen extends ConsumerWidget { value: animatePageTransitions, title: Text(context.l10n.animate_page_transitions), onChanged: (value) { - ref.read(animatePageTransitionsStateProvider.notifier).set(value); + ref + .read(animatePageTransitionsStateProvider.notifier) + .set(value); }), SwitchListTile( value: cropBorders, @@ -327,7 +364,8 @@ class ReaderScreen extends ConsumerWidget { String getReaderModeName(ReaderMode readerMode, BuildContext context) { return switch (readerMode) { ReaderMode.vertical => context.l10n.reading_mode_vertical, - ReaderMode.verticalContinuous => context.l10n.reading_mode_vertical_continuous, + ReaderMode.verticalContinuous => + context.l10n.reading_mode_vertical_continuous, ReaderMode.ltr => context.l10n.reading_mode_left_to_right, ReaderMode.rtl => context.l10n.reading_mode_right_to_left, ReaderMode.horizontalContinuous => context.l10n.horizontal_continious, @@ -335,7 +373,8 @@ String getReaderModeName(ReaderMode readerMode, BuildContext context) { }; } -String getBackgroundColorName(BackgroundColor backgroundColor, BuildContext context) { +String getBackgroundColorName( + BackgroundColor backgroundColor, BuildContext context) { return switch (backgroundColor) { BackgroundColor.white => context.l10n.white, BackgroundColor.grey => context.l10n.grey, @@ -353,7 +392,8 @@ Color? getBackgroundColor(BackgroundColor backgroundColor) { }; } -String getColorFilterBlendModeName(ColorFilterBlendMode backgroundColor, BuildContext context) { +String getColorFilterBlendModeName( + ColorFilterBlendMode backgroundColor, BuildContext context) { return switch (backgroundColor) { ColorFilterBlendMode.none => context.l10n.blend_mode_default, ColorFilterBlendMode.multiply => context.l10n.blend_mode_multiply, @@ -371,7 +411,8 @@ String getColorFilterBlendModeName(ColorFilterBlendMode backgroundColor, BuildCo }; } -BlendMode? getColorFilterBlendMode(ColorFilterBlendMode backgroundColor, BuildContext context) { +BlendMode? getColorFilterBlendMode( + ColorFilterBlendMode backgroundColor, BuildContext context) { return switch (backgroundColor) { ColorFilterBlendMode.none => null, ColorFilterBlendMode.multiply => BlendMode.multiply, diff --git a/lib/modules/more/settings/settings_screen.dart b/lib/modules/more/settings/settings_screen.dart index e5cbc6b..4bf95c0 100644 --- a/lib/modules/more/settings/settings_screen.dart +++ b/lib/modules/more/settings/settings_screen.dart @@ -37,7 +37,10 @@ class SettingsScreen extends StatelessWidget { icon: Icons.download_outlined, onTap: () => context.push('/downloads')), ListTileWidget( - title: l10n.tracking, subtitle: "", icon: Icons.sync_outlined, onTap: () => context.push('/track')), + title: l10n.tracking, + subtitle: "", + icon: Icons.sync_outlined, + onTap: () => context.push('/track')), ListTileWidget( title: l10n.syncing, subtitle: l10n.syncing_subtitle, diff --git a/lib/modules/more/settings/sync/providers/sync_providers.dart b/lib/modules/more/settings/sync/providers/sync_providers.dart index 1f9ec5d..67dc75c 100644 --- a/lib/modules/more/settings/sync/providers/sync_providers.dart +++ b/lib/modules/more/settings/sync/providers/sync_providers.dart @@ -14,7 +14,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; part 'sync_providers.g.dart'; @riverpod -void addUpdatedChapterIndependent(Ref ref, Chapter chapter, bool deleted, bool txn) { +void addUpdatedChapterIndependent( + Ref ref, Chapter chapter, bool deleted, bool txn) { final changedItems = isar.changedItems.getSync(1) ?? ChangedItems(); bool updated = false; changedItems.updatedChapters = changedItems.updatedChapters?.map((e) { @@ -34,7 +35,8 @@ void addUpdatedChapterIndependent(Ref ref, Chapter chapter, bool deleted, bool t isRead: chapter.isRead, lastPageRead: chapter.lastPageRead, deleted: deleted); - changedItems.updatedChapters = changedItems.updatedChapters?.toList()?..add(updatedChapter); + changedItems.updatedChapters = changedItems.updatedChapters?.toList() + ?..add(updatedChapter); } if (!txn) { isar.changedItems.putSync(changedItems); @@ -58,7 +60,8 @@ class ChangedItemsManager extends _$ChangedItemsManager { } void cleanChangedItems(bool txn) { - final changedItems = isar.changedItems.getSync(managerId!) ?? ChangedItems(id: managerId); + final changedItems = + isar.changedItems.getSync(managerId!) ?? ChangedItems(id: managerId); changedItems.deletedMangas = []; changedItems.updatedChapters = []; changedItems.deletedCategories = []; @@ -72,11 +75,13 @@ class ChangedItemsManager extends _$ChangedItemsManager { } void addDeletedManga(Manga manga, bool txn) { - final changedItems = isar.changedItems.getSync(managerId!) ?? ChangedItems(id: managerId); + final changedItems = + isar.changedItems.getSync(managerId!) ?? ChangedItems(id: managerId); log("DEBUG"); log(jsonEncode(changedItems)); final deletedManga = DeletedManga(mangaId: manga.id); - changedItems.deletedMangas = changedItems.deletedMangas?.toList()?..add(deletedManga); + changedItems.deletedMangas = changedItems.deletedMangas?.toList() + ?..add(deletedManga); if (!txn) { isar.changedItems.putSync(changedItems); } else { @@ -87,9 +92,11 @@ class ChangedItemsManager extends _$ChangedItemsManager { } Future addDeletedMangaAsync(Manga manga, bool txn) async { - final changedItems = await isar.changedItems.get(managerId!) ?? ChangedItems(id: managerId); + final changedItems = + await isar.changedItems.get(managerId!) ?? ChangedItems(id: managerId); final deletedManga = DeletedManga(mangaId: manga.id); - changedItems.deletedMangas = changedItems.deletedMangas?.toList()?..add(deletedManga); + changedItems.deletedMangas = changedItems.deletedMangas?.toList() + ?..add(deletedManga); if (!txn) { await isar.changedItems.put(changedItems); } else { @@ -100,7 +107,8 @@ class ChangedItemsManager extends _$ChangedItemsManager { } void addUpdatedChapter(Chapter chapter, bool deleted, bool txn) { - final changedItems = isar.changedItems.getSync(managerId!) ?? ChangedItems(id: managerId); + final changedItems = + isar.changedItems.getSync(managerId!) ?? ChangedItems(id: managerId); bool updated = false; changedItems.updatedChapters = changedItems.updatedChapters?.map((e) { if (e.chapterId == chapter.id && e.mangaId == chapter.mangaId) { @@ -120,7 +128,8 @@ class ChangedItemsManager extends _$ChangedItemsManager { isRead: chapter.isRead, lastPageRead: chapter.lastPageRead, deleted: deleted); - changedItems.updatedChapters = changedItems.updatedChapters?.toList()?..add(updatedChapter); + changedItems.updatedChapters = changedItems.updatedChapters?.toList() + ?..add(updatedChapter); } if (!txn) { isar.changedItems.putSync(changedItems); @@ -132,7 +141,8 @@ class ChangedItemsManager extends _$ChangedItemsManager { } Future addUpdatedChapterAsync(Chapter chapter, bool deleted, bool txn) async { - final changedItems = await isar.changedItems.get(managerId!) ?? ChangedItems(id: managerId); + final changedItems = + await isar.changedItems.get(managerId!) ?? ChangedItems(id: managerId); bool updated = false; changedItems.updatedChapters = changedItems.updatedChapters?.map((e) { if (e.chapterId == chapter.id && e.mangaId == chapter.mangaId) { @@ -152,7 +162,8 @@ class ChangedItemsManager extends _$ChangedItemsManager { isRead: chapter.isRead, lastPageRead: chapter.lastPageRead, deleted: deleted); - changedItems.updatedChapters = changedItems.updatedChapters?.toList()?..add(updatedChapter); + changedItems.updatedChapters = changedItems.updatedChapters?.toList() + ?..add(updatedChapter); } if (!txn) { await isar.changedItems.put(changedItems); @@ -164,9 +175,11 @@ class ChangedItemsManager extends _$ChangedItemsManager { } void addDeletedCategory(Category category, bool txn) { - final changedItems = isar.changedItems.getSync(managerId!) ?? ChangedItems(id: managerId); + final changedItems = + isar.changedItems.getSync(managerId!) ?? ChangedItems(id: managerId); final deletedCategory = DeletedCategory(categoryId: category.id); - changedItems.deletedCategories = changedItems.deletedCategories?.toList()?..add(deletedCategory); + changedItems.deletedCategories = changedItems.deletedCategories?.toList() + ?..add(deletedCategory); if (!txn) { isar.changedItems.putSync(changedItems); } else { @@ -177,9 +190,11 @@ class ChangedItemsManager extends _$ChangedItemsManager { } Future addDeletedCategoryAsync(Category category, bool txn) async { - final changedItems = await isar.changedItems.get(managerId!) ?? ChangedItems(id: managerId); + final changedItems = + await isar.changedItems.get(managerId!) ?? ChangedItems(id: managerId); final deletedCategory = DeletedCategory(categoryId: category.id); - changedItems.deletedCategories = changedItems.deletedCategories?.toList()?..add(deletedCategory); + changedItems.deletedCategories = changedItems.deletedCategories?.toList() + ?..add(deletedCategory); if (!txn) { await isar.changedItems.put(changedItems); } else { @@ -211,25 +226,29 @@ class Synching extends _$Synching { void setLastSync(int timestamp) { isar.writeTxnSync(() { - isar.syncPreferences.putSync(isar.syncPreferences.getSync(syncId!)!..lastSync = timestamp); + isar.syncPreferences.putSync( + isar.syncPreferences.getSync(syncId!)!..lastSync = timestamp); }); } void setLastUpload(int timestamp) { isar.writeTxnSync(() { - isar.syncPreferences.putSync(isar.syncPreferences.getSync(syncId!)!..lastUpload = timestamp); + isar.syncPreferences.putSync( + isar.syncPreferences.getSync(syncId!)!..lastUpload = timestamp); }); } void setLastDownload(int timestamp) { isar.writeTxnSync(() { - isar.syncPreferences.putSync(isar.syncPreferences.getSync(syncId!)!..lastDownload = timestamp); + isar.syncPreferences.putSync( + isar.syncPreferences.getSync(syncId!)!..lastDownload = timestamp); }); } void setServer(String? server) { isar.writeTxnSync(() { - isar.syncPreferences.putSync(isar.syncPreferences.getSync(syncId!)!..server = server); + isar.syncPreferences + .putSync(isar.syncPreferences.getSync(syncId!)!..server = server); }); } } @@ -244,7 +263,8 @@ class SyncOnAppLaunchState extends _$SyncOnAppLaunchState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..syncOnAppLaunch = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..syncOnAppLaunch = value)); } } @@ -258,6 +278,7 @@ class SyncAfterReadingState extends _$SyncAfterReadingState { void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..syncAfterReading = value)); + isar.writeTxnSync( + () => isar.settings.putSync(settings!..syncAfterReading = value)); } } diff --git a/lib/modules/more/settings/sync/sync.dart b/lib/modules/more/settings/sync/sync.dart index c74ff40..ad41286 100644 --- a/lib/modules/more/settings/sync/sync.dart +++ b/lib/modules/more/settings/sync/sync.dart @@ -24,11 +24,16 @@ class SyncScreen extends ConsumerWidget { ), body: SingleChildScrollView( child: StreamBuilder( - stream: isar.syncPreferences.filter().syncIdIsNotNull().watch(fireImmediately: true), + stream: isar.syncPreferences + .filter() + .syncIdIsNotNull() + .watch(fireImmediately: true), builder: (context, snapshot) { - SyncPreference syncPreference = - snapshot.data?.isNotEmpty ?? false ? snapshot.data?.first ?? SyncPreference() : SyncPreference(); - final bool isLogged = syncPreference.authToken?.isNotEmpty ?? false; + SyncPreference syncPreference = snapshot.data?.isNotEmpty ?? false + ? snapshot.data?.first ?? SyncPreference() + : SyncPreference(); + final bool isLogged = + syncPreference.authToken?.isNotEmpty ?? false; return Column( children: [ SwitchListTile( @@ -37,7 +42,9 @@ class SyncScreen extends ConsumerWidget { onChanged: !isLogged ? null : (value) { - ref.read(syncAfterReadingStateProvider.notifier).set(value); + ref + .read(syncAfterReadingStateProvider.notifier) + .set(value); }), SwitchListTile( value: syncOnAppLaunch, @@ -45,13 +52,18 @@ class SyncScreen extends ConsumerWidget { onChanged: !isLogged ? null : (value) { - ref.read(syncOnAppLaunchStateProvider.notifier).set(value); + ref + .read(syncOnAppLaunchStateProvider.notifier) + .set(value); }), Padding( - padding: const EdgeInsets.only(left: 15, right: 15, bottom: 10, top: 5), + padding: const EdgeInsets.only( + left: 15, right: 15, bottom: 10, top: 5), child: Row( children: [ - Text(l10n.services, style: TextStyle(fontSize: 13, color: context.primaryColor)), + Text(l10n.services, + style: TextStyle( + fontSize: 13, color: context.primaryColor)), ], ), ), @@ -72,7 +84,9 @@ class SyncScreen extends ConsumerWidget { color: context.secondaryColor, ), const SizedBox(width: 10), - Text(l10n.syncing_subtitle, style: TextStyle(fontSize: 11, color: context.secondaryColor)) + Text(l10n.syncing_subtitle, + style: TextStyle( + fontSize: 11, color: context.secondaryColor)) ], ), ), @@ -91,15 +105,21 @@ class SyncScreen extends ConsumerWidget { const SizedBox(width: 20), Text( "${l10n.last_sync}: ${dateFormat((syncPreference.lastSync ?? 0).toString(), ref: ref, context: context)} ${dateFormatHour((syncPreference.lastSync ?? 0).toString(), context)}", - style: TextStyle(fontSize: 11, color: context.secondaryColor)), + style: TextStyle( + fontSize: 11, + color: context.secondaryColor)), const SizedBox(width: 20), Text( "${l10n.last_upload}: ${dateFormat((syncPreference.lastUpload ?? 0).toString(), ref: ref, context: context)} ${dateFormatHour((syncPreference.lastUpload ?? 0).toString(), context)}", - style: TextStyle(fontSize: 11, color: context.secondaryColor)), + style: TextStyle( + fontSize: 11, + color: context.secondaryColor)), const SizedBox(width: 20), Text( "${l10n.last_download}: ${dateFormat((syncPreference.lastDownload ?? 0).toString(), ref: ref, context: context)} ${dateFormatHour((syncPreference.lastDownload ?? 0).toString(), context)}", - style: TextStyle(fontSize: 11, color: context.secondaryColor)), + style: TextStyle( + fontSize: 11, + color: context.secondaryColor)), ]), ], ), @@ -114,11 +134,16 @@ class SyncScreen extends ConsumerWidget { onPressed: !isLogged ? null : () { - ref.read(syncServerProvider(syncId: 1).notifier).checkForSync(false); + ref + .read(syncServerProvider(syncId: 1) + .notifier) + .checkForSync(false); }, icon: Icon( Icons.sync, - color: !isLogged ? context.secondaryColor : context.primaryColor, + color: !isLogged + ? context.secondaryColor + : context.primaryColor, )), Text(l10n.sync_button_sync), ], @@ -134,39 +159,67 @@ class SyncScreen extends ConsumerWidget { context: context, builder: (context) { return AlertDialog( - title: Text(l10n.sync_confirm_upload), + title: Text( + l10n.sync_confirm_upload), actions: [ Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.end, children: [ ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: Colors.transparent, - shadowColor: Colors.transparent, - surfaceTintColor: Colors.transparent, + backgroundColor: + Colors + .transparent, + shadowColor: Colors + .transparent, + surfaceTintColor: + Colors + .transparent, shape: RoundedRectangleBorder( - side: BorderSide(color: context.secondaryColor), - borderRadius: BorderRadius.circular(20))), + side: BorderSide( + color: context + .secondaryColor), + borderRadius: + BorderRadius + .circular( + 20))), onPressed: () { - Navigator.pop(context); + Navigator.pop( + context); }, child: Text( l10n.cancel, - style: TextStyle(color: context.secondaryColor), + style: TextStyle( + color: context + .secondaryColor), )), const SizedBox(width: 15), ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red.withValues(alpha: 0.7)), + style: ElevatedButton + .styleFrom( + backgroundColor: Colors + .red + .withValues( + alpha: + 0.7)), onPressed: () { ref - .read(syncServerProvider(syncId: 1).notifier) - .uploadToServer(l10n); - Navigator.pop(context); + .read( + syncServerProvider( + syncId: + 1) + .notifier) + .uploadToServer( + l10n); + Navigator.pop( + context); }, child: Text( l10n.dialog_confirm, - style: TextStyle(color: context.secondaryColor), + style: TextStyle( + color: context + .secondaryColor), )), ], ) @@ -176,7 +229,9 @@ class SyncScreen extends ConsumerWidget { }, icon: Icon( Icons.cloud_upload_outlined, - color: !isLogged ? context.secondaryColor : context.primaryColor, + color: !isLogged + ? context.secondaryColor + : context.primaryColor, )), Text(l10n.sync_button_upload), ], @@ -192,39 +247,67 @@ class SyncScreen extends ConsumerWidget { context: context, builder: (context) { return AlertDialog( - title: Text(l10n.sync_confirm_download), + title: Text( + l10n.sync_confirm_download), actions: [ Row( - mainAxisAlignment: MainAxisAlignment.end, + mainAxisAlignment: + MainAxisAlignment.end, children: [ ElevatedButton( style: ElevatedButton.styleFrom( - backgroundColor: Colors.transparent, - shadowColor: Colors.transparent, - surfaceTintColor: Colors.transparent, + backgroundColor: + Colors + .transparent, + shadowColor: Colors + .transparent, + surfaceTintColor: + Colors + .transparent, shape: RoundedRectangleBorder( - side: BorderSide(color: context.secondaryColor), - borderRadius: BorderRadius.circular(20))), + side: BorderSide( + color: context + .secondaryColor), + borderRadius: + BorderRadius + .circular( + 20))), onPressed: () { - Navigator.pop(context); + Navigator.pop( + context); }, child: Text( l10n.cancel, - style: TextStyle(color: context.secondaryColor), + style: TextStyle( + color: context + .secondaryColor), )), const SizedBox(width: 15), ElevatedButton( - style: ElevatedButton.styleFrom( - backgroundColor: Colors.red.withValues(alpha: 0.7)), + style: ElevatedButton + .styleFrom( + backgroundColor: Colors + .red + .withValues( + alpha: + 0.7)), onPressed: () { ref - .read(syncServerProvider(syncId: 1).notifier) - .downloadFromServer(l10n); - Navigator.pop(context); + .read( + syncServerProvider( + syncId: + 1) + .notifier) + .downloadFromServer( + l10n); + Navigator.pop( + context); }, child: Text( l10n.dialog_confirm, - style: TextStyle(color: context.secondaryColor), + style: TextStyle( + color: context + .secondaryColor), )), ], ) @@ -234,7 +317,9 @@ class SyncScreen extends ConsumerWidget { }, icon: Icon( Icons.cloud_download_outlined, - color: !isLogged ? context.secondaryColor : context.primaryColor, + color: !isLogged + ? context.secondaryColor + : context.primaryColor, )), Text(l10n.sync_button_download), ], @@ -288,11 +373,14 @@ void _showDialogLogin(BuildContext context, WidgetRef ref) { filled: false, contentPadding: const EdgeInsets.all(12), enabledBorder: OutlineInputBorder( - borderSide: const BorderSide(width: 0.4), borderRadius: BorderRadius.circular(5)), - focusedBorder: - OutlineInputBorder(borderSide: const BorderSide(), borderRadius: BorderRadius.circular(5)), + borderSide: const BorderSide(width: 0.4), + borderRadius: BorderRadius.circular(5)), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide(), + borderRadius: BorderRadius.circular(5)), border: OutlineInputBorder( - borderRadius: BorderRadius.circular(5), borderSide: const BorderSide()))), + borderRadius: BorderRadius.circular(5), + borderSide: const BorderSide()))), ), const SizedBox(height: 10), Padding( @@ -308,11 +396,14 @@ void _showDialogLogin(BuildContext context, WidgetRef ref) { filled: false, contentPadding: const EdgeInsets.all(12), enabledBorder: OutlineInputBorder( - borderSide: const BorderSide(width: 0.4), borderRadius: BorderRadius.circular(5)), - focusedBorder: - OutlineInputBorder(borderSide: const BorderSide(), borderRadius: BorderRadius.circular(5)), + borderSide: const BorderSide(width: 0.4), + borderRadius: BorderRadius.circular(5)), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide(), + borderRadius: BorderRadius.circular(5)), border: OutlineInputBorder( - borderRadius: BorderRadius.circular(5), borderSide: const BorderSide()))), + borderRadius: BorderRadius.circular(5), + borderSide: const BorderSide()))), ), const SizedBox(height: 10), Padding( @@ -329,15 +420,20 @@ void _showDialogLogin(BuildContext context, WidgetRef ref) { onPressed: () => setState(() { obscureText = !obscureText; }), - icon: Icon(obscureText ? Icons.visibility_outlined : Icons.visibility_off_outlined)), + icon: Icon(obscureText + ? Icons.visibility_outlined + : Icons.visibility_off_outlined)), filled: false, contentPadding: const EdgeInsets.all(12), enabledBorder: OutlineInputBorder( - borderSide: const BorderSide(width: 0.4), borderRadius: BorderRadius.circular(5)), - focusedBorder: - OutlineInputBorder(borderSide: const BorderSide(), borderRadius: BorderRadius.circular(5)), + borderSide: const BorderSide(width: 0.4), + borderRadius: BorderRadius.circular(5)), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide(), + borderRadius: BorderRadius.circular(5)), border: OutlineInputBorder( - borderRadius: BorderRadius.circular(5), borderSide: const BorderSide()))), + borderRadius: BorderRadius.circular(5), + borderSide: const BorderSide()))), ), const SizedBox(height: 10), Text(errorMessage, style: const TextStyle(color: Colors.red)), @@ -355,7 +451,8 @@ void _showDialogLogin(BuildContext context, WidgetRef ref) { isLoading = true; }); final res = await ref - .read(syncServerProvider(syncId: 1).notifier) + .read( + syncServerProvider(syncId: 1).notifier) .login(l10n, server, email, password); if (!res.$1) { setState(() { @@ -368,7 +465,9 @@ void _showDialogLogin(BuildContext context, WidgetRef ref) { } } }, - child: isLoading ? const CircularProgressIndicator() : Text(l10n.login))), + child: isLoading + ? const CircularProgressIndicator() + : Text(l10n.login))), ) ], ), diff --git a/lib/modules/more/settings/sync/widgets/sync_listile.dart b/lib/modules/more/settings/sync/widgets/sync_listile.dart index ed76b86..96cf7e7 100644 --- a/lib/modules/more/settings/sync/widgets/sync_listile.dart +++ b/lib/modules/more/settings/sync/widgets/sync_listile.dart @@ -10,7 +10,12 @@ class SyncListile extends ConsumerWidget { final int id; final SyncPreference preference; final String? text; - const SyncListile({super.key, required this.onTap, required this.id, required this.preference, this.text}); + const SyncListile( + {super.key, + required this.onTap, + required this.id, + required this.preference, + this.text}); @override Widget build(BuildContext context, WidgetRef ref) { @@ -21,8 +26,9 @@ class SyncListile extends ConsumerWidget { child: ListTile( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), leading: Container( - decoration: - BoxDecoration(borderRadius: BorderRadius.circular(10), color: const Color.fromRGBO(18, 25, 35, 1)), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: const Color.fromRGBO(18, 25, 35, 1)), width: 60, height: 70, child: const Icon( @@ -55,25 +61,34 @@ class SyncListile extends ConsumerWidget { shadowColor: Colors.transparent, surfaceTintColor: Colors.transparent, shape: RoundedRectangleBorder( - side: BorderSide(color: context.secondaryColor), - borderRadius: BorderRadius.circular(20))), + side: BorderSide( + color: context.secondaryColor), + borderRadius: + BorderRadius.circular(20))), onPressed: () { Navigator.pop(context); }, child: Text( l10n.cancel, - style: TextStyle(color: context.secondaryColor), + style: TextStyle( + color: context.secondaryColor), )), const SizedBox(width: 15), ElevatedButton( - style: ElevatedButton.styleFrom(backgroundColor: Colors.red.withValues(alpha: 0.7)), + style: ElevatedButton.styleFrom( + backgroundColor: + Colors.red.withValues(alpha: 0.7)), onPressed: () { - ref.read(synchingProvider(syncId: id).notifier).logout(); + ref + .read(synchingProvider(syncId: id) + .notifier) + .logout(); Navigator.pop(context); }, child: Text( l10n.log_out, - style: TextStyle(color: context.secondaryColor), + style: TextStyle( + color: context.secondaryColor), )), ], ) diff --git a/lib/modules/more/settings/track/manage_trackers/manage_trackers.dart b/lib/modules/more/settings/track/manage_trackers/manage_trackers.dart index 0de6847..87bb660 100644 --- a/lib/modules/more/settings/track/manage_trackers/manage_trackers.dart +++ b/lib/modules/more/settings/track/manage_trackers/manage_trackers.dart @@ -19,7 +19,8 @@ class _ManageTrackersScreenState extends State { late List trackPreferences = []; @override void initState() { - trackPreferences = isar.trackPreferences.filter().syncIdIsNotNull().findAllSync(); + trackPreferences = + isar.trackPreferences.filter().syncIdIsNotNull().findAllSync(); // trackPreferences.insert(0, TrackPreference(syncId: -1)); super.initState(); } @@ -36,7 +37,8 @@ class _ManageTrackersScreenState extends State { return Padding( padding: const EdgeInsets.all(8.0), child: MaterialButton( - shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(15)), onPressed: () { context.push('/trackingDetail', extra: trackerPref); }, @@ -47,17 +49,26 @@ class _ManageTrackersScreenState extends State { padding: const EdgeInsets.symmetric(vertical: 5), child: Container( decoration: BoxDecoration( - color: trackerPref.syncId == -1 ? Colors.grey : trackInfos(trackerPref.syncId!).$3, + color: trackerPref.syncId == -1 + ? Colors.grey + : trackInfos(trackerPref.syncId!).$3, borderRadius: BorderRadius.circular(10)), child: trackerPref.syncId == -1 ? SizedBox( - width: context.width(1), child: const Icon(Icons.local_library_rounded, size: 60)) - : Image.asset(trackInfos(trackerPref.syncId!).$1)), + width: context.width(1), + child: const Icon(Icons.local_library_rounded, + size: 60)) + : Image.asset( + trackInfos(trackerPref.syncId!).$1)), )), Padding( padding: const EdgeInsets.symmetric(vertical: 10), - child: Text(trackerPref.syncId == -1 ? 'Local' : trackInfos(trackerPref.syncId!).$2, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 19)), + child: Text( + trackerPref.syncId == -1 + ? 'Local' + : trackInfos(trackerPref.syncId!).$2, + style: const TextStyle( + fontWeight: FontWeight.bold, fontSize: 19)), ), ], ), diff --git a/lib/modules/more/settings/track/manage_trackers/tracking_detail.dart b/lib/modules/more/settings/track/manage_trackers/tracking_detail.dart index f303289..387a5be 100644 --- a/lib/modules/more/settings/track/manage_trackers/tracking_detail.dart +++ b/lib/modules/more/settings/track/manage_trackers/tracking_detail.dart @@ -15,7 +15,8 @@ class TrackingDetail extends StatefulWidget { State createState() => _TrackingDetailState(); } -class _TrackingDetailState extends State with TickerProviderStateMixin { +class _TrackingDetailState extends State + with TickerProviderStateMixin { late TabController _tabBarController; @override void initState() { @@ -35,7 +36,9 @@ class _TrackingDetailState extends State with TickerProviderStat appBar: AppBar( elevation: 0, backgroundColor: Colors.transparent, - title: Text(widget.trackerPref.syncId == -1 ? 'Local' : trackInfos(widget.trackerPref.syncId!).$2), + title: Text(widget.trackerPref.syncId == -1 + ? 'Local' + : trackInfos(widget.trackerPref.syncId!).$2), bottom: TabBar( indicatorSize: TabBarIndicatorSize.tab, controller: _tabBarController, @@ -80,10 +83,14 @@ class TrackingTab extends StatelessWidget { shrinkWrap: true, itemBuilder: (context, index) { final mediaId = mediaIds[index]; - final track = trackRes.firstWhere((element) => element.mediaId == mediaId); + final track = trackRes + .firstWhere((element) => element.mediaId == mediaId); return ExpansionTile( title: Text(track.title!), - children: [TrackingWidget(isManga: isManga, syncId: syncId, mediaId: mediaId!)], + children: [ + TrackingWidget( + isManga: isManga, syncId: syncId, mediaId: mediaId!) + ], ); }, separatorBuilder: (_, index) { @@ -99,7 +106,11 @@ class TrackingWidget extends StatelessWidget { final int syncId; final bool isManga; final int mediaId; - const TrackingWidget({super.key, required this.mediaId, required this.isManga, required this.syncId}); + const TrackingWidget( + {super.key, + required this.mediaId, + required this.isManga, + required this.syncId}); @override Widget build(BuildContext context) { @@ -114,7 +125,10 @@ class TrackingWidget extends StatelessWidget { List? trackRes = []; List res = snapshot.data ?? []; for (var track in res) { - if (!trackRes.map((e) => e.mediaId).toList().contains(track.mediaId)) { + if (!trackRes + .map((e) => e.mediaId) + .toList() + .contains(track.mediaId)) { trackRes.add(track); } } diff --git a/lib/modules/more/settings/track/myanimelist/model.dart b/lib/modules/more/settings/track/myanimelist/model.dart index ee0872a..38cd588 100644 --- a/lib/modules/more/settings/track/myanimelist/model.dart +++ b/lib/modules/more/settings/track/myanimelist/model.dart @@ -8,7 +8,8 @@ class OAuth { OAuth.fromJson(Map json) { tokenType = json['token_type']; - expiresIn = (json['expires_in'] as int) * 1000 + DateTime.now().millisecondsSinceEpoch; + expiresIn = (json['expires_in'] as int) * 1000 + + DateTime.now().millisecondsSinceEpoch; accessToken = json['access_token']; refreshToken = json['refresh_token']; } diff --git a/lib/modules/more/settings/track/providers/track_providers.dart b/lib/modules/more/settings/track/providers/track_providers.dart index c1a4310..fb1df51 100644 --- a/lib/modules/more/settings/track/providers/track_providers.dart +++ b/lib/modules/more/settings/track/providers/track_providers.dart @@ -26,7 +26,11 @@ class Tracks extends _$Tracks { } void updateTrackManga(Track track, bool? isManga) { - final tra = isar.tracks.filter().syncIdEqualTo(syncId).mangaIdEqualTo(track.mangaId).findAllSync(); + final tra = isar.tracks + .filter() + .syncIdEqualTo(syncId) + .mangaIdEqualTo(track.mangaId) + .findAllSync(); if (tra.isNotEmpty) { if (tra.first.mediaId != track.mangaId) { track.id = tra.first.id; @@ -44,7 +48,8 @@ class Tracks extends _$Tracks { } @riverpod -class UpdateProgressAfterReadingState extends _$UpdateProgressAfterReadingState { +class UpdateProgressAfterReadingState + extends _$UpdateProgressAfterReadingState { @override bool build() { return isar.settings.getSync(227)!.updateProgressAfterReading ?? true; @@ -53,6 +58,7 @@ class UpdateProgressAfterReadingState extends _$UpdateProgressAfterReadingState void set(bool value) { final settings = isar.settings.getSync(227); state = value; - isar.writeTxnSync(() => isar.settings.putSync(settings!..updateProgressAfterReading = value)); + isar.writeTxnSync(() => + isar.settings.putSync(settings!..updateProgressAfterReading = value)); } } diff --git a/lib/modules/more/settings/track/track.dart b/lib/modules/more/settings/track/track.dart index f26013e..9c73a07 100644 --- a/lib/modules/more/settings/track/track.dart +++ b/lib/modules/more/settings/track/track.dart @@ -18,7 +18,8 @@ class TrackScreen extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final updateProgressAfterReading = ref.watch(updateProgressAfterReadingStateProvider); + final updateProgressAfterReading = + ref.watch(updateProgressAfterReadingStateProvider); final l10n = l10nLocalizations(context)!; return Scaffold( appBar: AppBar( @@ -26,28 +27,40 @@ class TrackScreen extends ConsumerWidget { ), body: SingleChildScrollView( child: StreamBuilder( - stream: isar.trackPreferences.filter().syncIdIsNotNull().watch(fireImmediately: true), + stream: isar.trackPreferences + .filter() + .syncIdIsNotNull() + .watch(fireImmediately: true), builder: (context, snapshot) { - List? entries = snapshot.hasData ? snapshot.data : []; + List? entries = + snapshot.hasData ? snapshot.data : []; return Column( children: [ SwitchListTile( value: updateProgressAfterReading, title: Text(context.l10n.updateProgressAfterReading), onChanged: (value) { - ref.read(updateProgressAfterReadingStateProvider.notifier).set(value); + ref + .read(updateProgressAfterReadingStateProvider + .notifier) + .set(value); }), Padding( - padding: const EdgeInsets.only(left: 15, right: 15, bottom: 10, top: 5), + padding: const EdgeInsets.only( + left: 15, right: 15, bottom: 10, top: 5), child: Row( children: [ - Text(l10n.services, style: TextStyle(fontSize: 13, color: context.primaryColor)), + Text(l10n.services, + style: TextStyle( + fontSize: 13, color: context.primaryColor)), ], ), ), TrackListile( onTap: () async { - await ref.read(anilistProvider(syncId: 2).notifier).login(); + await ref + .read(anilistProvider(syncId: 2).notifier) + .login(); }, id: 2, entries: entries!), @@ -59,7 +72,10 @@ class TrackScreen extends ConsumerWidget { entries: entries), TrackListile( onTap: () async { - await ref.read(myAnimeListProvider(syncId: 1, isManga: null).notifier).login(); + await ref + .read(myAnimeListProvider(syncId: 1, isManga: null) + .notifier) + .login(); }, id: 1, entries: entries), @@ -75,11 +91,14 @@ class TrackScreen extends ConsumerWidget { ], ), ), - subtitle: - Text(l10n.tracking_warning_info, style: TextStyle(fontSize: 11, color: context.secondaryColor)), + subtitle: Text(l10n.tracking_warning_info, + style: TextStyle( + fontSize: 11, color: context.secondaryColor)), ), ListTileWidget( - title: l10n.manage_trackers, icon: Icons.settings, onTap: () => context.push('/manageTrackers')), + title: l10n.manage_trackers, + icon: Icons.settings, + onTap: () => context.push('/manageTrackers')), ], ); }), @@ -125,11 +144,14 @@ void _showDialogLogin(BuildContext context, WidgetRef ref) { filled: false, contentPadding: const EdgeInsets.all(12), enabledBorder: OutlineInputBorder( - borderSide: const BorderSide(width: 0.4), borderRadius: BorderRadius.circular(5)), - focusedBorder: - OutlineInputBorder(borderSide: const BorderSide(), borderRadius: BorderRadius.circular(5)), + borderSide: const BorderSide(width: 0.4), + borderRadius: BorderRadius.circular(5)), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide(), + borderRadius: BorderRadius.circular(5)), border: OutlineInputBorder( - borderRadius: BorderRadius.circular(5), borderSide: const BorderSide()))), + borderRadius: BorderRadius.circular(5), + borderSide: const BorderSide()))), ), const SizedBox(height: 10), Padding( @@ -146,15 +168,20 @@ void _showDialogLogin(BuildContext context, WidgetRef ref) { onPressed: () => setState(() { obscureText = !obscureText; }), - icon: Icon(obscureText ? Icons.visibility_outlined : Icons.visibility_off_outlined)), + icon: Icon(obscureText + ? Icons.visibility_outlined + : Icons.visibility_off_outlined)), filled: false, contentPadding: const EdgeInsets.all(12), enabledBorder: OutlineInputBorder( - borderSide: const BorderSide(width: 0.4), borderRadius: BorderRadius.circular(5)), - focusedBorder: - OutlineInputBorder(borderSide: const BorderSide(), borderRadius: BorderRadius.circular(5)), + borderSide: const BorderSide(width: 0.4), + borderRadius: BorderRadius.circular(5)), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide(), + borderRadius: BorderRadius.circular(5)), border: OutlineInputBorder( - borderRadius: BorderRadius.circular(5), borderSide: const BorderSide()))), + borderRadius: BorderRadius.circular(5), + borderSide: const BorderSide()))), ), const SizedBox(height: 10), Text(errorMessage, style: const TextStyle(color: Colors.red)), @@ -171,7 +198,9 @@ void _showDialogLogin(BuildContext context, WidgetRef ref) { setState(() { isLoading = true; }); - final res = await ref.read(kitsuProvider(syncId: 3).notifier).login(email, password); + final res = await ref + .read(kitsuProvider(syncId: 3).notifier) + .login(email, password); if (!res.$1) { setState(() { isLoading = false; @@ -183,7 +212,9 @@ void _showDialogLogin(BuildContext context, WidgetRef ref) { } } }, - child: isLoading ? const CircularProgressIndicator() : Text(l10n.login))), + child: isLoading + ? const CircularProgressIndicator() + : Text(l10n.login))), ) ], ), diff --git a/lib/modules/more/settings/track/widgets/track_listile.dart b/lib/modules/more/settings/track/widgets/track_listile.dart index 4d384df..03af457 100644 --- a/lib/modules/more/settings/track/widgets/track_listile.dart +++ b/lib/modules/more/settings/track/widgets/track_listile.dart @@ -11,18 +11,26 @@ class TrackListile extends ConsumerWidget { final int id; final List entries; final String? text; - const TrackListile({super.key, required this.onTap, required this.id, required this.entries, this.text}); + const TrackListile( + {super.key, + required this.onTap, + required this.id, + required this.entries, + this.text}); @override Widget build(BuildContext context, WidgetRef ref) { - final bool isLogged = entries.where((element) => element.syncId == id).isNotEmpty; + final bool isLogged = + entries.where((element) => element.syncId == id).isNotEmpty; final l10n = l10nLocalizations(context)!; return Padding( padding: const EdgeInsets.symmetric(vertical: 5), child: ListTile( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)), leading: Container( - decoration: BoxDecoration(borderRadius: BorderRadius.circular(10), color: trackInfos(id).$3), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: trackInfos(id).$3), width: 60, height: 70, child: Image.asset( @@ -54,25 +62,34 @@ class TrackListile extends ConsumerWidget { shadowColor: Colors.transparent, surfaceTintColor: Colors.transparent, shape: RoundedRectangleBorder( - side: BorderSide(color: context.secondaryColor), - borderRadius: BorderRadius.circular(20))), + side: BorderSide( + color: context.secondaryColor), + borderRadius: + BorderRadius.circular(20))), onPressed: () { Navigator.pop(context); }, child: Text( l10n.cancel, - style: TextStyle(color: context.secondaryColor), + style: TextStyle( + color: context.secondaryColor), )), const SizedBox(width: 15), ElevatedButton( - style: ElevatedButton.styleFrom(backgroundColor: Colors.red.withValues(alpha: 0.7)), + style: ElevatedButton.styleFrom( + backgroundColor: + Colors.red.withValues(alpha: 0.7)), onPressed: () { - ref.read(tracksProvider(syncId: id).notifier).logout(); + ref + .read( + tracksProvider(syncId: id).notifier) + .logout(); Navigator.pop(context); }, child: Text( l10n.log_out, - style: TextStyle(color: context.secondaryColor), + style: TextStyle( + color: context.secondaryColor), )), ], ) diff --git a/lib/modules/more/widgets/list_tile_widget.dart b/lib/modules/more/widgets/list_tile_widget.dart index 6357669..3cc4b04 100644 --- a/lib/modules/more/widgets/list_tile_widget.dart +++ b/lib/modules/more/widgets/list_tile_widget.dart @@ -8,7 +8,12 @@ class ListTileWidget extends StatelessWidget { final String? subtitle; final Widget? trailing; const ListTileWidget( - {super.key, required this.onTap, required this.title, required this.icon, this.subtitle, this.trailing}); + {super.key, + required this.onTap, + required this.title, + required this.icon, + this.subtitle, + this.trailing}); @override Widget build(BuildContext context) { diff --git a/lib/modules/updates/updates_screen.dart b/lib/modules/updates/updates_screen.dart index d5ea629..c1fcf0d 100644 --- a/lib/modules/updates/updates_screen.dart +++ b/lib/modules/updates/updates_screen.dart @@ -27,14 +27,16 @@ class UpdatesScreen extends ConsumerStatefulWidget { ConsumerState createState() => _UpdatesScreenState(); } -class _UpdatesScreenState extends ConsumerState with TickerProviderStateMixin { +class _UpdatesScreenState extends ConsumerState + with TickerProviderStateMixin { late TabController _tabBarController; bool _isLoading = false; Future _updateLibrary() async { setState(() { _isLoading = true; }); - botToast(context.l10n.updating_library, fontSize: 13, second: 1600, alignY: !context.isTablet ? 0.85 : 1); + botToast(context.l10n.updating_library, + fontSize: 13, second: 1600, alignY: !context.isTablet ? 0.85 : 1); final mangaList = isar.mangas .filter() .idIsNotNull() @@ -46,7 +48,8 @@ class _UpdatesScreenState extends ConsumerState with TickerProvid for (var manga in mangaList) { try { - await ref.read(updateMangaDetailProvider(mangaId: manga.id, isInit: false).future); + await ref.read( + updateMangaDetailProvider(mangaId: manga.id, isInit: false).future); } catch (_) {} numbers++; } @@ -120,13 +123,15 @@ class _UpdatesScreenState extends ConsumerState with TickerProvid _isSearch = true; }); }, - icon: Icon(Icons.search_outlined, color: Theme.of(context).hintColor)), + icon: Icon(Icons.search_outlined, + color: Theme.of(context).hintColor)), IconButton( splashRadius: 20, onPressed: () { _updateLibrary(); }, - icon: Icon(Icons.refresh_outlined, color: Theme.of(context).hintColor)), + icon: Icon(Icons.refresh_outlined, + color: Theme.of(context).hintColor)), IconButton( splashRadius: 20, onPressed: () { @@ -155,8 +160,10 @@ class _UpdatesScreenState extends ConsumerState with TickerProvid List updates = isar.updates .filter() .idIsNotNull() - .chapter( - (q) => q.manga((q) => q.isMangaEqualTo(_tabBarController.index == 0))) + .chapter((q) => q.manga((q) => + q.isMangaEqualTo( + _tabBarController.index == + 0))) .findAllSync() .toList(); isar.writeTxnSync(() { @@ -175,7 +182,8 @@ class _UpdatesScreenState extends ConsumerState with TickerProvid ); }); }, - icon: Icon(Icons.delete_sweep_outlined, color: Theme.of(context).hintColor)), + icon: Icon(Icons.delete_sweep_outlined, + color: Theme.of(context).hintColor)), ], bottom: TabBar( indicatorSize: TabBarIndicatorSize.tab, @@ -189,8 +197,14 @@ class _UpdatesScreenState extends ConsumerState with TickerProvid body: Padding( padding: const EdgeInsets.only(top: 10), child: TabBarView(controller: _tabBarController, children: [ - UpdateTab(isManga: true, query: _textEditingController.text, isLoading: _isLoading), - UpdateTab(isManga: false, query: _textEditingController.text, isLoading: _isLoading) + UpdateTab( + isManga: true, + query: _textEditingController.text, + isLoading: _isLoading), + UpdateTab( + isManga: false, + query: _textEditingController.text, + isLoading: _isLoading) ]), ), ), @@ -202,7 +216,11 @@ class UpdateTab extends ConsumerStatefulWidget { final String query; final bool isManga; final bool isLoading; - const UpdateTab({required this.isManga, required this.query, required this.isLoading, super.key}); + const UpdateTab( + {required this.isManga, + required this.query, + required this.isLoading, + super.key}); @override ConsumerState createState() => _UpdateTabState(); @@ -212,7 +230,8 @@ class _UpdateTabState extends ConsumerState { @override Widget build(BuildContext context) { final l10n = l10nLocalizations(context)!; - final update = ref.watch(getAllUpdateStreamProvider(isManga: widget.isManga)); + final update = + ref.watch(getAllUpdateStreamProvider(isManga: widget.isManga)); return Scaffold( body: Stack( children: [ @@ -220,10 +239,14 @@ class _UpdateTabState extends ConsumerState { data: (data) { final entries = data .where((element) => widget.query.isNotEmpty - ? element.chapter.value!.manga.value!.name!.toLowerCase().contains(widget.query.toLowerCase()) + ? element.chapter.value!.manga.value!.name! + .toLowerCase() + .contains(widget.query.toLowerCase()) : true) .toList(); - final lastUpdatedList = data.map((e) => e.chapter.value!.manga.value!.lastUpdate!).toList(); + final lastUpdatedList = data + .map((e) => e.chapter.value!.manga.value!.lastUpdate!) + .toList(); lastUpdatedList.sort((a, b) => a.compareTo(b)); final lastUpdated = lastUpdatedList.firstOrNull; if (entries.isNotEmpty) { @@ -231,19 +254,28 @@ class _UpdateTabState extends ConsumerState { slivers: [ if (lastUpdated != null) SliverPadding( - padding: const EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 20), + padding: const EdgeInsets.only( + left: 10, right: 10, top: 10, bottom: 20), sliver: SliverList( delegate: SliverChildListDelegate.fixed([ Text( - l10n.library_last_updated( - dateFormat(lastUpdated.toString(), ref: ref, context: context, showHOURorMINUTE: true)), - style: TextStyle(fontStyle: FontStyle.italic, color: context.secondaryColor)) + l10n.library_last_updated(dateFormat( + lastUpdated.toString(), + ref: ref, + context: context, + showHOURorMINUTE: true)), + style: TextStyle( + fontStyle: FontStyle.italic, + color: context.secondaryColor)) ])), ), SliverGroupedListView( elements: entries, groupBy: (element) => dateFormat(element.date!, - context: context, ref: ref, forHistoryValue: true, useRelativeTimesTamps: false), + context: context, + ref: ref, + forHistoryValue: true, + useRelativeTimesTamps: false), groupSeparatorBuilder: (String groupByValue) => Padding( padding: const EdgeInsets.only(bottom: 8, left: 12), child: Row( @@ -259,9 +291,11 @@ class _UpdateTabState extends ConsumerState { ), itemBuilder: (context, element) { final chapter = element.chapter.value!; - return UpdateChapterListTileWidget(chapter: chapter, sourceExist: true); + return UpdateChapterListTileWidget( + chapter: chapter, sourceExist: true); }, - itemComparator: (item1, item2) => item1.date!.compareTo(item2.date!), + itemComparator: (item1, item2) => + item1.date!.compareTo(item2.date!), order: GroupedListOrder.DESC, ), ], diff --git a/lib/modules/updates/widgets/update_chapter_list_tile_widget.dart b/lib/modules/updates/widgets/update_chapter_list_tile_widget.dart index 41528f4..342a997 100644 --- a/lib/modules/updates/widgets/update_chapter_list_tile_widget.dart +++ b/lib/modules/updates/widgets/update_chapter_list_tile_widget.dart @@ -48,17 +48,23 @@ class UpdateChapterListTileWidget extends ConsumerWidget { child: Material( child: GestureDetector( onTap: () { - context.push('/manga-reader/detail', extra: manga.id); + context.push('/manga-reader/detail', + extra: manga.id); }, child: Ink.image( fit: BoxFit.cover, width: 40, height: 45, image: manga.customCoverImage != null - ? MemoryImage(manga.customCoverImage as Uint8List) as ImageProvider + ? MemoryImage( + manga.customCoverImage as Uint8List) + as ImageProvider : CustomExtendedNetworkImageProvider( - toImgUrl(manga.customCoverFromTracker ?? manga.imageUrl!), - headers: ref.watch(headersProvider(source: manga.source!, lang: manga.lang!)), + toImgUrl(manga.customCoverFromTracker ?? + manga.imageUrl!), + headers: ref.watch(headersProvider( + source: manga.source!, + lang: manga.lang!)), ), child: InkWell(child: Container()), ), @@ -74,14 +80,22 @@ class UpdateChapterListTileWidget extends ConsumerWidget { children: [ Text(manga.name!, overflow: TextOverflow.ellipsis, - style: TextStyle(fontSize: 14, color: Theme.of(context).textTheme.bodyLarge!.color)), + style: TextStyle( + fontSize: 14, + color: Theme.of(context) + .textTheme + .bodyLarge! + .color)), Text(chapter.name!, overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 11, color: chapter.isRead ?? false ? Colors.grey - : Theme.of(context).textTheme.bodyLarge!.color)), + : Theme.of(context) + .textTheme + .bodyLarge! + .color)), ], ), ), diff --git a/lib/modules/widgets/bottom_text_widget.dart b/lib/modules/widgets/bottom_text_widget.dart index 4d6197a..bc4746b 100644 --- a/lib/modules/widgets/bottom_text_widget.dart +++ b/lib/modules/widgets/bottom_text_widget.dart @@ -58,7 +58,9 @@ class BottomTextWidget extends StatelessWidget { style: TextStyle( fontSize: 13.0, color: textColor ?? Colors.white, - shadows: const [Shadow(offset: Offset(0.5, 0.9), blurRadius: 3.0)], + shadows: const [ + Shadow(offset: Offset(0.5, 0.9), blurRadius: 3.0) + ], ), maxLines: isTorrent! ? 8 : maxLines, overflow: TextOverflow.ellipsis, @@ -74,7 +76,10 @@ class BottomTextWidget extends StatelessWidget { gradient: LinearGradient( begin: Alignment.topCenter, end: Alignment.bottomCenter, - colors: [Colors.transparent, Colors.black.withValues(alpha: 0.6)], + colors: [ + Colors.transparent, + Colors.black.withValues(alpha: 0.6) + ], stops: const [0, 1], ), ), @@ -89,7 +94,10 @@ class BottomTextWidget extends StatelessWidget { style: TextStyle( fontSize: 13.0, color: textColor ?? Colors.white, - shadows: const [Shadow(offset: Offset(0.5, 0.9), blurRadius: 3.0)], + shadows: const [ + Shadow( + offset: Offset(0.5, 0.9), blurRadius: 3.0) + ], ), maxLines: isTorrent! ? 8 : maxLines, overflow: TextOverflow.ellipsis, diff --git a/lib/modules/widgets/custom_draggable_tabbar.dart b/lib/modules/widgets/custom_draggable_tabbar.dart index dfac5fd..9b3ecf3 100644 --- a/lib/modules/widgets/custom_draggable_tabbar.dart +++ b/lib/modules/widgets/custom_draggable_tabbar.dart @@ -10,7 +10,8 @@ class MeasureWidgetSize extends StatefulWidget { final Function(Size? size) onCalculateSize; final Widget child; - const MeasureWidgetSize({super.key, required this.onCalculateSize, required this.child}); + const MeasureWidgetSize( + {super.key, required this.onCalculateSize, required this.child}); @override State createState() => _MeasureWidgetSizeState(); @@ -21,7 +22,8 @@ class _MeasureWidgetSizeState extends State { @override initState() { - WidgetsBinding.instance.addPostFrameCallback((_) => widget.onCalculateSize(_key.currentContext?.size)); + WidgetsBinding.instance.addPostFrameCallback( + (_) => widget.onCalculateSize(_key.currentContext?.size)); super.initState(); } @@ -47,7 +49,8 @@ Future customDraggableTabBar( List> widgetsHeight = []; void refresh() { - controller.animateTo(widgetsHeight.indexWhere((element) => element["index"] == index)); + controller.animateTo( + widgetsHeight.indexWhere((element) => element["index"] == index)); } tabBarController.animation!.addListener(() { @@ -70,7 +73,10 @@ Future customDraggableTabBar( for (var i = 0; i < children.length; i++) ...[ MeasureWidgetSize( onCalculateSize: (size) { - final additionnalHeight = ((List.generate(10000, (index) => index * 0.0001))..shuffle()).first; + final additionnalHeight = + ((List.generate(10000, (index) => index * 0.0001)) + ..shuffle()) + .first; double newHeight = size!.height + 52.0 + additionnalHeight; if (!(newHeight <= maxHeight)) { newHeight = maxHeight + additionnalHeight; @@ -87,20 +93,30 @@ Future customDraggableTabBar( ); }, ); - widgetsHeight.sort((a, b) => (a["height"] as double).compareTo(b["height"] as double)); + widgetsHeight + .sort((a, b) => (a["height"] as double).compareTo(b["height"] as double)); if (context.mounted) { await DraggableMenu.open( context, DraggableMenu( curve: Curves.linearToEaseOut, controller: controller, - levels: widgetsHeight.map((e) => e["height"]).map((e) => DraggableMenuLevel(height: e)).toList(), + levels: widgetsHeight + .map((e) => e["height"]) + .map((e) => DraggableMenuLevel(height: e)) + .toList(), customUi: Consumer(builder: (context, ref, child) { - final location = ref.watch(routerCurrentLocationStateProvider(context)); + final location = + ref.watch(routerCurrentLocationStateProvider(context)); final width = context.isTablet && !fullWidth ? switch (location) { null => 100, - != '/MangaLibrary' && != '/AnimeLibrary' && != '/history' && != '/browse' && != '/more' => 0, + != '/MangaLibrary' && + != '/AnimeLibrary' && + != '/history' && + != '/browse' && + != '/more' => + 0, _ => 100, } : 0; @@ -109,8 +125,9 @@ Future customDraggableTabBar( body: Container( width: context.width(1) - width, decoration: BoxDecoration( - borderRadius: - const BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20)), + borderRadius: const BorderRadius.only( + topLeft: Radius.circular(20), + topRight: Radius.circular(20)), color: Theme.of(context).scaffoldBackgroundColor), child: DefaultTabController( length: tabs.length, @@ -121,9 +138,13 @@ Future customDraggableTabBar( Flexible( flex: 9, child: TabBar( - unselectedLabelStyle: const TextStyle(fontWeight: FontWeight.w500), - labelStyle: const TextStyle(fontWeight: FontWeight.bold), - dividerColor: context.isLight ? Colors.black : Colors.grey, + unselectedLabelStyle: const TextStyle( + fontWeight: FontWeight.w500), + labelStyle: const TextStyle( + fontWeight: FontWeight.bold), + dividerColor: context.isLight + ? Colors.black + : Colors.grey, dividerHeight: 0.4, controller: tabBarController, tabs: tabs), @@ -138,8 +159,11 @@ Future customDraggableTabBar( Row( children: [ Flexible( - child: - Container(color: context.isLight ? Colors.black : Colors.grey, height: 0.4), + child: Container( + color: context.isLight + ? Colors.black + : Colors.grey, + height: 0.4), ), ], ) @@ -153,7 +177,9 @@ Future customDraggableTabBar( controller: tabBarController, children: children .map((e) => SingleChildScrollView( - child: MeasureWidgetSize(onCalculateSize: (_) => refresh(), child: e))) + child: MeasureWidgetSize( + onCalculateSize: (_) => refresh(), + child: e))) .toList())) ]), ), diff --git a/lib/modules/widgets/custom_extended_image_provider.dart b/lib/modules/widgets/custom_extended_image_provider.dart index 05bb960..df20458 100644 --- a/lib/modules/widgets/custom_extended_image_provider.dart +++ b/lib/modules/widgets/custom_extended_image_provider.dart @@ -10,9 +10,11 @@ import 'package:http_client_helper/http_client_helper.dart'; import 'package:mangayomi/services/http/m_client.dart'; import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:extended_image_library/src/network/extended_network_image_provider.dart' as image_provider; +import 'package:extended_image_library/src/network/extended_network_image_provider.dart' + as image_provider; -class CustomExtendedNetworkImageProvider extends ImageProvider +class CustomExtendedNetworkImageProvider + extends ImageProvider with ExtendedImageProvider implements image_provider.ExtendedNetworkImageProvider { /// Creates an object that fetches the image at the given URL. @@ -104,7 +106,8 @@ class CustomExtendedNetworkImageProvider extends ImageProvider chunkEvents = StreamController(); + final StreamController chunkEvents = + StreamController(); return MultiFrameImageStreamCompleter( codec: _loadAsync( @@ -118,14 +121,16 @@ class CustomExtendedNetworkImageProvider extends ImageProvider[ DiagnosticsProperty('Image provider', this), - DiagnosticsProperty('Image key', key), + DiagnosticsProperty( + 'Image key', key), ]; }, ); } @override - Future obtainKey(ImageConfiguration configuration) { + Future obtainKey( + ImageConfiguration configuration) { return SynchronousFuture(this); } @@ -185,8 +190,10 @@ class CustomExtendedNetworkImageProvider extends ImageProvider? chunkEvents, String md5Key, ) async { - final Directory cacheImagesDirectory = - Directory(join((await getTemporaryDirectory()).path, 'Mangayomi', imageCacheFolderName ?? 'cacheimagecover')); + final Directory cacheImagesDirectory = Directory(join( + (await getTemporaryDirectory()).path, + 'Mangayomi', + imageCacheFolderName ?? 'cacheimagecover')); Uint8List? data; // exist, try to find cache image file if (cacheImagesDirectory.existsSync()) { @@ -242,7 +249,8 @@ class CustomExtendedNetworkImageProvider extends ImageProvider.error(StateError('NetworkImage is an empty file: $resolved')); + return Future.error( + StateError('NetworkImage is an empty file: $resolved')); } return Uint8List.fromList(bytes); @@ -277,9 +286,13 @@ class CustomExtendedNetworkImageProvider extends ImageProvider pushToMangaReaderDetail( lastUpdate: 0, isManga: isManga ?? true, artist: getManga.artist ?? ''); - final empty = - isar.mangas.filter().langEqualTo(lang).nameEqualTo(manga.name).sourceEqualTo(manga.source).isEmptySync(); + final empty = isar.mangas + .filter() + .langEqualTo(lang) + .nameEqualTo(manga.name) + .sourceEqualTo(manga.source) + .isEmptySync(); if (empty) { isar.writeTxnSync(() { isar.mangas.putSync(manga); }); } - mangaId = - isar.mangas.filter().langEqualTo(lang).nameEqualTo(manga.name).sourceEqualTo(manga.source).findFirstSync()!.id!; + mangaId = isar.mangas + .filter() + .langEqualTo(lang) + .nameEqualTo(manga.name) + .sourceEqualTo(manga.source) + .findFirstSync()! + .id!; } else { mangaId = archiveId; } final settings = isar.settings.getSync(227)!; final sortList = settings.sortChapterList ?? []; - final checkIfExist = sortList.where((element) => element.mangaId == mangaId).toList(); + final checkIfExist = + sortList.where((element) => element.mangaId == mangaId).toList(); if (checkIfExist.isEmpty) { isar.writeTxnSync( () { @@ -281,8 +318,10 @@ Future pushToMangaReaderDetail( chapterFilterUnreadList.add(sortChapter); } sortChapterList.add(SortChapter()..mangaId = mangaId); - chapterFilterBookmarkedList.add(ChapterFilterBookmarked()..mangaId = mangaId); - chapterFilterDownloadedList.add(ChapterFilterDownloaded()..mangaId = mangaId); + chapterFilterBookmarkedList + .add(ChapterFilterBookmarked()..mangaId = mangaId); + chapterFilterDownloadedList + .add(ChapterFilterDownloaded()..mangaId = mangaId); chapterFilterUnreadList.add(ChapterFilterUnread()..mangaId = mangaId); isar.settings.putSync(settings ..sortChapterList = sortChapterList diff --git a/lib/providers/l10n_providers.dart b/lib/providers/l10n_providers.dart index 306ece2..b281ace 100644 --- a/lib/providers/l10n_providers.dart +++ b/lib/providers/l10n_providers.dart @@ -9,24 +9,29 @@ part 'l10n_providers.g.dart'; class L10nLocaleState extends _$L10nLocaleState { @override Locale build() { - return Locale(_getLocale()!.languageCode ?? "en", _getLocale()!.countryCode ?? ""); + return Locale( + _getLocale()!.languageCode ?? "en", _getLocale()!.countryCode ?? ""); } L10nLocale? _getLocale() { - return isar.settings.getSync(227)!.locale ?? L10nLocale(languageCode: "en", countryCode: ""); + return isar.settings.getSync(227)!.locale ?? + L10nLocale(languageCode: "en", countryCode: ""); } void setLocale(Locale locale) async { final settings = isar.settings.getSync(227)!; isar.writeTxnSync(() { - isar.settings - .putSync(settings..locale = L10nLocale(languageCode: locale.languageCode, countryCode: locale.countryCode)); + isar.settings.putSync(settings + ..locale = L10nLocale( + languageCode: locale.languageCode, + countryCode: locale.countryCode)); }); state = locale; } } -AppLocalizations? l10nLocalizations(BuildContext context) => AppLocalizations.of(context); +AppLocalizations? l10nLocalizations(BuildContext context) => + AppLocalizations.of(context); Locale currentLocale(BuildContext context) { return Localizations.localeOf(context); } diff --git a/lib/providers/storage_provider.dart b/lib/providers/storage_provider.dart index 47ab25e..c16f407 100644 --- a/lib/providers/storage_provider.dart +++ b/lib/providers/storage_provider.dart @@ -71,7 +71,8 @@ class StorageProvider { Directory? directory; String path = isar.settings.getSync(227)!.downloadLocation ?? ""; if (Platform.isAndroid) { - directory = Directory(path.isEmpty ? "/storage/emulated/0/Mangayomi/" : "$path/"); + directory = + Directory(path.isEmpty ? "/storage/emulated/0/Mangayomi/" : "$path/"); } else { final dir = await getApplicationDocumentsDirectory(); final p = path.isEmpty ? dir.path : path; @@ -84,8 +85,9 @@ class StorageProvider { Chapter chapter, ) async { final manga = chapter.manga.value!; - String scanlator = - chapter.scanlator?.isNotEmpty ?? false ? "${chapter.scanlator!.replaceForbiddenCharacters('_')}_" : ""; + String scanlator = chapter.scanlator?.isNotEmpty ?? false + ? "${chapter.scanlator!.replaceForbiddenCharacters('_')}_" + : ""; final isManga = chapter.manga.value!.isManga!; final dir = await getDirectory(); return Directory( diff --git a/lib/router/router.dart b/lib/router/router.dart index 52a097e..df81ea6 100644 --- a/lib/router/router.dart +++ b/lib/router/router.dart @@ -67,9 +67,11 @@ class RouterCurrentLocationState extends _$RouterCurrentLocationState { _listener() { final router = GoRouter.of(context); router.routerDelegate.addListener(() { - final RouteMatch lastMatch = router.routerDelegate.currentConfiguration.last; - final RouteMatchList matchList = - lastMatch is ImperativeRouteMatch ? lastMatch.matches : router.routerDelegate.currentConfiguration; + final RouteMatch lastMatch = + router.routerDelegate.currentConfiguration.last; + final RouteMatchList matchList = lastMatch is ImperativeRouteMatch + ? lastMatch.matches + : router.routerDelegate.currentConfiguration; state = matchList.uri.toString(); }); } @@ -77,70 +79,72 @@ class RouterCurrentLocationState extends _$RouterCurrentLocationState { class RouterNotifier extends ChangeNotifier { List get _routes => [ - ShellRoute(builder: (context, state, child) => MainScreen(child: child), routes: [ - GoRoute( - name: "MangaLibrary", - path: '/MangaLibrary', - builder: (context, state) => const LibraryScreen( - isManga: true, - ), - pageBuilder: (context, state) => transitionPage( - key: state.pageKey, - child: const LibraryScreen( - isManga: true, + ShellRoute( + builder: (context, state, child) => MainScreen(child: child), + routes: [ + GoRoute( + name: "MangaLibrary", + path: '/MangaLibrary', + builder: (context, state) => const LibraryScreen( + isManga: true, + ), + pageBuilder: (context, state) => transitionPage( + key: state.pageKey, + child: const LibraryScreen( + isManga: true, + ), + ), ), - ), - ), - GoRoute( - name: "AnimeLibrary", - path: '/AnimeLibrary', - builder: (context, state) => const LibraryScreen( - isManga: false, - ), - pageBuilder: (context, state) => transitionPage( - key: state.pageKey, - child: const LibraryScreen( - isManga: false, + GoRoute( + name: "AnimeLibrary", + path: '/AnimeLibrary', + builder: (context, state) => const LibraryScreen( + isManga: false, + ), + pageBuilder: (context, state) => transitionPage( + key: state.pageKey, + child: const LibraryScreen( + isManga: false, + ), + ), ), - ), - ), - GoRoute( - name: "history", - path: '/history', - builder: (context, state) => const HistoryScreen(), - pageBuilder: (context, state) => transitionPage( - key: state.pageKey, - child: const HistoryScreen(), - ), - ), - GoRoute( - name: "updates", - path: '/updates', - builder: (context, state) => const UpdatesScreen(), - pageBuilder: (context, state) => transitionPage( - key: state.pageKey, - child: const UpdatesScreen(), - ), - ), - GoRoute( - name: "browse", - path: '/browse', - builder: (context, state) => const BrowseScreen(), - pageBuilder: (context, state) => transitionPage( - key: state.pageKey, - child: const BrowseScreen(), - ), - ), - GoRoute( - name: "more", - path: '/more', - builder: (context, state) => const MoreScreen(), - pageBuilder: (context, state) => transitionPage( - key: state.pageKey, - child: const MoreScreen(), - ), - ), - ]), + GoRoute( + name: "history", + path: '/history', + builder: (context, state) => const HistoryScreen(), + pageBuilder: (context, state) => transitionPage( + key: state.pageKey, + child: const HistoryScreen(), + ), + ), + GoRoute( + name: "updates", + path: '/updates', + builder: (context, state) => const UpdatesScreen(), + pageBuilder: (context, state) => transitionPage( + key: state.pageKey, + child: const UpdatesScreen(), + ), + ), + GoRoute( + name: "browse", + path: '/browse', + builder: (context, state) => const BrowseScreen(), + pageBuilder: (context, state) => transitionPage( + key: state.pageKey, + child: const BrowseScreen(), + ), + ), + GoRoute( + name: "more", + path: '/more', + builder: (context, state) => const MoreScreen(), + pageBuilder: (context, state) => transitionPage( + key: state.pageKey, + child: const MoreScreen(), + ), + ), + ]), GoRoute( path: "/mangaHome", name: "mangaHome", @@ -547,7 +551,9 @@ class RouterNotifier extends ChangeNotifier { } Page transitionPage({required LocalKey key, required child}) { - return Platform.isIOS ? CupertinoPage(key: key, child: child) : CustomTransition(child: child, key: key); + return Platform.isIOS + ? CupertinoPage(key: key, child: child) + : CustomTransition(child: child, key: key); } class CustomTransition extends CustomTransitionPage { diff --git a/lib/services/anime_extractors/dood_extractor.dart b/lib/services/anime_extractors/dood_extractor.dart index 2804043..b0d410f 100644 --- a/lib/services/anime_extractors/dood_extractor.dart +++ b/lib/services/anime_extractors/dood_extractor.dart @@ -10,7 +10,8 @@ class DoodExtractor { String? quality, bool redirect = true, }) async { - final InterceptedClient client = MClient.init(reqcopyWith: {'useDartHttpClient': true}); + final InterceptedClient client = + MClient.init(reqcopyWith: {'useDartHttpClient': true}); final newQuality = quality ?? ('Doodstream ${redirect ? ' mirror' : ''}'); try { @@ -29,7 +30,8 @@ class DoodExtractor { headers: {'referer': newUrl}, ); - final videoUrl = '${videoUrlStart.body}$randomString?token=$token&expiry=$expiry'; + final videoUrl = + '${videoUrlStart.body}$randomString?token=$token&expiry=$expiry'; return [ Video(newUrl, newQuality, videoUrl, headers: { 'User-Agent': 'Mangayomi', @@ -42,7 +44,11 @@ class DoodExtractor { } String getRandomString({int length = 10}) { - const allowedChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - return List.generate(length, (index) => allowedChars.runes.elementAt(Random().nextInt(allowedChars.length))).join(); + const allowedChars = + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; + return List.generate( + length, + (index) => allowedChars.runes + .elementAt(Random().nextInt(allowedChars.length))).join(); } } diff --git a/lib/services/anime_extractors/filemoon.dart b/lib/services/anime_extractors/filemoon.dart index abb4c70..4022e0d 100644 --- a/lib/services/anime_extractors/filemoon.dart +++ b/lib/services/anime_extractors/filemoon.dart @@ -7,9 +7,11 @@ import 'package:mangayomi/utils/extensions/string_extensions.dart'; import 'package:mangayomi/utils/xpath_selector.dart'; class FilemoonExtractor { - final InterceptedClient client = MClient.init(reqcopyWith: {'useDartHttpClient': true}); + final InterceptedClient client = + MClient.init(reqcopyWith: {'useDartHttpClient': true}); - Future> videosFromUrl(String url, String prefix, String suffix) async { + Future> videosFromUrl( + String url, String prefix, String suffix) async { prefix = prefix.isEmpty ? "Filemoon " : prefix; try { final videoHeaders = { @@ -18,11 +20,15 @@ class FilemoonExtractor { }; final response = await client.get(Uri.parse(url)); - final jsEval = xpathSelector(response.body).queryXPath('//script[contains(text(), "eval")]/text()').attr; + final jsEval = xpathSelector(response.body) + .queryXPath('//script[contains(text(), "eval")]/text()') + .attr; final unpacked = JSPacker(jsEval!).unpack() ?? ""; - final masterUrl = unpacked.isNotEmpty ? unpacked.substringAfter('{file:"').substringBefore('"}') : ''; + final masterUrl = unpacked.isNotEmpty + ? unpacked.substringAfter('{file:"').substringBefore('"}') + : ''; if (masterUrl.isEmpty) { return []; @@ -32,7 +38,8 @@ class FilemoonExtractor { unpacked.substringAfter("""fetch('", """).substringBefore("""')."""); if (subUrl.isNotEmpty) { try { - final subResponse = await client.get(Uri.parse(subUrl), headers: videoHeaders); + final subResponse = + await client.get(Uri.parse(subUrl), headers: videoHeaders); final subList = jsonDecode(subResponse.body) as List; for (var item in subList) { subtitleTracks.add(Track(file: item["file"], label: item["label"])); @@ -47,7 +54,8 @@ class FilemoonExtractor { final playlists = masterPlaylist.split(separator).sublist(1); return playlists.map((playlist) { - final resolution = '${playlist.substringAfter('RESOLUTION=').substringAfter('x').substringBefore(',').trim()}p'; + final resolution = + '${playlist.substringAfter('RESOLUTION=').substringAfter('x').substringBefore(',').trim()}p'; final videoUrl = playlist.split('\n')[1].trim(); return Video(videoUrl, "$prefix - $resolution $suffix", videoUrl, diff --git a/lib/services/anime_extractors/gogocdn_extractor.dart b/lib/services/anime_extractors/gogocdn_extractor.dart index e68c38b..1740f64 100644 --- a/lib/services/anime_extractors/gogocdn_extractor.dart +++ b/lib/services/anime_extractors/gogocdn_extractor.dart @@ -8,7 +8,8 @@ import 'package:mangayomi/services/http/m_client.dart'; import 'package:mangayomi/utils/extensions/string_extensions.dart'; class GogoCdnExtractor { - final InterceptedClient client = MClient.init(reqcopyWith: {'useDartHttpClient': true}); + final InterceptedClient client = + MClient.init(reqcopyWith: {'useDartHttpClient': true}); final JsonCodec json = const JsonCodec(); Future> videosFromUrl(String serverUrl) async { @@ -17,11 +18,20 @@ class GogoCdnExtractor { final document = response.body; Document parsedResponse = parser.parse(response.body); - final iv = parsedResponse.querySelector('div.wrapper')!.attributes["class"]!.split('container-').last; + final iv = parsedResponse + .querySelector('div.wrapper')! + .attributes["class"]! + .split('container-') + .last; - final secretKey = parsedResponse.querySelector('body[class]')!.attributes["class"]!.split('container-').last; + final secretKey = parsedResponse + .querySelector('body[class]')! + .attributes["class"]! + .split('container-') + .last; RegExp(r'container-(\d+)').firstMatch(document)?.group(1); - final decryptionKey = RegExp(r'videocontent-(\d+)').firstMatch(document)?.group(1); + final decryptionKey = + RegExp(r'videocontent-(\d+)').firstMatch(document)?.group(1); final encryptAjaxParams = MBridge.cryptoHandler( RegExp(r'data-value="([^"]+)').firstMatch(document)?.group(1) ?? "", iv, @@ -37,30 +47,37 @@ class GogoCdnExtractor { final token = httpUrl.queryParameters['token']; final qualityPrefix = token != null ? "Gogostream - " : "Vidstreaming - "; - final encryptAjaxUrl = "${host}encrypt-ajax.php?id=$encryptedId&$encryptAjaxParams&alias=$id"; + final encryptAjaxUrl = + "${host}encrypt-ajax.php?id=$encryptedId&$encryptAjaxParams&alias=$id"; - final encryptAjaxResponse = - await client.get(Uri.parse(encryptAjaxUrl), headers: {"X-Requested-With": "XMLHttpRequest"}); + final encryptAjaxResponse = await client.get(Uri.parse(encryptAjaxUrl), + headers: {"X-Requested-With": "XMLHttpRequest"}); final jsonResponse = encryptAjaxResponse.body; final data = json.decode(jsonResponse)["data"]; - final decryptedData = MBridge.cryptoHandler(data ?? "", iv, decryptionKey!, false); + final decryptedData = + MBridge.cryptoHandler(data ?? "", iv, decryptionKey!, false); final videoList =