筛选框样式
This commit is contained in:
@@ -58,32 +58,53 @@ class _ReservationListBottomSheetState extends State<ReservationListBottomSheet>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Container _buildChoice() {
|
Widget _buildChoice() {
|
||||||
return Container(
|
return SingleChildScrollView(
|
||||||
padding: const EdgeInsets.fromLTRB(20, 8, 0, 0),
|
scrollDirection: Axis.horizontal,
|
||||||
alignment: AlignmentGeometry.centerLeft,
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||||
child: Container(
|
child: Row( children: _statusOptions.entries.map((entry) {
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
bool isSelected = _selectedStatus == entry.key;
|
||||||
decoration: BoxDecoration(
|
return GestureDetector(
|
||||||
color: Colors.grey[100],
|
// 关键点:增加 HitTestBehavior.opaque 扩大点击有效范围
|
||||||
borderRadius: BorderRadius.circular(8),
|
behavior: HitTestBehavior.opaque,
|
||||||
),
|
onTap: () {
|
||||||
child: DropdownButton<String>(
|
if (_selectedStatus == entry.key) return;
|
||||||
value: _selectedStatus,
|
|
||||||
underline: const SizedBox.shrink(), // 隐藏下划线
|
// 立即执行刷新逻辑
|
||||||
items: _statusOptions.entries.map((entry) {
|
_controller.getReservationList(addStatus: entry.key);
|
||||||
return DropdownMenuItem<String>(value: entry.key, child: Text(entry.value));
|
|
||||||
}).toList(),
|
// 先更新本地状态改变 UI 选中效果
|
||||||
onChanged: (newValue) {
|
setState(() {
|
||||||
if (newValue != null) {
|
_selectedStatus = entry.key;
|
||||||
setState(() {
|
});
|
||||||
_selectedStatus = newValue;
|
|
||||||
});
|
|
||||||
// 当选择新状态时,调用接口刷新数据
|
|
||||||
_controller.getReservationList(addStatus: _selectedStatus);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(right: 12),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 8),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
// 选中色使用深绿色,未选中保持纯白
|
||||||
|
color: isSelected ? const Color(0xFF006633) : Colors.white,
|
||||||
|
borderRadius: BorderRadius.circular(25), // 圆角稍微调大一点更像胶囊
|
||||||
|
boxShadow: [
|
||||||
|
BoxShadow(
|
||||||
|
color: Colors.black.withOpacity(0.04),
|
||||||
|
blurRadius: 6,
|
||||||
|
offset: const Offset(0, 2),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
entry.key == '' ? '全部' : entry.value,
|
||||||
|
style: TextStyle(
|
||||||
|
// 未选中文字颜色微调为图片中的灰蓝色
|
||||||
|
color: isSelected ? Colors.white : const Color(0xFFAAB6C3),
|
||||||
|
fontSize: 14.sp,
|
||||||
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user