fix(pre-planting): 预种开关关闭时隐藏"我的"页面预种按钮

- profile_page: 加载预种配置,根据 isActive 控制预种按钮显隐
- 开关关闭时不显示「预种购买」「预种明细」按钮
- 默认不显示(_isPrePlantingActive = false),加载成功后更新

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-02-26 23:11:53 -08:00
parent e328c75fc1
commit ef68b7b9c0
1 changed files with 24 additions and 2 deletions

View File

@ -191,6 +191,9 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
Timer? _walletDebounceTimer;
static const int _debounceDelayMs = 300; // 300ms
//
bool _isPrePlantingActive = false;
// "我的团队"
int _teamPlantingTapCount = 0;
DateTime? _lastTeamPlantingTapTime;
@ -212,6 +215,8 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
});
//
_startAutoRefreshTimer();
//
_loadPrePlantingConfig();
}
///
@ -1234,6 +1239,20 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
context.push(RoutePaths.plantingQuantity);
}
///
Future<void> _loadPrePlantingConfig() async {
try {
final prePlantingService = ref.read(prePlantingServiceProvider);
final config = await prePlantingService.getConfig();
if (mounted) {
setState(() => _isPrePlantingActive = config.isActive);
}
} catch (e) {
debugPrint('[ProfilePage] 加载预种配置失败: $e');
// false
}
}
/// [2026-02-17]
void _goToPrePlantingPurchase() {
context.push(RoutePaths.prePlantingPurchase);
@ -1440,8 +1459,11 @@ class _ProfilePageState extends ConsumerState<ProfilePage> {
_buildPlantingButton(),
const SizedBox(height: 8),
// [2026-02-17] +
_buildPrePlantingButtons(),
const SizedBox(height: 8),
//
if (_isPrePlantingActive) ...[
_buildPrePlantingButtons(),
const SizedBox(height: 8),
],
// [2026-02-19] +
_buildTransferButtons(),
const SizedBox(height: 16),