-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added input formatters structure in Mirai to support input formatters…
… in text fields.
- Loading branch information
1 parent
f91d483
commit 3f4853c
Showing
13 changed files
with
481 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/mirai/lib/src/parsers/mirai_input_formatters/mirai_input_formatter.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:mirai/src/utils/input_formatters.dart'; | ||
|
||
part 'mirai_input_formatter.freezed.dart'; | ||
part 'mirai_input_formatter.g.dart'; | ||
|
||
@freezed | ||
class MiraiInputFormatter with _$MiraiInputFormatter { | ||
const factory MiraiInputFormatter({ | ||
required InputFormatterType type, | ||
String? rule, | ||
String? value, | ||
}) = _MiraiInputFormatter; | ||
|
||
factory MiraiInputFormatter.fromJson(Map<String, dynamic> json) => | ||
_$MiraiInputFormatterFromJson(json); | ||
} |
187 changes: 187 additions & 0 deletions
187
packages/mirai/lib/src/parsers/mirai_input_formatters/mirai_input_formatter.freezed.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
// 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_input_formatter.dart'; | ||
|
||
// ************************************************************************** | ||
// FreezedGenerator | ||
// ************************************************************************** | ||
|
||
T _$identity<T>(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'); | ||
|
||
MiraiInputFormatter _$MiraiInputFormatterFromJson(Map<String, dynamic> json) { | ||
return _MiraiInputFormatter.fromJson(json); | ||
} | ||
|
||
/// @nodoc | ||
mixin _$MiraiInputFormatter { | ||
InputFormatterType get type => throw _privateConstructorUsedError; | ||
String? get rule => throw _privateConstructorUsedError; | ||
String? get value => throw _privateConstructorUsedError; | ||
|
||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError; | ||
@JsonKey(ignore: true) | ||
$MiraiInputFormatterCopyWith<MiraiInputFormatter> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} | ||
|
||
/// @nodoc | ||
abstract class $MiraiInputFormatterCopyWith<$Res> { | ||
factory $MiraiInputFormatterCopyWith( | ||
MiraiInputFormatter value, $Res Function(MiraiInputFormatter) then) = | ||
_$MiraiInputFormatterCopyWithImpl<$Res, MiraiInputFormatter>; | ||
@useResult | ||
$Res call({InputFormatterType type, String? rule, String? value}); | ||
} | ||
|
||
/// @nodoc | ||
class _$MiraiInputFormatterCopyWithImpl<$Res, $Val extends MiraiInputFormatter> | ||
implements $MiraiInputFormatterCopyWith<$Res> { | ||
_$MiraiInputFormatterCopyWithImpl(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? type = null, | ||
Object? rule = freezed, | ||
Object? value = freezed, | ||
}) { | ||
return _then(_value.copyWith( | ||
type: null == type | ||
? _value.type | ||
: type // ignore: cast_nullable_to_non_nullable | ||
as InputFormatterType, | ||
rule: freezed == rule | ||
? _value.rule | ||
: rule // ignore: cast_nullable_to_non_nullable | ||
as String?, | ||
value: freezed == value | ||
? _value.value | ||
: value // ignore: cast_nullable_to_non_nullable | ||
as String?, | ||
) as $Val); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
abstract class _$$_MiraiInputFormatterCopyWith<$Res> | ||
implements $MiraiInputFormatterCopyWith<$Res> { | ||
factory _$$_MiraiInputFormatterCopyWith(_$_MiraiInputFormatter value, | ||
$Res Function(_$_MiraiInputFormatter) then) = | ||
__$$_MiraiInputFormatterCopyWithImpl<$Res>; | ||
@override | ||
@useResult | ||
$Res call({InputFormatterType type, String? rule, String? value}); | ||
} | ||
|
||
/// @nodoc | ||
class __$$_MiraiInputFormatterCopyWithImpl<$Res> | ||
extends _$MiraiInputFormatterCopyWithImpl<$Res, _$_MiraiInputFormatter> | ||
implements _$$_MiraiInputFormatterCopyWith<$Res> { | ||
__$$_MiraiInputFormatterCopyWithImpl(_$_MiraiInputFormatter _value, | ||
$Res Function(_$_MiraiInputFormatter) _then) | ||
: super(_value, _then); | ||
|
||
@pragma('vm:prefer-inline') | ||
@override | ||
$Res call({ | ||
Object? type = null, | ||
Object? rule = freezed, | ||
Object? value = freezed, | ||
}) { | ||
return _then(_$_MiraiInputFormatter( | ||
type: null == type | ||
? _value.type | ||
: type // ignore: cast_nullable_to_non_nullable | ||
as InputFormatterType, | ||
rule: freezed == rule | ||
? _value.rule | ||
: rule // ignore: cast_nullable_to_non_nullable | ||
as String?, | ||
value: freezed == value | ||
? _value.value | ||
: value // ignore: cast_nullable_to_non_nullable | ||
as String?, | ||
)); | ||
} | ||
} | ||
|
||
/// @nodoc | ||
@JsonSerializable() | ||
class _$_MiraiInputFormatter implements _MiraiInputFormatter { | ||
const _$_MiraiInputFormatter({required this.type, this.rule, this.value}); | ||
|
||
factory _$_MiraiInputFormatter.fromJson(Map<String, dynamic> json) => | ||
_$$_MiraiInputFormatterFromJson(json); | ||
|
||
@override | ||
final InputFormatterType type; | ||
@override | ||
final String? rule; | ||
@override | ||
final String? value; | ||
|
||
@override | ||
String toString() { | ||
return 'MiraiInputFormatter(type: $type, rule: $rule, value: $value)'; | ||
} | ||
|
||
@override | ||
bool operator ==(dynamic other) { | ||
return identical(this, other) || | ||
(other.runtimeType == runtimeType && | ||
other is _$_MiraiInputFormatter && | ||
(identical(other.type, type) || other.type == type) && | ||
(identical(other.rule, rule) || other.rule == rule) && | ||
(identical(other.value, value) || other.value == value)); | ||
} | ||
|
||
@JsonKey(ignore: true) | ||
@override | ||
int get hashCode => Object.hash(runtimeType, type, rule, value); | ||
|
||
@JsonKey(ignore: true) | ||
@override | ||
@pragma('vm:prefer-inline') | ||
_$$_MiraiInputFormatterCopyWith<_$_MiraiInputFormatter> get copyWith => | ||
__$$_MiraiInputFormatterCopyWithImpl<_$_MiraiInputFormatter>( | ||
this, _$identity); | ||
|
||
@override | ||
Map<String, dynamic> toJson() { | ||
return _$$_MiraiInputFormatterToJson( | ||
this, | ||
); | ||
} | ||
} | ||
|
||
abstract class _MiraiInputFormatter implements MiraiInputFormatter { | ||
const factory _MiraiInputFormatter( | ||
{required final InputFormatterType type, | ||
final String? rule, | ||
final String? value}) = _$_MiraiInputFormatter; | ||
|
||
factory _MiraiInputFormatter.fromJson(Map<String, dynamic> json) = | ||
_$_MiraiInputFormatter.fromJson; | ||
|
||
@override | ||
InputFormatterType get type; | ||
@override | ||
String? get rule; | ||
@override | ||
String? get value; | ||
@override | ||
@JsonKey(ignore: true) | ||
_$$_MiraiInputFormatterCopyWith<_$_MiraiInputFormatter> get copyWith => | ||
throw _privateConstructorUsedError; | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/mirai/lib/src/parsers/mirai_input_formatters/mirai_input_formatter.g.dart
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.