From 8c6475328394fd909b054a03ffdb891bc3105486 Mon Sep 17 00:00:00 2001 From: shen <> Date: Wed, 28 Oct 2026 00:51:58 -0700 Subject: [PATCH] =?UTF-8?q?fix(ui):=20=E8=8D=AF=E7=AE=B1=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E6=94=B9=E7=94=A8=E8=87=AA=E9=80=82=E5=BA=94?= =?UTF-8?q?Wrap=E5=A4=9A=E8=A1=8C=E6=8E=92=E7=89=88=EF=BC=8C=E5=BD=BB?= =?UTF-8?q?=E5=BA=95=E6=B6=88=E9=99=A4=E6=A8=AA=E5=90=91=E8=B6=85=E5=87=BA?= =?UTF-8?q?=E5=B1=8F=E5=B9=95=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/screens/medicine_cabinet_screen.dart | 73 ++++++++++++------------ 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/lib/screens/medicine_cabinet_screen.dart b/lib/screens/medicine_cabinet_screen.dart index 775d7e3..f02c1ac 100644 --- a/lib/screens/medicine_cabinet_screen.dart +++ b/lib/screens/medicine_cabinet_screen.dart @@ -29,9 +29,9 @@ class _MedicineCabinetScreenState extends State { final List _filters = [ '全部', - '常温药箱', - '冰箱冷藏', - '宝宝专用', + '常温', + '冷藏', + '宝宝', '已开封', '⚠️ 需处理', ]; @@ -218,10 +218,14 @@ class _MedicineCabinetScreenState extends State { // 标签筛选 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 { // 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 { 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(), ), ], ),