fix(ui): 药箱分类标签改用自适应Wrap多行排版,彻底消除横向超出屏幕问题
This commit is contained in:
@@ -29,9 +29,9 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
||||
|
||||
final List<String> _filters = [
|
||||
'全部',
|
||||
'常温药箱',
|
||||
'冰箱冷藏',
|
||||
'宝宝专用',
|
||||
'常温',
|
||||
'冷藏',
|
||||
'宝宝',
|
||||
'已开封',
|
||||
'⚠️ 需处理',
|
||||
];
|
||||
@@ -218,10 +218,14 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
||||
|
||||
// 标签筛选
|
||||
switch (_selectedFilter) {
|
||||
case '常温':
|
||||
case '常温药箱':
|
||||
return m.storageLocation.contains('常温');
|
||||
case '冷藏':
|
||||
case '冷藏 ❄️':
|
||||
case '冰箱冷藏':
|
||||
return m.storageLocation.contains('冷藏') || m.storageLocation.contains('冰箱');
|
||||
case '宝宝':
|
||||
case '宝宝专用':
|
||||
return m.targetUser.contains('宝宝');
|
||||
case '已开封':
|
||||
@@ -317,9 +321,11 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
||||
|
||||
// 2. 搜索框与过滤器标签
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
color: Colors.white,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextField(
|
||||
decoration: InputDecoration(
|
||||
@@ -337,42 +343,37 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
|
||||
onChanged: (val) => setState(() => _searchQuery = val.trim()),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Row(
|
||||
children: _filters.map((f) {
|
||||
final selected = _selectedFilter == f;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: InkWell(
|
||||
onTap: () => setState(() => _selectedFilter = f),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: _filters.map((f) {
|
||||
final selected = _selectedFilter == f;
|
||||
return InkWell(
|
||||
onTap: () => setState(() => _selectedFilter = f),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: selected ? const Color(0xFF2563EB) : const Color(0xFFF1F5F9),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
child: AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 150),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: selected ? const Color(0xFF2563EB) : const Color(0xFFF1F5F9),
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: selected ? const Color(0xFF2563EB) : const Color(0xFFE2E8F0),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
f,
|
||||
style: TextStyle(
|
||||
color: selected ? Colors.white : const Color(0xFF334155),
|
||||
fontSize: 13,
|
||||
fontWeight: selected ? FontWeight.bold : FontWeight.w500,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
border: Border.all(
|
||||
color: selected ? const Color(0xFF2563EB) : const Color(0xFFE2E8F0),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
child: Text(
|
||||
f,
|
||||
style: TextStyle(
|
||||
color: selected ? Colors.white : const Color(0xFF334155),
|
||||
fontSize: 12,
|
||||
fontWeight: selected ? FontWeight.bold : FontWeight.w500,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user