-
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.
- Loading branch information
Showing
8 changed files
with
404 additions
and
300 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,60 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/router.dart'; | ||
|
||
/// ref: [PageLayoutBuilder] | ||
Widget layout(BuildContext context, ToUri uri, PageBuilder builder) { | ||
// ignore: unnecessary_type_check | ||
assert(layout is PageLayoutBuilder); | ||
return RootLayout( | ||
uri: uri, | ||
builder: builder, | ||
); | ||
} | ||
|
||
@immutable | ||
final class RootLayout extends StatelessWidget { | ||
final PageBuilder builder; | ||
final ToUri uri; | ||
|
||
const RootLayout({super.key, required this.uri, required this.builder}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
var child = builder(context, uri); | ||
|
||
|
||
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: const Text("widget.title"), actions: [ | ||
IconButton(iconSize: 24, icon: const Icon(Icons.color_lens_outlined), onPressed: () {}), | ||
IconButton(iconSize: 24, icon: const Icon(Icons.settings), onPressed: () {}), | ||
if (kDebugMode) const Text("debug模式"), | ||
]), | ||
floatingActionButton: FloatingActionButton(onPressed: () {}, tooltip: 'Increment', child: const Icon(Icons.add)), | ||
body: SafeArea( | ||
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), | ||
]), | ||
Drawer( | ||
width: 200, | ||
child: ListView(scrollDirection: Axis.vertical, children: [ | ||
const Divider(), | ||
ListTile(title: const Text('根页面'), subtitle: const Text("xxx"), onTap: () {}), | ||
const Divider(), | ||
])), | ||
Expanded(child: child), | ||
]), | ||
), | ||
); | ||
} | ||
} |
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,18 @@ | ||
// ignore_for_file: non_constant_identifier_names,camel_case_types | ||
import 'package:flutter/material.dart'; | ||
import 'package:you_flutter/router.dart'; | ||
|
||
RootPage build(BuildContext context, ToUri uri) { | ||
return RootPage(uri: uri); | ||
} | ||
|
||
class RootPage extends StatelessWidget { | ||
final ToUri uri; | ||
|
||
const RootPage({required this.uri, super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const Text("/ root page"); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.