fix(ui): 认种页面省市选择器选择后禁用
- 首次选择省市后保存到本地存储 - 非首次进入时禁用省市选择器(不可重新选择) - 添加"已锁定"标签和锁定图标显示禁用状态 - UI 显示灰色背景表示禁用 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
257236480f
commit
f24b15b34e
|
|
@ -165,11 +165,19 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
|
|||
|
||||
/// 显示省份选择器
|
||||
void _showProvinceSelector() {
|
||||
// 如果已经保存过省市,则禁止重新选择
|
||||
if (_hasSavedLocation) {
|
||||
return;
|
||||
}
|
||||
_showCityPicker();
|
||||
}
|
||||
|
||||
/// 显示城市选择器
|
||||
void _showCitySelector() {
|
||||
// 如果已经保存过省市,则禁止重新选择
|
||||
if (_hasSavedLocation) {
|
||||
return;
|
||||
}
|
||||
_showCityPicker();
|
||||
}
|
||||
|
||||
|
|
@ -387,32 +395,57 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
|
|||
|
||||
/// 构建省份选择器
|
||||
Widget _buildProvinceSelector() {
|
||||
final bool isDisabled = _hasSavedLocation;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 标签
|
||||
const Text(
|
||||
'省份(必选)',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: 'Inter',
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.5,
|
||||
color: Color(0xFF5D4037),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'省份(必选)',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: 'Inter',
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.5,
|
||||
color: isDisabled ? const Color(0xFF5D4037).withValues(alpha: 0.6) : const Color(0xFF5D4037),
|
||||
),
|
||||
),
|
||||
if (isDisabled) ...[
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFD4AF37).withValues(alpha: 0.2),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Text(
|
||||
'已锁定',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'Inter',
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFFD4AF37),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 7),
|
||||
// 选择框
|
||||
GestureDetector(
|
||||
onTap: _showProvinceSelector,
|
||||
onTap: isDisabled ? null : _showProvinceSelector,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 13),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDisabled ? const Color(0xFFF5F5F5) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: const Color(0x4D8B5A2B),
|
||||
color: isDisabled ? const Color(0x338B5A2B) : const Color(0x4D8B5A2B),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
|
|
@ -426,13 +459,13 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
|
|||
fontFamily: 'Inter',
|
||||
height: 1.5,
|
||||
color: _selectedProvinceName != null
|
||||
? const Color(0xFF5D4037)
|
||||
? (isDisabled ? const Color(0xFF5D4037).withValues(alpha: 0.6) : const Color(0xFF5D4037))
|
||||
: const Color(0xFF5D4037).withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
color: Color(0xFF8B5A2B),
|
||||
Icon(
|
||||
isDisabled ? Icons.lock_outline : Icons.keyboard_arrow_down,
|
||||
color: isDisabled ? const Color(0xFF8B5A2B).withValues(alpha: 0.5) : const Color(0xFF8B5A2B),
|
||||
size: 24,
|
||||
),
|
||||
],
|
||||
|
|
@ -445,32 +478,57 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
|
|||
|
||||
/// 构建城市选择器
|
||||
Widget _buildCitySelector() {
|
||||
final bool isDisabled = _hasSavedLocation;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 标签
|
||||
const Text(
|
||||
'市级(必选)',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: 'Inter',
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.5,
|
||||
color: Color(0xFF5D4037),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'市级(必选)',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: 'Inter',
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.5,
|
||||
color: isDisabled ? const Color(0xFF5D4037).withValues(alpha: 0.6) : const Color(0xFF5D4037),
|
||||
),
|
||||
),
|
||||
if (isDisabled) ...[
|
||||
const SizedBox(width: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFD4AF37).withValues(alpha: 0.2),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Text(
|
||||
'已锁定',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontFamily: 'Inter',
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Color(0xFFD4AF37),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 7),
|
||||
// 选择框
|
||||
GestureDetector(
|
||||
onTap: _showCitySelector,
|
||||
onTap: isDisabled ? null : _showCitySelector,
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 13),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
color: isDisabled ? const Color(0xFFF5F5F5) : Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(
|
||||
color: const Color(0x4D8B5A2B),
|
||||
color: isDisabled ? const Color(0x338B5A2B) : const Color(0x4D8B5A2B),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
|
|
@ -484,13 +542,13 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
|
|||
fontFamily: 'Inter',
|
||||
height: 1.5,
|
||||
color: _selectedCityName != null
|
||||
? const Color(0xFF5D4037)
|
||||
? (isDisabled ? const Color(0xFF5D4037).withValues(alpha: 0.6) : const Color(0xFF5D4037))
|
||||
: const Color(0xFF5D4037).withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
const Icon(
|
||||
Icons.keyboard_arrow_down,
|
||||
color: Color(0xFF8B5A2B),
|
||||
Icon(
|
||||
isDisabled ? Icons.lock_outline : Icons.keyboard_arrow_down,
|
||||
color: isDisabled ? const Color(0xFF8B5A2B).withValues(alpha: 0.5) : const Color(0xFF8B5A2B),
|
||||
size: 24,
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue