|
|
|
|
@ -28,9 +28,9 @@ import '../../lookups/auth_lookup.dart';
|
|
|
|
|
import '../../util/dr_app_shared_pref.dart';
|
|
|
|
|
import '../../widgets/auth/auth_header.dart';
|
|
|
|
|
import '../../widgets/shared/app_scaffold_widget.dart';
|
|
|
|
|
|
|
|
|
|
//TODO Elham remove it
|
|
|
|
|
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
|
|
|
|
|
|
|
|
|
|
//TODO Elham change the name
|
|
|
|
|
class Loginsreen extends StatefulWidget {
|
|
|
|
|
@override
|
|
|
|
|
_LoginsreenState createState() => _LoginsreenState();
|
|
|
|
|
@ -51,12 +51,13 @@ class _LoginsreenState extends State<Loginsreen> {
|
|
|
|
|
FocusNode focusPass = FocusNode();
|
|
|
|
|
FocusNode focusProject = FocusNode();
|
|
|
|
|
// HospitalViewModel hospitalViewModel;
|
|
|
|
|
//TODO Elham to change it ti UserModel
|
|
|
|
|
var userInfo = UserModel();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
|
|
//TODO Elham move it root page and the logic in the view model
|
|
|
|
|
_firebaseMessaging.setAutoInitEnabled(true);
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
_firebaseMessaging.requestNotificationPermissions();
|
|
|
|
|
@ -88,6 +89,7 @@ class _LoginsreenState extends State<Loginsreen> {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO Elham change it to GIF
|
|
|
|
|
void changeLoadingState(isLoading) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = isLoading;
|
|
|
|
|
@ -100,6 +102,7 @@ class _LoginsreenState extends State<Loginsreen> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return BaseView<AuthenticationViewModel>(
|
|
|
|
|
//TODO Elham remove it
|
|
|
|
|
onModelReady: (model) => {},
|
|
|
|
|
builder: (_, model, w) =>
|
|
|
|
|
AppScaffold(
|
|
|
|
|
@ -457,6 +460,7 @@ class _LoginsreenState extends State<Loginsreen> {
|
|
|
|
|
loginFormKey.currentState.save();
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
sharedPref.setInt(PROJECT_ID, userInfo.projectID);
|
|
|
|
|
//TODO Elham move the sharedPref to view model
|
|
|
|
|
await model.login(userInfo);
|
|
|
|
|
if (model.state == ViewState.ErrorLocal) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
@ -466,6 +470,7 @@ class _LoginsreenState extends State<Loginsreen> {
|
|
|
|
|
saveObjToString(LOGGED_IN_USER, model.loginInfo);
|
|
|
|
|
sharedPref.remove(LAST_LOGIN_USER);
|
|
|
|
|
sharedPref.setString(TOKEN, model.loginInfo.logInTokenID);
|
|
|
|
|
//TODO Elham move the sharedPref to view model
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
|
|
|
|
|
Navigator.of(context).pushReplacement(
|
|
|
|
|
@ -478,13 +483,13 @@ class _LoginsreenState extends State<Loginsreen> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//TODO Elham to it view model
|
|
|
|
|
Future<void> setSharedPref(key, value) async {
|
|
|
|
|
sharedPref.setString(key, value).then((success) {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//TODO Elham to it view model
|
|
|
|
|
saveObjToString(String key, value) async {
|
|
|
|
|
sharedPref.setObj(key, value);
|
|
|
|
|
}
|
|
|
|
|
|