This commit is contained in:
toly
2023-11-04 08:48:16 +08:00
parent 8ef81ddb33
commit 88cd6fb3b4
130 changed files with 2563 additions and 5327 deletions

View File

@@ -57,6 +57,7 @@ Map<String, String> kRouteLabelMap = {
'/color/add': '添加颜色',
'/color/detail': '颜色详情',
'/counter': '计数器',
'/sort': '可视化排序算法',
'/user': '我的',
'/settings': '系统设置',
};

View File

@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
import 'package:iroute/components/components.dart';
import '../../router/app_router_delegate.dart';
import '../../router/route_history.dart';
import '../../router/iroute_config.dart';
import 'app_top_bar.dart';
class HistoryViewIcon extends StatelessWidget{
@@ -55,7 +55,7 @@ class HistoryViewIcon extends StatelessWidget{
}
class HistoryItem extends StatefulWidget {
final RouteHistory history;
final IRouteConfig history;
final VoidCallback onPressed;
final VoidCallback onDelete;
@@ -83,7 +83,7 @@ class _HistoryItemState extends State<HistoryItem> {
const SizedBox(
height: 2,
),
Text(kRouteLabelMap[widget.history.path]!),
Text(kRouteLabelMap[widget.history.path]??'未知路由'),
],
)),
GestureDetector(
@@ -124,7 +124,8 @@ class _HistoryPanelState extends State<HistoryPanel> {
@override
Widget build(BuildContext context) {
if(router.histories.isEmpty){
List<IRouteConfig> histories = router.historyManager.histories;
if(histories.isEmpty){
return const Center(
child: Text(
'暂无浏览历史记录',
@@ -135,18 +136,18 @@ class _HistoryPanelState extends State<HistoryPanel> {
return ListView.builder(
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
itemExtent: 46,
itemCount: router.histories.length,
itemCount: histories.length,
itemBuilder: (_, index) =>
HistoryItem(
onDelete: (){
int fixIndex = router.histories.length - 1 - index;
int fixIndex = histories.length - 1 - index;
router.closeHistory(fixIndex);
},
onPressed: (){
router.toHistory(router.histories[index]);
router.changeRoute(histories[index].copyWith(recordHistory: false));
Navigator.of(context).pop();
},
history: router.histories[index]),
history: histories[index]),
);
}

View File

@@ -25,8 +25,8 @@ class _RouteHistoryButtonState extends State<RouteHistoryButton> {
@override
Widget build(BuildContext context) {
bool hasHistory = router.hasHistory;
bool hasBackHistory = router.hasBackHistory;
bool hasHistory = router.historyManager.hasHistory;
bool hasBackHistory = router.historyManager.hasBackHistory;
Color activeColor = const Color(0xff9195AC);
Color inActiveColor = const Color(0xffC7CAD5);
Color historyColor = hasHistory?activeColor:inActiveColor;