From f24b15b34ed1453bfba0ad34655ff2179ad26dd6 Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 16 Dec 2025 07:22:46 -0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20=E8=AE=A4=E7=A7=8D=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9C=81=E5=B8=82=E9=80=89=E6=8B=A9=E5=99=A8=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=90=8E=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 首次选择省市后保存到本地存储 - 非首次进入时禁用省市选择器(不可重新选择) - 添加"已锁定"标签和锁定图标显示禁用状态 - UI 显示灰色背景表示禁用 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../pages/planting_location_page.dart | 122 +++++++++++++----- 1 file changed, 90 insertions(+), 32 deletions(-) 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, ), ],