Skip to content

Commit

Permalink
v6.14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
agordn52 committed Jan 4, 2025
1 parent 2f4b269 commit 1050043
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 47 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [6.14.2] - 2025-01-04

* Fix updateState method when using NyPage.path
* Small fix for route guards when using redirect
* Make `updatePageState` private
* Update pubspec.yaml

## [6.14.1] - 2024-12-31

* Small fix for `NyLanguageSwitcher` to support dark mode
Expand Down
18 changes: 9 additions & 9 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ packages:
dependency: transitive
description:
name: error_stack
sha256: ce2825abfb23ac75cb30bcf05303c714899a10a13e32058cd846058ba968576b
sha256: f1f14820500d6b1931756758f8e6e899a0a0829b8b926ba04f141791cdf7b79e
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.10.0"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -231,26 +231,26 @@ packages:
dependency: transitive
description:
name: flutter_secure_storage
sha256: "165164745e6afb5c0e3e3fcc72a012fb9e58496fb26ffb92cf22e16a821e85d0"
sha256: "1913841ac4c7bf57cd2e05b717e1fbff7841b542962feff827b16525a781b3e4"
url: "https://pub.dev"
source: hosted
version: "9.2.2"
version: "9.2.3"
flutter_secure_storage_linux:
dependency: transitive
description:
name: flutter_secure_storage_linux
sha256: "4d91bfc23047422cbcd73ac684bc169859ee766482517c22172c86596bf1464b"
sha256: bf7404619d7ab5c0a1151d7c4e802edad8f33535abfbeff2f9e1fe1274e2d705
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "1.2.2"
flutter_secure_storage_macos:
dependency: transitive
description:
name: flutter_secure_storage_macos
sha256: "1693ab11121a5f925bbea0be725abfcfbbcf36c1e29e571f84a0c0f436147a81"
sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
version: "3.1.3"
flutter_secure_storage_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -411,7 +411,7 @@ packages:
path: ".."
relative: true
source: path
version: "6.14.1"
version: "6.14.2"
path:
dependency: transitive
description:
Expand Down
30 changes: 15 additions & 15 deletions lib/controllers/ny_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ class NyController extends BaseController {

/// Updates the page [state]
/// Provide an [action] and [data] to call a method in the [NyState].
void updatePageState(String action, dynamic data) {
void _updatePageState(String action, dynamic data) {
assert(state != null, "State cannot be null");
if (state == null) return;
updateState(state!, data: {"action": action, "data": data});
}

/// Refreshes the page
refreshPage() {
updatePageState("refresh-page", {"setState": () {}});
_updatePageState("refresh-page", {"setState": () {}});
}

/// Set the state of the page
setState({required Function() setState}) {
updatePageState("set-state", {"setState": setState});
_updatePageState("set-state", {"setState": setState});
}

/// Pop the page
pop({dynamic result}) {
updatePageState("pop", {"result": result});
_updatePageState("pop", {"result": result});
}

/// Displays a Toast message containing "Sorry" for the title, you
Expand All @@ -38,7 +38,7 @@ class NyController extends BaseController {
{String? title,
required String description,
ToastNotificationStyleType? style}) {
updatePageState("toast-sorry", {
_updatePageState("toast-sorry", {
"title": title ?? "Sorry",
"description": description,
"style": style ?? ToastNotificationStyleType.danger
Expand All @@ -51,7 +51,7 @@ class NyController extends BaseController {
{String? title,
required String description,
ToastNotificationStyleType? style}) {
updatePageState("toast-warning", {
_updatePageState("toast-warning", {
"title": title ?? "Warning",
"description": description,
"style": style ?? ToastNotificationStyleType.warning
Expand All @@ -64,7 +64,7 @@ class NyController extends BaseController {
{String? title,
required String description,
ToastNotificationStyleType? style}) {
updatePageState("toast-info", {
_updatePageState("toast-info", {
"title": title ?? "Info",
"description": description,
"style": style ?? ToastNotificationStyleType.info
Expand All @@ -77,7 +77,7 @@ class NyController extends BaseController {
{String? title,
required String description,
ToastNotificationStyleType? style}) {
updatePageState("toast-danger", {
_updatePageState("toast-danger", {
"title": title ?? "Error",
"description": description,
"style": style ?? ToastNotificationStyleType.danger
Expand All @@ -90,7 +90,7 @@ class NyController extends BaseController {
{String? title,
required String description,
ToastNotificationStyleType? style}) {
updatePageState("toast-oops", {
_updatePageState("toast-oops", {
"title": title ?? "Oops",
"description": description,
"style": style ?? ToastNotificationStyleType.danger
Expand All @@ -103,7 +103,7 @@ class NyController extends BaseController {
{String? title,
required String description,
ToastNotificationStyleType? style}) {
updatePageState("toast-success", {
_updatePageState("toast-success", {
"title": title ?? "Success",
"description": description,
"style": style ?? ToastNotificationStyleType.success
Expand All @@ -115,7 +115,7 @@ class NyController extends BaseController {
{String? title,
required String description,
ToastNotificationStyleType? style}) {
updatePageState("toast-custom", {
_updatePageState("toast-custom", {
"title": title ?? "",
"description": description,
"style": style ?? ToastNotificationStyleType.custom
Expand All @@ -134,7 +134,7 @@ class NyController extends BaseController {
required Function()? onSuccess,
Function(Exception exception)? onFailure,
String? lockRelease}) {
updatePageState("validate", {
_updatePageState("validate", {
"rules": rules,
"data": data,
"messages": messages,
Expand All @@ -149,7 +149,7 @@ class NyController extends BaseController {

/// Update the language in the application
void changeLanguage(String language, {bool restartState = true}) {
updatePageState("change-language", {
_updatePageState("change-language", {
"language": language,
"restartState": restartState,
});
Expand All @@ -158,14 +158,14 @@ class NyController extends BaseController {
/// Perform a lock release
void lockRelease(String name,
{required Function perform, bool shouldSetState = true}) async {
updatePageState("lock-release",
_updatePageState("lock-release",
{"name": name, "perform": perform, "shouldSetState": shouldSetState});
}

/// Perform a confirm action
void confirmAction(Function() action,
{required String title, String dismissText = "Cancel"}) async {
updatePageState("confirm-action",
_updatePageState("confirm-action",
{"action": action, "title": title, "dismissText": dismissText});
}
}
3 changes: 1 addition & 2 deletions lib/helpers/helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,7 @@ void updateState<T>(dynamic name,
}
if (name is RouteView) {
stateName =
"${name.$2.runtimeType.toString().replaceAll("BuildContext", "")}State"
.replaceAll("() => ", "() => _");
"Closure: ${"${name.$2.runtimeType.toString().replaceAll("BuildContext", "")}State".replaceAll("() => ", "() => _")}";
}

final event = UpdateState(data: dataUpdate, stateName: stateName);
Expand Down
60 changes: 57 additions & 3 deletions lib/router/models/nyrouter_route_guard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class NyRouteGuard extends RouteGuard {
if (data != null) {
currentData = data;
}
routeTo(path,

return PageRequest.redirect(path,
data: currentData,
queryParameters: queryParameters,
navigationType: navigationType,
Expand All @@ -90,7 +91,6 @@ class NyRouteGuard extends RouteGuard {
pageTransitionSettings: pageTransitionSettings,
pageTransitionType: pageTransitionType,
onPop: onPop);
return PageRequest.redirect();
}
}

Expand All @@ -100,18 +100,72 @@ class PageRequest {
NyArgument? nyArgument;
Map<String, String>? queryParameters;
bool isRedirect = false;
RouteData? routeData;

get data => nyArgument?.data;

PageRequest({this.context, this.nyArgument, this.queryParameters});

/// Redirect to a new route.
PageRequest.redirect() {
PageRequest.redirect(dynamic path,
{dynamic data,
Map<String, dynamic>? queryParameters,
NavigationType navigationType = NavigationType.pushReplace,
dynamic result,
bool Function(Route<dynamic> route)? removeUntilPredicate,
PageTransitionSettings? pageTransitionSettings,
PageTransitionType? pageTransitionType,
Function(dynamic value)? onPop}) {
isRedirect = true;
routeData = RouteData(path,
data: data,
queryParameters: queryParameters,
navigationType: navigationType,
result: result,
removeUntilPredicate: removeUntilPredicate,
pageTransitionSettings: pageTransitionSettings,
pageTransitionType: pageTransitionType,
onPop: onPop);
}

/// Add data to the current route.
addData(dynamic Function(dynamic data) currentData) {
nyArgument?.setData((currentData(data)));
}
}

/// Route data class.
class RouteData {
dynamic path;
dynamic data;
Map<String, dynamic>? queryParameters;
NavigationType navigationType = NavigationType.pushReplace;
dynamic result;
bool Function(Route<dynamic> route)? removeUntilPredicate;
PageTransitionSettings? pageTransitionSettings;
PageTransitionType? pageTransitionType;
Function(dynamic value)? onPop;

RouteData(this.path,
{this.data,
this.queryParameters,
this.navigationType = NavigationType.pushReplace,
this.result,
this.removeUntilPredicate,
this.pageTransitionSettings,
this.pageTransitionType,
this.onPop});

/// Redirect to a new route.
routeToPage() async {
await routeTo(path,
data: data,
queryParameters: queryParameters,
navigationType: navigationType,
result: result,
removeUntilPredicate: removeUntilPredicate,
pageTransitionSettings: pageTransitionSettings,
pageTransitionType: pageTransitionType,
onPop: onPop);
}
}
5 changes: 4 additions & 1 deletion lib/widgets/ny_base_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,10 @@ abstract class NyBaseState<T extends StatefulWidget> extends State<T> {
} on Exception catch (e) {
NyLogger.error(e.toString());
}
hasInitComplete = true;
if (widget is NyStatefulWidget &&
(widget as NyStatefulWidget).controller.routeGuards.isEmpty) {
hasInitComplete = true;
}
_updateLoadingState(
shouldSetState: shouldSetStateAfter, name: name, value: false);
}
Expand Down
9 changes: 3 additions & 6 deletions lib/widgets/ny_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,9 @@ abstract class NyPage<T extends StatefulWidget> extends NyBaseState<T> {
if (pageRequestFromRouteGuard?.isRedirect == true) {
routeGuardsPassed = false;
}
if (pageRequestFromRouteGuard?.data != null) {
(widget as NyStatefulWidget)
.controller
.request
?.setData(pageRequestFromRouteGuard?.data);
}
WidgetsBinding.instance.addPostFrameCallback((_) {
pageRequestFromRouteGuard?.routeData?.routeToPage();
});
}
if (!routeGuardsPassed) {
return;
Expand Down
16 changes: 8 additions & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ packages:
dependency: "direct main"
description:
name: error_stack
sha256: ce2825abfb23ac75cb30bcf05303c714899a10a13e32058cd846058ba968576b
sha256: f1f14820500d6b1931756758f8e6e899a0a0829b8b926ba04f141791cdf7b79e
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.10.0"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -239,26 +239,26 @@ packages:
dependency: "direct main"
description:
name: flutter_secure_storage
sha256: "165164745e6afb5c0e3e3fcc72a012fb9e58496fb26ffb92cf22e16a821e85d0"
sha256: "1913841ac4c7bf57cd2e05b717e1fbff7841b542962feff827b16525a781b3e4"
url: "https://pub.dev"
source: hosted
version: "9.2.2"
version: "9.2.3"
flutter_secure_storage_linux:
dependency: transitive
description:
name: flutter_secure_storage_linux
sha256: "4d91bfc23047422cbcd73ac684bc169859ee766482517c22172c86596bf1464b"
sha256: bf7404619d7ab5c0a1151d7c4e802edad8f33535abfbeff2f9e1fe1274e2d705
url: "https://pub.dev"
source: hosted
version: "1.2.1"
version: "1.2.2"
flutter_secure_storage_macos:
dependency: transitive
description:
name: flutter_secure_storage_macos
sha256: "1693ab11121a5f925bbea0be725abfcfbbcf36c1e29e571f84a0c0f436147a81"
sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
version: "3.1.3"
flutter_secure_storage_platform_interface:
dependency: transitive
description:
Expand Down
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: nylo_support
description: Support library for the Nylo framework. This library supports routing, widgets, localization, cli, storage and more.
version: 6.14.1
version: 6.14.2
homepage: https://nylo.dev
repository: https://github.com/nylo-core/support/tree/6.x
issue_tracker: https://github.com/nylo-core/support/issues
Expand All @@ -16,7 +16,7 @@ environment:
flutter: ">=3.24.0"

dependencies:
flutter_secure_storage: ^9.2.2
flutter_secure_storage: ^9.2.3
flutter_dotenv: ^5.2.1
theme_provider: ^0.6.0
validated: ^2.0.0
Expand All @@ -32,7 +32,7 @@ dependencies:
pretty_dio_logger: ^1.4.0
intl: ^0.19.0
skeletonizer: ^1.4.1+1
error_stack: ^1.9.0
error_stack: ^1.10.0
date_field: ^6.0.0
flutter_multi_formatter: ^2.13.0
flutter_local_notifications: ^18.0.1
Expand Down

0 comments on commit 1050043

Please sign in to comment.