Merge branch 'undelivered_packages' into 'master'

Undelivered packages

See merge request Cloud_Solution/driver-app!116
barcode_scanner
Elham 5 years ago
commit cc3173d269

@ -8,19 +8,19 @@ class AuthenticatedUser {
bool active; bool active;
String createdOn; String createdOn;
int createdBy; int createdBy;
Null editedOn; dynamic editedOn;
Null editedBy; dynamic editedBy;
String mobileNumber; String mobileNumber;
int realRoleID; int realRoleID;
AuthenticatedUser( AuthenticatedUser(
{this.iD, {this.iD,
this.userID, this.userID,
this.password, this.password,
this.userName, this.userName,
this.roleID, this.roleID,
this.name, this.name,
this.active, this.active,
this.createdOn, this.createdOn,
this.createdBy, this.createdBy,
this.editedOn, this.editedOn,

@ -22,7 +22,8 @@ class OrdersService extends BaseService {
List<PendingOrdersRes> get nextOrdersList => _nextOrdersList; List<PendingOrdersRes> get nextOrdersList => _nextOrdersList;
bool isOrderInserted; bool isOrderInserted;
bool isOrderStatusUpdated; bool isOrderStatusUpdated;
bool isGetPendingOrdersServices = false;
bool isGetDeliveredOrdersServices = false;
DeliverdOrderModel _requestGetDeliveredOrders = DeliverdOrderModel( DeliverdOrderModel _requestGetDeliveredOrders = DeliverdOrderModel(
searchKey: "", searchKey: "",
pageSize: 0, pageSize: 0,
@ -33,7 +34,9 @@ class OrdersService extends BaseService {
Future getPendingOrders() async { Future getPendingOrders() async {
LocationData loc = await Utils.getLocation(); LocationData loc = await Utils.getLocation();
if (user != null) {
isGetPendingOrdersServices = true;
}
if (loc != null) { if (loc != null) {
PendingOrders _requestGetPendingOrders = PendingOrders( PendingOrders _requestGetPendingOrders = PendingOrders(
searchKey: "", searchKey: "",
@ -127,6 +130,9 @@ class OrdersService extends BaseService {
latitude: loc.latitude.toString(), latitude: loc.latitude.toString(),
longitude: loc.longitude.toString(), longitude: loc.longitude.toString(),
); );
if (user != null) {
isGetDeliveredOrdersServices = true;
}
if (loc != null) { if (loc != null) {
hasError = false; hasError = false;
try { try {

@ -20,17 +20,22 @@ class OrdersViewModel extends BaseViewModel {
List<PendingOrdersRes> get nextOrdersList => _ordersService.nextOrdersList; List<PendingOrdersRes> get nextOrdersList => _ordersService.nextOrdersList;
bool isBottomSheetAppear = false; bool isBottomSheetAppear = false;
bool get isGetPendingOrdersServices =>
_ordersService.isGetPendingOrdersServices;
bool get isGetDeliveredOrdersServices =>
_ordersService.isGetDeliveredOrdersServices;
Future getPendingOrders() async { Future getPendingOrders() async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _ordersService.getPendingOrders(); await _ordersService.getPendingOrders();
if (_ordersService.hasError) { if (_ordersService.hasError) {
error = _ordersService.error; error = _ordersService.error;
setState(ViewState.Error); setState(ViewState.Error);
} else }
setState(ViewState.Idle);
} }
Future getDeliverdOrders() async { Future getDeliveredOrders() async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _ordersService.getDeliveredList(); await _ordersService.getDeliveredList();
if (_ordersService.hasError) { if (_ordersService.hasError) {

@ -19,21 +19,21 @@ class LoginPage extends StatelessWidget {
ProjectViewModel projectViewModel; ProjectViewModel projectViewModel;
AuthenticationViewModel authenticationViewModel; AuthenticationViewModel authenticationViewModel;
login() async {
if (loginFormKey.currentState.validate()) {
loginFormKey.currentState.save();
await authenticationViewModel.login(loginRequest);
if (authenticationViewModel.isError) {
Utils.showErrorToast(authenticationViewModel.error);
}
}
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
projectViewModel = Provider.of(context); projectViewModel = Provider.of(context);
authenticationViewModel = 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( return AnimatedSwitcher(
duration: Duration(microseconds: 350), duration: Duration(microseconds: 350),
child: AppScaffold( child: AppScaffold(
@ -44,59 +44,59 @@ class LoginPage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
FractionallySizedBox( FractionallySizedBox(
widthFactor: 0.80, widthFactor: 0.80,
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
SizedBox( SizedBox(
height: 40, height: 40,
), ),
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Container( Container(
child: Icon( child: Icon(
DriverApp.logo, DriverApp.logo,
size: 70, size: 70,
color: Theme.of(context).primaryColor, 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),
),
],
),
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),
), ),
], margin: EdgeInsets.only(
), right: projectViewModel.isArabic
SizedBox( ? 0
height: 30, : 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( // Row(
// mainAxisAlignment: MainAxisAlignment.center, // mainAxisAlignment: MainAxisAlignment.center,
@ -143,47 +143,48 @@ class LoginPage extends StatelessWidget {
// : Colors.transparent), // : Colors.transparent),
// ], // ],
// ), // ),
SizedBox( SizedBox(
height: 10, height: 10,
), ),
Form( Form(
key: loginFormKey, key: loginFormKey,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
Padding( Padding(
padding: padding:
const EdgeInsets.symmetric(horizontal: 20), const EdgeInsets.symmetric(horizontal: 20),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Text( child: Text(
TranslationBase.of(context) TranslationBase.of(context)
.enterCredentialsMsg, .enterCredentialsMsg,
style: TextStyle( style: TextStyle(
fontSize: 13, color: Colors.grey), fontSize: 13, color: Colors.grey),
),
), ),
SizedBox( ),
height: 10, SizedBox(
) height: 10,
], )
), ],
), ),
SizedBox( ),
height: 10, SizedBox(
), height: 10,
Container( ),
child: TextFields( Container(
hintText: TranslationBase.of(context).enterId, child: TextFields(
validator: (value) { hintText: TranslationBase.of(context).enterId,
if (value.isEmpty) { keyboardType: TextInputType.number,
return TranslationBase.of(context) validator: (value) {
.pleaseEnterYourID; if (value.isEmpty) {
} return TranslationBase.of(context)
return null; .pleaseEnterYourID;
}, }
return null;
},
onSaved: (value) { onSaved: (value) {
loginRequest.userID = int.parse(value.trim()); loginRequest.userID = int.parse(value.trim());
}, },
@ -196,7 +197,7 @@ class LoginPage extends StatelessWidget {
child: TextFields( child: TextFields(
borderRadiusValue: 6, borderRadiusValue: 6,
hintText: hintText:
TranslationBase.of(context).enterPassword, TranslationBase.of(context).enterPassword,
validator: (value) { validator: (value) {
if (value.isEmpty) { if (value.isEmpty) {
return TranslationBase.of(context) return TranslationBase.of(context)
@ -228,15 +229,15 @@ class LoginPage extends StatelessWidget {
], ],
), ),
), ),
], ],
),
),
SizedBox(
height: 20,
),
SizedBox(
height: 10,
), ),
),
SizedBox(
height: 20,
),
SizedBox(
height: 10,
),
Container( Container(
margin: EdgeInsets.all(10), margin: EdgeInsets.all(10),

@ -52,9 +52,18 @@ class _DashboardScreenState extends State<DashboardScreen> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
int orderId; int orderId;
return BaseView<OrdersViewModel>( return BaseView<OrdersViewModel>(
onModelReady: (model) => model.getPendingOrders(), onModelReady: (model) async {
if (!model.isGetPendingOrdersServices) {
await model.getPendingOrders();
}
if (!model.isGetDeliveredOrdersServices) {
await model.getDeliveredOrders();
}
},
builder: (BuildContext context, OrdersViewModel model, Widget child) => builder: (BuildContext context, OrdersViewModel model, Widget child) =>
AppScaffold( AppScaffold(
baseViewModel: model,
body: SingleChildScrollView( body: SingleChildScrollView(
child: Container( child: Container(
height: MediaQuery.of(context).orientation == Orientation.landscape height: MediaQuery.of(context).orientation == Orientation.landscape
@ -149,93 +158,105 @@ class _DashboardScreenState extends State<DashboardScreen> {
borderRadius: BorderRadius.circular(15.0), borderRadius: BorderRadius.circular(15.0),
gradient: LINEAR_GRADIENT, gradient: LINEAR_GRADIENT,
), ),
child: Row( child: InkWell(
mainAxisAlignment: onTap: () => Navigator.push(
MainAxisAlignment.spaceBetween, context,
children: <Widget>[ MaterialPageRoute(
Expanded( builder: (context) =>
child: Padding( OrdersListScreen())),
padding: EdgeInsets.all(2.0), child: Row(
child: Column( mainAxisAlignment:
mainAxisAlignment: MainAxisAlignment.spaceBetween,
MainAxisAlignment.spaceEvenly, children: <Widget>[
children: <Widget>[ Expanded(
Text( child: Padding(
TranslationBase.of(context).youHave, padding: EdgeInsets.all(2.0),
style: TextStyle( child: Column(
color: Colors.white, mainAxisAlignment:
fontSize: MediaQuery.of(context) MainAxisAlignment.spaceEvenly,
.orientation == children: <Widget>[
Orientation.landscape Text(
? SizeConfig.textMultiplier * TranslationBase.of(context)
2.2 .youHave,
: SizeConfig.textMultiplier * style: TextStyle(
1.3,
),
),
Text(
'5',
style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: fontSize: MediaQuery.of(context)
SizeConfig.textMultiplier * .orientation ==
3.0), Orientation.landscape
), ? SizeConfig
Text( .textMultiplier *
TranslationBase.of(context) 2.2
.undeliveredPackages, : SizeConfig
style: TextStyle( .textMultiplier *
color: Colors.white, 1.3,
fontSize: MediaQuery.of(context) ),
.orientation == ),
Orientation.landscape Text(
? SizeConfig.textMultiplier * model.orders.length.toString(),
2.2 style: TextStyle(
: SizeConfig.textMultiplier * color: Colors.white,
1.3, fontSize: SizeConfig
.textMultiplier *
3.0),
), ),
) Text(
], TranslationBase.of(context)
.undeliveredPackages,
style: TextStyle(
color: Colors.white,
fontSize: MediaQuery.of(context)
.orientation ==
Orientation.landscape
? SizeConfig
.textMultiplier *
2.2
: SizeConfig
.textMultiplier *
1.3,
),
)
],
),
), ),
), ),
), Padding(
Padding( padding: EdgeInsets.only(right: 9.5),
padding: EdgeInsets.only(right: 9.5), child: Container(
child: Container( width: 100,
width: 100, height: 100,
height: 100, decoration: BoxDecoration(
decoration: BoxDecoration( color: Colors.white10,
color: Colors.white10, shape: BoxShape.circle),
shape: BoxShape.circle), child: Column(
child: Column( mainAxisAlignment:
mainAxisAlignment: MainAxisAlignment.center,
MainAxisAlignment.center, children: <Widget>[
children: <Widget>[ Image.asset(
Image.asset( 'assets/images/closed_box.png',
'assets/images/closed_box.png', height: MediaQuery.of(context)
height: MediaQuery.of(context) .orientation ==
.orientation == Orientation.portrait
Orientation.portrait ? MediaQuery.of(context)
? MediaQuery.of(context) .size
.size .height *
.height * 0.09
0.09 : MediaQuery.of(context)
: MediaQuery.of(context) .size
.size .height *
.height * 0.20,
0.20, width: MediaQuery.of(context)
width: MediaQuery.of(context) .size
.size .width *
.width * 0.20,
0.20, scale: 0.9,
scale: 0.9, fit: BoxFit.contain,
fit: BoxFit.contain, ),
), ],
], ),
), ),
), ),
), ],
], ),
), ),
), ),
) )
@ -291,7 +312,8 @@ class _DashboardScreenState extends State<DashboardScreen> {
), ),
), ),
Text( Text(
'3', model.deliverdOrders.length
.toString(),
style: TextStyle( style: TextStyle(
color: Colors.white, color: Colors.white,
fontSize: SizeConfig fontSize: SizeConfig
@ -511,7 +533,9 @@ class _DashboardScreenState extends State<DashboardScreen> {
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
itemCount: model.orders == null itemCount: model.orders == null
? 0 ? 0
: model.orders.length < 3 ? model.orders.length : 3, : model.orders.length < 3
? model.orders.length
: 3,
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Padding( return Padding(
padding: EdgeInsets.symmetric(horizontal: 0.2), padding: EdgeInsets.symmetric(horizontal: 0.2),

@ -218,34 +218,35 @@ class InformationPage extends StatelessWidget {
item.latitude, item.longitude); item.latitude, item.longitude);
}, },
), ),
DeliveryInfoButton( //TODO: return it back when it needed
btnColor: Colors.white, //Color(0xFF61B260), // DeliveryInfoButton(
btnIcon: Icon( // btnColor: Colors.white, //Color(0xFF61B260),
DriverApp.whatsapp, // btnIcon: Icon(
size: // DriverApp.whatsapp,
MediaQuery.of(context).orientation == // size:
Orientation.portrait // MediaQuery.of(context).orientation ==
? 50 // Orientation.portrait
: 90, // ? 50
color: Color(0xFF5EA34A), // : 90,
), // color: Color(0xFF5EA34A),
btnName: 'Whatsapp', // ),
btnFunction: () {}, // btnName: 'Whatsapp',
), // btnFunction: () {},
DeliveryInfoButton( // ),
btnColor: Colors.white, //Color(0xFFFCB657), // DeliveryInfoButton(
btnIcon: Icon( // btnColor: Colors.white, //Color(0xFFFCB657),
DriverApp.message, // btnIcon: Icon(
size: // DriverApp.message,
MediaQuery.of(context).orientation == // size:
Orientation.portrait // MediaQuery.of(context).orientation ==
? 50 // Orientation.portrait
: 90, // ? 50
color: Color(0xffFFA540), // : 90,
), // color: Color(0xffFFA540),
btnName: TranslationBase.of(context).sms, // ),
btnFunction: () {}, // btnName: TranslationBase.of(context).sms,
), // btnFunction: () {},
// ),
DeliveryInfoButton( DeliveryInfoButton(
btnColor: Colors.white, btnColor: Colors.white,
//Theme.of(context).primaryColor, //Theme.of(context).primaryColor,

@ -17,7 +17,7 @@ class _DeliverdOrdersPageState extends State<DeliverdOrdersPage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BaseView<OrdersViewModel>( return BaseView<OrdersViewModel>(
onModelReady: (model) => model.getDeliverdOrders(), // onModelReady: (model) => model.getDeliveredOrders(),
builder: (BuildContext context, OrdersViewModel model, Widget child) => builder: (BuildContext context, OrdersViewModel model, Widget child) =>
AppScaffold( AppScaffold(
isShowAppBar: true, isShowAppBar: true,

@ -1,21 +1,33 @@
import 'dart:async';
import 'package:driverapp/app-icons/driver_app_icons.dart'; import 'package:driverapp/app-icons/driver_app_icons.dart';
import 'package:driverapp/core/viewModels/orders_view_model.dart';
import 'package:driverapp/core/viewModels/project_view_model.dart'; import 'package:driverapp/core/viewModels/project_view_model.dart';
import 'package:driverapp/root_page.dart'; import 'package:driverapp/root_page.dart';
import 'package:driverapp/widgets/others/app_scaffold_widget.dart'; import 'package:driverapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../locator.dart';
class SplashScreenPage extends StatefulWidget { class SplashScreenPage extends StatefulWidget {
@override @override
_SplashScreenPageState createState() => _SplashScreenPageState(); _SplashScreenPageState createState() => _SplashScreenPageState();
} }
class _SplashScreenPageState extends State<SplashScreenPage> { class _SplashScreenPageState extends State<SplashScreenPage> {
OrdersViewModel _ordersViewModel = locator<OrdersViewModel>();
// AuthenticationService _authenticationService =
// locator<AuthenticationService>();
startTime() async { startTime() async {
var _duration = new Duration(seconds: 5); // if (_authenticationService.isLogin) {
return new Timer(_duration, navigationPage); await _ordersViewModel.getPendingOrders();
await _ordersViewModel.getDeliveredOrders();
// }
navigationPage();
// var _duration = new Duration(seconds: 5);
// return new Timer(_duration, navigationPage);
} }
@override @override
@ -24,6 +36,8 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
startTime(); startTime();
} }
//
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
ProjectViewModel projectViewModel = Provider.of(context); ProjectViewModel projectViewModel = Provider.of(context);
@ -54,7 +68,7 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
children: <Widget>[ children: <Widget>[
SizedBox( SizedBox(
height: MediaQuery.of(context).orientation == height: MediaQuery.of(context).orientation ==
Orientation.portrait Orientation.portrait
? 200 ? 200
: 50, : 50,
), ),
@ -65,7 +79,7 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
child: Icon( child: Icon(
DriverApp.logo, DriverApp.logo,
size: MediaQuery.of(context).orientation == size: MediaQuery.of(context).orientation ==
Orientation.portrait Orientation.portrait
? 120 ? 120
: 70, : 70,
color: Colors.white, color: Colors.white,
@ -85,7 +99,7 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
), ),
SizedBox( SizedBox(
height: MediaQuery.of(context).orientation == height: MediaQuery.of(context).orientation ==
Orientation.portrait Orientation.portrait
? 20 ? 20
: 15, : 15,
), ),
@ -95,7 +109,7 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
"Driver", "Driver",
style: TextStyle( style: TextStyle(
fontSize: MediaQuery.of(context).orientation == fontSize: MediaQuery.of(context).orientation ==
Orientation.portrait Orientation.portrait
? 70 ? 70
: 35, : 35,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
@ -105,7 +119,7 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
"Delivery", "Delivery",
style: TextStyle( style: TextStyle(
fontSize: MediaQuery.of(context).orientation == fontSize: MediaQuery.of(context).orientation ==
Orientation.portrait Orientation.portrait
? 50 ? 50
: 25, : 25,
letterSpacing: 1, letterSpacing: 1,
@ -114,15 +128,19 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
Text( Text(
"APP", "APP",
style: TextStyle( style: TextStyle(
fontSize: MediaQuery.of(context).orientation == fontSize: MediaQuery
Orientation.portrait .of(context)
.orientation ==
Orientation.portrait
? 53 ? 53
: 21, : 21,
letterSpacing: letterSpacing:
MediaQuery.of(context).orientation == MediaQuery
Orientation.portrait .of(context)
? 53 .orientation ==
: 27, Orientation.portrait
? 53
: 27,
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.w400), fontWeight: FontWeight.w400),
), ),
@ -130,7 +148,7 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
), ),
SizedBox( SizedBox(
height: MediaQuery.of(context).orientation == height: MediaQuery.of(context).orientation ==
Orientation.portrait Orientation.portrait
? 100 ? 100
: 50, : 50,
) )
@ -162,7 +180,7 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
), ),
SizedBox( SizedBox(
height: MediaQuery.of(context).orientation == height: MediaQuery.of(context).orientation ==
Orientation.portrait Orientation.portrait
? 10 ? 10
: 5, : 5,
) )

@ -25,7 +25,7 @@ class NetworkBaseView extends StatelessWidget {
return child; return child;
break; break;
case ViewState.Busy: case ViewState.Busy:
return Expanded(child: AppCircularProgressIndicator()); return AppCircularProgressIndicator();
break; break;
case ViewState.Error: case ViewState.Error:
return Center( return Center(

Loading…
Cancel
Save