Finish login Functionality

merge-requests/11/merge
Elham Rababah 5 years ago
parent 7e50545dd1
commit 57e60178a3

@ -225,12 +225,47 @@
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/Flutter.framework",
"${BUILT_PRODUCTS_DIR}/MTBBarcodeScanner/MTBBarcodeScanner.framework",
"${BUILT_PRODUCTS_DIR}/Reachability/Reachability.framework",
"${BUILT_PRODUCTS_DIR}/SwiftProtobuf/SwiftProtobuf.framework",
"${BUILT_PRODUCTS_DIR}/TOCropViewController/TOCropViewController.framework",
"${BUILT_PRODUCTS_DIR}/barcode_scan/barcode_scan.framework",
"${BUILT_PRODUCTS_DIR}/connectivity/connectivity.framework",
"${BUILT_PRODUCTS_DIR}/device_info/device_info.framework",
"${BUILT_PRODUCTS_DIR}/flutter_flexible_toast/flutter_flexible_toast.framework",
"${BUILT_PRODUCTS_DIR}/flutter_local_notifications/flutter_local_notifications.framework",
"${BUILT_PRODUCTS_DIR}/flutter_plugin_android_lifecycle/flutter_plugin_android_lifecycle.framework",
"${BUILT_PRODUCTS_DIR}/hexcolor/hexcolor.framework",
"${BUILT_PRODUCTS_DIR}/image_cropper/image_cropper.framework",
"${BUILT_PRODUCTS_DIR}/image_picker/image_picker.framework",
"${BUILT_PRODUCTS_DIR}/local_auth/local_auth.framework",
"${BUILT_PRODUCTS_DIR}/maps_launcher/maps_launcher.framework",
"${BUILT_PRODUCTS_DIR}/shared_preferences/shared_preferences.framework",
"${BUILT_PRODUCTS_DIR}/url_launcher/url_launcher.framework",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MTBBarcodeScanner.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Reachability.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftProtobuf.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/TOCropViewController.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/barcode_scan.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/connectivity.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_flexible_toast.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_local_notifications.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_plugin_android_lifecycle.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/hexcolor.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_cropper.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/local_auth.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/maps_launcher.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;

@ -16,7 +16,7 @@ class AuthenticationViewModel extends BaseViewModel {
if (state == ViewState.Busy || state == ViewState.BusyLocal) {
return APP_STATUS.LOADING;
} else {
if (user != null) {
if ( user != null) {
return APP_STATUS.AUTHENTICATED;
} else {
return APP_STATUS.UNAUTHENTICATED;
@ -24,6 +24,10 @@ class AuthenticationViewModel extends BaseViewModel {
}
}
AuthenticationViewModel(){
sharedPref.clear();
}
login(LoginRequest loginRequest) async {
setState(ViewState.BusyLocal);
await _authenticationService.login(loginRequest);

@ -12,6 +12,7 @@ import 'package:driverapp/widgets/data_display/circle-container.dart';
import 'package:driverapp/widgets/input/text_field.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:provider/provider.dart';
@ -27,220 +28,220 @@ class LoginPage extends StatelessWidget {
duration: Duration(microseconds: 350),
child: BaseView<AuthenticationViewModel>(
builder: (_, model, widget) => Scaffold(
//baseViewModel: model,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FractionallySizedBox(
widthFactor: 0.80,
child: Column(
children: <Widget>[
SizedBox(
height: 40,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
child: Icon(
DriverApp.logo,
size: 70,
color: Theme.of(context).primaryColor,
body: SingleChildScrollView(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FractionallySizedBox(
widthFactor: 0.80,
child: Column(
children: <Widget>[
SizedBox(
height: 40,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
child: Icon(
DriverApp.logo,
size: 70,
color: Theme.of(context).primaryColor,
),
margin: EdgeInsets.only(
right: projectViewModel.isArabic
? 0
: MediaQuery.of(context).size.width * 0.15,
left: !projectViewModel.isArabic
? 0
: MediaQuery.of(context).size.width * 0.15),
),
margin: EdgeInsets.only(
right: projectViewModel.isArabic
? 0
: MediaQuery.of(context).size.width * 0.15,
left: !projectViewModel.isArabic
? 0
: MediaQuery.of(context).size.width * 0.15),
),
],
),
SizedBox(
height: 20,
),
Column(
children: <Widget>[
Text(
"Driver",
style: TextStyle(
fontSize: 50, fontWeight: FontWeight.bold),
),
Text(
"Delivery",
style: TextStyle(fontSize: 36, letterSpacing: 1),
),
Text(
"APP",
style: TextStyle(
fontSize: 33,
letterSpacing: 33,
fontWeight: FontWeight.w400),
),
],
),
SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CircleContainer(
onTap: () => projectViewModel.changeLanguage('en'),
child: Text(
TranslationBase.of(context).lanEnglish,
],
),
SizedBox(
height: 20,
),
Column(
children: <Widget>[
Text(
"Driver",
style: TextStyle(
fontSize: 12,
color: projectViewModel.isArabic
? Colors.black
: Colors.white),
fontSize: 50, fontWeight: FontWeight.bold),
),
color: projectViewModel.isArabic
? Colors.transparent
: Theme.of(context).primaryColor,
borderWidth: projectViewModel.isArabic ? 3 : 0,
borderColor: projectViewModel.isArabic
? Theme.of(context).primaryColor
: Colors.transparent,
),
SizedBox(
width: 20,
),
CircleContainer(
onTap: () =>
projectViewModel.changeLanguage('ar'),
Text(
"Delivery",
style: TextStyle(fontSize: 36, letterSpacing: 1),
),
Text(
"APP",
style: TextStyle(
fontSize: 33,
letterSpacing: 33,
fontWeight: FontWeight.w400),
),
],
),
SizedBox(
height: 30,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
CircleContainer(
onTap: () => projectViewModel.changeLanguage('en'),
child: Text(
TranslationBase.of(context).lanArabic,
TranslationBase.of(context).lanEnglish,
style: TextStyle(
fontSize: 12,
color: !projectViewModel.isArabic
color: projectViewModel.isArabic
? Colors.black
: Colors.white),
),
color: !projectViewModel.isArabic
color: projectViewModel.isArabic
? Colors.transparent
: Theme.of(context).primaryColor,
borderWidth: !projectViewModel.isArabic ? 3 : 0,
borderColor: !projectViewModel.isArabic
borderWidth: projectViewModel.isArabic ? 3 : 0,
borderColor: projectViewModel.isArabic
? Theme.of(context).primaryColor
: Colors.transparent),
],
),
SizedBox(
height: 10,
),
Form(
key: loginFormKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 20),
child: Row(
: Colors.transparent,
),
SizedBox(
width: 20,
),
CircleContainer(
onTap: () =>
projectViewModel.changeLanguage('ar'),
child: Text(
TranslationBase.of(context).lanArabic,
style: TextStyle(
fontSize: 12,
color: !projectViewModel.isArabic
? Colors.black
: Colors.white),
),
color: !projectViewModel.isArabic
? Colors.transparent
: Theme.of(context).primaryColor,
borderWidth: !projectViewModel.isArabic ? 3 : 0,
borderColor: !projectViewModel.isArabic
? Theme.of(context).primaryColor
: Colors.transparent),
],
),
SizedBox(
height: 10,
),
Form(
key: loginFormKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Padding(
padding:
const EdgeInsets.symmetric(horizontal: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Expanded(
child: Text(
TranslationBase.of(context).enterCredentialsMsg,
style: TextStyle(
fontSize: 13, color: Colors.grey),
),
),
SizedBox(
height: 10,
)
],
),
),
SizedBox(
height: 10,
),
Container(
child: TextFields(
hintText: TranslationBase.of(context).enterId,
validator: (value) {
if (value.isEmpty) {
return TranslationBase.of(context)
.pleaseEnterYourID;
}
return null;
},
onSaved: (value) {
loginRequest.userID = int.parse(value.trim());
},
),
),
SizedBox(
height: 20,
),
Container(
child: TextFields(
borderRadiusValue: 6,
hintText:
TranslationBase.of(context).enterPassword,
validator: (value) {
if (value.isEmpty) {
return TranslationBase.of(context)
.pleaseEnterPassword;
}
return null;
},
onSaved: (value) {
loginRequest.password = value;
},
),
),
SizedBox(
height: 25,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
TranslationBase.of(context).enterCredentialsMsg,
TranslationBase.of(context).forgotPassword,
style: TextStyle(
fontSize: 13, color: Colors.grey),
fontSize: 14,
color: Theme.of(context).primaryColor),
),
SizedBox(
height: 10,
)
],
),
),
SizedBox(
height: 10,
),
Container(
child: TextFields(
onChanged: (value) => {},
hintText: TranslationBase.of(context).enterId,
validator: (value) {
if (value.isEmpty) {
return TranslationBase.of(context)
.pleaseEnterYourID;
}
return null;
},
onSaved: (value) {
loginRequest.userID = int.parse(value.trim());
},
),
),
SizedBox(
height: 20,
),
Container(
child: TextFields(
borderRadiusValue: 6,
onChanged: (value) => {},
hintText:
TranslationBase.of(context).enterPassword,
validator: (value) {
if (value.isEmpty) {
return TranslationBase.of(context)
.pleaseEnterPassword;
}
return null;
},
onSaved: (value) {
loginRequest.password = value;
},
),
),
SizedBox(
height: 25,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
Text(
TranslationBase.of(context).forgotPassword,
style: TextStyle(
fontSize: 14,
color: Theme.of(context).primaryColor),
),
],
),
],
],
),
),
),
],
],
),
),
),
SizedBox(
height: 20,
),
SizedBox(
height: 10,
)
],
),
),
bottomSheet: Container(
margin: EdgeInsets.all(10),
height: MediaQuery.of(context).size.height * 0.12,
child: Column(
children: <Widget>[
SecondaryButton(
label: TranslationBase.of(context).login,
onTap: () {
login(model, context);
},
disabled: model.state == ViewState.BusyLocal,
loading: model.state == ViewState.BusyLocal,
SizedBox(
height: 20,
),
SizedBox(
height: 30,
)
height: 10,
),Container(
margin: EdgeInsets.all(10),
height: MediaQuery.of(context).size.height * 0.22,
child: Column(
children: <Widget>[
SecondaryButton(
label: TranslationBase.of(context).login,
onTap: () {
login(model, context);
},
disabled: model.state == ViewState.BusyLocal,
loading: model.state == ViewState.BusyLocal,
),
SizedBox(
height: 30,
)
],
))
],
)),
),
),
),
),
),
);
@ -252,7 +253,6 @@ class LoginPage extends StatelessWidget {
await model.login(loginRequest);
if (model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(model.error);
// Show error
} else {
Navigator.push(
context, MaterialPageRoute(builder: (context) => LandingPage()));

Loading…
Cancel
Save