feat: add accessory module card to home page
Add 附件登记 (accessory registration) card to the home page module registry with developing status, keyboard shortcut 3, and navigation to AccessoryPage. Refactor _moduleFromShortcut to use dynamic index lookup for better maintainability. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,10 +4,11 @@ import 'package:pad_scanner/services/app_config_service.dart';
|
||||
import 'package:pad_scanner/pages/settings_page.dart';
|
||||
import 'package:pad_scanner/pages/registration_page.dart';
|
||||
import 'package:pad_scanner/pages/boxing_page.dart';
|
||||
import 'package:pad_scanner/pages/accessory_page.dart';
|
||||
import 'package:pad_scanner/services/api_service.dart';
|
||||
|
||||
/// Module type enum for each available feature card
|
||||
enum ModuleType { registration, boxing, shelfQuery }
|
||||
enum ModuleType { registration, boxing, accessory, shelfQuery }
|
||||
|
||||
/// Module status for PRD state tracking
|
||||
enum ModuleStatus { online, developing, planning }
|
||||
@@ -64,8 +65,16 @@ class _HomePageState extends State<HomePage> {
|
||||
route: '/boxing',
|
||||
),
|
||||
FeatureCard(
|
||||
type: ModuleType.shelfQuery,
|
||||
type: ModuleType.accessory,
|
||||
shortcut: '3',
|
||||
icon: Icons.build,
|
||||
title: '附件登记',
|
||||
status: ModuleStatus.developing,
|
||||
route: '/accessory',
|
||||
),
|
||||
FeatureCard(
|
||||
type: ModuleType.shelfQuery,
|
||||
shortcut: '4',
|
||||
icon: Icons.search_outlined,
|
||||
title: '货架查询',
|
||||
status: ModuleStatus.planning,
|
||||
@@ -101,16 +110,10 @@ class _HomePageState extends State<HomePage> {
|
||||
|
||||
FeatureCard? _moduleFromShortcut(KeyEvent event) {
|
||||
final shortcut = _shortcutNumberFromKeyEvent(event);
|
||||
if (shortcut == 1) {
|
||||
return _modules[0];
|
||||
if (shortcut == null || shortcut < 1 || shortcut > _modules.length) {
|
||||
return null;
|
||||
}
|
||||
if (shortcut == 2) {
|
||||
return _modules[1];
|
||||
}
|
||||
if (shortcut == 3) {
|
||||
return _modules[2];
|
||||
}
|
||||
return null;
|
||||
return _modules[shortcut - 1];
|
||||
}
|
||||
|
||||
int? _shortcutNumberFromKeyEvent(KeyEvent event) {
|
||||
@@ -130,6 +133,11 @@ class _HomePageState extends State<HomePage> {
|
||||
event.character == '3') {
|
||||
return 3;
|
||||
}
|
||||
if (key == LogicalKeyboardKey.digit4 ||
|
||||
key == LogicalKeyboardKey.numpad4 ||
|
||||
event.character == '4') {
|
||||
return 4;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -181,6 +189,9 @@ class _HomePageState extends State<HomePage> {
|
||||
case ModuleType.boxing:
|
||||
targetPage = const BoxingPage();
|
||||
break;
|
||||
case ModuleType.accessory:
|
||||
targetPage = const AccessoryPage();
|
||||
break;
|
||||
case ModuleType.shelfQuery:
|
||||
return; // 规划中,不导航
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user