-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debug , To的继承有点问题,继承后,layout,builder信息丢了
- Loading branch information
Showing
6 changed files
with
130 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
packages/you_flutter/lib/src/layouts/page_layout_default.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/src/router.dart'; | ||
|
||
class PageLayoutDefault extends StatelessWidget { | ||
final PageBuilder builder; | ||
final ToUri uri; | ||
|
||
PageLayoutDefault({required this.builder, required this.uri}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
var child = builder(context); | ||
|
||
NavigationRailDestination rail({required String title, required IconData icon}) { | ||
return NavigationRailDestination( | ||
icon: Tooltip(message: title, child: Icon(icon)), | ||
label: Text(title), | ||
); | ||
} | ||
|
||
return Scaffold( | ||
primary: true, | ||
// content... | ||
appBar: AppBar(toolbarHeight: 38, title: Text("location: $uri"), actions: [ | ||
IconButton(iconSize: 24, icon: const Icon(Icons.color_lens_outlined), onPressed: () {}), | ||
IconButton(iconSize: 24, icon: const Icon(Icons.settings), onPressed: () {}), | ||
]), | ||
floatingActionButton: FloatingActionButton(onPressed: () {}, tooltip: 'Increment', child: const Icon(Icons.add)), | ||
body: SafeArea( | ||
child: SelectionArea( | ||
child: Row( | ||
crossAxisAlignment: CrossAxisAlignment.stretch, | ||
children: [ | ||
NavigationRail(onDestinationSelected: (index) {}, minWidth: 24, minExtendedWidth: 24, selectedIndex: null, groupAlignment: -1, labelType: NavigationRailLabelType.none, destinations: <NavigationRailDestination>[ | ||
rail(title: "文件夹", icon: Icons.folder_outlined), | ||
rail(title: "文件夹2", icon: Icons.folder_outlined), | ||
]), | ||
Drawer( | ||
width: 200, | ||
child: _RouteTree(), | ||
), | ||
Expanded(child: child), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _RouteTree extends StatelessWidget { | ||
const _RouteTree(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final router = YouRouter.of(context); | ||
|
||
var validRoutes = router.root.toList(); | ||
var routeWidgets = validRoutes.map((node) { | ||
String title = "▼ ${node.part}"; | ||
title = title.padLeft((node.level * 3) + title.length); | ||
|
||
var click = () { | ||
router.to(node.toUri()); | ||
}; | ||
return Align( | ||
alignment: Alignment.centerLeft, | ||
child: TextButton(onPressed: click, child: Text(title)), | ||
); | ||
}); | ||
return ConstrainedBox( | ||
constraints: BoxConstraints.tightFor(width: 350), | ||
child: ListView( | ||
children: [ | ||
...routeWidgets, | ||
], | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters