fix(ui): 优化药物配置界面喷数和吸气时间选项布局,杜绝屏幕溢出

This commit is contained in:
shen
2026-10-27 04:05:10 -07:00
parent 9d4458c489
commit cd84d308cb
+97 -38
View File
@@ -118,13 +118,20 @@ class _PlanConfigScreenState extends State<PlanConfigScreen> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
const Row( const Expanded(
child: Row(
children: [ children: [
Icon(Icons.hourglass_top, color: Color(0xFFD97706), size: 20), Icon(Icons.hourglass_top, color: Color(0xFFD97706), size: 20),
SizedBox(width: 8), SizedBox(width: 8),
Text('两药之间的等待时间', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: Color(0xFF92400E))), Flexible(
child: Text(
'两药之间的等待时间',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: Color(0xFF92400E)),
),
),
], ],
), ),
),
Container( Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration( decoration: BoxDecoration(
@@ -285,11 +292,11 @@ class _PlanConfigScreenState extends State<PlanConfigScreen> {
if (canister.isEnabled) ...[ if (canister.isEnabled) ...[
const Divider(height: 1), const Divider(height: 1),
Padding( Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// 配置 1:每次几喷 // 配置 1:每次用药喷数
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@@ -297,80 +304,132 @@ class _PlanConfigScreenState extends State<PlanConfigScreen> {
'每次用药喷数', '每次用药喷数',
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 13, color: Color(0xFF334155)), style: TextStyle(fontWeight: FontWeight.w600, fontSize: 13, color: Color(0xFF334155)),
), ),
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: const Color(0xFFEFF6FF),
borderRadius: BorderRadius.circular(6),
),
child: Text(
'${canister.puffsPerSession} 喷',
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 12, color: Color(0xFF2563EB)),
),
),
],
),
const SizedBox(height: 10),
Row( Row(
children: [1, 2, 3, 4].map((puff) { children: [1, 2, 3, 4].map((puff) {
final selected = canister.puffsPerSession == puff; final selected = canister.puffsPerSession == puff;
return Padding( return Expanded(
padding: const EdgeInsets.only(left: 6), child: Padding(
child: ChoiceChip( padding: const EdgeInsets.symmetric(horizontal: 3),
label: Text('$puff 喷'), child: InkWell(
selected: selected, onTap: () {
selectedColor: const Color(0xFF2563EB),
labelStyle: TextStyle(
color: selected ? Colors.white : const Color(0xFF475569),
fontWeight: FontWeight.bold,
fontSize: 12,
),
showCheckmark: false,
onSelected: (_) {
setState(() { setState(() {
canister.puffsPerSession = puff; canister.puffsPerSession = puff;
}); });
}, },
borderRadius: BorderRadius.circular(10),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 9),
decoration: BoxDecoration(
color: selected ? const Color(0xFF2563EB) : const Color(0xFFF8FAFC),
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: selected ? const Color(0xFF2563EB) : const Color(0xFFE2E8F0),
width: selected ? 1.5 : 1,
),
),
alignment: Alignment.center,
child: Text(
'$puff 喷',
style: TextStyle(
color: selected ? Colors.white : const Color(0xFF475569),
fontWeight: FontWeight.bold,
fontSize: 13,
),
),
),
),
), ),
); );
}).toList(), }).toList(),
), ),
],
),
const SizedBox(height: 14), const SizedBox(height: 16),
// 配置 2:每次雾化/吸气时长 // 配置 2:每次雾化/吸气时长
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Column( Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
const Text( const Text(
'单喷雾化吸入时间', '单喷雾化吸入时间',
style: TextStyle(fontWeight: FontWeight.w600, fontSize: 13, color: Color(0xFF334155)), style: TextStyle(fontWeight: FontWeight.w600, fontSize: 13, color: Color(0xFF334155)),
), ),
const SizedBox(width: 6),
Text( Text(
'面罩口鼻密闭吸气倒计时', '(面罩密闭吸气)',
style: TextStyle(fontSize: 11, color: Colors.grey.shade500), style: TextStyle(fontSize: 11, color: Colors.grey.shade500),
), ),
], ],
), ),
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: const Color(0xFFF1F5F9),
borderRadius: BorderRadius.circular(6),
),
child: Text(
'${canister.inhalationSeconds} 秒',
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 12, color: Color(0xFF0F172A)),
),
),
],
),
const SizedBox(height: 10),
Row( Row(
children: [10, 15, 30, 60].map((sec) { children: [10, 15, 30, 60].map((sec) {
final selected = canister.inhalationSeconds == sec; final selected = canister.inhalationSeconds == sec;
return Padding( return Expanded(
padding: const EdgeInsets.only(left: 6), child: Padding(
child: ChoiceChip( padding: const EdgeInsets.symmetric(horizontal: 3),
label: Text('$sec秒'), child: InkWell(
selected: selected, onTap: () {
selectedColor: const Color(0xFF0F172A),
labelStyle: TextStyle(
color: selected ? Colors.white : const Color(0xFF475569),
fontWeight: FontWeight.bold,
fontSize: 12,
),
showCheckmark: false,
onSelected: (_) {
setState(() { setState(() {
canister.inhalationSeconds = sec; canister.inhalationSeconds = sec;
}); });
}, },
borderRadius: BorderRadius.circular(10),
child: Container(
padding: const EdgeInsets.symmetric(vertical: 9),
decoration: BoxDecoration(
color: selected ? const Color(0xFF0F172A) : const Color(0xFFF8FAFC),
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: selected ? const Color(0xFF0F172A) : const Color(0xFFE2E8F0),
width: selected ? 1.5 : 1,
),
),
alignment: Alignment.center,
child: Text(
'$sec 秒',
style: TextStyle(
color: selected ? Colors.white : const Color(0xFF475569),
fontWeight: FontWeight.bold,
fontSize: 13,
),
),
),
),
), ),
); );
}).toList(), }).toList(),
), ),
], ],
), ),
],
),
), ),
], ],
], ],