v5
This commit is contained in:
@@ -54,8 +54,9 @@ class _AppNavigationRailState extends State<AppNavigationRail> {
|
||||
void _onDestinationSelected(int index) {
|
||||
if(index==1){
|
||||
router.setPathKeepLive(kDestinationsPaths[index]);
|
||||
}else{
|
||||
router.path = kDestinationsPaths[index];
|
||||
}
|
||||
router.path = kDestinationsPaths[index];
|
||||
}
|
||||
|
||||
void _onRouterChange() {
|
||||
|
||||
64
lib/v5/app/navigation/views/app_router_editor.dart
Normal file
64
lib/v5/app/navigation/views/app_router_editor.dart
Normal file
@@ -0,0 +1,64 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:iroute/components/toly_ui/button/hover_icon_button.dart';
|
||||
import '../router/app_router_delegate.dart';
|
||||
|
||||
class AppRouterEditor extends StatefulWidget {
|
||||
final ValueChanged<String>? onSubmit;
|
||||
const AppRouterEditor({super.key, this.onSubmit});
|
||||
|
||||
@override
|
||||
State<AppRouterEditor> createState() => _AppRouterEditorState();
|
||||
}
|
||||
|
||||
class _AppRouterEditorState extends State<AppRouterEditor> {
|
||||
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_onRouteChange();
|
||||
router.addListener(_onRouteChange);
|
||||
}
|
||||
|
||||
void _onRouteChange() {
|
||||
_controller.text=router.path;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
router.removeListener(_onRouteChange);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
alignment: Alignment.centerRight,
|
||||
children: [
|
||||
SizedBox(
|
||||
child: CupertinoTextField(
|
||||
controller: _controller,
|
||||
style: TextStyle(fontSize: 14),
|
||||
padding: EdgeInsets.only(left:12,top: 6,bottom: 6,right: 32),
|
||||
placeholder: '输入路由地址导航',
|
||||
onSubmitted: widget.onSubmit,
|
||||
decoration: BoxDecoration(color: Color(0xffF1F2F3),borderRadius: BorderRadius.circular(6)),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0),
|
||||
child: HoverIconButton(
|
||||
icon: Icons.directions_outlined,
|
||||
defaultColor: Color(0xff68696B),
|
||||
onPressed:()=>widget.onSubmit?.call(_controller.text),
|
||||
size: 20
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:iroute/components/components.dart';
|
||||
import '../router/app_router_delegate.dart';
|
||||
import 'app_router_editor.dart';
|
||||
|
||||
class AppTopBar extends StatelessWidget {
|
||||
const AppTopBar({super.key});
|
||||
@@ -11,13 +12,26 @@ class AppTopBar extends StatelessWidget {
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
height: 46,
|
||||
child: const Row(
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(width: 16),
|
||||
Expanded(child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: RouterIndicator())),
|
||||
WindowButtons()
|
||||
const SizedBox(width: 16),
|
||||
const RouterIndicator(),
|
||||
Expanded(
|
||||
child: Row(children: [
|
||||
const Spacer(),
|
||||
SizedBox(
|
||||
width: 250,
|
||||
child: AppRouterEditor(
|
||||
onSubmit: (path) => router.path = path,
|
||||
)),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 12.0),
|
||||
child: VerticalDivider(
|
||||
width: 32,
|
||||
),
|
||||
)
|
||||
])),
|
||||
const WindowButtons()
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -41,7 +55,6 @@ Map<String, String> kRouteLabelMap = {
|
||||
'/settings': '系统设置',
|
||||
};
|
||||
|
||||
|
||||
class _RouterIndicatorState extends State<RouterIndicator> {
|
||||
@override
|
||||
void initState() {
|
||||
@@ -59,8 +72,8 @@ class _RouterIndicatorState extends State<RouterIndicator> {
|
||||
Widget build(BuildContext context) {
|
||||
return TolyBreadcrumb(
|
||||
items: pathToBreadcrumbItems(router.path),
|
||||
onTapItem: (item){
|
||||
if(item.to!=null){
|
||||
onTapItem: (item) {
|
||||
if (item.to != null) {
|
||||
router.path = item.to!;
|
||||
}
|
||||
},
|
||||
@@ -84,9 +97,8 @@ class _RouterIndicatorState extends State<RouterIndicator> {
|
||||
for (String segment in uri.pathSegments) {
|
||||
to += '/$segment';
|
||||
String label = kRouteLabelMap[to] ?? '未知路由';
|
||||
result.add(BreadcrumbItem(to: to, label: label,active: to==distPath));
|
||||
result.add(BreadcrumbItem(to: to, label: label, active: to == distPath));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user