Skip to content

Commit

Permalink
Merge pull request #705 from Flutterando/fix/release5
Browse files Browse the repository at this point in the history
fix: prepare to release
  • Loading branch information
jacobaraujo7 authored May 12, 2022
2 parents d10cdf7 + 57413a5 commit 1ce79b6
Show file tree
Hide file tree
Showing 24 changed files with 232 additions and 84 deletions.
1 change: 1 addition & 0 deletions flutter_modular/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## [5.0.0] - 2022-04-21
- Support Flutter 3.0.0
- [BREAK CHANGE]: Removed `MaterialApp.modular()` and `Cupertino().modular()`.
Use instead:
```dart
Expand Down
8 changes: 8 additions & 0 deletions flutter_modular/example/linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
)

set(PLUGIN_BUNDLED_LIBRARIES)

foreach(plugin ${FLUTTER_PLUGIN_LIST})
Expand All @@ -13,3 +16,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)

foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
final ReportPop reportPop;
List<NavigatorObserver> observers = [];

ModularRouterDelegate({required this.parser, required this.navigatorKey, required this.reportPop});
ModularRouterDelegate(
{required this.parser,
required this.navigatorKey,
required this.reportPop});

@override
ModularBook? currentConfiguration;
Expand Down Expand Up @@ -65,8 +68,11 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
Future<void> setNewRoutePath(ModularBook configuration) async {
final disposableRoutes = <ParallelRoute>[];

for (var route in currentConfiguration?.routes ?? <ParallelRoute<dynamic>>[]) {
if (configuration.routes.indexWhere((element) => element.uri.path == route.uri.path) == -1) {
for (var route
in currentConfiguration?.routes ?? <ParallelRoute<dynamic>>[]) {
if (configuration.routes
.indexWhere((element) => element.uri.path == route.uri.path) ==
-1) {
disposableRoutes.add(route);
}
}
Expand Down Expand Up @@ -112,28 +118,41 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
final parallel = page.route;
parallel.popCallback?.call(result);
currentConfiguration?.routes.remove(parallel);
if (currentConfiguration?.routes.indexWhere((element) => element.uri.toString() == parallel.uri.toString()) == -1) {
if (currentConfiguration?.routes.indexWhere(
(element) => element.uri.toString() == parallel.uri.toString()) ==
-1) {
reportPop.call(parallel);
}
final arguments = parser.getArguments().getOrElse((l) => ModularArguments.empty());
final arguments =
parser.getArguments().getOrElse((l) => ModularArguments.empty());
parser.setArguments(arguments.copyWith(uri: currentConfiguration!.uri));
notifyListeners();

return true;
}

@override
Future<T?> pushNamed<T extends Object?>(String routeName, {Object? arguments, bool forRoot = false}) async {
Future<T?> pushNamed<T extends Object?>(String routeName,
{Object? arguments, bool forRoot = false}) async {
final popComplete = Completer();
var book = await parser.selectBook(routeName, arguments: arguments, popCallback: popComplete.complete);
var book = await parser.selectBook(routeName,
arguments: arguments, popCallback: popComplete.complete);
if (forRoot) {
book = currentConfiguration!.copyWith(routes: [...currentConfiguration!.routes, book.routes.last.copyWith(schema: '')]);
book = currentConfiguration!.copyWith(routes: [
...currentConfiguration!.routes,
book.routes.last.copyWith(schema: '')
]);
await setNewRoutePath(book);
} else {
final list = [...currentConfiguration!.routes];

for (var route in book.routes.reversed) {
if (list.firstWhere((element) => element.uri.toString() == route.uri.toString(), orElse: () => ParallelRoute.empty()).name == '') {
if (list
.firstWhere(
(element) => element.uri.toString() == route.uri.toString(),
orElse: () => ParallelRoute.empty())
.name ==
'') {
list.add(route);
}
}
Expand All @@ -149,21 +168,32 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
}

@override
Future<T?> pushReplacementNamed<T extends Object?, TO extends Object?>(String routeName, {TO? result, Object? arguments, bool forRoot = false}) async {
Future<T?> pushReplacementNamed<T extends Object?, TO extends Object?>(
String routeName,
{TO? result,
Object? arguments,
bool forRoot = false}) async {
final popComplete = Completer();
var book = await parser.selectBook(routeName, arguments: arguments, popCallback: popComplete.complete);
var book = await parser.selectBook(routeName,
arguments: arguments, popCallback: popComplete.complete);
final currentRoutes = [...currentConfiguration!.routes];
if (forRoot) {
//;currentRoutes.removeWhere((element) => element.schema != '');
final indexLast = currentRoutes.lastIndexWhere((element) => element.schema == '');
final indexLast =
currentRoutes.lastIndexWhere((element) => element.schema == '');
currentRoutes[indexLast] = book.routes.first.copyWith(schema: '');
book = currentConfiguration!.copyWith(routes: [...currentRoutes]);
await setNewRoutePath(book);
} else {
final list = currentRoutes..removeLast();

for (var route in book.routes.reversed) {
if (list.firstWhere((element) => element.uri.toString() == route.uri.toString(), orElse: () => ParallelRoute.empty()).name == '') {
if (list
.firstWhere(
(element) => element.uri.toString() == route.uri.toString(),
orElse: () => ParallelRoute.empty())
.name ==
'') {
list.add(route);
}
}
Expand All @@ -174,7 +204,11 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
}

@override
Future<T?> popAndPushNamed<T extends Object?, TO extends Object?>(String routeName, {TO? result, Object? arguments, bool forRoot = false}) {
Future<T?> popAndPushNamed<T extends Object?, TO extends Object?>(
String routeName,
{TO? result,
Object? arguments,
bool forRoot = false}) {
pop(result);
return pushNamed(routeName, arguments: arguments);
}
Expand All @@ -183,15 +217,20 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
bool canPop() => navigatorKey.currentState?.canPop() ?? false;

@override
Future<bool> maybePop<T extends Object?>([T? result]) => navigatorKey.currentState?.maybePop(result) ?? Future.value(false);
Future<bool> maybePop<T extends Object?>([T? result]) =>
navigatorKey.currentState?.maybePop(result) ?? Future.value(false);

@override
void pop<T extends Object?>([T? result]) => navigatorKey.currentState?.pop(result);
void pop<T extends Object?>([T? result]) =>
navigatorKey.currentState?.pop(result);

@override
void popUntil(bool Function(Route) predicate) {
var isFoundedPages = currentConfiguration?.routes.where((route) {
return predicate(CustomModalRoute(ModularPage(route: route, args: ModularArguments.empty(), flags: ModularFlags())));
return predicate(CustomModalRoute(ModularPage(
route: route,
args: ModularArguments.empty(),
flags: ModularFlags())));
});

isFoundedPages ??= [];
Expand All @@ -203,21 +242,36 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
}

@override
Future<T?> pushNamedAndRemoveUntil<T extends Object?>(String routeName, bool Function(Route) predicate, {Object? arguments, bool forRoot = false}) async {
Future<T?> pushNamedAndRemoveUntil<T extends Object?>(
String routeName, bool Function(Route) predicate,
{Object? arguments, bool forRoot = false}) async {
final popComplete = Completer();
var book = await parser.selectBook(routeName, arguments: arguments, popCallback: popComplete.complete);
var book = await parser.selectBook(routeName,
arguments: arguments, popCallback: popComplete.complete);
if (forRoot) {
final list = currentConfiguration!.routes.where((route) {
return predicate(CustomModalRoute(ModularPage(route: route, args: ModularArguments.empty(), flags: ModularFlags())));
return predicate(CustomModalRoute(ModularPage(
route: route,
args: ModularArguments.empty(),
flags: ModularFlags())));
}).toList();
book = currentConfiguration!.copyWith(routes: [...list, book.routes.last.copyWith(schema: '')]);
book = currentConfiguration!
.copyWith(routes: [...list, book.routes.last.copyWith(schema: '')]);
await setNewRoutePath(book);
} else {
final list = currentConfiguration!.routes.where((route) {
return predicate(CustomModalRoute(ModularPage(route: route, args: ModularArguments.empty(), flags: ModularFlags())));
return predicate(CustomModalRoute(ModularPage(
route: route,
args: ModularArguments.empty(),
flags: ModularFlags())));
}).toList();
for (var route in book.routes.reversed) {
if (list.firstWhere((element) => element.uri.toString() == route.uri.toString(), orElse: () => ParallelRoute.empty()).name == '') {
if (list
.firstWhere(
(element) => element.uri.toString() == route.uri.toString(),
orElse: () => ParallelRoute.empty())
.name ==
'') {
list.add(route);
}
}
Expand Down Expand Up @@ -250,7 +304,8 @@ class CustomModalRoute extends ModalRoute {
String? get barrierLabel => throw UnimplementedError();

@override
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
throw UnimplementedError();
}

Expand Down
4 changes: 2 additions & 2 deletions flutter_modular/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: flutter_modular
description: Smart project structure with dependency injection and route management
version: 5.0.0-dev.15
version: 5.0.0
homepage: https://github.com/Flutterando/modular

environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter_modular_annotations: ^0.0.2
modular_core: 2.0.0-dev.10
modular_core: ">=2.0.0 <3.0.0"
meta: ">=1.3.0 <2.0.0"
flutter:
sdk: flutter
Expand Down
Loading

0 comments on commit 1ce79b6

Please sign in to comment.