Skip to content

Commit

Permalink
v6.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
agordn52 committed Dec 29, 2024
1 parent 4c13fa5 commit 35b6822
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 176 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [6.13.0] - 2024-12-29

* Fix validation max and min rules
* New `init` method added to Forms
* Small refactor to `NyForm` class
* Update loadingStyle `render` method

## [6.12.2] - 2024-12-22

* Fix stateName in NyState
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ packages:
path: ".."
relative: true
source: path
version: "6.12.1"
version: "6.13.0"
path:
dependency: transitive
description:
Expand Down
18 changes: 18 additions & 0 deletions lib/helpers/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,24 @@ extension NyInt on int? {
}
}

/// Extensions for List<Widget>
extension NyListWidget on List<Widget> {
/// Add a gap between each child.
List<Widget> withGap(double space) {
assert(space >= 0, 'Space should be a non-negative value.');

List<Widget> newChildren = [];
for (int i = 0; i < length; i++) {
newChildren.add(this[i]);
if (i < length - 1) {
newChildren.add(SizedBox(height: space));
}
}

return newChildren;
}
}

/// Extensions for [Map]
extension NyMap on Map? {
/// dump the value to the console. [tag] is optional.
Expand Down
7 changes: 4 additions & 3 deletions lib/helpers/loading_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ class LoadingStyle {
skeletonizerEffect = null;

/// Render the loading widget
Widget render() {
Widget render({Widget? child}) {
switch (type) {
case LoadingStyleType.normal:
return child ?? Nylo.appLoader();
if (child != null) return child;
return this.child ?? Nylo.appLoader();
case LoadingStyleType.skeletonizer:
return Skeletonizer(
enabled: true,
child: child ?? Nylo.appLoader(),
child: child ?? (this.child ?? Nylo.appLoader()),
);
case LoadingStyleType.none:
return SizedBox.shrink();
Expand Down
40 changes: 20 additions & 20 deletions lib/validation/rules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -448,35 +448,35 @@ class MaxRule extends ValidationRule {
"$attribute must be a maximum length of $intMatch characters.";
textFieldMessage = "Must be a maximum of $intMatch characters.";
super.handle(info);
return (data.length < intMatch);
return (data.length <= intMatch);
}

if (data is int) {
description = "$attribute must be a maximum of $intMatch.";
textFieldMessage = "Must be a maximum of $intMatch.";
super.handle(info);
return (data < intMatch);
return (data <= intMatch);
}

if (data is List) {
description = "$attribute must be a maximum of $intMatch.";
textFieldMessage = "Must be a maximum of $intMatch.";
super.handle(info);
return (data.length < intMatch);
return (data.length <= intMatch);
}

if (data is Map) {
description = "$attribute must be a maximum of $intMatch.";
textFieldMessage = "Must be a maximum of $intMatch.";
super.handle(info);
return (data.length < intMatch);
return (data.length <= intMatch);
}

if (data is double) {
description = "$attribute must be a maximum of $intMatch.";
textFieldMessage = "Must be a maximum of $intMatch.";
super.handle(info);
return (data < intMatch);
return (data <= intMatch);
}

return false;
Expand Down Expand Up @@ -505,38 +505,38 @@ class MinRule extends ValidationRule {
dynamic data = info['data'];
if (data is String) {
description =
"$attribute must be a maximum length of $intMatch characters.";
textFieldMessage = "Must be a maximum of $intMatch characters.";
"$attribute must be a minimum length of $intMatch characters.";
textFieldMessage = "Must be a minimum of $intMatch characters.";
super.handle(info);
return (data.length > intMatch);
return (data.length >= intMatch);
}

if (data is int) {
description = "$attribute must be a maximum of $intMatch.";
textFieldMessage = "Must be a maximum of $intMatch.";
description = "$attribute must be a minimum of $intMatch.";
textFieldMessage = "Must be a minimum of $intMatch.";
super.handle(info);
return (data > intMatch);
return (data >= intMatch);
}

if (data is List) {
description = "$attribute must be a maximum of $intMatch.";
textFieldMessage = "Must be a maximum of $intMatch.";
description = "$attribute must be a minimum of $intMatch.";
textFieldMessage = "Must be a minimum of $intMatch.";
super.handle(info);
return (data.length > intMatch);
return (data.length >= intMatch);
}

if (data is Map) {
description = "$attribute must be a maximum of $intMatch.";
textFieldMessage = "Must be a maximum of $intMatch.";
description = "$attribute must be a minimum of $intMatch.";
textFieldMessage = "Must be a minimum of $intMatch.";
super.handle(info);
return (data.length > intMatch);
return (data.length >= intMatch);
}

if (data is double) {
description = "$attribute must be a maximum of $intMatch.";
textFieldMessage = "Must be a maximum of $intMatch.";
description = "$attribute must be a minimum of $intMatch.";
textFieldMessage = "Must be a minimum of $intMatch.";
super.handle(info);
return (data > intMatch);
return (data >= intMatch);
}
return false;
}
Expand Down
Loading

0 comments on commit 35b6822

Please sign in to comment.