Skip to content

Commit

Permalink
fix: Removed compareVal and added obscure text in text-field
Browse files Browse the repository at this point in the history
  • Loading branch information
i-asimkhan committed Oct 26, 2023
1 parent 439b16f commit d5a239f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 75 deletions.
42 changes: 21 additions & 21 deletions packages/mirai/lib/src/parsers/mirai_align/mirai_align.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ class _$MiraiAlignCopyWithImpl<$Res, $Val extends MiraiAlign>
}

/// @nodoc
abstract class _$$MiraiAlignImplCopyWith<$Res>
abstract class _$$_MiraiAlignCopyWith<$Res>
implements $MiraiAlignCopyWith<$Res> {
factory _$$MiraiAlignImplCopyWith(
_$MiraiAlignImpl value, $Res Function(_$MiraiAlignImpl) then) =
__$$MiraiAlignImplCopyWithImpl<$Res>;
factory _$$_MiraiAlignCopyWith(
_$_MiraiAlign value, $Res Function(_$_MiraiAlign) then) =
__$$_MiraiAlignCopyWithImpl<$Res>;
@override
@useResult
$Res call(
Expand All @@ -99,11 +99,11 @@ abstract class _$$MiraiAlignImplCopyWith<$Res>
}

/// @nodoc
class __$$MiraiAlignImplCopyWithImpl<$Res>
extends _$MiraiAlignCopyWithImpl<$Res, _$MiraiAlignImpl>
implements _$$MiraiAlignImplCopyWith<$Res> {
__$$MiraiAlignImplCopyWithImpl(
_$MiraiAlignImpl _value, $Res Function(_$MiraiAlignImpl) _then)
class __$$_MiraiAlignCopyWithImpl<$Res>
extends _$MiraiAlignCopyWithImpl<$Res, _$_MiraiAlign>
implements _$$_MiraiAlignCopyWith<$Res> {
__$$_MiraiAlignCopyWithImpl(
_$_MiraiAlign _value, $Res Function(_$_MiraiAlign) _then)
: super(_value, _then);

@pragma('vm:prefer-inline')
Expand All @@ -114,7 +114,7 @@ class __$$MiraiAlignImplCopyWithImpl<$Res>
Object? heightFactor = freezed,
Object? child = freezed,
}) {
return _then(_$MiraiAlignImpl(
return _then(_$_MiraiAlign(
alignment: null == alignment
? _value.alignment
: alignment // ignore: cast_nullable_to_non_nullable
Expand All @@ -137,16 +137,16 @@ class __$$MiraiAlignImplCopyWithImpl<$Res>

/// @nodoc
@JsonSerializable()
class _$MiraiAlignImpl implements _MiraiAlign {
const _$MiraiAlignImpl(
class _$_MiraiAlign implements _MiraiAlign {
const _$_MiraiAlign(
{this.alignment = MiraiAlignmentDirectional.center,
this.widthFactor,
this.heightFactor,
final Map<String, dynamic>? child})
: _child = child;

factory _$MiraiAlignImpl.fromJson(Map<String, dynamic> json) =>
_$$MiraiAlignImplFromJson(json);
factory _$_MiraiAlign.fromJson(Map<String, dynamic> json) =>
_$$_MiraiAlignFromJson(json);

@override
@JsonKey()
Expand Down Expand Up @@ -174,7 +174,7 @@ class _$MiraiAlignImpl implements _MiraiAlign {
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$MiraiAlignImpl &&
other is _$_MiraiAlign &&
(identical(other.alignment, alignment) ||
other.alignment == alignment) &&
(identical(other.widthFactor, widthFactor) ||
Expand All @@ -192,12 +192,12 @@ class _$MiraiAlignImpl implements _MiraiAlign {
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$MiraiAlignImplCopyWith<_$MiraiAlignImpl> get copyWith =>
__$$MiraiAlignImplCopyWithImpl<_$MiraiAlignImpl>(this, _$identity);
_$$_MiraiAlignCopyWith<_$_MiraiAlign> get copyWith =>
__$$_MiraiAlignCopyWithImpl<_$_MiraiAlign>(this, _$identity);

@override
Map<String, dynamic> toJson() {
return _$$MiraiAlignImplToJson(
return _$$_MiraiAlignToJson(
this,
);
}
Expand All @@ -208,10 +208,10 @@ abstract class _MiraiAlign implements MiraiAlign {
{final MiraiAlignmentDirectional alignment,
final double? widthFactor,
final double? heightFactor,
final Map<String, dynamic>? child}) = _$MiraiAlignImpl;
final Map<String, dynamic>? child}) = _$_MiraiAlign;

factory _MiraiAlign.fromJson(Map<String, dynamic> json) =
_$MiraiAlignImpl.fromJson;
_$_MiraiAlign.fromJson;

@override
MiraiAlignmentDirectional get alignment;
Expand All @@ -223,6 +223,6 @@ abstract class _MiraiAlign implements MiraiAlign {
Map<String, dynamic>? get child;
@override
@JsonKey(ignore: true)
_$$MiraiAlignImplCopyWith<_$MiraiAlignImpl> get copyWith =>
_$$_MiraiAlignCopyWith<_$_MiraiAlign> get copyWith =>
throw _privateConstructorUsedError;
}
6 changes: 3 additions & 3 deletions packages/mirai/lib/src/parsers/mirai_align/mirai_align.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MiraiTextFormField with _$MiraiTextFormField {
int? maxLines,
int? minLines,
int? maxLength,
bool? obscureText,
@Default(false) bool obscureText,
@Default(true) bool autocorrect,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mixin _$MiraiTextFormField {
int? get maxLines => throw _privateConstructorUsedError;
int? get minLines => throw _privateConstructorUsedError;
int? get maxLength => throw _privateConstructorUsedError;
bool? get obscureText => throw _privateConstructorUsedError;
bool get obscureText => throw _privateConstructorUsedError;
bool get autocorrect => throw _privateConstructorUsedError;
SmartDashesType? get smartDashesType => throw _privateConstructorUsedError;
SmartQuotesType? get smartQuotesType => throw _privateConstructorUsedError;
Expand Down Expand Up @@ -94,7 +94,7 @@ abstract class $MiraiTextFormFieldCopyWith<$Res> {
int? maxLines,
int? minLines,
int? maxLength,
bool? obscureText,
bool obscureText,
bool autocorrect,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
Expand Down Expand Up @@ -150,7 +150,7 @@ class _$MiraiTextFormFieldCopyWithImpl<$Res, $Val extends MiraiTextFormField>
Object? maxLines = freezed,
Object? minLines = freezed,
Object? maxLength = freezed,
Object? obscureText = freezed,
Object? obscureText = null,
Object? autocorrect = null,
Object? smartDashesType = freezed,
Object? smartQuotesType = freezed,
Expand Down Expand Up @@ -243,10 +243,10 @@ class _$MiraiTextFormFieldCopyWithImpl<$Res, $Val extends MiraiTextFormField>
? _value.maxLength
: maxLength // ignore: cast_nullable_to_non_nullable
as int?,
obscureText: freezed == obscureText
obscureText: null == obscureText
? _value.obscureText
: obscureText // ignore: cast_nullable_to_non_nullable
as bool?,
as bool,
autocorrect: null == autocorrect
? _value.autocorrect
: autocorrect // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -382,7 +382,7 @@ abstract class _$$_MiraiTextFormFieldCopyWith<$Res>
int? maxLines,
int? minLines,
int? maxLength,
bool? obscureText,
bool obscureText,
bool autocorrect,
SmartDashesType? smartDashesType,
SmartQuotesType? smartQuotesType,
Expand Down Expand Up @@ -439,7 +439,7 @@ class __$$_MiraiTextFormFieldCopyWithImpl<$Res>
Object? maxLines = freezed,
Object? minLines = freezed,
Object? maxLength = freezed,
Object? obscureText = freezed,
Object? obscureText = null,
Object? autocorrect = null,
Object? smartDashesType = freezed,
Object? smartQuotesType = freezed,
Expand Down Expand Up @@ -532,10 +532,10 @@ class __$$_MiraiTextFormFieldCopyWithImpl<$Res>
? _value.maxLength
: maxLength // ignore: cast_nullable_to_non_nullable
as int?,
obscureText: freezed == obscureText
obscureText: null == obscureText
? _value.obscureText
: obscureText // ignore: cast_nullable_to_non_nullable
as bool?,
as bool,
autocorrect: null == autocorrect
? _value.autocorrect
: autocorrect // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -634,7 +634,7 @@ class _$_MiraiTextFormField implements _MiraiTextFormField {
this.maxLines,
this.minLines,
this.maxLength,
this.obscureText,
this.obscureText = false,
this.autocorrect = true,
this.smartDashesType,
this.smartQuotesType,
Expand Down Expand Up @@ -702,7 +702,8 @@ class _$_MiraiTextFormField implements _MiraiTextFormField {
@override
final int? maxLength;
@override
final bool? obscureText;
@JsonKey()
final bool obscureText;
@override
@JsonKey()
final bool autocorrect;
Expand Down Expand Up @@ -921,7 +922,7 @@ abstract class _MiraiTextFormField implements MiraiTextFormField {
final int? maxLines,
final int? minLines,
final int? maxLength,
final bool? obscureText,
final bool obscureText,
final bool autocorrect,
final SmartDashesType? smartDashesType,
final SmartQuotesType? smartQuotesType,
Expand Down Expand Up @@ -982,7 +983,7 @@ abstract class _MiraiTextFormField implements MiraiTextFormField {
@override
int? get maxLength;
@override
bool? get obscureText;
bool get obscureText;
@override
bool get autocorrect;
@override
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/material.dart';
import 'package:mirai/src/framework/framework.dart';
import 'package:mirai/src/parsers/mirai_edge_insets/mirai_edge_insets.dart';
import 'package:mirai/src/parsers/mirai_form/mirai_form_parser.dart';
import 'package:mirai/src/parsers/mirai_form_field_validator/mirai_form_validator.dart';
Expand Down Expand Up @@ -62,13 +61,11 @@ class _TextFormFieldWidget extends StatefulWidget {
class _TextFormFieldWidgetState extends State<_TextFormFieldWidget> {
TextEditingController controller = TextEditingController();
FocusNode? focusNode = FocusNode();
bool obscureText = false;

@override
void initState() {
controller = widget.controler ??
TextEditingController(text: widget.model.initialValue);
obscureText = widget.model.obscureText ?? false;
super.initState();
}

Expand Down Expand Up @@ -101,7 +98,7 @@ class _TextFormFieldWidgetState extends State<_TextFormFieldWidget> {
maxLines: widget.model.maxLines,
minLines: widget.model.minLines,
maxLength: widget.model.maxLength,
obscureText: obscureText,
obscureText: widget.model.obscureText,
autocorrect: widget.model.autocorrect,
smartDashesType: widget.model.smartDashesType,
smartQuotesType: widget.model.smartQuotesType,
Expand All @@ -117,7 +114,7 @@ class _TextFormFieldWidgetState extends State<_TextFormFieldWidget> {
cursorHeight: widget.model.cursorHeight,
cursorColor: widget.model.cursorColor?.toColor,
style: widget.model.style?.parse,
decoration: _inputDecoration(widget.model),
decoration: widget.model.decoration?.parse(context),
inputFormatters: widget.model.inputFormatters
.map((MiraiInputFormatter formatter) =>
formatter.type.format(formatter.rule ?? ""))
Expand All @@ -134,44 +131,14 @@ class _TextFormFieldWidgetState extends State<_TextFormFieldWidget> {
);
}

InputDecoration? _inputDecoration(MiraiTextFormField model) {
if (model.obscureText != null) {
return model.decoration?.parse(context).copyWith(
suffixIcon: GestureDetector(
onTap: () {
setState(() {
obscureText = !obscureText;
});
},
child: Mirai.fromJson(
widget.model.decoration?.suffixIcon, context) ??
const SizedBox(),
),
);
}

return model.decoration?.parse(context);
}

String? _validate(String? value, MiraiTextFormField model) {
if (value != null && widget.model.validatorRules.isNotEmpty) {
for (MiraiFormFieldValidator validator in widget.model.validatorRules) {
try {
InputValidationType? validationType = InputValidationType.values
.firstWhere((e) => e.name == validator.rule);

String? compareVal;
if (widget.model.compareId != null) {
try {
// compareVal = context
// .read<MiraiFormCubit>()
// .getValue(widget.model.compareId!);
} catch (e) {
Log.e(e);
}
}
if (!validationType.validate(value, validator.rule,
compareValue: compareVal)) {
if (!validationType.validate(value, validator.rule)) {
return validator.message;
}
} catch (_) {
Expand Down

0 comments on commit d5a239f

Please sign in to comment.