Jonny Borges
Committed by GitHub

Merge pull request #2697 from jonataslaw/inherit-bindings

Inherit bindings
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 {
@@ -187,11 +187,25 @@ class ParseRouteTree { @@ -187,11 +187,25 @@ class ParseRouteTree {
187 if (page.middlewares.isNotEmpty) ...page.middlewares, 187 if (page.middlewares.isNotEmpty) ...page.middlewares,
188 if (route.middlewares.isNotEmpty) ...route.middlewares 188 if (route.middlewares.isNotEmpty) ...route.middlewares
189 ]; 189 ];
  190 +
  191 + final parentBindings = [
  192 + if (page.binding != null) page.binding!,
  193 + if (page.bindings.isNotEmpty) ...page.bindings,
  194 + if (route.bindings.isNotEmpty) ...route.bindings
  195 + ];
  196 +
  197 + final parentBinds = [
  198 + if (page.binds.isNotEmpty) ...page.binds,
  199 + if (route.binds.isNotEmpty) ...route.binds
  200 + ];
  201 +
190 result.add( 202 result.add(
191 _addChild( 203 _addChild(
192 page, 204 page,
193 parentPath, 205 parentPath,
194 parentMiddlewares, 206 parentMiddlewares,
  207 + parentBindings,
  208 + parentBinds,
195 ), 209 ),
196 ); 210 );
197 211
@@ -204,6 +218,15 @@ class ParseRouteTree { @@ -204,6 +218,15 @@ class ParseRouteTree {
204 ...parentMiddlewares, 218 ...parentMiddlewares,
205 if (child.middlewares.isNotEmpty) ...child.middlewares, 219 if (child.middlewares.isNotEmpty) ...child.middlewares,
206 ], 220 ],
  221 + [
  222 + ...parentBindings,
  223 + if (child.binding != null) child.binding!,
  224 + if (child.bindings.isNotEmpty) ...child.bindings,
  225 + ],
  226 + [
  227 + ...parentBinds,
  228 + if (child.binds.isNotEmpty) ...child.binds,
  229 + ],
207 )); 230 ));
208 } 231 }
209 } 232 }
@@ -212,10 +235,19 @@ class ParseRouteTree { @@ -212,10 +235,19 @@ class ParseRouteTree {
212 235
213 /// Change the Path for a [GetPage] 236 /// Change the Path for a [GetPage]
214 GetPage _addChild( 237 GetPage _addChild(
215 - GetPage origin, String parentPath, List<GetMiddleware> middlewares) { 238 + GetPage origin,
  239 + String parentPath,
  240 + List<GetMiddleware> middlewares,
  241 + List<BindingsInterface> bindings,
  242 + List<Bind> binds,
  243 + ) {
216 return origin.copyWith( 244 return origin.copyWith(
217 middlewares: middlewares, 245 middlewares: middlewares,
218 - name: (parentPath + origin.name).replaceAll(r'//', '/'), 246 + name: origin.inheritParentPath
  247 + ? (parentPath + origin.name).replaceAll(r'//', '/')
  248 + : origin.name,
  249 + bindings: bindings,
  250 + binds: binds,
219 // key: 251 // key:
220 ); 252 );
221 } 253 }