|
|
|
|
@ -2,11 +2,9 @@ import 'package:driverapp/app-icons/driver_app_icons.dart';
|
|
|
|
|
import 'package:driverapp/core/model/authentication/login_request.dart';
|
|
|
|
|
import 'package:driverapp/core/viewModels/authentication_view_model.dart';
|
|
|
|
|
import 'package:driverapp/core/viewModels/project_view_model.dart';
|
|
|
|
|
import 'package:driverapp/pages/dashboard/dashboard_screen.dart';
|
|
|
|
|
import 'package:driverapp/uitl/translations_delegate_base.dart';
|
|
|
|
|
import 'package:driverapp/uitl/utils.dart';
|
|
|
|
|
import 'package:driverapp/widgets/buttons/secondary_button.dart';
|
|
|
|
|
import 'package:driverapp/widgets/data_display/circle-container.dart';
|
|
|
|
|
import 'package:driverapp/widgets/input/text_field.dart';
|
|
|
|
|
import 'package:driverapp/widgets/others/app_scaffold_widget.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
@ -25,16 +23,27 @@ class LoginPage extends StatelessWidget {
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
projectViewModel = Provider.of(context);
|
|
|
|
|
authenticationViewModel = Provider.of(context);
|
|
|
|
|
|
|
|
|
|
login() async {
|
|
|
|
|
if (loginFormKey.currentState.validate()) {
|
|
|
|
|
loginFormKey.currentState.save();
|
|
|
|
|
await authenticationViewModel.login(loginRequest);
|
|
|
|
|
if (authenticationViewModel.isError) {
|
|
|
|
|
Utils.showErrorToast(authenticationViewModel.error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return AnimatedSwitcher(
|
|
|
|
|
duration: Duration(microseconds: 350),
|
|
|
|
|
child: AppScaffold(
|
|
|
|
|
isShowAppBar: false,
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
FractionallySizedBox(
|
|
|
|
|
child: AppScaffold(
|
|
|
|
|
isShowAppBar: false,
|
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
FractionallySizedBox(
|
|
|
|
|
widthFactor: 0.80,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
@ -237,7 +246,7 @@ class LoginPage extends StatelessWidget {
|
|
|
|
|
SecondaryButton(
|
|
|
|
|
label: TranslationBase.of(context).login,
|
|
|
|
|
onTap: () {
|
|
|
|
|
login(context);
|
|
|
|
|
login();
|
|
|
|
|
},
|
|
|
|
|
disabled: authenticationViewModel.isLoading,
|
|
|
|
|
loading: authenticationViewModel.isLoading,
|
|
|
|
|
@ -255,17 +264,4 @@ class LoginPage extends StatelessWidget {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
login(BuildContext context) async {
|
|
|
|
|
if (loginFormKey.currentState.validate()) {
|
|
|
|
|
loginFormKey.currentState.save();
|
|
|
|
|
await authenticationViewModel.login(loginRequest);
|
|
|
|
|
if (authenticationViewModel.isError) {
|
|
|
|
|
Utils.showErrorToast(authenticationViewModel.error);
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
|
|
|
|
MaterialPageRoute(builder: (context) => DashboardScreen()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|