fix(ui): 药箱健康看板卡片拆分独立状态并增加间距,彻底消除粘连贴合问题
This commit is contained in:
@@ -33,7 +33,8 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
||||
'冷藏',
|
||||
'宝宝',
|
||||
'已开封',
|
||||
'⚠️ 需处理',
|
||||
'临期',
|
||||
'过期',
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -230,6 +231,17 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
||||
return m.targetUser.contains('宝宝');
|
||||
case '已开封':
|
||||
return m.isOpened;
|
||||
case '安全正常':
|
||||
case '安全':
|
||||
return m.healthStatus == MedicineHealthStatus.safe;
|
||||
case '临期预警':
|
||||
case '临期':
|
||||
return m.healthStatus == MedicineHealthStatus.expiringSoon;
|
||||
case '超期/过期':
|
||||
case '过期':
|
||||
case '超期':
|
||||
return m.healthStatus == MedicineHealthStatus.overdueInUse ||
|
||||
m.healthStatus == MedicineHealthStatus.expired;
|
||||
case '⚠️ 需处理':
|
||||
return m.healthStatus == MedicineHealthStatus.expiringSoon ||
|
||||
m.healthStatus == MedicineHealthStatus.overdueInUse ||
|
||||
@@ -283,7 +295,7 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
||||
children: [
|
||||
// 1. 顶部健康看板统计卡片
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
||||
color: Colors.white,
|
||||
child: Row(
|
||||
children: [
|
||||
@@ -298,22 +310,28 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
||||
label: '安全正常',
|
||||
count: safeCount,
|
||||
color: const Color(0xFF10B981),
|
||||
isSelected: false,
|
||||
onTap: () => setState(() => _selectedFilter = '全部'),
|
||||
isSelected: _selectedFilter == '安全正常' || _selectedFilter == '安全',
|
||||
onTap: () => setState(() {
|
||||
_selectedFilter = (_selectedFilter == '安全' || _selectedFilter == '安全正常') ? '全部' : '安全';
|
||||
}),
|
||||
),
|
||||
_buildStatMetric(
|
||||
label: '临期预警',
|
||||
count: soonCount,
|
||||
color: const Color(0xFFF59E0B),
|
||||
isSelected: _selectedFilter == '⚠️ 需处理',
|
||||
onTap: () => setState(() => _selectedFilter = '⚠️ 需处理'),
|
||||
isSelected: _selectedFilter == '临期预警' || _selectedFilter == '临期',
|
||||
onTap: () => setState(() {
|
||||
_selectedFilter = (_selectedFilter == '临期' || _selectedFilter == '临期预警') ? '全部' : '临期';
|
||||
}),
|
||||
),
|
||||
_buildStatMetric(
|
||||
label: '超期/过期',
|
||||
count: dangerCount,
|
||||
color: const Color(0xFFEF4444),
|
||||
isSelected: _selectedFilter == '⚠️ 需处理',
|
||||
onTap: () => setState(() => _selectedFilter = '⚠️ 需处理'),
|
||||
isSelected: _selectedFilter == '超期/过期' || _selectedFilter == '过期',
|
||||
onTap: () => setState(() {
|
||||
_selectedFilter = (_selectedFilter == '过期' || _selectedFilter == '超期/过期') ? '全部' : '过期';
|
||||
}),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -349,7 +367,7 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
||||
children: _filters.map((f) {
|
||||
final selected = _selectedFilter == f;
|
||||
return InkWell(
|
||||
onTap: () => setState(() => _selectedFilter = f),
|
||||
onTap: () => setState(() => _selectedFilter = _selectedFilter == f ? '全部' : f),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
@@ -444,30 +462,45 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? color.withValues(alpha: 0.1) : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
count.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: InkWell(
|
||||
onTap: onTap,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 180),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? color.withValues(alpha: 0.12) : const Color(0xFFF8FAFC),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: isSelected ? color.withValues(alpha: 0.5) : const Color(0xFFE2E8F0),
|
||||
width: isSelected ? 1.5 : 1,
|
||||
),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
count.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
label,
|
||||
style: const TextStyle(fontSize: 11, color: Colors.black54),
|
||||
),
|
||||
],
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.w500,
|
||||
color: isSelected ? color : const Color(0xFF64748B),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -104,5 +104,19 @@ void main() {
|
||||
// 页面无缝切换到家庭药箱模块
|
||||
expect(find.text('家庭智能药箱'), findsOneWidget);
|
||||
expect(find.text('扫码录药'), findsOneWidget);
|
||||
|
||||
// 顶部 4 个健康状态看板独立分明
|
||||
expect(find.text('在库药品'), findsOneWidget);
|
||||
expect(find.text('安全正常'), findsOneWidget);
|
||||
expect(find.text('临期预警'), findsOneWidget);
|
||||
expect(find.text('超期/过期'), findsOneWidget);
|
||||
|
||||
// 点击【临期预警】看板卡片,独立高亮
|
||||
await tester.tap(find.text('临期预警'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// 点击【超期/过期】看板卡片,独立切换
|
||||
await tester.tap(find.text('超期/过期'));
|
||||
await tester.pumpAndSettle();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user