diff --git a/docs/docs/basics/parsers.md b/docs/docs/basics/parsers.md index b9b3b1d1..9d9101ac 100644 --- a/docs/docs/basics/parsers.md +++ b/docs/docs/basics/parsers.md @@ -34,7 +34,7 @@ class MiraiTextParser extends MiraiParser { textDirection: model.textDirection, softWrap: model.softWrap, overflow: model.overflow, - textScaleFactor: model.textScaleFactor, + textScaler: MiraiTextScalerParser.parse(model.textScaler), maxLines: model.maxLines, semanticsLabel: model.semanticsLabel, textWidthBasis: model.textWidthBasis, diff --git a/packages/mirai/lib/src/parsers/mirai_text/mirai_text.freezed.dart b/packages/mirai/lib/src/parsers/mirai_text/mirai_text.freezed.dart index 9aa2bd76..2cf0c9fd 100644 --- a/packages/mirai/lib/src/parsers/mirai_text/mirai_text.freezed.dart +++ b/packages/mirai/lib/src/parsers/mirai_text/mirai_text.freezed.dart @@ -153,10 +153,11 @@ class _$MiraiTextCopyWithImpl<$Res, $Val extends MiraiText> } /// @nodoc -abstract class _$$_MiraiTextCopyWith<$Res> implements $MiraiTextCopyWith<$Res> { - factory _$$_MiraiTextCopyWith( - _$_MiraiText value, $Res Function(_$_MiraiText) then) = - __$$_MiraiTextCopyWithImpl<$Res>; +abstract class _$$MiraiTextImplCopyWith<$Res> + implements $MiraiTextCopyWith<$Res> { + factory _$$MiraiTextImplCopyWith( + _$MiraiTextImpl value, $Res Function(_$MiraiTextImpl) then) = + __$$MiraiTextImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -178,11 +179,11 @@ abstract class _$$_MiraiTextCopyWith<$Res> implements $MiraiTextCopyWith<$Res> { } /// @nodoc -class __$$_MiraiTextCopyWithImpl<$Res> - extends _$MiraiTextCopyWithImpl<$Res, _$_MiraiText> - implements _$$_MiraiTextCopyWith<$Res> { - __$$_MiraiTextCopyWithImpl( - _$_MiraiText _value, $Res Function(_$_MiraiText) _then) +class __$$MiraiTextImplCopyWithImpl<$Res> + extends _$MiraiTextCopyWithImpl<$Res, _$MiraiTextImpl> + implements _$$MiraiTextImplCopyWith<$Res> { + __$$MiraiTextImplCopyWithImpl( + _$MiraiTextImpl _value, $Res Function(_$MiraiTextImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -201,7 +202,7 @@ class __$$_MiraiTextCopyWithImpl<$Res> Object? textWidthBasis = freezed, Object? selectionColor = freezed, }) { - return _then(_$_MiraiText( + return _then(_$MiraiTextImpl( data: null == data ? _value.data : data // ignore: cast_nullable_to_non_nullable @@ -256,8 +257,8 @@ class __$$_MiraiTextCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$_MiraiText implements _MiraiText { - const _$_MiraiText( +class _$MiraiTextImpl implements _MiraiText { + const _$MiraiTextImpl( {required this.data, final List children = const [], this.style, @@ -272,8 +273,8 @@ class _$_MiraiText implements _MiraiText { this.selectionColor}) : _children = children; - factory _$_MiraiText.fromJson(Map json) => - _$$_MiraiTextFromJson(json); + factory _$MiraiTextImpl.fromJson(Map json) => + _$$MiraiTextImplFromJson(json); @override final String data; @@ -316,7 +317,7 @@ class _$_MiraiText implements _MiraiText { bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$_MiraiText && + other is _$MiraiTextImpl && (identical(other.data, data) || other.data == data) && const DeepCollectionEquality().equals(other._children, _children) && (identical(other.style, style) || other.style == style) && @@ -360,12 +361,12 @@ class _$_MiraiText implements _MiraiText { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_MiraiTextCopyWith<_$_MiraiText> get copyWith => - __$$_MiraiTextCopyWithImpl<_$_MiraiText>(this, _$identity); + _$$MiraiTextImplCopyWith<_$MiraiTextImpl> get copyWith => + __$$MiraiTextImplCopyWithImpl<_$MiraiTextImpl>(this, _$identity); @override Map toJson() { - return _$$_MiraiTextToJson( + return _$$MiraiTextImplToJson( this, ); } @@ -384,10 +385,10 @@ abstract class _MiraiText implements MiraiText { final int? maxLines, final String? semanticsLabel, final TextWidthBasis? textWidthBasis, - final String? selectionColor}) = _$_MiraiText; + final String? selectionColor}) = _$MiraiTextImpl; factory _MiraiText.fromJson(Map json) = - _$_MiraiText.fromJson; + _$MiraiTextImpl.fromJson; @override String get data; @@ -415,7 +416,7 @@ abstract class _MiraiText implements MiraiText { String? get selectionColor; @override @JsonKey(ignore: true) - _$$_MiraiTextCopyWith<_$_MiraiText> get copyWith => + _$$MiraiTextImplCopyWith<_$MiraiTextImpl> get copyWith => throw _privateConstructorUsedError; } @@ -493,11 +494,11 @@ class _$MiraiTextSpanCopyWithImpl<$Res, $Val extends MiraiTextSpan> } /// @nodoc -abstract class _$$_MiraiTextSpanCopyWith<$Res> +abstract class _$$MiraiTextSpanImplCopyWith<$Res> implements $MiraiTextSpanCopyWith<$Res> { - factory _$$_MiraiTextSpanCopyWith( - _$_MiraiTextSpan value, $Res Function(_$_MiraiTextSpan) then) = - __$$_MiraiTextSpanCopyWithImpl<$Res>; + factory _$$MiraiTextSpanImplCopyWith( + _$MiraiTextSpanImpl value, $Res Function(_$MiraiTextSpanImpl) then) = + __$$MiraiTextSpanImplCopyWithImpl<$Res>; @override @useResult $Res call({String? data, MiraiTextStyle? style, Map? onTap}); @@ -507,11 +508,11 @@ abstract class _$$_MiraiTextSpanCopyWith<$Res> } /// @nodoc -class __$$_MiraiTextSpanCopyWithImpl<$Res> - extends _$MiraiTextSpanCopyWithImpl<$Res, _$_MiraiTextSpan> - implements _$$_MiraiTextSpanCopyWith<$Res> { - __$$_MiraiTextSpanCopyWithImpl( - _$_MiraiTextSpan _value, $Res Function(_$_MiraiTextSpan) _then) +class __$$MiraiTextSpanImplCopyWithImpl<$Res> + extends _$MiraiTextSpanCopyWithImpl<$Res, _$MiraiTextSpanImpl> + implements _$$MiraiTextSpanImplCopyWith<$Res> { + __$$MiraiTextSpanImplCopyWithImpl( + _$MiraiTextSpanImpl _value, $Res Function(_$MiraiTextSpanImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -521,7 +522,7 @@ class __$$_MiraiTextSpanCopyWithImpl<$Res> Object? style = freezed, Object? onTap = freezed, }) { - return _then(_$_MiraiTextSpan( + return _then(_$MiraiTextSpanImpl( data: freezed == data ? _value.data : data // ignore: cast_nullable_to_non_nullable @@ -540,13 +541,13 @@ class __$$_MiraiTextSpanCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$_MiraiTextSpan implements _MiraiTextSpan { - const _$_MiraiTextSpan( +class _$MiraiTextSpanImpl implements _MiraiTextSpan { + const _$MiraiTextSpanImpl( {this.data, this.style, final Map? onTap}) : _onTap = onTap; - factory _$_MiraiTextSpan.fromJson(Map json) => - _$$_MiraiTextSpanFromJson(json); + factory _$MiraiTextSpanImpl.fromJson(Map json) => + _$$MiraiTextSpanImplFromJson(json); @override final String? data; @@ -571,7 +572,7 @@ class _$_MiraiTextSpan implements _MiraiTextSpan { bool operator ==(dynamic other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$_MiraiTextSpan && + other is _$MiraiTextSpanImpl && (identical(other.data, data) || other.data == data) && (identical(other.style, style) || other.style == style) && const DeepCollectionEquality().equals(other._onTap, _onTap)); @@ -585,12 +586,12 @@ class _$_MiraiTextSpan implements _MiraiTextSpan { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_MiraiTextSpanCopyWith<_$_MiraiTextSpan> get copyWith => - __$$_MiraiTextSpanCopyWithImpl<_$_MiraiTextSpan>(this, _$identity); + _$$MiraiTextSpanImplCopyWith<_$MiraiTextSpanImpl> get copyWith => + __$$MiraiTextSpanImplCopyWithImpl<_$MiraiTextSpanImpl>(this, _$identity); @override Map toJson() { - return _$$_MiraiTextSpanToJson( + return _$$MiraiTextSpanImplToJson( this, ); } @@ -600,10 +601,10 @@ abstract class _MiraiTextSpan implements MiraiTextSpan { const factory _MiraiTextSpan( {final String? data, final MiraiTextStyle? style, - final Map? onTap}) = _$_MiraiTextSpan; + final Map? onTap}) = _$MiraiTextSpanImpl; factory _MiraiTextSpan.fromJson(Map json) = - _$_MiraiTextSpan.fromJson; + _$MiraiTextSpanImpl.fromJson; @override String? get data; @@ -613,6 +614,6 @@ abstract class _MiraiTextSpan implements MiraiTextSpan { Map? get onTap; @override @JsonKey(ignore: true) - _$$_MiraiTextSpanCopyWith<_$_MiraiTextSpan> get copyWith => + _$$MiraiTextSpanImplCopyWith<_$MiraiTextSpanImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/mirai/lib/src/parsers/mirai_text/mirai_text.g.dart b/packages/mirai/lib/src/parsers/mirai_text/mirai_text.g.dart index 3e228c0d..e12d4ec7 100644 --- a/packages/mirai/lib/src/parsers/mirai_text/mirai_text.g.dart +++ b/packages/mirai/lib/src/parsers/mirai_text/mirai_text.g.dart @@ -6,7 +6,8 @@ part of 'mirai_text.dart'; // JsonSerializableGenerator // ************************************************************************** -_$_MiraiText _$$_MiraiTextFromJson(Map json) => _$_MiraiText( +_$MiraiTextImpl _$$MiraiTextImplFromJson(Map json) => + _$MiraiTextImpl( data: json['data'] as String, children: (json['children'] as List?) ?.map((e) => MiraiTextSpan.fromJson(e as Map)) @@ -28,7 +29,7 @@ _$_MiraiText _$$_MiraiTextFromJson(Map json) => _$_MiraiText( selectionColor: json['selectionColor'] as String?, ); -Map _$$_MiraiTextToJson(_$_MiraiText instance) => +Map _$$MiraiTextImplToJson(_$MiraiTextImpl instance) => { 'data': instance.data, 'children': instance.children, @@ -70,8 +71,8 @@ const _$TextWidthBasisEnumMap = { TextWidthBasis.longestLine: 'longestLine', }; -_$_MiraiTextSpan _$$_MiraiTextSpanFromJson(Map json) => - _$_MiraiTextSpan( +_$MiraiTextSpanImpl _$$MiraiTextSpanImplFromJson(Map json) => + _$MiraiTextSpanImpl( data: json['data'] as String?, style: json['style'] == null ? null @@ -79,7 +80,7 @@ _$_MiraiTextSpan _$$_MiraiTextSpanFromJson(Map json) => onTap: json['onTap'] as Map?, ); -Map _$$_MiraiTextSpanToJson(_$_MiraiTextSpan instance) => +Map _$$MiraiTextSpanImplToJson(_$MiraiTextSpanImpl instance) => { 'data': instance.data, 'style': instance.style, diff --git a/packages/mirai/lib/src/parsers/mirai_text/mirai_text_parser.dart b/packages/mirai/lib/src/parsers/mirai_text/mirai_text_parser.dart index bdf26cac..939f4960 100644 --- a/packages/mirai/lib/src/parsers/mirai_text/mirai_text_parser.dart +++ b/packages/mirai/lib/src/parsers/mirai_text/mirai_text_parser.dart @@ -37,7 +37,9 @@ class MiraiTextParser extends MiraiParser { textDirection: model.textDirection, softWrap: model.softWrap, overflow: model.overflow, - textScaleFactor: model.textScaleFactor, + textScaler: model.textScaleFactor != null + ? TextScaler.linear(model.textScaleFactor!) + : TextScaler.noScaling, maxLines: model.maxLines, semanticsLabel: model.semanticsLabel, textWidthBasis: model.textWidthBasis,