Skip to content

Commit

Permalink
Merge pull request #564 from Flutterando/fix
Browse files Browse the repository at this point in the history
version 4.0.1
  • Loading branch information
jacobaraujo7 committed Sep 22, 2021
2 parents 1cbb2d9 + 5865072 commit 86db0c5
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 34 deletions.
4 changes: 4 additions & 0 deletions flutter_modular/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release


# coverage
coverage/
7 changes: 6 additions & 1 deletion flutter_modular/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## [4.0.0+11] - 2021-09-16
## [4.0.1] - 2021-09-22
* Fixed pushNamed.
* Fixed bug that allowed access to parameters and arguments in other modules.
* Fixed transitions bug.

## [4.0.0+12] - 2021-09-16

* New documentation is here! [https://modular.flutterando.com.br](https://modular.flutterando.com.br).
* Modular design now uses Layered Architecture (Clean Architecture) with 100% code coverage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
for (var disposableRoute in disposableRoutes) {
reportPop.call(disposableRoute);
}

final arguments =
parser.getArguments().getOrElse((l) => ModularArguments.empty());
parser.setArguments(arguments.copyWith(params: {}, data: null));
}

var _lastClick = DateTime.now();
Expand Down Expand Up @@ -116,7 +112,11 @@ class ModularRouterDelegate extends RouterDelegate<ModularBook>
final parallel = page.route;
parallel.popCallback?.call(result);
currentConfiguration?.routes.remove(parallel);
reportPop.call(parallel);
if (currentConfiguration?.routes.indexWhere(
(element) => element.uri.toString() == parallel.uri.toString()) ==
-1) {
reportPop.call(parallel);
}
final arguments =
parser.getArguments().getOrElse((l) => ModularArguments.empty());
parser.setArguments(arguments.copyWith(uri: currentConfiguration!.uri));
Expand Down
4 changes: 2 additions & 2 deletions flutter_modular/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_modular
description: Smart project structure with dependency injection and route management
version: 4.0.0+11
version: 4.0.1
homepage: https://github.com/Flutterando/modular

environment:
Expand All @@ -9,7 +9,7 @@ environment:
dependencies:
flutter_modular_annotations: ^0.0.2
triple: ">=1.3.0+2 <2.0.0"
modular_core: ">=1.0.3 <=2.0.0"
modular_core: ">=1.0.4 <=2.0.0"
meta: ">=1.3.0 <2.0.0"
flutter:
sdk: flutter
Expand Down
4 changes: 2 additions & 2 deletions modular_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## 1.0.0+1 - 2021/09/21
* Fix ordenation routes
## 1.0.4 - 2021/09/22
* Rebuild modularArguments after get route
## 1.0.0+1 - 2021/09/05
* Stable version

Expand Down
14 changes: 5 additions & 9 deletions modular_core/lib/src/route/tracker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ class TrackerImpl implements Tracker {

String get currentPath => arguments.uri.toString();

FutureOr<ModularRoute?> findRoute(String path,
{dynamic data, String schema = ''}) async {
FutureOr<ModularRoute?> findRoute(String path, {dynamic data, String schema = ''}) async {
var uri = _resolverPath(path);
final modularKey = ModularKey(schema: schema, name: uri.path);

Expand All @@ -41,13 +40,11 @@ class TrackerImpl implements Tracker {
break;
}
}
if (uriCandidate.pathSegments.length != uri.pathSegments.length &&
!uriCandidate.path.contains('**')) {
if (uriCandidate.pathSegments.length != uri.pathSegments.length && !uriCandidate.path.contains('**')) {
continue;
}

if (!(uriCandidate.path.contains(':') ||
uriCandidate.path.contains('**'))) {
if (!(uriCandidate.path.contains(':') || uriCandidate.path.contains('**'))) {
continue;
}

Expand Down Expand Up @@ -75,7 +72,7 @@ class TrackerImpl implements Tracker {

if (route == null) return null;

_arguments = arguments.copyWith(data: data, uri: uri, params: params);
_arguments = ModularArguments(uri: uri, data: data, params: params);

return route;
}
Expand Down Expand Up @@ -139,6 +136,5 @@ class TrackerImpl implements Tracker {
}

class TrackerNotInitiated extends ModularError {
const TrackerNotInitiated(String message, [StackTrace? stackTrace])
: super(message, stackTrace);
const TrackerNotInitiated(String message, [StackTrace? stackTrace]) : super(message, stackTrace);
}
2 changes: 1 addition & 1 deletion modular_core/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: modular_core
description: Smart project structure with dependency injection and route management
version: 1.0.3
version: 1.0.4
homepage: https://github.com/Flutterando/modular

environment:
Expand Down
17 changes: 7 additions & 10 deletions modular_core/test/src/route/tracker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ void main() {

route = await ModularTracker.findRoute('/product/test') as CustomRoute?;
expect(route?.uri.path, '/product/test');
expect(ModularTracker.currentPath, '/product/test');
expect(ModularTracker.arguments.params['id'], isNull);
});

test('find route with queries', () async {
Expand All @@ -53,8 +55,7 @@ void main() {
});

test('find child route in other module', () async {
var route =
await ModularTracker.findRoute('/other/details') as CustomRoute?;
var route = await ModularTracker.findRoute('/other/details') as CustomRoute?;
expect(route?.uri.path, '/other/details');
expect(route?.parent, '/other/');
expect(route?.data, 'otherWithDetails');
Expand All @@ -64,8 +65,7 @@ void main() {
});

test('find child route in deep module', () async {
var route =
await ModularTracker.findRoute('/other/internal/') as CustomRoute?;
var route = await ModularTracker.findRoute('/other/internal/') as CustomRoute?;
expect(route, isNotNull);
ModularTracker.reportPushRoute(route!);
expect(ModularTracker.injector.isModuleAlive<DeepModule>(), true);
Expand All @@ -75,8 +75,7 @@ void main() {
ModularTracker.reportPopRoute(route);
expect(ModularTracker.injector.isModuleAlive<DeepModule>(), false);

route =
await ModularTracker.findRoute('/other/internal/deep') as CustomRoute?;
route = await ModularTracker.findRoute('/other/internal/deep') as CustomRoute?;
expect(route, isNotNull);
ModularTracker.reportPushRoute(route!);
expect(ModularTracker.injector.isModuleAlive<DeepModule>(), true);
Expand All @@ -92,15 +91,13 @@ void main() {

test('find route with schema', () async {
expect(await ModularTracker.findRoute('/schema'), isNull);
final route = await ModularTracker.findRoute('/schema', schema: 'tag')
as CustomRoute?;
final route = await ModularTracker.findRoute('/schema', schema: 'tag') as CustomRoute?;
expect(route?.uri.path, '/schema');
expect(route?.data, 'withSchema');
});

test('find route with wildcard', () async {
final route =
await ModularTracker.findRoute('/wildcard/test/2') as CustomRoute?;
final route = await ModularTracker.findRoute('/wildcard/test/2') as CustomRoute?;
expect(route?.uri.path, '/wildcard/test/2');
expect(route?.data, 'wildcard');
});
Expand Down
2 changes: 0 additions & 2 deletions modular_test/lib/modular_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ library modular_test;

import 'package:modular_core/modular_core.dart';

void main() {}

void initModule(BindContext module, {List<BindContract> replaceBinds = const []}) {
// ignore: invalid_use_of_visible_for_testing_member
final bindModules = module.getProcessBinds();
Expand Down
2 changes: 0 additions & 2 deletions modular_test/test/modular_test_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class MyModule extends RouteContextImpl {
void main() {
final repo = RepoImpl2();

modular_test.main();

modular_test.initModules(
[MyModule()],
replaceBinds: [
Expand Down

0 comments on commit 86db0c5

Please sign in to comment.