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.dart b/packages/mirai/lib/src/parsers/mirai_text/mirai_text.dart index 5a766c40..e4b86bb6 100644 --- a/packages/mirai/lib/src/parsers/mirai_text/mirai_text.dart +++ b/packages/mirai/lib/src/parsers/mirai_text/mirai_text.dart @@ -1,5 +1,6 @@ import 'package:flutter/cupertino.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:mirai/src/parsers/mirai_text_scaler/mirai_text_scaler.dart'; import 'package:mirai/src/parsers/mirai_text_style/mirai_text_style.dart'; export 'package:mirai/src/parsers/mirai_text/mirai_text_parser.dart'; @@ -17,7 +18,7 @@ class MiraiText with _$MiraiText { TextDirection? textDirection, bool? softWrap, TextOverflow? overflow, - double? textScaleFactor, + MiraiTextScaler? textScaler, int? maxLines, String? semanticsLabel, TextWidthBasis? 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..39d4735d 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 @@ -27,7 +27,7 @@ mixin _$MiraiText { TextDirection? get textDirection => throw _privateConstructorUsedError; bool? get softWrap => throw _privateConstructorUsedError; TextOverflow? get overflow => throw _privateConstructorUsedError; - double? get textScaleFactor => throw _privateConstructorUsedError; + MiraiTextScaler? get textScaler => throw _privateConstructorUsedError; int? get maxLines => throw _privateConstructorUsedError; String? get semanticsLabel => throw _privateConstructorUsedError; TextWidthBasis? get textWidthBasis => throw _privateConstructorUsedError; @@ -52,13 +52,14 @@ abstract class $MiraiTextCopyWith<$Res> { TextDirection? textDirection, bool? softWrap, TextOverflow? overflow, - double? textScaleFactor, + MiraiTextScaler? textScaler, int? maxLines, String? semanticsLabel, TextWidthBasis? textWidthBasis, String? selectionColor}); $MiraiTextStyleCopyWith<$Res>? get style; + $MiraiTextScalerCopyWith<$Res>? get textScaler; } /// @nodoc @@ -81,7 +82,7 @@ class _$MiraiTextCopyWithImpl<$Res, $Val extends MiraiText> Object? textDirection = freezed, Object? softWrap = freezed, Object? overflow = freezed, - Object? textScaleFactor = freezed, + Object? textScaler = freezed, Object? maxLines = freezed, Object? semanticsLabel = freezed, Object? textWidthBasis = freezed, @@ -116,10 +117,10 @@ class _$MiraiTextCopyWithImpl<$Res, $Val extends MiraiText> ? _value.overflow : overflow // ignore: cast_nullable_to_non_nullable as TextOverflow?, - textScaleFactor: freezed == textScaleFactor - ? _value.textScaleFactor - : textScaleFactor // ignore: cast_nullable_to_non_nullable - as double?, + textScaler: freezed == textScaler + ? _value.textScaler + : textScaler // ignore: cast_nullable_to_non_nullable + as MiraiTextScaler?, maxLines: freezed == maxLines ? _value.maxLines : maxLines // ignore: cast_nullable_to_non_nullable @@ -150,13 +151,26 @@ class _$MiraiTextCopyWithImpl<$Res, $Val extends MiraiText> return _then(_value.copyWith(style: value) as $Val); }); } + + @override + @pragma('vm:prefer-inline') + $MiraiTextScalerCopyWith<$Res>? get textScaler { + if (_value.textScaler == null) { + return null; + } + + return $MiraiTextScalerCopyWith<$Res>(_value.textScaler!, (value) { + return _then(_value.copyWith(textScaler: value) as $Val); + }); + } } /// @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( @@ -167,7 +181,7 @@ abstract class _$$_MiraiTextCopyWith<$Res> implements $MiraiTextCopyWith<$Res> { TextDirection? textDirection, bool? softWrap, TextOverflow? overflow, - double? textScaleFactor, + MiraiTextScaler? textScaler, int? maxLines, String? semanticsLabel, TextWidthBasis? textWidthBasis, @@ -175,14 +189,16 @@ abstract class _$$_MiraiTextCopyWith<$Res> implements $MiraiTextCopyWith<$Res> { @override $MiraiTextStyleCopyWith<$Res>? get style; + @override + $MiraiTextScalerCopyWith<$Res>? get textScaler; } /// @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') @@ -195,13 +211,13 @@ class __$$_MiraiTextCopyWithImpl<$Res> Object? textDirection = freezed, Object? softWrap = freezed, Object? overflow = freezed, - Object? textScaleFactor = freezed, + Object? textScaler = freezed, Object? maxLines = freezed, Object? semanticsLabel = freezed, Object? textWidthBasis = freezed, Object? selectionColor = freezed, }) { - return _then(_$_MiraiText( + return _then(_$MiraiTextImpl( data: null == data ? _value.data : data // ignore: cast_nullable_to_non_nullable @@ -230,10 +246,10 @@ class __$$_MiraiTextCopyWithImpl<$Res> ? _value.overflow : overflow // ignore: cast_nullable_to_non_nullable as TextOverflow?, - textScaleFactor: freezed == textScaleFactor - ? _value.textScaleFactor - : textScaleFactor // ignore: cast_nullable_to_non_nullable - as double?, + textScaler: freezed == textScaler + ? _value.textScaler + : textScaler // ignore: cast_nullable_to_non_nullable + as MiraiTextScaler?, maxLines: freezed == maxLines ? _value.maxLines : maxLines // ignore: cast_nullable_to_non_nullable @@ -256,8 +272,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, @@ -265,15 +281,15 @@ class _$_MiraiText implements _MiraiText { this.textDirection, this.softWrap, this.overflow, - this.textScaleFactor, + this.textScaler, this.maxLines, this.semanticsLabel, this.textWidthBasis, this.selectionColor}) : _children = children; - factory _$_MiraiText.fromJson(Map json) => - _$$_MiraiTextFromJson(json); + factory _$MiraiTextImpl.fromJson(Map json) => + _$$MiraiTextImplFromJson(json); @override final String data; @@ -297,7 +313,7 @@ class _$_MiraiText implements _MiraiText { @override final TextOverflow? overflow; @override - final double? textScaleFactor; + final MiraiTextScaler? textScaler; @override final int? maxLines; @override @@ -309,14 +325,14 @@ class _$_MiraiText implements _MiraiText { @override String toString() { - return 'MiraiText(data: $data, children: $children, style: $style, textAlign: $textAlign, textDirection: $textDirection, softWrap: $softWrap, overflow: $overflow, textScaleFactor: $textScaleFactor, maxLines: $maxLines, semanticsLabel: $semanticsLabel, textWidthBasis: $textWidthBasis, selectionColor: $selectionColor)'; + return 'MiraiText(data: $data, children: $children, style: $style, textAlign: $textAlign, textDirection: $textDirection, softWrap: $softWrap, overflow: $overflow, textScaler: $textScaler, maxLines: $maxLines, semanticsLabel: $semanticsLabel, textWidthBasis: $textWidthBasis, selectionColor: $selectionColor)'; } @override 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) && @@ -328,8 +344,8 @@ class _$_MiraiText implements _MiraiText { other.softWrap == softWrap) && (identical(other.overflow, overflow) || other.overflow == overflow) && - (identical(other.textScaleFactor, textScaleFactor) || - other.textScaleFactor == textScaleFactor) && + (identical(other.textScaler, textScaler) || + other.textScaler == textScaler) && (identical(other.maxLines, maxLines) || other.maxLines == maxLines) && (identical(other.semanticsLabel, semanticsLabel) || @@ -351,7 +367,7 @@ class _$_MiraiText implements _MiraiText { textDirection, softWrap, overflow, - textScaleFactor, + textScaler, maxLines, semanticsLabel, textWidthBasis, @@ -360,12 +376,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, ); } @@ -380,14 +396,14 @@ abstract class _MiraiText implements MiraiText { final TextDirection? textDirection, final bool? softWrap, final TextOverflow? overflow, - final double? textScaleFactor, + final MiraiTextScaler? textScaler, 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; @@ -404,7 +420,7 @@ abstract class _MiraiText implements MiraiText { @override TextOverflow? get overflow; @override - double? get textScaleFactor; + MiraiTextScaler? get textScaler; @override int? get maxLines; @override @@ -415,7 +431,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 +509,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 +523,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 +537,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 +556,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 +587,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 +601,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 +616,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 +629,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..6b0167b3 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)) @@ -20,7 +21,10 @@ _$_MiraiText _$$_MiraiTextFromJson(Map json) => _$_MiraiText( $enumDecodeNullable(_$TextDirectionEnumMap, json['textDirection']), softWrap: json['softWrap'] as bool?, overflow: $enumDecodeNullable(_$TextOverflowEnumMap, json['overflow']), - textScaleFactor: (json['textScaleFactor'] as num?)?.toDouble(), + textScaler: json['textScaler'] == null + ? null + : MiraiTextScaler.fromJson( + json['textScaler'] as Map), maxLines: json['maxLines'] as int?, semanticsLabel: json['semanticsLabel'] as String?, textWidthBasis: @@ -28,7 +32,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, @@ -37,7 +41,7 @@ Map _$$_MiraiTextToJson(_$_MiraiText instance) => 'textDirection': _$TextDirectionEnumMap[instance.textDirection], 'softWrap': instance.softWrap, 'overflow': _$TextOverflowEnumMap[instance.overflow], - 'textScaleFactor': instance.textScaleFactor, + 'textScaler': instance.textScaler, 'maxLines': instance.maxLines, 'semanticsLabel': instance.semanticsLabel, 'textWidthBasis': _$TextWidthBasisEnumMap[instance.textWidthBasis], @@ -70,8 +74,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 +83,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..cc5d7a07 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 @@ -2,6 +2,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:mirai/src/framework/framework.dart'; import 'package:mirai/src/parsers/mirai_text/mirai_text.dart'; +import 'package:mirai/src/parsers/mirai_text_scaler/mirai_text_scaler.dart'; import 'package:mirai/src/parsers/mirai_text_style/mirai_text_style.dart'; import 'package:mirai/src/utils/color_utils.dart'; import 'package:mirai/src/utils/widget_type.dart'; @@ -37,7 +38,7 @@ class MiraiTextParser extends MiraiParser { textDirection: model.textDirection, softWrap: model.softWrap, overflow: model.overflow, - textScaleFactor: model.textScaleFactor, + textScaler: model.textScaler?.parse, maxLines: model.maxLines, semanticsLabel: model.semanticsLabel, textWidthBasis: model.textWidthBasis, diff --git a/packages/mirai/lib/src/parsers/mirai_text_scaler/mirai_text_scaler.dart b/packages/mirai/lib/src/parsers/mirai_text_scaler/mirai_text_scaler.dart new file mode 100644 index 00000000..6bdf2fab --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_text_scaler/mirai_text_scaler.dart @@ -0,0 +1,24 @@ +import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'mirai_text_scaler.freezed.dart'; +part 'mirai_text_scaler.g.dart'; + +@freezed +class MiraiTextScaler with _$MiraiTextScaler { + const factory MiraiTextScaler({ + double? textScaleFactor, + }) = _MiraiTextScaler; + + factory MiraiTextScaler.fromJson(Map json) => + _$MiraiTextScalerFromJson(json); +} + +extension MiraiTextScalerParser on MiraiTextScaler { + TextScaler? get parse { + if (textScaleFactor != null) { + return TextScaler.linear(textScaleFactor!); + } + return TextScaler.noScaling; + } +} diff --git a/packages/mirai/lib/src/parsers/mirai_text_scaler/mirai_text_scaler.freezed.dart b/packages/mirai/lib/src/parsers/mirai_text_scaler/mirai_text_scaler.freezed.dart new file mode 100644 index 00000000..535ba043 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_text_scaler/mirai_text_scaler.freezed.dart @@ -0,0 +1,154 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'mirai_text_scaler.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + +MiraiTextScaler _$MiraiTextScalerFromJson(Map json) { + return _MiraiTextScaler.fromJson(json); +} + +/// @nodoc +mixin _$MiraiTextScaler { + double? get textScaleFactor => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $MiraiTextScalerCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $MiraiTextScalerCopyWith<$Res> { + factory $MiraiTextScalerCopyWith( + MiraiTextScaler value, $Res Function(MiraiTextScaler) then) = + _$MiraiTextScalerCopyWithImpl<$Res, MiraiTextScaler>; + @useResult + $Res call({double? textScaleFactor}); +} + +/// @nodoc +class _$MiraiTextScalerCopyWithImpl<$Res, $Val extends MiraiTextScaler> + implements $MiraiTextScalerCopyWith<$Res> { + _$MiraiTextScalerCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? textScaleFactor = freezed, + }) { + return _then(_value.copyWith( + textScaleFactor: freezed == textScaleFactor + ? _value.textScaleFactor + : textScaleFactor // ignore: cast_nullable_to_non_nullable + as double?, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$MiraiTextScalerImplCopyWith<$Res> + implements $MiraiTextScalerCopyWith<$Res> { + factory _$$MiraiTextScalerImplCopyWith(_$MiraiTextScalerImpl value, + $Res Function(_$MiraiTextScalerImpl) then) = + __$$MiraiTextScalerImplCopyWithImpl<$Res>; + @override + @useResult + $Res call({double? textScaleFactor}); +} + +/// @nodoc +class __$$MiraiTextScalerImplCopyWithImpl<$Res> + extends _$MiraiTextScalerCopyWithImpl<$Res, _$MiraiTextScalerImpl> + implements _$$MiraiTextScalerImplCopyWith<$Res> { + __$$MiraiTextScalerImplCopyWithImpl( + _$MiraiTextScalerImpl _value, $Res Function(_$MiraiTextScalerImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? textScaleFactor = freezed, + }) { + return _then(_$MiraiTextScalerImpl( + textScaleFactor: freezed == textScaleFactor + ? _value.textScaleFactor + : textScaleFactor // ignore: cast_nullable_to_non_nullable + as double?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$MiraiTextScalerImpl implements _MiraiTextScaler { + const _$MiraiTextScalerImpl({this.textScaleFactor}); + + factory _$MiraiTextScalerImpl.fromJson(Map json) => + _$$MiraiTextScalerImplFromJson(json); + + @override + final double? textScaleFactor; + + @override + String toString() { + return 'MiraiTextScaler(textScaleFactor: $textScaleFactor)'; + } + + @override + bool operator ==(dynamic other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$MiraiTextScalerImpl && + (identical(other.textScaleFactor, textScaleFactor) || + other.textScaleFactor == textScaleFactor)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, textScaleFactor); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$MiraiTextScalerImplCopyWith<_$MiraiTextScalerImpl> get copyWith => + __$$MiraiTextScalerImplCopyWithImpl<_$MiraiTextScalerImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$MiraiTextScalerImplToJson( + this, + ); + } +} + +abstract class _MiraiTextScaler implements MiraiTextScaler { + const factory _MiraiTextScaler({final double? textScaleFactor}) = + _$MiraiTextScalerImpl; + + factory _MiraiTextScaler.fromJson(Map json) = + _$MiraiTextScalerImpl.fromJson; + + @override + double? get textScaleFactor; + @override + @JsonKey(ignore: true) + _$$MiraiTextScalerImplCopyWith<_$MiraiTextScalerImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/mirai/lib/src/parsers/mirai_text_scaler/mirai_text_scaler.g.dart b/packages/mirai/lib/src/parsers/mirai_text_scaler/mirai_text_scaler.g.dart new file mode 100644 index 00000000..1875f082 --- /dev/null +++ b/packages/mirai/lib/src/parsers/mirai_text_scaler/mirai_text_scaler.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mirai_text_scaler.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$MiraiTextScalerImpl _$$MiraiTextScalerImplFromJson( + Map json) => + _$MiraiTextScalerImpl( + textScaleFactor: (json['textScaleFactor'] as num?)?.toDouble(), + ); + +Map _$$MiraiTextScalerImplToJson( + _$MiraiTextScalerImpl instance) => + { + 'textScaleFactor': instance.textScaleFactor, + };