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() { void _showProvinceSelector() {
//
if (_hasSavedLocation) {
return;
}
_showCityPicker(); _showCityPicker();
} }
/// ///
void _showCitySelector() { void _showCitySelector() {
//
if (_hasSavedLocation) {
return;
}
_showCityPicker(); _showCityPicker();
} }
@ -387,32 +395,57 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
/// ///
Widget _buildProvinceSelector() { Widget _buildProvinceSelector() {
final bool isDisabled = _hasSavedLocation;
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// //
const Text( Row(
'省份(必选)', children: [
style: TextStyle( Text(
fontSize: 16, '省份(必选)',
fontFamily: 'Inter', style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 16,
height: 1.5, fontFamily: 'Inter',
color: Color(0xFF5D4037), 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), const SizedBox(height: 7),
// //
GestureDetector( GestureDetector(
onTap: _showProvinceSelector, onTap: isDisabled ? null : _showProvinceSelector,
child: Container( child: Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 13), padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 13),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: isDisabled ? const Color(0xFFF5F5F5) : Colors.white,
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
border: Border.all( border: Border.all(
color: const Color(0x4D8B5A2B), color: isDisabled ? const Color(0x338B5A2B) : const Color(0x4D8B5A2B),
width: 1, width: 1,
), ),
), ),
@ -426,13 +459,13 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
fontFamily: 'Inter', fontFamily: 'Inter',
height: 1.5, height: 1.5,
color: _selectedProvinceName != null 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 Color(0xFF5D4037).withValues(alpha: 0.5),
), ),
), ),
const Icon( Icon(
Icons.keyboard_arrow_down, isDisabled ? Icons.lock_outline : Icons.keyboard_arrow_down,
color: Color(0xFF8B5A2B), color: isDisabled ? const Color(0xFF8B5A2B).withValues(alpha: 0.5) : const Color(0xFF8B5A2B),
size: 24, size: 24,
), ),
], ],
@ -445,32 +478,57 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
/// ///
Widget _buildCitySelector() { Widget _buildCitySelector() {
final bool isDisabled = _hasSavedLocation;
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// //
const Text( Row(
'市级(必选)', children: [
style: TextStyle( Text(
fontSize: 16, '市级(必选)',
fontFamily: 'Inter', style: TextStyle(
fontWeight: FontWeight.w500, fontSize: 16,
height: 1.5, fontFamily: 'Inter',
color: Color(0xFF5D4037), 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), const SizedBox(height: 7),
// //
GestureDetector( GestureDetector(
onTap: _showCitySelector, onTap: isDisabled ? null : _showCitySelector,
child: Container( child: Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 13), padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 13),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: isDisabled ? const Color(0xFFF5F5F5) : Colors.white,
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
border: Border.all( border: Border.all(
color: const Color(0x4D8B5A2B), color: isDisabled ? const Color(0x338B5A2B) : const Color(0x4D8B5A2B),
width: 1, width: 1,
), ),
), ),
@ -484,13 +542,13 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
fontFamily: 'Inter', fontFamily: 'Inter',
height: 1.5, height: 1.5,
color: _selectedCityName != null 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 Color(0xFF5D4037).withValues(alpha: 0.5),
), ),
), ),
const Icon( Icon(
Icons.keyboard_arrow_down, isDisabled ? Icons.lock_outline : Icons.keyboard_arrow_down,
color: Color(0xFF8B5A2B), color: isDisabled ? const Color(0xFF8B5A2B).withValues(alpha: 0.5) : const Color(0xFF8B5A2B),
size: 24, size: 24,
), ),
], ],