fix(sync): 修复喷数重复扣减与重装恢复,支持余量校准
This commit is contained in:
@@ -78,9 +78,18 @@ class _SessionScreenState extends State<SessionScreen> {
|
||||
}
|
||||
|
||||
Future<void> _saveAndExit() async {
|
||||
await _sessionService.confirmAndSave(widget.storageService);
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop(true);
|
||||
if (_sessionService.isSaving) return;
|
||||
try {
|
||||
await _sessionService.confirmAndSave(widget.storageService);
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
} catch (_) {
|
||||
if (mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('保存失败,请重试')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -640,14 +649,17 @@ class _SessionScreenState extends State<SessionScreen> {
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ElevatedButton(
|
||||
onPressed: _saveAndExit,
|
||||
onPressed: _sessionService.isSaving ? null : _saveAndExit,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF0F172A),
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
),
|
||||
child: const Text('确认并保存记录', style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
child: Text(
|
||||
_sessionService.isSaving ? '保存中…' : '确认并保存记录',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user