v5
This commit is contained in:
@@ -38,16 +38,7 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
|
||||
|
||||
Completer<dynamic>? completer;
|
||||
|
||||
final List<String> _alivePaths = [];
|
||||
final Map<String,List<Page>> _alivePageMap = {};
|
||||
|
||||
void setPathKeepLive(String value){
|
||||
_alivePageMap[value] = _buildPageByPath(value);
|
||||
path = value;
|
||||
}
|
||||
|
||||
final Map<String,dynamic> _pathExtraMap = {};
|
||||
final List<Page> _livePages = [];
|
||||
|
||||
void setPathForData(String value,dynamic data){
|
||||
_pathExtraMap[value] = data;
|
||||
@@ -69,29 +60,15 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Page> pages = [];
|
||||
if(_alivePageMap.containsKey(path)){
|
||||
pages = _alivePageMap[path]!;
|
||||
}else{
|
||||
for (var element in _alivePageMap.values) {
|
||||
pages.addAll(element);
|
||||
}
|
||||
pages.addAll(_buildPageByPath(path));
|
||||
}
|
||||
|
||||
return Navigator(
|
||||
onPopPage: _onPopPage,
|
||||
pages: pages.toSet().toList(),
|
||||
pages: _buildPageByPath(path),
|
||||
);
|
||||
}
|
||||
|
||||
List<Page> _buildPageByPath(String path) {
|
||||
Widget? child;
|
||||
if(path.startsWith('/color')){
|
||||
// child = Navigator(
|
||||
// pages: ,
|
||||
// onPopPage: _onPopPage,
|
||||
// );
|
||||
return buildColorPages(path);
|
||||
}
|
||||
|
||||
@@ -125,10 +102,9 @@ class AppRouterDelegate extends RouterDelegate<Object> with ChangeNotifier {
|
||||
if(segment =='detail'){
|
||||
final Map<String, String> queryParams = uri.queryParameters;
|
||||
String? selectedColor = queryParams['color'];
|
||||
|
||||
if (selectedColor != null) {
|
||||
Color color = Color(int.parse(selectedColor, radix: 16));
|
||||
result.add( FadeTransitionPage(
|
||||
result.add(FadeTransitionPage(
|
||||
key: const ValueKey('/color/detail'),
|
||||
child:ColorDetailPage(color: color),
|
||||
));
|
||||
|
||||
@@ -52,11 +52,7 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
|
||||
}
|
||||
|
||||
void _onDestinationSelected(int index) {
|
||||
if(index==1){
|
||||
router.setPathKeepLive(kDestinationsPaths[index]);
|
||||
}else{
|
||||
router.path = kDestinationsPaths[index];
|
||||
}
|
||||
router.path = kDestinationsPaths[index];
|
||||
}
|
||||
|
||||
void _onRouterChange() {
|
||||
|
||||
@@ -89,9 +89,6 @@ class _ColorAddPageState extends State<ColorAddPage> {
|
||||
);
|
||||
}
|
||||
|
||||
void _selectColor() {
|
||||
Navigator.of(context).pop(_color);
|
||||
}
|
||||
|
||||
void changeColor(Color value) {
|
||||
_color = value;
|
||||
|
||||
@@ -15,15 +15,6 @@ class ColorDetailPage extends StatelessWidget {
|
||||
);
|
||||
String text = '# ${color.value.toRadixString(16)}';
|
||||
return Scaffold(
|
||||
// appBar: AppBar(
|
||||
// systemOverlayStyle: SystemUiOverlayStyle(
|
||||
// statusBarColor: Colors.transparent,
|
||||
// statusBarIconBrightness: Brightness.light
|
||||
// ),
|
||||
// iconTheme: IconThemeData(color: Colors.white),
|
||||
// titleTextStyle:TextStyle(color: Colors.white,fontSize: 18) ,
|
||||
// backgroundColor: color,
|
||||
// title: Text('颜色界面',),),
|
||||
body: Container(
|
||||
alignment: Alignment.center,
|
||||
color: color,
|
||||
|
||||
@@ -36,10 +36,9 @@ class _ColorPageState extends State<ColorPage> {
|
||||
}
|
||||
|
||||
void _selectColor(Color color){
|
||||
String value = color.value.toRadixString(16);
|
||||
router.path = '/color/detail?color=$value';
|
||||
// router.setPathForData('/color/detail',color);
|
||||
// router.setPathKeepLive('/color/detail?color=$value');
|
||||
// String value = color.value.toRadixString(16);
|
||||
// router.path = '/color/detail?color=$value';
|
||||
router.setPathForData('/color/detail',color);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user