diff --git a/frontend/mobile-app/lib/features/planting/presentation/pages/planting_location_page.dart b/frontend/mobile-app/lib/features/planting/presentation/pages/planting_location_page.dart index c9f6e985..7718f42e 100644 --- a/frontend/mobile-app/lib/features/planting/presentation/pages/planting_location_page.dart +++ b/frontend/mobile-app/lib/features/planting/presentation/pages/planting_location_page.dart @@ -165,11 +165,19 @@ class _PlantingLocationPageState extends ConsumerState { /// 显示省份选择器 void _showProvinceSelector() { + // 如果已经保存过省市,则禁止重新选择 + if (_hasSavedLocation) { + return; + } _showCityPicker(); } /// 显示城市选择器 void _showCitySelector() { + // 如果已经保存过省市,则禁止重新选择 + if (_hasSavedLocation) { + return; + } _showCityPicker(); } @@ -387,32 +395,57 @@ class _PlantingLocationPageState extends ConsumerState { /// 构建省份选择器 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 { 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 { /// 构建城市选择器 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 { 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, ), ],