v4
This commit is contained in:
@@ -9,7 +9,7 @@ import '../../../pages/empty/empty_page.dart';
|
||||
import '../../../pages/settings/settings_page.dart';
|
||||
import '../../../pages/counter/counter_page.dart';
|
||||
import '../../../pages/sort/sort_page.dart';
|
||||
import '../../../transition/fade_transition_page.dart';
|
||||
import '../transition/fade_transition_page.dart';
|
||||
import '../../../pages/color/color_add_page.dart';
|
||||
|
||||
const List<String> kDestinationsPaths = [
|
||||
|
||||
@@ -1,36 +1,31 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../router/app_router_delegate.dart';
|
||||
import 'app_navigation_rail.dart';
|
||||
import 'background.dart';
|
||||
import 'top_bar.dart';
|
||||
import 'app_top_bar.dart';
|
||||
|
||||
class AppNavigation extends StatelessWidget {
|
||||
const AppNavigation({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double px1 = 1/View.of(context).devicePixelRatio;
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
body: Row(
|
||||
children: [
|
||||
// const Background(),
|
||||
Row(
|
||||
children: [
|
||||
const AppNavigationRail(),
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
TopBar(),
|
||||
Divider(height: 1,),
|
||||
Expanded(
|
||||
child: Router(
|
||||
routerDelegate: router,
|
||||
backButtonDispatcher: RootBackButtonDispatcher(),
|
||||
),
|
||||
),
|
||||
],
|
||||
const AppNavigationRail(),
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
const AppTopBar(),
|
||||
Divider(height: px1,),
|
||||
Expanded(
|
||||
child: Router(
|
||||
routerDelegate: router,
|
||||
backButtonDispatcher: RootBackButtonDispatcher(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:iroute/components/toly_ui/toly_ui.dart';
|
||||
import 'package:iroute/components/components.dart';
|
||||
import '../router/app_router_delegate.dart';
|
||||
|
||||
class AppNavigationRail extends StatefulWidget {
|
||||
@@ -10,11 +10,12 @@ class AppNavigationRail extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _AppNavigationRailState extends State<AppNavigationRail> {
|
||||
final List<NavigationRailDestination> destinations = const [
|
||||
NavigationRailDestination(icon: Icon(Icons.color_lens_outlined), label: Text("颜色板")),
|
||||
NavigationRailDestination(icon: Icon(Icons.add_chart), label: Text("计数器")),
|
||||
NavigationRailDestination(icon: Icon(Icons.person), label: Text("我的")),
|
||||
NavigationRailDestination(icon: Icon(Icons.settings), label: Text("设置")),
|
||||
|
||||
final List<MenuMeta> deskNavBarMenus = const [
|
||||
MenuMeta(label: '颜色板', icon: Icons.color_lens_outlined),
|
||||
MenuMeta(label: '计数器', icon: Icons.add_chart),
|
||||
MenuMeta(label: '我的', icon: Icons.person),
|
||||
MenuMeta(label: '设置', icon: Icons.settings),
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -31,23 +32,19 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TolyNavigationRail(
|
||||
leading: Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 18.0),
|
||||
child: FlutterLogo(),
|
||||
return DragToMoveWrap(
|
||||
child: TolyNavigationRail(
|
||||
items: deskNavBarMenus,
|
||||
leading: const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 18.0),
|
||||
child: FlutterLogo(),
|
||||
),
|
||||
backgroundColor: const Color(0xff3975c6),
|
||||
onDestinationSelected: _onDestinationSelected,
|
||||
selectedIndex: router.activeIndex,
|
||||
),
|
||||
backgroundColor: const Color(0xff3975c6),
|
||||
onDestinationSelected: _onDestinationSelected,
|
||||
selectedIndex: router.activeIndex,
|
||||
);
|
||||
|
||||
// return NavigationRail(
|
||||
// backgroundColor: Colors.transparent,
|
||||
// labelType: NavigationRailLabelType.all,
|
||||
// onDestinationSelected: _onDestinationSelected,
|
||||
// destinations: destinations,
|
||||
// selectedIndex: router.activeIndex,
|
||||
// );
|
||||
}
|
||||
|
||||
void _onDestinationSelected(int index) {
|
||||
|
||||
24
lib/v3/app/navigation/views/app_top_bar.dart
Normal file
24
lib/v3/app/navigation/views/app_top_bar.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:iroute/components/components.dart';
|
||||
import '../router/app_router_delegate.dart';
|
||||
|
||||
class AppTopBar extends StatelessWidget {
|
||||
const AppTopBar({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DragToMoveWrap(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: 46,
|
||||
child: const Row(
|
||||
children: [
|
||||
Expanded(child: SizedBox()),
|
||||
WindowButtons()
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Background extends StatelessWidget {
|
||||
const Background({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: const BoxDecoration(
|
||||
gradient:
|
||||
LinearGradient(transform: GradientRotation(pi / 2), colors: [
|
||||
Color(0xffF1EFF1),
|
||||
Color(0xffFFFFFF),
|
||||
])),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:iroute/components/components.dart';
|
||||
import '../router/app_router_delegate.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
|
||||
|
||||
class TopBar extends StatelessWidget {
|
||||
const TopBar({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return DragToMoveAreaNoDouble(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: 46,
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
RouterIndicator(),
|
||||
Spacer(),
|
||||
WindowButtons()
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class RouterIndicator extends StatefulWidget {
|
||||
const RouterIndicator({super.key});
|
||||
|
||||
@override
|
||||
State<RouterIndicator> createState() => _RouterIndicatorState();
|
||||
}
|
||||
|
||||
class _RouterIndicatorState extends State<RouterIndicator> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
router.addListener(_onRouterChange);
|
||||
}
|
||||
|
||||
Map<String, String> routeLabelMap = {
|
||||
'/color': '颜色板',
|
||||
'/color/add': '添加颜色',
|
||||
'/color/detail': '颜色详情',
|
||||
'/counter': '计数器',
|
||||
'/user': '我的',
|
||||
'/settings': '系统设置',
|
||||
};
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TolyBreadcrumb(
|
||||
items: pathToBreadcrumbItems(router.path),
|
||||
onTapItem: (item){
|
||||
if(item.to!=null){
|
||||
router.path = item.to!;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _onRouterChange() {
|
||||
print('_onRouterChange');
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
List<BreadcrumbItem> pathToBreadcrumbItems(String path) {
|
||||
Uri uri = Uri.parse(path);
|
||||
List<BreadcrumbItem> result = [];
|
||||
String to = '';
|
||||
|
||||
String distPath = '';
|
||||
for (String segment in uri.pathSegments) {
|
||||
distPath += '/$segment';
|
||||
}
|
||||
|
||||
for (String segment in uri.pathSegments) {
|
||||
to += '/$segment';
|
||||
result.add(BreadcrumbItem(to: to, label: routeLabelMap[to] ?? '未知路由',active: to==distPath));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class DragToMoveAreaNoDouble extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const DragToMoveAreaNoDouble({
|
||||
Key? key,
|
||||
required this.child,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onPanStart: (details) {
|
||||
windowManager.startDragging();
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'navigation/router/app_router_delegate.dart';
|
||||
import 'navigation/views/app_navigation.dart';
|
||||
import 'navigation/views/app_navigation_rail.dart';
|
||||
|
||||
class UnitApp extends StatelessWidget {
|
||||
const UnitApp({super.key});
|
||||
@@ -11,6 +9,7 @@ class UnitApp extends StatelessWidget {
|
||||
|
||||
return MaterialApp(
|
||||
theme: ThemeData(
|
||||
scaffoldBackgroundColor: Colors.white,
|
||||
fontFamily: "宋体",
|
||||
appBarTheme: const AppBarTheme(
|
||||
elevation: 0,
|
||||
|
||||
12
lib/v3/pages/color/color_navigation.dart
Normal file
12
lib/v3/pages/color/color_navigation.dart
Normal file
@@ -0,0 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ColorNavigation extends StatelessWidget {
|
||||
const ColorNavigation({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Navigator(
|
||||
pages: [],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user