Jonny Borges

fix transitions

... ... @@ -12,7 +12,7 @@ class HomeController extends StateController<CasesModel> {
void onInit() {
super.onInit();
//Loading, Success, Error handle with 1 line of code
futurize(() => homeRepository.getCases);
futurize(homeRepository.getCases);
}
Country getCountryById(String id) {
... ...
... ... @@ -2,12 +2,13 @@
FLUTTER_ROOT=/Users/jonatasborges/flutter
FLUTTER_APPLICATION_PATH=/Users/jonatasborges/consertar/getx/example_nav2
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_TARGET=lib/main.dart
FLUTTER_TARGET=/Users/jonatasborges/consertar/getx/example_nav2/lib/main.dart
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386
DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
PACKAGE_CONFIG=.dart_tool/package_config.json
PACKAGE_CONFIG=/Users/jonatasborges/consertar/getx/example_nav2/.dart_tool/package_config.json
... ...
... ... @@ -3,11 +3,12 @@
export "FLUTTER_ROOT=/Users/jonatasborges/flutter"
export "FLUTTER_APPLICATION_PATH=/Users/jonatasborges/consertar/getx/example_nav2"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_TARGET=/Users/jonatasborges/consertar/getx/example_nav2/lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=="
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
export "PACKAGE_CONFIG=/Users/jonatasborges/consertar/getx/example_nav2/.dart_tool/package_config.json"
... ...
... ... @@ -41,5 +41,7 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
</dict>
</plist>
... ...
... ... @@ -73,12 +73,15 @@ class AppPages {
name: _Paths.products,
page: () => const ProductsView(),
title: 'Products',
transition: Transition.zoom,
transition: Transition.cupertino,
showCupertinoParallax: true,
participatesInRootNavigator: false,
bindings: [ProductsBinding()],
children: [
GetPage(
name: _Paths.productDetails,
transition: Transition.cupertino,
showCupertinoParallax: true,
page: () => ProductDetailsView(),
bindings: [ProductDetailsBinding()],
middlewares: [
... ...
... ... @@ -560,12 +560,6 @@ class GetDelegate extends RouterDelegate<RouteDecoder>
_activePages.remove(RouteDecoder.fromRoute(name));
}
@override
void back<T>([T? result]) {
_checkIfCanBack();
_popWithResult<T>(result);
notifyListeners();
}
bool get canBack {
return _activePages.length > 1;
... ... @@ -799,21 +793,30 @@ class GetDelegate extends RouterDelegate<RouteDecoder>
return false;
}
@override
void back<T>([T? result]) {
_checkIfCanBack();
_popWithResult<T>(result);
notifyListeners();
}
bool _onPopVisualRoute(Route<dynamic> route, dynamic result) {
final didPop = route.didPop(result);
if (!didPop) {
return false;
}
final settings = route.settings;
if (settings is GetPage) {
final config = _activePages.cast<RouteDecoder?>().firstWhere(
(element) => element?.route == settings,
orElse: () => null,
);
if (config != null) {
_removeHistoryEntry(config, result);
}
}
_popWithResult(result);
// final settings = route.settings;
// if (settings is GetPage) {
// final config = _activePages.cast<RouteDecoder?>().firstWhere(
// (element) => element?.route == settings,
// orElse: () => null,
// );
// if (config != null) {
// _removeHistoryEntry(config, result);
// }
// }
notifyListeners();
//return !route.navigator!.userGestureInProgress;
return true;
... ...
... ... @@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/utils.dart';
import '../../../get_rx/src/rx_types/rx_types.dart';
import '../../../instance_manager.dart';
... ... @@ -70,9 +71,9 @@ mixin StateMixin<T> on ListNotifier {
}
}
void futurize(Future<T> Function() Function() body,
{String? errorMessage, bool useEmpty = true}) {
final compute = body();
void futurize(Future<T> Function() body,
{T? initialData, String? errorMessage, bool useEmpty = true}) {
final compute = body;
compute().then((newValue) {
if ((newValue == null || newValue._isEmpty()) && useEmpty) {
status = GetStatus<T>.loading();
... ... @@ -88,6 +89,10 @@ mixin StateMixin<T> on ListNotifier {
}
}
typedef FuturizeCallback<T> = Future<T> Function(VoidCallback fn);
typedef VoidCallback = void Function();
class GetListenable<T> extends ListNotifierSingle implements RxInterface<T> {
GetListenable(T val) : _value = val;
... ... @@ -239,28 +244,45 @@ extension StateExt<T> on StateMixin<T> {
typedef NotifierBuilder<T> = Widget Function(T state);
abstract class GetStatus<T> {
abstract class GetStatus<T> with Equality {
const GetStatus();
factory GetStatus.loading() => LoadingStatus();
factory GetStatus.error(String message) => ErrorStatus(message);
factory GetStatus.empty() => EmptyStatus();
factory GetStatus.success(T data) => SuccessStatus(data);
factory GetStatus.custom() => CustomStatus();
}
class CustomStatus<T> extends GetStatus<T> {
@override
List get props => [];
}
class LoadingStatus<T> extends GetStatus<T> {}
class LoadingStatus<T> extends GetStatus<T> {
@override
List get props => [];
}
class SuccessStatus<T> extends GetStatus<T> {
final T data;
const SuccessStatus(this.data);
SuccessStatus(this.data);
@override
List get props => [data];
}
class ErrorStatus<T, S> extends GetStatus<T> {
final S? error;
ErrorStatus([this.error]);
const ErrorStatus([this.error]);
@override
List get props => [error];
}
class EmptyStatus<T> extends GetStatus<T> {}
class EmptyStatus<T> extends GetStatus<T> {
@override
List get props => [];
}
extension StatusDataExt<T> on GetStatus<T> {
bool get isLoading => this is LoadingStatus;
... ...