You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
840 B
Dart
31 lines
840 B
Dart
|
5 years ago
|
import 'package:driverapp/core/enum/viewstate.dart';
|
||
|
|
import 'package:driverapp/core/service/authentication_service.dart';
|
||
|
|
import 'package:driverapp/core/viewModels/base_view_model.dart';
|
||
|
|
|
||
|
|
import '../../locator.dart';
|
||
|
|
|
||
|
|
enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED }
|
||
|
|
|
||
|
|
class AuthenticationViewModel extends BaseViewModel {
|
||
|
|
AuthenticationService _authenticationService = locator<AuthenticationService>();
|
||
|
|
|
||
|
|
APP_STATUS get status {
|
||
|
|
if (state == ViewState.Busy || state == ViewState.BusyLocal) {
|
||
|
|
return APP_STATUS.LOADING;
|
||
|
|
} else {
|
||
|
|
if (user != null) {
|
||
|
|
return APP_STATUS.AUTHENTICATED;
|
||
|
|
} else {
|
||
|
|
return APP_STATUS.UNAUTHENTICATED;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
login({String userName,String password}){
|
||
|
|
setState(ViewState.BusyLocal);
|
||
|
|
// call api
|
||
|
|
// if()
|
||
|
|
// setState(viewState)
|
||
|
|
}
|
||
|
|
}
|