Showing
9 changed files
with
63 additions
and
78 deletions
1 | // This is a generated file; do not edit or check into version control. | 1 | // This is a generated file; do not edit or check into version control. |
2 | FLUTTER_ROOT=/Users/jonatasborges/flutter | 2 | FLUTTER_ROOT=/Users/jonatasborges/flutter |
3 | -FLUTTER_APPLICATION_PATH=/Users/jonatasborges/consertar/getx/example_nav2 | 3 | +FLUTTER_APPLICATION_PATH=/Users/jonatasborges/getx-parse/getx/example_nav2 |
4 | COCOAPODS_PARALLEL_CODE_SIGN=true | 4 | COCOAPODS_PARALLEL_CODE_SIGN=true |
5 | -FLUTTER_TARGET=/Users/jonatasborges/consertar/getx/example_nav2/lib/main.dart | 5 | +FLUTTER_TARGET=lib/main.dart |
6 | FLUTTER_BUILD_DIR=build | 6 | FLUTTER_BUILD_DIR=build |
7 | FLUTTER_BUILD_NAME=1.0.0 | 7 | FLUTTER_BUILD_NAME=1.0.0 |
8 | FLUTTER_BUILD_NUMBER=1 | 8 | FLUTTER_BUILD_NUMBER=1 |
9 | EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 | 9 | EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 |
10 | EXCLUDED_ARCHS[sdk=iphoneos*]=armv7 | 10 | EXCLUDED_ARCHS[sdk=iphoneos*]=armv7 |
11 | -DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ== | ||
12 | DART_OBFUSCATION=false | 11 | DART_OBFUSCATION=false |
13 | TRACK_WIDGET_CREATION=true | 12 | TRACK_WIDGET_CREATION=true |
14 | TREE_SHAKE_ICONS=false | 13 | TREE_SHAKE_ICONS=false |
15 | -PACKAGE_CONFIG=/Users/jonatasborges/consertar/getx/example_nav2/.dart_tool/package_config.json | 14 | +PACKAGE_CONFIG=.dart_tool/package_config.json |
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # This is a generated file; do not edit or check into version control. | 2 | # This is a generated file; do not edit or check into version control. |
3 | export "FLUTTER_ROOT=/Users/jonatasborges/flutter" | 3 | export "FLUTTER_ROOT=/Users/jonatasborges/flutter" |
4 | -export "FLUTTER_APPLICATION_PATH=/Users/jonatasborges/consertar/getx/example_nav2" | 4 | +export "FLUTTER_APPLICATION_PATH=/Users/jonatasborges/getx-parse/getx/example_nav2" |
5 | export "COCOAPODS_PARALLEL_CODE_SIGN=true" | 5 | export "COCOAPODS_PARALLEL_CODE_SIGN=true" |
6 | -export "FLUTTER_TARGET=/Users/jonatasborges/consertar/getx/example_nav2/lib/main.dart" | 6 | +export "FLUTTER_TARGET=lib/main.dart" |
7 | export "FLUTTER_BUILD_DIR=build" | 7 | export "FLUTTER_BUILD_DIR=build" |
8 | export "FLUTTER_BUILD_NAME=1.0.0" | 8 | export "FLUTTER_BUILD_NAME=1.0.0" |
9 | export "FLUTTER_BUILD_NUMBER=1" | 9 | export "FLUTTER_BUILD_NUMBER=1" |
10 | -export "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" | ||
11 | export "DART_OBFUSCATION=false" | 10 | export "DART_OBFUSCATION=false" |
12 | export "TRACK_WIDGET_CREATION=true" | 11 | export "TRACK_WIDGET_CREATION=true" |
13 | export "TREE_SHAKE_ICONS=false" | 12 | export "TREE_SHAKE_ICONS=false" |
14 | -export "PACKAGE_CONFIG=/Users/jonatasborges/consertar/getx/example_nav2/.dart_tool/package_config.json" | 13 | +export "PACKAGE_CONFIG=.dart_tool/package_config.json" |
@@ -10,11 +10,6 @@ class RootController extends GetxController { | @@ -10,11 +10,6 @@ class RootController extends GetxController { | ||
10 | } | 10 | } |
11 | 11 | ||
12 | @override | 12 | @override |
13 | - void onReady() { | ||
14 | - super.onReady(); | ||
15 | - } | ||
16 | - | ||
17 | - @override | ||
18 | void onClose() {} | 13 | void onClose() {} |
19 | void increment() => count.value++; | 14 | void increment() => count.value++; |
20 | } | 15 | } |
@@ -10,11 +10,6 @@ class SettingsController extends GetxController { | @@ -10,11 +10,6 @@ class SettingsController extends GetxController { | ||
10 | } | 10 | } |
11 | 11 | ||
12 | @override | 12 | @override |
13 | - void onReady() { | ||
14 | - super.onReady(); | ||
15 | - } | ||
16 | - | ||
17 | - @override | ||
18 | void onClose() {} | 13 | void onClose() {} |
19 | void increment() => count.value++; | 14 | void increment() => count.value++; |
20 | } | 15 | } |
@@ -5,7 +5,6 @@ export 'src/extension_navigation.dart'; | @@ -5,7 +5,6 @@ export 'src/extension_navigation.dart'; | ||
5 | export 'src/root/get_cupertino_app.dart'; | 5 | export 'src/root/get_cupertino_app.dart'; |
6 | export 'src/root/get_material_app.dart'; | 6 | export 'src/root/get_material_app.dart'; |
7 | export 'src/root/internacionalization.dart'; | 7 | export 'src/root/internacionalization.dart'; |
8 | -export 'src/root/root_controller.dart'; | ||
9 | export 'src/routes/custom_transition.dart'; | 8 | export 'src/routes/custom_transition.dart'; |
10 | export 'src/routes/default_route.dart'; | 9 | export 'src/routes/default_route.dart'; |
11 | export 'src/routes/get_route.dart'; | 10 | export 'src/routes/get_route.dart'; |
1 | -import 'package:flutter/foundation.dart'; | ||
2 | -import 'package:flutter/material.dart'; | ||
3 | - | ||
4 | -import '../../../get.dart'; | ||
5 | - | ||
6 | - | ||
7 | - | ||
8 | -// class GetMaterialController extends FullLifeCycleController { | ||
9 | -// GetMaterialController(this.config); | ||
10 | - | ||
11 | -// // late final RouterDelegate<Object> routerDelegate; | ||
12 | -// // late final RouteInformationParser<Object> routeInformationParser; | ||
13 | -// final ConfigData config; | ||
14 | -// // bool testMode = false; | ||
15 | -// // Key? unikey; | ||
16 | -// // ThemeData? theme; | ||
17 | -// // ThemeData? darkTheme; | ||
18 | -// // ThemeMode? themeMode; | ||
19 | - | ||
20 | -// // final scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>(); | ||
21 | - | ||
22 | -// // bool defaultPopGesture = GetPlatform.isIOS; | ||
23 | -// // bool defaultOpaqueRoute = true; | ||
24 | -// // Transition? defaultTransition; | ||
25 | -// // Duration defaultTransitionDuration = Duration(milliseconds: 300); | ||
26 | -// // Curve defaultTransitionCurve = Curves.easeOutQuad; | ||
27 | -// // Curve defaultDialogTransitionCurve = Curves.easeOutQuad; | ||
28 | -// // Duration defaultDialogTransitionDuration = Duration(milliseconds: 300); | ||
29 | - | ||
30 | -// // final routing = Routing(); | ||
31 | - | ||
32 | -// // Map<String, String?> parameters = {}; | ||
33 | -// // CustomTransition? customTransition; | ||
34 | - | ||
35 | -// // Map<dynamic, GetDelegate> keys = {}; | ||
36 | - | ||
37 | -// // GetDelegate? nestedKey(String? key) { | ||
38 | -// // if (key == null) { | ||
39 | -// // return routerDelegate as GetDelegate; | ||
40 | -// // } | ||
41 | -// // keys.putIfAbsent( | ||
42 | -// // key, | ||
43 | -// // () => GetDelegate( | ||
44 | -// // showHashOnUrl: true, | ||
45 | -// // //debugLabel: 'Getx nested key: ${key.toString()}', | ||
46 | -// // pages: RouteDecoder.fromRoute(key).currentChildrens ?? [], | ||
47 | -// // ), | ||
48 | -// // ); | ||
49 | -// // return keys[key]; | ||
50 | -// // } | ||
51 | -// } |
@@ -133,11 +133,11 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | @@ -133,11 +133,11 @@ class GetDelegate extends RouterDelegate<RouteDecoder> | ||
133 | _activePages.add(res); | 133 | _activePages.add(res); |
134 | } | 134 | } |
135 | 135 | ||
136 | - Future<T?> _unsafeHistoryRemove<T>(RouteDecoder config, T result) async { | ||
137 | - var index = _activePages.indexOf(config); | ||
138 | - if (index >= 0) return _unsafeHistoryRemoveAt(index, result); | ||
139 | - return null; | ||
140 | - } | 136 | + // Future<T?> _unsafeHistoryRemove<T>(RouteDecoder config, T result) async { |
137 | + // var index = _activePages.indexOf(config); | ||
138 | + // if (index >= 0) return _unsafeHistoryRemoveAt(index, result); | ||
139 | + // return null; | ||
140 | + // } | ||
141 | 141 | ||
142 | Future<T?> _unsafeHistoryRemoveAt<T>(int index, T result) async { | 142 | Future<T?> _unsafeHistoryRemoveAt<T>(int index, T result) async { |
143 | if (index == _activePages.length - 1 && _activePages.length > 1) { | 143 | if (index == _activePages.length - 1 && _activePages.length > 1) { |
@@ -185,6 +185,7 @@ class GetObserver extends NavigatorObserver { | @@ -185,6 +185,7 @@ class GetObserver extends NavigatorObserver { | ||
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | +//TODO: Use copyWith, and remove mutate variables | ||
188 | class Routing { | 189 | class Routing { |
189 | String current; | 190 | String current; |
190 | String previous; | 191 | String previous; |
1 | import 'package:flutter/foundation.dart'; | 1 | import 'package:flutter/foundation.dart'; |
2 | 2 | ||
3 | -import '../../../route_manager.dart'; | 3 | +import '../../../get.dart'; |
4 | 4 | ||
5 | @immutable | 5 | @immutable |
6 | class RouteDecoder { | 6 | class RouteDecoder { |
@@ -174,6 +174,22 @@ class ParseRouteTree { | @@ -174,6 +174,22 @@ class ParseRouteTree { | ||
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | + void handleChild(GetPage route) { | ||
178 | + final children = route.children; | ||
179 | + for (var child in children) { | ||
180 | + final middlewares = List.of(route.middlewares); | ||
181 | + final bindings = List.of(route.bindings); | ||
182 | + middlewares.addAll(child.middlewares); | ||
183 | + bindings.addAll(child.bindings); | ||
184 | + child = child.copyWith(middlewares: middlewares, bindings: bindings); | ||
185 | + if (child.inheritParentPath) { | ||
186 | + child = child.copyWith( | ||
187 | + name: ('${route.path}/${child.path}').replaceAll(r'//', '/')); | ||
188 | + } | ||
189 | + addRoute(child); | ||
190 | + } | ||
191 | + } | ||
192 | + | ||
177 | List<GetPage> _flattenPage(GetPage route) { | 193 | List<GetPage> _flattenPage(GetPage route) { |
178 | final result = <GetPage>[]; | 194 | final result = <GetPage>[]; |
179 | if (route.children.isEmpty) { | 195 | if (route.children.isEmpty) { |
@@ -187,11 +203,25 @@ class ParseRouteTree { | @@ -187,11 +203,25 @@ class ParseRouteTree { | ||
187 | if (page.middlewares.isNotEmpty) ...page.middlewares, | 203 | if (page.middlewares.isNotEmpty) ...page.middlewares, |
188 | if (route.middlewares.isNotEmpty) ...route.middlewares | 204 | if (route.middlewares.isNotEmpty) ...route.middlewares |
189 | ]; | 205 | ]; |
206 | + | ||
207 | + final parentBindings = [ | ||
208 | + if (page.binding != null) page.binding!, | ||
209 | + if (page.bindings.isNotEmpty) ...page.bindings, | ||
210 | + if (route.bindings.isNotEmpty) ...route.bindings | ||
211 | + ]; | ||
212 | + | ||
213 | + final parentBinds = [ | ||
214 | + if (page.binds.isNotEmpty) ...page.binds, | ||
215 | + if (route.binds.isNotEmpty) ...route.binds | ||
216 | + ]; | ||
217 | + | ||
190 | result.add( | 218 | result.add( |
191 | _addChild( | 219 | _addChild( |
192 | page, | 220 | page, |
193 | parentPath, | 221 | parentPath, |
194 | parentMiddlewares, | 222 | parentMiddlewares, |
223 | + parentBindings, | ||
224 | + parentBinds, | ||
195 | ), | 225 | ), |
196 | ); | 226 | ); |
197 | 227 | ||
@@ -204,6 +234,15 @@ class ParseRouteTree { | @@ -204,6 +234,15 @@ class ParseRouteTree { | ||
204 | ...parentMiddlewares, | 234 | ...parentMiddlewares, |
205 | if (child.middlewares.isNotEmpty) ...child.middlewares, | 235 | if (child.middlewares.isNotEmpty) ...child.middlewares, |
206 | ], | 236 | ], |
237 | + [ | ||
238 | + ...parentBindings, | ||
239 | + if (child.binding != null) child.binding!, | ||
240 | + if (child.bindings.isNotEmpty) ...child.bindings, | ||
241 | + ], | ||
242 | + [ | ||
243 | + ...parentBinds, | ||
244 | + if (child.binds.isNotEmpty) ...child.binds, | ||
245 | + ], | ||
207 | )); | 246 | )); |
208 | } | 247 | } |
209 | } | 248 | } |
@@ -212,10 +251,19 @@ class ParseRouteTree { | @@ -212,10 +251,19 @@ class ParseRouteTree { | ||
212 | 251 | ||
213 | /// Change the Path for a [GetPage] | 252 | /// Change the Path for a [GetPage] |
214 | GetPage _addChild( | 253 | GetPage _addChild( |
215 | - GetPage origin, String parentPath, List<GetMiddleware> middlewares) { | 254 | + GetPage origin, |
255 | + String parentPath, | ||
256 | + List<GetMiddleware> middlewares, | ||
257 | + List<BindingsInterface> bindings, | ||
258 | + List<Bind> binds, | ||
259 | + ) { | ||
216 | return origin.copyWith( | 260 | return origin.copyWith( |
217 | middlewares: middlewares, | 261 | middlewares: middlewares, |
218 | - name: (parentPath + origin.name).replaceAll(r'//', '/'), | 262 | + name: origin.inheritParentPath |
263 | + ? (parentPath + origin.name).replaceAll(r'//', '/') | ||
264 | + : origin.name, | ||
265 | + bindings: bindings, | ||
266 | + binds: binds, | ||
219 | // key: | 267 | // key: |
220 | ); | 268 | ); |
221 | } | 269 | } |
-
Please register or login to post a comment