Skip to content

Commit

Permalink
v5.82.0
Browse files Browse the repository at this point in the history
  • Loading branch information
agordn52 committed Jul 18, 2024
1 parent 4b9f5e9 commit f0cbbfa
Show file tree
Hide file tree
Showing 10 changed files with 419 additions and 328 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## [5.82.0] - 2024-07-18

* New `create` method added to `NyFormData` class. This will allow you to create the form from the instance.
* Add `FormStyle` to NyForm. This will allow you to set a global style for the form. It currently only supports `TextField` and `NyFormCheckbox` widgets.
* Ability to create custom validation rules in `NyForm`'s
* Added `refreshState` to `NyForm` class. This will refresh the state of the form.
* Added new typedefs `FormStyleTextField` and `FormStyleCheckbox` for handling custom styles in `NyForm`
* Added `clear` method to `NyForm` class. This will clear the form.
* Added `clearField` method to `NyForm` class. This will clear a specific field in the form.
* Update `setField` and `setData` methods in `NyForm` class. This will now update the state of the form after setting the field.
* Small refactor to the `NyTextField` class
* Refactor `NyFormCheckbox` class to support global styles
* `FormStyle` added to Nylo class
* Update pubspec.yaml

## [5.81.2] - 2024-07-09

* Update default toast widget text style
Expand Down
10 changes: 5 additions & 5 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ packages:
dependency: transitive
description:
name: flutter_multi_formatter
sha256: "3495dc0056c96e467039a05bd184a5285c271a0efb2024a7030c7e84ba828994"
sha256: "68274ade17e836e7de9080ad354aa4322906baee2abf49afb1f6fec99ff17aea"
url: "https://pub.dev"
source: hosted
version: "2.12.8"
version: "2.13.0"
flutter_secure_storage:
dependency: transitive
description:
Expand Down Expand Up @@ -331,7 +331,7 @@ packages:
path: ".."
relative: true
source: path
version: "5.81.2"
version: "5.82.0"
page_transition:
dependency: transitive
description:
Expand Down Expand Up @@ -504,10 +504,10 @@ packages:
dependency: transitive
description:
name: skeletonizer
sha256: d94ae24d9fcedc5fd2984ccbe5af5e9d76e2bf6a35ee775fe8c737c90297908e
sha256: "9dcaec747d200a299bc457ffe51f135b9856b7f9097e851e277c4c95f563893b"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.4.1+1"
sky_engine:
dependency: transitive
description: flutter
Expand Down
7 changes: 4 additions & 3 deletions lib/forms/ny_login_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ class NyLoginForm extends NyFormData {
style: _style),
Field("Password",
cast: FormCast.password(viewable: passwordViewable),
validate: passwordValidationRule == null ? null : FormValidator.rule(
passwordValidationRule,
message: passwordValidationMessage),
validate: passwordValidationRule == null
? null
: FormValidator.rule(passwordValidationRule,
message: passwordValidationMessage),
style: _style),
];

Expand Down
10 changes: 10 additions & 0 deletions lib/nylo.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:error_stack/error_stack.dart';
import 'package:intl/intl.dart';
import 'package:nylo_support/widgets/ny_form.dart';
import '/controllers/ny_controller.dart';
import '/event_bus/event_bus_plus.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -50,6 +51,7 @@ class Nylo {
Map<Type, dynamic> _controllerDecoders = {};
Map<Type, dynamic> _singletonControllers = {};
Function(String route, dynamic data)? onDeepLinkAction;
NyFormStyle? _formStyle;

/// Create a new Nylo instance.
Nylo({this.router, bool useNyRouteObserver = true})
Expand Down Expand Up @@ -82,6 +84,14 @@ class Nylo {
}
}

/// Set the form style
addFormStyle(NyFormStyle formStyle) {
_formStyle = formStyle;
}

/// Get the form style
NyFormStyle? getFormStyle() => _formStyle;

/// Update the stack on the router.
/// [routes] is a list of routes to navigate to. E.g. [HomePage.path, SettingPage.path]
/// [replace] is a boolean that determines if the current route should be replaced.
Expand Down
31 changes: 28 additions & 3 deletions lib/widgets/fields/form_checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,34 @@ class _NyFormCheckboxState extends State<NyFormCheckbox> {

@override
Widget build(BuildContext context) {
Widget? title = getMetaData('title');

if (title == null) {
title = Text(
widget.field.name,
);
}
if (title is Text && (title.data == null || title.data!.isEmpty)) {
title = Text(
widget.field.name,
);
}

Color? fillColorMetaData = getMetaData('fillColor');
WidgetStateProperty<Color?>? fillColor;
if (fillColorMetaData != null) {
fillColor = WidgetStateProperty.all(fillColorMetaData);
}

Color? overlayColorMetaData = getMetaData('overlayColor');
WidgetStateProperty<Color?>? overlayColor;
if (overlayColorMetaData != null) {
overlayColor = WidgetStateProperty.all(overlayColorMetaData);
}

return CheckboxListTile(
mouseCursor: getMetaData('mouseCursor'),
title: Text(widget.field.name),
title: title,
value: currentValue,
onChanged: (value) {
setState(() {
Expand All @@ -129,10 +154,10 @@ class _NyFormCheckboxState extends State<NyFormCheckbox> {
},
controlAffinity: ListTileControlAffinity.leading,
activeColor: getMetaData('activeColor'),
fillColor: getMetaData('fillColor'),
fillColor: fillColor,
checkColor: getMetaData('checkColor'),
hoverColor: getMetaData('hoverColor'),
overlayColor: getMetaData('overlayColor'),
overlayColor: overlayColor,
splashRadius: getMetaData('splashRadius'),
materialTapTargetSize: getMetaData('materialTapTargetSize'),
visualDensity: getMetaData('visualDensity'),
Expand Down
Loading

0 comments on commit f0cbbfa

Please sign in to comment.