108 lines
3.1 KiB
Dart
108 lines
3.1 KiB
Dart
import 'package:camera/camera.dart';
|
||
import 'package:cims_apps/application/component/select_form/select_form_view.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:shared_preferences/shared_preferences.dart';
|
||
|
||
class SubmissionDataViewModel extends ChangeNotifier {
|
||
SubmissionDataViewModel() {
|
||
_getData();
|
||
}
|
||
|
||
static int _currentStep = 1;
|
||
int get getCurrentStep => _currentStep;
|
||
int stepAmount = 9;
|
||
bool _isEmailVerify = false;
|
||
bool get isEmailVerify => _isEmailVerify;
|
||
var formKeyPersonalData = GlobalKey<FormState>();
|
||
TextEditingController ctrlOccupation = TextEditingController();
|
||
TextEditingController ctrlIncome = TextEditingController();
|
||
TextEditingController ctrlMarital = TextEditingController();
|
||
TextEditingController ctrlSourceFund = TextEditingController();
|
||
TextEditingController ctrlBankName = TextEditingController();
|
||
int step = 1;
|
||
|
||
List<ItemSelectForm> listOccupation = [
|
||
ItemSelectForm('key1', 'Student'),
|
||
ItemSelectForm('key2', 'Entrepreneur'),
|
||
ItemSelectForm('key3', 'Civil Servant'),
|
||
];
|
||
List<ItemSelectForm> listIncome = [
|
||
ItemSelectForm('key1', '< 10 million/year'),
|
||
ItemSelectForm('key2', '10 – 50 million/year'),
|
||
ItemSelectForm('key3', '50 – 100 million/year'),
|
||
];
|
||
List<ItemSelectForm> listMarital = [
|
||
ItemSelectForm('key1', 'Single'),
|
||
ItemSelectForm('key2', 'Married'),
|
||
ItemSelectForm('key3', 'Divorced'),
|
||
];
|
||
List<ItemSelectForm> listSourceFund = [
|
||
ItemSelectForm('key1', 'Revenue'),
|
||
ItemSelectForm('key2', 'Business Profit'),
|
||
ItemSelectForm('key3', 'Saving interest'),
|
||
];
|
||
|
||
List<ItemSelectForm> listBank = [
|
||
ItemSelectForm('key1', 'BCA'),
|
||
ItemSelectForm('key2', 'BRI'),
|
||
ItemSelectForm('key3', 'BNI'),
|
||
ItemSelectForm('key4', 'BANK MANDIRI'),
|
||
ItemSelectForm('key5', 'CIMB NIAGA'),
|
||
];
|
||
|
||
List<ItemSelectForm> listImg = [
|
||
ItemSelectForm('', 'ID Card', image: ''),
|
||
ItemSelectForm('', 'Selfie with ID Card', image: ''),
|
||
];
|
||
|
||
Future<List<CameraDescription>> initCamera() async {
|
||
final cameras = await availableCameras();
|
||
final camerasDesc = cameras;
|
||
return camerasDesc;
|
||
}
|
||
|
||
submitEmail() {
|
||
_isEmailVerify = !_isEmailVerify;
|
||
notifyListeners();
|
||
}
|
||
|
||
onWillPopSubmission(BuildContext context) {
|
||
if (getCurrentStep != 1) {
|
||
_currentStep--;
|
||
notifyListeners();
|
||
} else {
|
||
Navigator.of(context).pop(true);
|
||
}
|
||
}
|
||
|
||
nextSubmission(BuildContext context) {
|
||
if (getCurrentStep < stepAmount) {
|
||
_currentStep++;
|
||
} else {
|
||
//ToDo : Go To next step after completing the submission
|
||
}
|
||
|
||
notifyListeners();
|
||
}
|
||
|
||
Future<bool> next(BuildContext context) async {
|
||
if (getCurrentStep < stepAmount) {
|
||
_currentStep++;
|
||
notifyListeners();
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
Future<void> _getData() async {
|
||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||
String? imagePath = prefs.getString('imagePath');
|
||
String? imagePathSelfie = prefs.getString('imagePathSelfie');
|
||
if (imagePath != null && imagePathSelfie != null) {
|
||
listImg[0].image = imagePath;
|
||
listImg[1].image = imagePathSelfie;
|
||
}
|
||
notifyListeners();
|
||
}
|
||
}
|