Yimaru-Mobile/StudioProjects/yimaru_app/lib/ui/views/onboarding/onboarding_viewmodel.dart

176 lines
4.0 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'package:stacked/stacked.dart';
import 'package:stacked_services/stacked_services.dart';
import '../../../app/app.locator.dart';
import 'onboarding_view.form.dart';
class OnboardingViewModel extends FormViewModel {
final _navigationService = locator<NavigationService>();
int _currentStep = 0;
int get currentStep => _currentStep;
// Full name
bool _focusFullName = false;
bool get focusFullName => _focusFullName;
// Educational background
final List<String> _educationalBackgrounds = [
'No formal education',
'Primary school',
'Secondary /High school',
'College / Diploma',
'Bachelors and above'
];
List<String> get educationalBackgrounds => _educationalBackgrounds;
String? _selectedEducationalBackground;
String? get selectedEducationalBackground => _selectedEducationalBackground;
// Age group
final List<String> _ageGroups = [
'8-14',
'15-18',
'19-26',
'26+',
];
List<String> get ageGroups => _ageGroups;
String? _selectedAgeGroup;
String? get selectedAgeGroup => _selectedAgeGroup;
// Occupation
bool _focusOccupation = false;
bool get focusOccupation => _focusOccupation;
// Learning goal
String? _selectedLearningGoal;
String? get selectedLearningGoal => _selectedLearningGoal;
final List<Map<String, dynamic>> _learningGoals = [
{
'icon': 0,
'title': 'Learn to Speak English',
'subtitle': 'I know some English, but i want to learn to speak it',
},
{
'icon': 1,
'title': 'Practice Speaking English',
'subtitle': 'I already speak English, but I want more practice.',
},
{
'icon': 2,
'title': 'Skill-based Courses',
'subtitle': 'I want courses for IELTS, TOEFL, Duolingo, or work.',
},
];
List<Map<String, dynamic>> get learningGoals => _learningGoals;
// Learning reason
bool _showTextBox = false;
bool get showTextBox => _showTextBox;
bool _focusLearningReason = false;
bool get focusLearningReason => _focusLearningReason;
String? _selectedLearningReason;
String? get selectedLearningReason => _selectedLearningReason;
final List<String> _learningReasons = [
'Speak confidently at work or school',
'Travel or handle daily situations',
'Connect with family or friends',
'General skills expansion',
'Other'
];
List<String> get learningReasons => _learningReasons;
// Full name
void setFullNameFocus() {
_focusFullName = true;
rebuildUi();
}
// Education background
void setSelectedEducationalBackground(String title) {
_selectedEducationalBackground = title;
rebuildUi();
}
bool isSelectedEducationalBackground(String title) =>
_selectedEducationalBackground == title;
// Age group
void setSelectedAgeGroup(String title) {
_selectedAgeGroup = title;
rebuildUi();
}
bool isSelectedAgeGroup(String title) => _selectedAgeGroup == title;
// Occupation
void setOccupationFocus() {
_focusOccupation = true;
rebuildUi();
}
// Country
Future<List<String>> getCountries() async => ['Ethiopia', 'Djibouti'];
// Region
Future<List<String>> getRegions(String country) async =>
['Addis Ababa', 'Oromia'];
// Learning goal
void setSelectedLearningGoal(String title) {
_selectedLearningGoal = title;
rebuildUi();
}
bool isSelectedLearningGoal(String title) => _selectedLearningGoal == title;
// Learning reason
void setLearningReasonFocus() {
_focusLearningReason = true;
rebuildUi();
}
void setSelectedLearningReason(String title) {
_selectedLearningReason = title;
if (title.toLowerCase() == 'other') {
_showTextBox = true;
} else {
if (_showTextBox) {
_showTextBox = false;
_focusLearningReason = false;
}
}
rebuildUi();
}
bool isSelectedLearningReason(String title) =>
_selectedLearningReason == title;
void next() {
_currentStep++;
rebuildUi();
}
void pop() {
_currentStep--;
rebuildUi();
}
}