Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added visibility icon in input_decoration in case - password visibility has diff icon #229

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions examples/mirai_gallery/assets/json/form_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@
"icon": "eye",
"size": 24
},
"visibilityIcon": {
"type": "icon",
"iconType": "cupertino",
"icon": "eye_slash",
"size": 24
},
"labelText": "Password*"
},
"validatorRules": [
Expand Down Expand Up @@ -256,6 +262,12 @@
"icon": "eye",
"size": 24
},
"visibilityIcon": {
"type": "icon",
"iconType": "cupertino",
"icon": "eye_slash",
"size": 24
},
"labelText": "Re-type password*"
},
"validatorRules": [
Expand Down
15 changes: 14 additions & 1 deletion examples/mirai_gallery/assets/json/text_field_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@
"icon": "eye",
"size": 24
},
"visibilityIcon": {
"type": "icon",
"iconType": "cupertino",
"icon": "eye_slash",
"size": 24
},
"labelText": "Password*"
},
"autovalidateMode": "onUserInteraction",
Expand Down Expand Up @@ -221,6 +227,12 @@
"icon": "eye",
"size": 24
},
"visibilityIcon": {
"type": "icon",
"iconType": "cupertino",
"icon": "eye_slash",
"size": 24
},
"labelText": "Re-type password*"
},
"readOnly": false,
Expand Down Expand Up @@ -254,7 +266,8 @@
},
"gradient": {
"colors": [
"#FF0000", "#0000FF"
"#FF0000",
"#0000FF"
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class MiraiInputDecoration with _$MiraiInputDecoration {
String? prefixIconColor,
Map<String, dynamic>? suffix,
Map<String, dynamic>? suffixIcon,
Map<String, dynamic>? visibilityIcon,
MiraiBoxConstraints? suffixIconConstraints,
String? suffixText,
MiraiTextStyle? suffixStyle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ mixin _$MiraiInputDecoration {
String? get prefixIconColor => throw _privateConstructorUsedError;
Map<String, dynamic>? get suffix => throw _privateConstructorUsedError;
Map<String, dynamic>? get suffixIcon => throw _privateConstructorUsedError;
Map<String, dynamic>? get visibilityIcon =>
throw _privateConstructorUsedError;
MiraiBoxConstraints? get suffixIconConstraints =>
throw _privateConstructorUsedError;
String? get suffixText => throw _privateConstructorUsedError;
Expand Down Expand Up @@ -118,6 +120,7 @@ abstract class $MiraiInputDecorationCopyWith<$Res> {
String? prefixIconColor,
Map<String, dynamic>? suffix,
Map<String, dynamic>? suffixIcon,
Map<String, dynamic>? visibilityIcon,
MiraiBoxConstraints? suffixIconConstraints,
String? suffixText,
MiraiTextStyle? suffixStyle,
Expand Down Expand Up @@ -203,6 +206,7 @@ class _$MiraiInputDecorationCopyWithImpl<$Res,
Object? prefixIconColor = freezed,
Object? suffix = freezed,
Object? suffixIcon = freezed,
Object? visibilityIcon = freezed,
Object? suffixIconConstraints = freezed,
Object? suffixText = freezed,
Object? suffixStyle = freezed,
Expand Down Expand Up @@ -342,6 +346,10 @@ class _$MiraiInputDecorationCopyWithImpl<$Res,
? _value.suffixIcon
: suffixIcon // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
visibilityIcon: freezed == visibilityIcon
? _value.visibilityIcon
: visibilityIcon // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
suffixIconConstraints: freezed == suffixIconConstraints
? _value.suffixIconConstraints
: suffixIconConstraints // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -686,6 +694,7 @@ abstract class _$$_MiraiInputDecorationCopyWith<$Res>
String? prefixIconColor,
Map<String, dynamic>? suffix,
Map<String, dynamic>? suffixIcon,
Map<String, dynamic>? visibilityIcon,
MiraiBoxConstraints? suffixIconConstraints,
String? suffixText,
MiraiTextStyle? suffixStyle,
Expand Down Expand Up @@ -786,6 +795,7 @@ class __$$_MiraiInputDecorationCopyWithImpl<$Res>
Object? prefixIconColor = freezed,
Object? suffix = freezed,
Object? suffixIcon = freezed,
Object? visibilityIcon = freezed,
Object? suffixIconConstraints = freezed,
Object? suffixText = freezed,
Object? suffixStyle = freezed,
Expand Down Expand Up @@ -925,6 +935,10 @@ class __$$_MiraiInputDecorationCopyWithImpl<$Res>
? _value._suffixIcon
: suffixIcon // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
visibilityIcon: freezed == visibilityIcon
? _value._visibilityIcon
: visibilityIcon // ignore: cast_nullable_to_non_nullable
as Map<String, dynamic>?,
suffixIconConstraints: freezed == suffixIconConstraints
? _value.suffixIconConstraints
: suffixIconConstraints // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -1046,6 +1060,7 @@ class _$_MiraiInputDecoration implements _MiraiInputDecoration {
this.prefixIconColor,
final Map<String, dynamic>? suffix,
final Map<String, dynamic>? suffixIcon,
final Map<String, dynamic>? visibilityIcon,
this.suffixIconConstraints,
this.suffixText,
this.suffixStyle,
Expand Down Expand Up @@ -1073,6 +1088,7 @@ class _$_MiraiInputDecoration implements _MiraiInputDecoration {
_prefix = prefix,
_suffix = suffix,
_suffixIcon = suffixIcon,
_visibilityIcon = visibilityIcon,
_counter = counter;

factory _$_MiraiInputDecoration.fromJson(Map<String, dynamic> json) =>
Expand Down Expand Up @@ -1186,6 +1202,16 @@ class _$_MiraiInputDecoration implements _MiraiInputDecoration {
return EqualUnmodifiableMapView(value);
}

final Map<String, dynamic>? _visibilityIcon;
@override
Map<String, dynamic>? get visibilityIcon {
final value = _visibilityIcon;
if (value == null) return null;
if (_visibilityIcon is EqualUnmodifiableMapView) return _visibilityIcon;
// ignore: implicit_dynamic_type
return EqualUnmodifiableMapView(value);
}

@override
final MiraiBoxConstraints? suffixIconConstraints;
@override
Expand Down Expand Up @@ -1241,7 +1267,7 @@ class _$_MiraiInputDecoration implements _MiraiInputDecoration {

@override
String toString() {
return 'MiraiInputDecoration(icon: $icon, iconColor: $iconColor, label: $label, labelText: $labelText, labelStyle: $labelStyle, floatingLabelStyle: $floatingLabelStyle, helperText: $helperText, helperStyle: $helperStyle, hintText: $hintText, hintStyle: $hintStyle, helperMaxLines: $helperMaxLines, hintTextDirection: $hintTextDirection, hintMaxLines: $hintMaxLines, errorText: $errorText, errorStyle: $errorStyle, errorMaxLines: $errorMaxLines, floatingLabelBehavior: $floatingLabelBehavior, floatingLabelAlignment: $floatingLabelAlignment, isCollapsed: $isCollapsed, isDense: $isDense, contentPadding: $contentPadding, prefixIcon: $prefixIcon, prefixIconConstraints: $prefixIconConstraints, prefix: $prefix, prefixText: $prefixText, prefixStyle: $prefixStyle, prefixIconColor: $prefixIconColor, suffix: $suffix, suffixIcon: $suffixIcon, suffixIconConstraints: $suffixIconConstraints, suffixText: $suffixText, suffixStyle: $suffixStyle, suffixIconColor: $suffixIconColor, counter: $counter, counterText: $counterText, counterStyle: $counterStyle, filled: $filled, fillColor: $fillColor, hoverColor: $hoverColor, focusColor: $focusColor, errorBorder: $errorBorder, focusedBorder: $focusedBorder, focusedErrorBorder: $focusedErrorBorder, disabledBorder: $disabledBorder, enabledBorder: $enabledBorder, border: $border, enabled: $enabled, semanticCounterText: $semanticCounterText, alignLabelWithHint: $alignLabelWithHint, constraints: $constraints)';
return 'MiraiInputDecoration(icon: $icon, iconColor: $iconColor, label: $label, labelText: $labelText, labelStyle: $labelStyle, floatingLabelStyle: $floatingLabelStyle, helperText: $helperText, helperStyle: $helperStyle, hintText: $hintText, hintStyle: $hintStyle, helperMaxLines: $helperMaxLines, hintTextDirection: $hintTextDirection, hintMaxLines: $hintMaxLines, errorText: $errorText, errorStyle: $errorStyle, errorMaxLines: $errorMaxLines, floatingLabelBehavior: $floatingLabelBehavior, floatingLabelAlignment: $floatingLabelAlignment, isCollapsed: $isCollapsed, isDense: $isDense, contentPadding: $contentPadding, prefixIcon: $prefixIcon, prefixIconConstraints: $prefixIconConstraints, prefix: $prefix, prefixText: $prefixText, prefixStyle: $prefixStyle, prefixIconColor: $prefixIconColor, suffix: $suffix, suffixIcon: $suffixIcon, visibilityIcon: $visibilityIcon, suffixIconConstraints: $suffixIconConstraints, suffixText: $suffixText, suffixStyle: $suffixStyle, suffixIconColor: $suffixIconColor, counter: $counter, counterText: $counterText, counterStyle: $counterStyle, filled: $filled, fillColor: $fillColor, hoverColor: $hoverColor, focusColor: $focusColor, errorBorder: $errorBorder, focusedBorder: $focusedBorder, focusedErrorBorder: $focusedErrorBorder, disabledBorder: $disabledBorder, enabledBorder: $enabledBorder, border: $border, enabled: $enabled, semanticCounterText: $semanticCounterText, alignLabelWithHint: $alignLabelWithHint, constraints: $constraints)';
}

@override
Expand Down Expand Up @@ -1302,6 +1328,8 @@ class _$_MiraiInputDecoration implements _MiraiInputDecoration {
const DeepCollectionEquality().equals(other._suffix, _suffix) &&
const DeepCollectionEquality()
.equals(other._suffixIcon, _suffixIcon) &&
const DeepCollectionEquality()
.equals(other._visibilityIcon, _visibilityIcon) &&
(identical(other.suffixIconConstraints, suffixIconConstraints) ||
other.suffixIconConstraints == suffixIconConstraints) &&
(identical(other.suffixText, suffixText) ||
Expand Down Expand Up @@ -1375,6 +1403,7 @@ class _$_MiraiInputDecoration implements _MiraiInputDecoration {
prefixIconColor,
const DeepCollectionEquality().hash(_suffix),
const DeepCollectionEquality().hash(_suffixIcon),
const DeepCollectionEquality().hash(_visibilityIcon),
suffixIconConstraints,
suffixText,
suffixStyle,
Expand Down Expand Up @@ -1444,6 +1473,7 @@ abstract class _MiraiInputDecoration implements MiraiInputDecoration {
final String? prefixIconColor,
final Map<String, dynamic>? suffix,
final Map<String, dynamic>? suffixIcon,
final Map<String, dynamic>? visibilityIcon,
final MiraiBoxConstraints? suffixIconConstraints,
final String? suffixText,
final MiraiTextStyle? suffixStyle,
Expand Down Expand Up @@ -1528,6 +1558,8 @@ abstract class _MiraiInputDecoration implements MiraiInputDecoration {
@override
Map<String, dynamic>? get suffixIcon;
@override
Map<String, dynamic>? get visibilityIcon;
@override
MiraiBoxConstraints? get suffixIconConstraints;
@override
String? get suffixText;
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
Expand Up @@ -135,7 +135,11 @@ class __TextFormFieldWidgetState extends State<_TextFormFieldWidget> {
});
},
child: Mirai.fromJson(
widget.model.decoration?.suffixIcon, context) ??
(!obscureText &&
widget.model.decoration?.visibilityIcon != null)
? widget.model.decoration?.visibilityIcon
: widget.model.decoration?.suffixIcon,
context) ??
const SizedBox(),
),
);
Expand Down