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:
parent
ca5e903724
commit
3644c04521
|
|
@ -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 ||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue