v10
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:iroute/v9/app/navigation/router/views/navigator_scope.dart';
|
||||
import 'views/navigator_scope.dart';
|
||||
import 'iroute.dart';
|
||||
import 'iroute_config.dart';
|
||||
import 'route_history_manager.dart';
|
||||
@@ -62,8 +62,7 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
|
||||
|
||||
// final List<IRouteConfig> _pathStack = [];
|
||||
|
||||
bool get canPop =>
|
||||
_configs.where((e) => e.routeStyle == RouteStyle.push).isNotEmpty;
|
||||
bool get canPop => _configs.where((e) => e.routeStyle == RouteStyle.push).isNotEmpty;
|
||||
|
||||
final Map<String, Completer<dynamic>> _completerMap = {};
|
||||
|
||||
@@ -129,75 +128,6 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
|
||||
configs: _configs,
|
||||
notFindPageBuilder: (notFindPageBuilder ?? _defaultNotFindPageBuilder),
|
||||
);
|
||||
// return Navigator(
|
||||
// onPopPage: _onPopPage,
|
||||
// pages: [
|
||||
// MaterialPage(child: NavigatorScope(
|
||||
// cellNode: cellNode,
|
||||
// onPopPage: _onPopPage,
|
||||
// configs: _configs,
|
||||
// notFindPageBuilder: (notFindPageBuilder ?? _defaultNotFindPageBuilder),
|
||||
// ))
|
||||
// ],
|
||||
// );
|
||||
}
|
||||
|
||||
List<Page> _buildPages(BuildContext context, List<IRouteConfig> configs) {
|
||||
IRouteConfig top = configs.last;
|
||||
List<IRouteConfig> bottoms =
|
||||
_configs.sublist(0, _configs.length - 1).toList();
|
||||
List<Page> pages = [];
|
||||
List<Page> topPages = _buildPageByPathFromTree(context, top);
|
||||
pages = _buildLivePageByPathList(context, bottoms, top, topPages);
|
||||
pages.addAll(topPages);
|
||||
return pages;
|
||||
}
|
||||
|
||||
List<Page> _buildLivePageByPathList(
|
||||
BuildContext context,
|
||||
List<IRouteConfig> paths,
|
||||
IRouteConfig curConfig,
|
||||
List<Page> curPages,
|
||||
) {
|
||||
List<Page> pages = [];
|
||||
if (paths.isNotEmpty) {
|
||||
for (IRouteConfig path in paths) {
|
||||
if (path != curConfig) {
|
||||
pages.addAll(_buildPageByPathFromTree(context, path));
|
||||
}
|
||||
}
|
||||
|
||||
/// 去除和 curPages 中重复的界面
|
||||
pages
|
||||
.removeWhere((page) => curPages.map((e) => e.key).contains(page.key));
|
||||
}
|
||||
return pages;
|
||||
}
|
||||
|
||||
List<Page> _buildPageByPathFromTree(
|
||||
BuildContext context, IRouteConfig config) {
|
||||
List<Page> result = [];
|
||||
List<IRouteNode> iRoutes = rootRoute.find(config.path);
|
||||
if (iRoutes.isNotEmpty) {
|
||||
for (int i = 0; i < iRoutes.length; i++) {
|
||||
IRouteNode iroute = iRoutes[i];
|
||||
config = config.copyWith(path: iroute.path);
|
||||
Page? page;
|
||||
if (iroute is NotFindNode) {
|
||||
page = (notFindPageBuilder ?? _defaultNotFindPageBuilder)(
|
||||
context, config);
|
||||
} else {
|
||||
page = iroute.createPage(context, config);
|
||||
}
|
||||
if (page != null) {
|
||||
result.add(page);
|
||||
}
|
||||
if (iroute is CellIRoute) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -223,7 +153,7 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
|
||||
_completerMap.remove(path);
|
||||
}
|
||||
|
||||
if (_configs.length > 1) {
|
||||
if (canPop) {
|
||||
_configs.removeLast();
|
||||
notifyListeners();
|
||||
} else {
|
||||
|
||||
@@ -79,7 +79,7 @@ Map<String, String> kRouteLabelMap = {
|
||||
'/app/color/add': '添加颜色',
|
||||
'/app/color/detail': '颜色详情',
|
||||
'/app/counter': '计数器',
|
||||
'/app/sort': '可视化排序算法',
|
||||
'/app/sort': '排序算法',
|
||||
'/app/sort/player': '演示',
|
||||
'/app/sort/settings': '排序配置',
|
||||
'/app/user': '我的',
|
||||
|
||||
@@ -28,7 +28,6 @@ class _AppNavigationState extends State<AppNavigation> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
print('=======AppNavigation#build===============');
|
||||
double px1 = 1/View.of(context).devicePixelRatio;
|
||||
return Scaffold(
|
||||
body: Row(
|
||||
|
||||
Reference in New Issue
Block a user