fix(ui): 首页开始雾化按钮宽度设为100%全宽并居中对齐文本

This commit is contained in:
shen
2026-10-27 17:54:32 -07:00
parent 83e18e5448
commit 16fb3d6606
+36 -32
View File
@@ -563,39 +563,43 @@ class _HomeScreenState extends State<HomeScreen> {
const SizedBox(height: 20),
// 主行动按钮:开始雾化 / 继续后台雾化
ElevatedButton(
onPressed: _startSession,
style: ElevatedButton.styleFrom(
backgroundColor: _sessionService.isActive ? const Color(0xFF10B981) : const Color(0xFF2563EB),
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
elevation: 2,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Icon(_sessionService.isActive ? Icons.play_arrow_rounded : Icons.play_circle_fill, size: 22),
const SizedBox(width: 8),
Flexible(
child: Text(
_sessionService.isActive
? (_sessionService.isWaitingForNextMed
? '两药间隔已结束:开始第二组'
: (_sessionService.isFinished
? '雾化已完成:确认打卡'
: '继续雾化 (${_formatTime(_sessionService.remainingSeconds)})'))
: (_activeCanisters.length > 1
? '开始联合雾化 (万托林先行)'
: '开始吸入 ${_activeCanisters.first.name.split(" ")[0]}'),
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
maxLines: 1,
overflow: TextOverflow.ellipsis,
// 主行动按钮:开始雾化 / 继续后台雾化 (加大宽度,文本居中显示)
SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: _startSession,
style: ElevatedButton.styleFrom(
backgroundColor: _sessionService.isActive ? const Color(0xFF10B981) : const Color(0xFF2563EB),
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(vertical: 16),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
elevation: 2,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Icon(_sessionService.isActive ? Icons.play_arrow_rounded : Icons.play_circle_fill, size: 22),
const SizedBox(width: 8),
Flexible(
child: Text(
_sessionService.isActive
? (_sessionService.isWaitingForNextMed
? '两药间隔已结束:开始第二组'
: (_sessionService.isFinished
? '雾化已完成:确认打卡'
: '继续雾化 (${_formatTime(_sessionService.remainingSeconds)})'))
: (_activeCanisters.length > 1
? '开始联合雾化 (万托林先行)'
: '开始吸入 ${_activeCanisters.first.name.split(" ")[0]}'),
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
],
],
),
),
),