9
This commit is contained in:
89
lib/13/03/pages/app/app.dart
Normal file
89
lib/13/03/pages/app/app.dart
Normal file
@@ -0,0 +1,89 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toly_menu/toly_menu.dart';
|
||||
|
||||
import '../../menus.dart';
|
||||
|
||||
class App extends StatelessWidget {
|
||||
const App({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(
|
||||
appBarTheme: const AppBarTheme(
|
||||
elevation: 0,
|
||||
iconTheme: IconThemeData(color: Colors.black),
|
||||
titleTextStyle: TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
))),
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: AppLayout());
|
||||
}
|
||||
}
|
||||
|
||||
class AppLayout extends StatelessWidget {
|
||||
const AppLayout({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 210,
|
||||
child: MenuPanel(),
|
||||
),
|
||||
// Container()
|
||||
],
|
||||
),
|
||||
// appBar: AppToolBar(),
|
||||
// body: AppNavigation(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MenuPanel extends StatefulWidget {
|
||||
const MenuPanel({super.key});
|
||||
|
||||
@override
|
||||
State<MenuPanel> createState() => _MenuPanelState();
|
||||
}
|
||||
|
||||
class _MenuPanelState extends State<MenuPanel> {
|
||||
MenuState state = MenuState(expandMenus: ['/dashboard'], activeMenu: '/dashboard/data_analyse', items: menus);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TolyMenu(state: state, onSelect: _onSelect);
|
||||
}
|
||||
|
||||
void _onSelect(MenuData menu) {
|
||||
if(menu.isLeaf){
|
||||
state = state.copyWith(activeMenu: menu.path);
|
||||
}else{
|
||||
List<String> menus = [];
|
||||
String path = menu.path.substring(1);
|
||||
List<String> parts = path.split('/');
|
||||
|
||||
if(parts.isNotEmpty){
|
||||
String path = '';
|
||||
for (String part in parts) {
|
||||
path+='/$part';
|
||||
menus.add(path);
|
||||
}
|
||||
}
|
||||
|
||||
if(state.expandMenus.contains(menu.path)){
|
||||
menus.remove(menu.path);
|
||||
}
|
||||
|
||||
state = state.copyWith(expandMenus: menus);
|
||||
|
||||
}
|
||||
setState(() {
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
43
lib/13/03/pages/app/root_content.dart
Normal file
43
lib/13/03/pages/app/root_content.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class RootContent extends StatelessWidget {
|
||||
const RootContent({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Router(routerDelegate: RootContentDelegate());
|
||||
}
|
||||
}
|
||||
|
||||
class RootContentDelegate extends RouterDelegate with ChangeNotifier,PopNavigatorRouterDelegateMixin{
|
||||
|
||||
|
||||
@override
|
||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Navigator(
|
||||
key: navigatorKey,
|
||||
pages: [
|
||||
|
||||
],
|
||||
onPopPage: (route, result) {
|
||||
// appState.selectedBook = null;
|
||||
// notifyListeners();
|
||||
return route.didPop(result);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Future<void> setNewRoutePath(configuration) {
|
||||
// TODO: implement setNewRoutePath
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user