Jonny Borges

fix transitions

@@ -12,7 +12,7 @@ class HomeController extends StateController<CasesModel> { @@ -12,7 +12,7 @@ class HomeController extends StateController<CasesModel> {
12 void onInit() { 12 void onInit() {
13 super.onInit(); 13 super.onInit();
14 //Loading, Success, Error handle with 1 line of code 14 //Loading, Success, Error handle with 1 line of code
15 - futurize(() => homeRepository.getCases); 15 + futurize(homeRepository.getCases);
16 } 16 }
17 17
18 Country getCountryById(String id) { 18 Country getCountryById(String id) {
@@ -2,12 +2,13 @@ @@ -2,12 +2,13 @@
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/consertar/getx/example_nav2
4 COCOAPODS_PARALLEL_CODE_SIGN=true 4 COCOAPODS_PARALLEL_CODE_SIGN=true
5 -FLUTTER_TARGET=lib/main.dart 5 +FLUTTER_TARGET=/Users/jonatasborges/consertar/getx/example_nav2/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 +DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==
10 DART_OBFUSCATION=false 11 DART_OBFUSCATION=false
11 -TRACK_WIDGET_CREATION=false 12 +TRACK_WIDGET_CREATION=true
12 TREE_SHAKE_ICONS=false 13 TREE_SHAKE_ICONS=false
13 -PACKAGE_CONFIG=.dart_tool/package_config.json 14 +PACKAGE_CONFIG=/Users/jonatasborges/consertar/getx/example_nav2/.dart_tool/package_config.json
@@ -3,11 +3,12 @@ @@ -3,11 +3,12 @@
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/consertar/getx/example_nav2"
5 export "COCOAPODS_PARALLEL_CODE_SIGN=true" 5 export "COCOAPODS_PARALLEL_CODE_SIGN=true"
6 -export "FLUTTER_TARGET=lib/main.dart" 6 +export "FLUTTER_TARGET=/Users/jonatasborges/consertar/getx/example_nav2/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=="
10 export "DART_OBFUSCATION=false" 11 export "DART_OBFUSCATION=false"
11 -export "TRACK_WIDGET_CREATION=false" 12 +export "TRACK_WIDGET_CREATION=true"
12 export "TREE_SHAKE_ICONS=false" 13 export "TREE_SHAKE_ICONS=false"
13 -export "PACKAGE_CONFIG=.dart_tool/package_config.json" 14 +export "PACKAGE_CONFIG=/Users/jonatasborges/consertar/getx/example_nav2/.dart_tool/package_config.json"
@@ -41,5 +41,7 @@ @@ -41,5 +41,7 @@
41 </array> 41 </array>
42 <key>UIViewControllerBasedStatusBarAppearance</key> 42 <key>UIViewControllerBasedStatusBarAppearance</key>
43 <false/> 43 <false/>
  44 + <key>CADisableMinimumFrameDurationOnPhone</key>
  45 + <true/>
44 </dict> 46 </dict>
45 </plist> 47 </plist>
@@ -73,12 +73,15 @@ class AppPages { @@ -73,12 +73,15 @@ class AppPages {
73 name: _Paths.products, 73 name: _Paths.products,
74 page: () => const ProductsView(), 74 page: () => const ProductsView(),
75 title: 'Products', 75 title: 'Products',
76 - transition: Transition.zoom, 76 + transition: Transition.cupertino,
  77 + showCupertinoParallax: true,
77 participatesInRootNavigator: false, 78 participatesInRootNavigator: false,
78 bindings: [ProductsBinding()], 79 bindings: [ProductsBinding()],
79 children: [ 80 children: [
80 GetPage( 81 GetPage(
81 name: _Paths.productDetails, 82 name: _Paths.productDetails,
  83 + transition: Transition.cupertino,
  84 + showCupertinoParallax: true,
82 page: () => ProductDetailsView(), 85 page: () => ProductDetailsView(),
83 bindings: [ProductDetailsBinding()], 86 bindings: [ProductDetailsBinding()],
84 middlewares: [ 87 middlewares: [
@@ -560,13 +560,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder> @@ -560,13 +560,7 @@ class GetDelegate extends RouterDelegate<RouteDecoder>
560 _activePages.remove(RouteDecoder.fromRoute(name)); 560 _activePages.remove(RouteDecoder.fromRoute(name));
561 } 561 }
562 562
563 - @override  
564 - void back<T>([T? result]) {  
565 - _checkIfCanBack();  
566 - _popWithResult<T>(result);  
567 - notifyListeners();  
568 - }  
569 - 563 +
570 bool get canBack { 564 bool get canBack {
571 return _activePages.length > 1; 565 return _activePages.length > 1;
572 } 566 }
@@ -799,21 +793,30 @@ class GetDelegate extends RouterDelegate<RouteDecoder> @@ -799,21 +793,30 @@ class GetDelegate extends RouterDelegate<RouteDecoder>
799 return false; 793 return false;
800 } 794 }
801 795
  796 + @override
  797 + void back<T>([T? result]) {
  798 + _checkIfCanBack();
  799 + _popWithResult<T>(result);
  800 + notifyListeners();
  801 + }
  802 +
  803 +
802 bool _onPopVisualRoute(Route<dynamic> route, dynamic result) { 804 bool _onPopVisualRoute(Route<dynamic> route, dynamic result) {
803 final didPop = route.didPop(result); 805 final didPop = route.didPop(result);
804 if (!didPop) { 806 if (!didPop) {
805 return false; 807 return false;
806 } 808 }
807 - final settings = route.settings;  
808 - if (settings is GetPage) {  
809 - final config = _activePages.cast<RouteDecoder?>().firstWhere(  
810 - (element) => element?.route == settings,  
811 - orElse: () => null,  
812 - );  
813 - if (config != null) {  
814 - _removeHistoryEntry(config, result);  
815 - }  
816 - } 809 + _popWithResult(result);
  810 + // final settings = route.settings;
  811 + // if (settings is GetPage) {
  812 + // final config = _activePages.cast<RouteDecoder?>().firstWhere(
  813 + // (element) => element?.route == settings,
  814 + // orElse: () => null,
  815 + // );
  816 + // if (config != null) {
  817 + // _removeHistoryEntry(config, result);
  818 + // }
  819 + // }
817 notifyListeners(); 820 notifyListeners();
818 //return !route.navigator!.userGestureInProgress; 821 //return !route.navigator!.userGestureInProgress;
819 return true; 822 return true;
@@ -2,6 +2,7 @@ import 'dart:async'; @@ -2,6 +2,7 @@ import 'dart:async';
2 2
3 import 'package:flutter/foundation.dart'; 3 import 'package:flutter/foundation.dart';
4 import 'package:flutter/material.dart'; 4 import 'package:flutter/material.dart';
  5 +import 'package:get/utils.dart';
5 6
6 import '../../../get_rx/src/rx_types/rx_types.dart'; 7 import '../../../get_rx/src/rx_types/rx_types.dart';
7 import '../../../instance_manager.dart'; 8 import '../../../instance_manager.dart';
@@ -70,9 +71,9 @@ mixin StateMixin<T> on ListNotifier { @@ -70,9 +71,9 @@ mixin StateMixin<T> on ListNotifier {
70 } 71 }
71 } 72 }
72 73
73 - void futurize(Future<T> Function() Function() body,  
74 - {String? errorMessage, bool useEmpty = true}) {  
75 - final compute = body(); 74 + void futurize(Future<T> Function() body,
  75 + {T? initialData, String? errorMessage, bool useEmpty = true}) {
  76 + final compute = body;
76 compute().then((newValue) { 77 compute().then((newValue) {
77 if ((newValue == null || newValue._isEmpty()) && useEmpty) { 78 if ((newValue == null || newValue._isEmpty()) && useEmpty) {
78 status = GetStatus<T>.loading(); 79 status = GetStatus<T>.loading();
@@ -88,6 +89,10 @@ mixin StateMixin<T> on ListNotifier { @@ -88,6 +89,10 @@ mixin StateMixin<T> on ListNotifier {
88 } 89 }
89 } 90 }
90 91
  92 +typedef FuturizeCallback<T> = Future<T> Function(VoidCallback fn);
  93 +
  94 +typedef VoidCallback = void Function();
  95 +
91 class GetListenable<T> extends ListNotifierSingle implements RxInterface<T> { 96 class GetListenable<T> extends ListNotifierSingle implements RxInterface<T> {
92 GetListenable(T val) : _value = val; 97 GetListenable(T val) : _value = val;
93 98
@@ -239,28 +244,45 @@ extension StateExt<T> on StateMixin<T> { @@ -239,28 +244,45 @@ extension StateExt<T> on StateMixin<T> {
239 244
240 typedef NotifierBuilder<T> = Widget Function(T state); 245 typedef NotifierBuilder<T> = Widget Function(T state);
241 246
242 -abstract class GetStatus<T> { 247 +abstract class GetStatus<T> with Equality {
243 const GetStatus(); 248 const GetStatus();
244 factory GetStatus.loading() => LoadingStatus(); 249 factory GetStatus.loading() => LoadingStatus();
245 factory GetStatus.error(String message) => ErrorStatus(message); 250 factory GetStatus.error(String message) => ErrorStatus(message);
246 factory GetStatus.empty() => EmptyStatus(); 251 factory GetStatus.empty() => EmptyStatus();
247 factory GetStatus.success(T data) => SuccessStatus(data); 252 factory GetStatus.success(T data) => SuccessStatus(data);
  253 + factory GetStatus.custom() => CustomStatus();
  254 +}
  255 +
  256 +class CustomStatus<T> extends GetStatus<T> {
  257 + @override
  258 + List get props => [];
248 } 259 }
249 260
250 -class LoadingStatus<T> extends GetStatus<T> {} 261 +class LoadingStatus<T> extends GetStatus<T> {
  262 + @override
  263 + List get props => [];
  264 +}
251 265
252 class SuccessStatus<T> extends GetStatus<T> { 266 class SuccessStatus<T> extends GetStatus<T> {
253 final T data; 267 final T data;
  268 + const SuccessStatus(this.data);
254 269
255 - SuccessStatus(this.data); 270 + @override
  271 + List get props => [data];
256 } 272 }
257 273
258 class ErrorStatus<T, S> extends GetStatus<T> { 274 class ErrorStatus<T, S> extends GetStatus<T> {
259 final S? error; 275 final S? error;
260 - ErrorStatus([this.error]); 276 + const ErrorStatus([this.error]);
  277 +
  278 + @override
  279 + List get props => [error];
261 } 280 }
262 281
263 -class EmptyStatus<T> extends GetStatus<T> {} 282 +class EmptyStatus<T> extends GetStatus<T> {
  283 + @override
  284 + List get props => [];
  285 +}
264 286
265 extension StatusDataExt<T> on GetStatus<T> { 287 extension StatusDataExt<T> on GetStatus<T> {
266 bool get isLoading => this is LoadingStatus; 288 bool get isLoading => this is LoadingStatus;