feat(audio): 引入audioplayers原生提示音效,修复做完提示音缺失与局域网配置溢出

This commit is contained in:
shen
2026-10-27 04:20:18 -07:00
parent 473fbb93ad
commit 1f794585cd
14 changed files with 289 additions and 13 deletions
+22 -1
View File
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import '../models/app_settings.dart';
import '../services/storage_service.dart';
import '../services/tts_service.dart';
import '../services/audio_service.dart';
import 'plan_config_screen.dart';
import 'lan_sync_screen.dart';
@@ -181,7 +182,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
children: [
SwitchListTile(
title: const Text('提示音效', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600)),
subtitle: const Text('倒计时结束时发出提示音', style: TextStyle(fontSize: 12)),
subtitle: const Text('各阶段完成及全部做完时的提示音(清脆铃声)', style: TextStyle(fontSize: 12)),
value: _settings.enableSound,
activeTrackColor: const Color(0xFF2563EB),
onChanged: (val) {
@@ -189,6 +190,26 @@ class _SettingsScreenState extends State<SettingsScreen> {
_save();
},
),
Padding(
padding: const EdgeInsets.only(left: 16, right: 16, bottom: 8),
child: Align(
alignment: Alignment.centerLeft,
child: OutlinedButton.icon(
onPressed: () {
AudioService().playSessionComplete();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('已播放用药完成提示铃声 🔔'), duration: Duration(seconds: 1)),
);
},
style: OutlinedButton.styleFrom(
visualDensity: VisualDensity.compact,
side: const BorderSide(color: Color(0xFFBFDBFE)),
),
icon: const Icon(Icons.music_note, size: 16, color: Color(0xFF2563EB)),
label: const Text('🔔 点击试听用药完成提示音', style: TextStyle(fontSize: 12, color: Color(0xFF2563EB))),
),
),
),
const Divider(height: 1),
SwitchListTile(
title: const Text('触觉震动', style: TextStyle(fontSize: 14, fontWeight: FontWeight.w600)),