feat: improve scan UX — case normalization, lock-mode list, layout swap
- CodeParser: normalize scanned barcode to uppercase and trim whitespace to handle scanner hardware outputting lowercase or trailing characters - RegistrationPage: swap layout so location field is above zongpai field - Lock mode: zongpai display changes to scrollable list supporting multiple entries with swipe-to-delete and per-item delete buttons - Lock mode: batch submit when multiple zongpai numbers are queued - Show scanned barcode content in invalid code error messages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -11,17 +11,19 @@ class CodeParser {
|
||||
);
|
||||
|
||||
static ParseResult parse(String code) {
|
||||
if (code.isEmpty) {
|
||||
final trimmed = code.trim();
|
||||
if (trimmed.isEmpty) {
|
||||
return ParseResult(type: CodeType.invalid, value: code);
|
||||
}
|
||||
if (_transitRegex.hasMatch(code)) {
|
||||
return ParseResult(type: CodeType.locationTransit, value: code);
|
||||
final normalized = trimmed.toUpperCase();
|
||||
if (_transitRegex.hasMatch(normalized)) {
|
||||
return ParseResult(type: CodeType.locationTransit, value: normalized);
|
||||
}
|
||||
if (_zongpaiRegex.hasMatch(code)) {
|
||||
return ParseResult(type: CodeType.zongpaiNo, value: code);
|
||||
if (_zongpaiRegex.hasMatch(normalized)) {
|
||||
return ParseResult(type: CodeType.zongpaiNo, value: normalized);
|
||||
}
|
||||
if (_locationRegex.hasMatch(code)) {
|
||||
return ParseResult(type: CodeType.locationNormal, value: code);
|
||||
if (_locationRegex.hasMatch(normalized)) {
|
||||
return ParseResult(type: CodeType.locationNormal, value: normalized);
|
||||
}
|
||||
return ParseResult(type: CodeType.invalid, value: code);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user