fix(mobile): auto-show confirm dialog when planting location is saved

When user has previously saved province/city selection:
- Automatically show confirm dialog on page load
- Skip the 5-second countdown timer
- Hide countdown text in dialog when skipCountdown is true
- User can directly confirm and proceed with planting

🤖 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-11 04:08:57 -08:00
parent ca5e903724
commit 3644c04521
2 changed files with 25 additions and 1 deletions

View File

@ -65,7 +65,10 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
@override
void initState() {
super.initState();
_loadSavedLocation();
// 使 WidgetsBinding build
WidgetsBinding.instance.addPostFrameCallback((_) {
_loadSavedLocation();
});
}
///
@ -87,12 +90,28 @@ class _PlantingLocationPageState extends ConsumerState<PlantingLocationPage> {
_hasSavedLocation = true;
});
debugPrint('[PlantingLocationPage] 已加载保存的省市: $provinceName · $cityName');
//
_showConfirmDialogDirectly();
}
} catch (e) {
debugPrint('[PlantingLocationPage] 加载省市失败: $e');
}
}
///
Future<void> _showConfirmDialogDirectly() async {
if (!mounted) return;
await PlantingConfirmDialog.show(
context: context,
province: _selectedProvinceName!,
city: _selectedCityName!,
skipCountdown: true, //
onConfirm: _submitPlanting,
);
}
///
Future<void> _saveLocation() async {
if (_selectedProvinceName == null || _selectedProvinceCode == null ||

View File

@ -264,6 +264,11 @@ class _PlantingConfirmDialogState extends State<PlantingConfirmDialog> {
///
Widget _buildCountdownText() {
//
if (widget.skipCountdown) {
return const SizedBox(height: 16);
}
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Text(