fix(ui): 修复家庭药箱分类标签字号间距与文字截断溢出问题,改用平滑自适应Pill标签

This commit is contained in:
shen
2026-10-28 00:20:40 -07:00
parent c9f478fe25
commit 5025e67ef1
2 changed files with 41 additions and 16 deletions
+35 -16
View File
@@ -333,25 +333,39 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
),
onChanged: (val) => setState(() => _searchQuery = val.trim()),
),
const SizedBox(height: 8),
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: ChoiceChip(
label: Text(f),
selected: selected,
selectedColor: const Color(0xFF2563EB),
labelStyle: TextStyle(
color: selected ? Colors.white : Colors.black87,
fontSize: 12,
child: InkWell(
onTap: () => setState(() => _selectedFilter = f),
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,
),
),
),
onSelected: (val) {
if (val) setState(() => _selectedFilter = f);
},
),
);
}).toList(),
@@ -718,19 +732,24 @@ class _MedicineCabinetScreenState extends State<MedicineCabinetScreen> {
required Color color,
}) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: color.withValues(alpha: 0.08),
borderRadius: BorderRadius.circular(4),
borderRadius: BorderRadius.circular(6),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, size: 12, color: color),
const SizedBox(width: 3),
Icon(icon, size: 13, color: color),
const SizedBox(width: 4),
Text(
text,
style: TextStyle(color: color, fontSize: 11, fontWeight: FontWeight.w500),
style: TextStyle(
color: color,
fontSize: 11,
fontWeight: FontWeight.w500,
height: 1.2,
),
),
],
),
+6
View File
@@ -263,6 +263,8 @@ class _MedicineEditDialogState extends State<MedicineEditDialog> {
children: MedicineCategory.values.map((cat) {
final selected = _category == cat;
return ChoiceChip(
showCheckmark: false,
labelPadding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
label: Row(
mainAxisSize: MainAxisSize.min,
children: [
@@ -324,6 +326,8 @@ class _MedicineEditDialogState extends State<MedicineEditDialog> {
children: _commonLocations.map((loc) {
final selected = _storageLocation == loc;
return ChoiceChip(
showCheckmark: false,
labelPadding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
label: Text(loc),
selected: selected,
selectedColor: const Color(0xFF059669),
@@ -350,6 +354,8 @@ class _MedicineEditDialogState extends State<MedicineEditDialog> {
children: _commonUsers.map((user) {
final selected = _targetUser == user;
return ChoiceChip(
showCheckmark: false,
labelPadding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
label: Text(user),
selected: selected,
selectedColor: const Color(0xFFD97706),