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:
hailin 2025-12-16 07:22:46 -08:00
parent 257236480f
commit f24b15b34e
1 changed files with 90 additions and 32 deletions

View File

@ -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,
),
],