fix(ui): 药箱健康看板卡片拆分独立状态并增加间距,彻底消除粘连贴合问题
This commit is contained in:
@@ -33,7 +33,8 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
|||||||
'冷藏',
|
'冷藏',
|
||||||
'宝宝',
|
'宝宝',
|
||||||
'已开封',
|
'已开封',
|
||||||
'⚠️ 需处理',
|
'临期',
|
||||||
|
'过期',
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -230,6 +231,17 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
|||||||
return m.targetUser.contains('宝宝');
|
return m.targetUser.contains('宝宝');
|
||||||
case '已开封':
|
case '已开封':
|
||||||
return m.isOpened;
|
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 '⚠️ 需处理':
|
case '⚠️ 需处理':
|
||||||
return m.healthStatus == MedicineHealthStatus.expiringSoon ||
|
return m.healthStatus == MedicineHealthStatus.expiringSoon ||
|
||||||
m.healthStatus == MedicineHealthStatus.overdueInUse ||
|
m.healthStatus == MedicineHealthStatus.overdueInUse ||
|
||||||
@@ -283,7 +295,7 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
|||||||
children: [
|
children: [
|
||||||
// 1. 顶部健康看板统计卡片
|
// 1. 顶部健康看板统计卡片
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 12),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -298,22 +310,28 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
|||||||
label: '安全正常',
|
label: '安全正常',
|
||||||
count: safeCount,
|
count: safeCount,
|
||||||
color: const Color(0xFF10B981),
|
color: const Color(0xFF10B981),
|
||||||
isSelected: false,
|
isSelected: _selectedFilter == '安全正常' || _selectedFilter == '安全',
|
||||||
onTap: () => setState(() => _selectedFilter = '全部'),
|
onTap: () => setState(() {
|
||||||
|
_selectedFilter = (_selectedFilter == '安全' || _selectedFilter == '安全正常') ? '全部' : '安全';
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
_buildStatMetric(
|
_buildStatMetric(
|
||||||
label: '临期预警',
|
label: '临期预警',
|
||||||
count: soonCount,
|
count: soonCount,
|
||||||
color: const Color(0xFFF59E0B),
|
color: const Color(0xFFF59E0B),
|
||||||
isSelected: _selectedFilter == '⚠️ 需处理',
|
isSelected: _selectedFilter == '临期预警' || _selectedFilter == '临期',
|
||||||
onTap: () => setState(() => _selectedFilter = '⚠️ 需处理'),
|
onTap: () => setState(() {
|
||||||
|
_selectedFilter = (_selectedFilter == '临期' || _selectedFilter == '临期预警') ? '全部' : '临期';
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
_buildStatMetric(
|
_buildStatMetric(
|
||||||
label: '超期/过期',
|
label: '超期/过期',
|
||||||
count: dangerCount,
|
count: dangerCount,
|
||||||
color: const Color(0xFFEF4444),
|
color: const Color(0xFFEF4444),
|
||||||
isSelected: _selectedFilter == '⚠️ 需处理',
|
isSelected: _selectedFilter == '超期/过期' || _selectedFilter == '过期',
|
||||||
onTap: () => setState(() => _selectedFilter = '⚠️ 需处理'),
|
onTap: () => setState(() {
|
||||||
|
_selectedFilter = (_selectedFilter == '过期' || _selectedFilter == '超期/过期') ? '全部' : '过期';
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -349,7 +367,7 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
|||||||
children: _filters.map((f) {
|
children: _filters.map((f) {
|
||||||
final selected = _selectedFilter == f;
|
final selected = _selectedFilter == f;
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () => setState(() => _selectedFilter = f),
|
onTap: () => setState(() => _selectedFilter = _selectedFilter == f ? '全部' : f),
|
||||||
borderRadius: BorderRadius.circular(20),
|
borderRadius: BorderRadius.circular(20),
|
||||||
child: AnimatedContainer(
|
child: AnimatedContainer(
|
||||||
duration: const Duration(milliseconds: 150),
|
duration: const Duration(milliseconds: 150),
|
||||||
@@ -444,30 +462,45 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
|||||||
required VoidCallback onTap,
|
required VoidCallback onTap,
|
||||||
}) {
|
}) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: GestureDetector(
|
child: Padding(
|
||||||
onTap: onTap,
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
child: Container(
|
child: InkWell(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
onTap: onTap,
|
||||||
decoration: BoxDecoration(
|
borderRadius: BorderRadius.circular(10),
|
||||||
color: isSelected ? color.withValues(alpha: 0.1) : Colors.transparent,
|
child: AnimatedContainer(
|
||||||
borderRadius: BorderRadius.circular(8),
|
duration: const Duration(milliseconds: 180),
|
||||||
),
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
child: Column(
|
decoration: BoxDecoration(
|
||||||
children: [
|
color: isSelected ? color.withValues(alpha: 0.12) : const Color(0xFFF8FAFC),
|
||||||
Text(
|
borderRadius: BorderRadius.circular(10),
|
||||||
count.toString(),
|
border: Border.all(
|
||||||
style: TextStyle(
|
color: isSelected ? color.withValues(alpha: 0.5) : const Color(0xFFE2E8F0),
|
||||||
fontSize: 20,
|
width: isSelected ? 1.5 : 1,
|
||||||
fontWeight: FontWeight.bold,
|
),
|
||||||
color: color,
|
),
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
count.toString(),
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: color,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
const SizedBox(height: 2),
|
||||||
const SizedBox(height: 2),
|
Text(
|
||||||
Text(
|
label,
|
||||||
label,
|
maxLines: 1,
|
||||||
style: const TextStyle(fontSize: 11, color: Colors.black54),
|
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);
|
||||||
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