Skip to content

Commit df0e78c

Browse files
authored
Merge pull request #3 from nylo-core/features/2.1.0
Fix 'updateLocale' method, Ability to add additional Router's to Nylo
2 parents 3db55ae + 17d0d4a commit df0e78c

File tree

4 files changed

+25
-3
lines changed

4 files changed

+25
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [2.1.0] - 2021-09-21
2+
3+
* Fix `updateLocale` method
4+
* Ability to add additional Router's to Nylo
5+
16
## [2.0.1] - 2021-09-18
27

38
* Upgrade Dart (v2.14.0)

lib/localization/app_localization.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ class AppLocale {
249249
/// Updates the current locale for the app.
250250
/// Provide the [locale] you wish to use like Locale("es")
251251
/// The locale needs to also exist within your /lang directory
252-
updateLocale(BuildContext context, Locale locale) {
252+
updateLocale(BuildContext context, Locale locale) async {
253253
this.locale = locale;
254-
reloadLocale(context, locale);
254+
await reloadLocale(context, locale);
255255
}
256256
}
257257

lib/nylo.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ class Nylo {
1818
router!.setNyRoutes(plugin.routes());
1919
}
2020

21+
/// Allows you to add additional Router's to your project.
22+
///
23+
/// file: e.g. /lib/routes/account_router.dart
24+
/// NyRouter accountRouter() => nyRoutes((router) {
25+
/// Add your routes here
26+
/// router.route("/account", (context) => AccountPage());
27+
/// router.route("/account/update", (context) => AccountUpdatePage());
28+
/// });
29+
///
30+
/// Usage in /lib/main.dart e.g. Nylo.addRouter(accountRouter());
31+
addRouter(NyRouter router) async {
32+
if (this.router == null) {
33+
this.router = NyRouter();
34+
}
35+
this.router!.setRegisteredRoutes(router.getRegisteredRoutes());
36+
}
37+
2138
/// Run to init Nylo
2239
static Future<Nylo> init({required router}) async {
2340
await dotenv.load(fileName: ".env");

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: nylo_support
22
description: Support library for the Nylo framework. This library supports routing, widgets, localization, cli, storage and more.
3-
version: 2.0.1
3+
version: 2.1.0
44
homepage: https://nylo.dev
55
repository: https://github.com/nylo-core/support
66
issue_tracker: https://github.com/nylo-core/support/issues

0 commit comments

Comments
 (0)