This commit is contained in:
toly
2023-09-22 09:15:11 +08:00
parent d456e3c523
commit e95c34018e
132 changed files with 8527 additions and 17 deletions

View File

@@ -0,0 +1,107 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:toly_menu/toly_menu.dart';
import '../../menus.dart';
import '../../transition/fade_transition.dart';
import 'root_content.dart';
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
TargetPlatform.iOS: CupertinoPageTransitionsBuilder(),
TargetPlatform.macOS: FadeUpwardsPageTransitionsBuilder(),
TargetPlatform.windows: FadeTransitionsBuilder(),
}
),
appBarTheme: const AppBarTheme(
elevation: 0,
iconTheme: IconThemeData(color: Colors.black),
backgroundColor: Colors.white,
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()
Expanded(child: RootContent())
],
),
// 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);
print("menu.path${menu.path}");
goRouter.go(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(() {
});
}
}

View File

@@ -0,0 +1,140 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:iroute/cases/cases.dart';
import '../color_page.dart';
// GoRouter configuration
final goRouter = GoRouter(
initialLocation: '/manager',
routes: [
GoRoute(
path: '/dashboard',
builder: (_,__)=>SizedBox(),
routes: [
GoRoute(
path: 'data_analyse',
// builder: (context, state) => ColorPage(title: 'data_analyse',),
pageBuilder: (context, state) {
return CustomTransitionPage(
key: state.pageKey,
child: ColorPage(title: 'data_analyse',),
transitionsBuilder: (context, animation, secondaryAnimation, child) {
// Change the opacity of the screen using a Curve based on the the animation's
// value
return FadeTransition(
opacity:
CurveTween(curve: Curves.easeInOutCirc).animate(animation),
child: child,
);
},
);
},
),
GoRoute(
path: 'work_board',
builder: (_,__)=>SizedBox(),
routes: [
GoRoute(
path: 'a',
builder: (context, state) => ColorPage(title: '第一工作区',),
),
GoRoute(
path: 'b',
builder: (context, state) => ColorPage(title: '第二工作区',),
),
GoRoute(
path: 'c',
builder: (context, state) => ColorPage(title: '第三工作区',),
),
]
),
]
),
GoRoute(
path: '/cases',
builder: (_,__)=>SizedBox(),
routes: [
GoRoute(
path: 'counter',
builder: (context, state) => CounterPage(),
),
GoRoute(
path: 'guess',
builder: (context, state) => GuessPage(),
),
GoRoute(
path: 'muyu',
builder: (context, state) => ColorPage(title: '第三工作区',),
), GoRoute(
path: 'canvas',
builder: (context, state) => Paper(),
), GoRoute(
path: 'muyu',
builder: (context, state) => ColorPage(title: '第三工作区',),
),
]
),
GoRoute(
path: '/manager', builder: (_,__)=>SizedBox(),
routes: [
GoRoute(
path: 'account',
builder: (context, state) => ColorPage(title: 'account',),
),
GoRoute(
path: 'role',
builder: (context, state) => ColorPage(title: 'role',),
),
]
),
],
);
class RootContent extends StatelessWidget {
const RootContent({super.key});
@override
Widget build(BuildContext context) {
return Router.withConfig(config: goRouter);
}
}
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();
}
}

View File

@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';
class ColorPage extends StatelessWidget {
final String title;
const ColorPage({super.key, required this.title});
@override
Widget build(BuildContext context) {
return Scaffold(body: Center(child: Text(title)));
}
}