import 'package:stacked/stacked.dart'; import 'package:yimaru_app/models/field_option.dart'; import '../app/app.locator.dart'; import 'api_service.dart'; class OnboardingService with ListenableServiceMixin { // Dependency injection final _apiService = locator(); // Initialization learnService() { listenToReactiveValues([ _topics, _regions, _ageGroups, _countries, _challenges, _occupations, _learningGoals, _languageGoals, _educationalBackgrounds ]); } // Topics List _topics = []; List get topics => _topics; // Regions List _regions = []; List get regions => _regions; // Age groups List _ageGroups = []; List get ageGroups => _ageGroups; // Countries List _countries = []; List get countries => _countries; // Challenges List _challenges = []; List get challenges => _challenges; // Occupations List _occupations = []; List get occupations => _occupations; // Learning goals List _learningGoals = []; List get learningGoals => _learningGoals; // Language goals List _languageGoals = []; List get languageGoals => _languageGoals; // Educational backgrounds List _educationalBackgrounds = []; List get educationalBackgrounds => _educationalBackgrounds; // Onboarding fields Future getOnboardingFields() async { _topics = await _apiService.getTopics(); _ageGroups = await _apiService.getAgeGroups(); _countries = await _apiService.getCountries(); _occupations = await _apiService.getOccupations(); _regions = await _apiService.getEthiopiaRegions(); _learningGoals = await _apiService.getLearningGoals(); _languageGoals = await _apiService.getLanguageGoals(); _challenges = await _apiService.getLanguageChallenges(); _educationalBackgrounds = await _apiService.getEducationalLevels(); notifyListeners(); if (_topics.isNotEmpty && _ageGroups.isNotEmpty && _countries.isNotEmpty && _occupations.isNotEmpty && _regions.isNotEmpty && _learningGoals.isNotEmpty && _challenges.isNotEmpty && _educationalBackgrounds.isNotEmpty) { return true; } return false; } }