This commit is contained in:
toly
2023-11-08 09:35:29 +08:00
parent 88cd6fb3b4
commit 8fb4bf57d6
78 changed files with 4344 additions and 544 deletions

View File

@@ -44,6 +44,7 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
final List<String> keepAlivePath = [] ;
void setPathKeepLive(String value){
if(keepAlivePath.contains(value)){
keepAlivePath.remove(value);
@@ -52,6 +53,8 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
path = value;
}
void setPathForData(String value,dynamic data){
_pathExtraMap[value] = data;
path = value;
@@ -82,6 +85,17 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
List<Page> pages = [];
List<Page> topPages = _buildPageByPath(path);
if(keepAlivePath.isNotEmpty){
for (String alivePath in keepAlivePath) {
if(alivePath!=path){
pages.addAll(_buildPageByPath(alivePath)) ;
}
}
/// 去除和 topPages 中重复的界面
pages.removeWhere((element) => topPages.map((e) => e.key).contains(element.key));
}
if(keepAlivePath.isNotEmpty){
for (String alivePath in keepAlivePath) {
if(alivePath!=path){
@@ -171,7 +185,6 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
_completerMap[path]?.complete(result);
_completerMap.remove(path);
}
path = backPath(path);
return route.didPop(result);
}

View File

@@ -10,7 +10,6 @@ class AppNavigationRail extends StatefulWidget {
}
class _AppNavigationRailState extends State<AppNavigationRail> {
final List<MenuMeta> deskNavBarMenus = const [
MenuMeta(label: '颜色板', icon: Icons.color_lens_outlined),
MenuMeta(label: '计数器', icon: Icons.add_chart),
@@ -41,22 +40,24 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
),
tail: Padding(
padding: const EdgeInsets.only(bottom: 6.0),
child: Text('V0.0.5',style: TextStyle(color: Colors.white,fontSize: 12),),
child: Text(
'V0.0.5',
style: TextStyle(color: Colors.white, fontSize: 12),
),
),
backgroundColor: const Color(0xff3975c6),
onDestinationSelected: _onDestinationSelected,
selectedIndex: router.activeIndex,
),
);
}
void _onDestinationSelected(int index) {
if(index==1){
if (index == 1) {
router.setPathKeepLive(kDestinationsPaths[index]);
}else{
router.path = kDestinationsPaths[index];
return;
}
router.path = kDestinationsPaths[index];
}
void _onRouterChange() {