refactor: unify error feedback system with FeedbackService and StatusBar widget

- Create FeedbackService as centralized sound/vibration dispatcher
- Create reusable StatusBar widget with StatusDotColor enum (blue/orange/green/red/yellow/amber)
- Extend SoundService with beep/error/alert sound types and loop playback
- Remove top feedback banners from both registration and boxing pages
- Route all feedback through bottom status bar per PRD requirements
- Add sound and vibration feedback to boxing module (was completely missing)
- Handle network errors with yellow status, general errors with red
- Enhance duplicate dialog with alert loop sound that stops on close
- Add beep/error/alert sound file selectors in settings page

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-05-12 17:15:28 +08:00
parent ac77294ecb
commit 1417c8baf9
7 changed files with 1068 additions and 517 deletions

View File

@@ -0,0 +1,60 @@
import 'package:flutter/material.dart';
/// Status bar dot colors matching PRD requirements.
enum StatusDotColor {
blue, // idle / waiting
orange, // submitting
green, // success
red, // error (invalid code / submit failure / duplicate)
yellow, // network error
amber, // warning (duplicate box number)
}
/// Reusable bottom status bar with a colored dot and text.
class StatusBar extends StatelessWidget {
final StatusDotColor dotColor;
final String text;
const StatusBar({super.key, required this.dotColor, required this.text});
Color _resolveDotColor(BuildContext context) {
return switch (dotColor) {
StatusDotColor.blue => Colors.blue,
StatusDotColor.orange => Colors.orange,
StatusDotColor.green => Colors.green,
StatusDotColor.red => Colors.red,
StatusDotColor.yellow => Colors.yellow.shade700,
StatusDotColor.amber => Colors.amber,
};
}
@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
return Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
color: colorScheme.surfaceContainerHighest,
child: Row(
children: [
Container(
width: 8,
height: 8,
decoration: BoxDecoration(
color: _resolveDotColor(context),
shape: BoxShape.circle,
),
),
const SizedBox(width: 8),
Expanded(
child: Text(
text,
style: const TextStyle(fontSize: 14),
overflow: TextOverflow.ellipsis,
),
),
],
),
);
}
}