import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:anyway/domain/repositories/onboarding_repository.dart';
import 'package:anyway/presentation/providers/core_providers.dart';

final onboardingStateProvider = FutureProvider<bool>((ref) async {
  final repo = ref.watch(onboardingRepositoryProvider);
  return repo.isOnboarded();
});


final onboardingControllerProvider = Provider<OnboardingController>((ref) {
  return OnboardingController(ref);
});

class OnboardingController {
  final Ref ref;
  OnboardingController(this.ref);

  Future<void> setOnboarded(bool value) async {
    final repo = ref.read(onboardingRepositoryProvider);
    await repo.setOnboarded(value);
    // refresh the read provider so UI updates
    ref.invalidate(onboardingStateProvider);
  }
}

