Merge branch 'ZohaibIqbalKambrani' of https://gitlab.com/Cloud_Solution/driver-app into development
Conflicts: pubspec.yamldevelopment
commit
7b20f789f6
@ -0,0 +1 @@
|
|||||||
|
include ':app'
|
||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 919 B |
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
@ -1,5 +1,6 @@
|
|||||||
const TOKEN = 'token';
|
const TOKEN = 'token';
|
||||||
const APP_LANGUAGE = 'language';
|
const APP_LANGUAGE = 'language';
|
||||||
const USER_PROFILE = 'user-profile';
|
const USER_PROFILE = 'user-profile';
|
||||||
|
const ACTIVE_DELIVERIES = 'active-order-deliveries';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,11 @@
|
|||||||
|
class ResponseModel<T>{
|
||||||
|
bool isSuccessful = false;
|
||||||
|
String message;
|
||||||
|
T data;
|
||||||
|
|
||||||
|
isSuccessfull(Function(bool) callback){
|
||||||
|
callback(isSuccessful);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResponseModel({this.message, this.isSuccessful, this.data});
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
class RequestInitiateOrderDelivery{
|
||||||
|
int orderNo = 0;
|
||||||
|
String mobileNumber = "";
|
||||||
|
RequestInitiateOrderDelivery({this.orderNo, this.mobileNumber});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['OrderNo'] = this.orderNo;
|
||||||
|
data['MobileNumber'] = this.mobileNumber;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
class RequestValidateDelivery{
|
||||||
|
String pinCode;
|
||||||
|
int orderNo;
|
||||||
|
RequestValidateDelivery({this.orderNo,this.pinCode});
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['Password'] = this.pinCode;
|
||||||
|
data['OrderNo'] = this.orderNo;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
class ResponseInitiateOrderDelivery{
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
import 'package:driverapp/config/shared_pref_kay.dart';
|
||||||
|
import 'package:driverapp/core/model/authentication/authenticated_user.dart';
|
||||||
|
import 'package:driverapp/uitl/app_shared_preferences.dart';
|
||||||
|
import 'package:location/location.dart';
|
||||||
|
|
||||||
|
class RequestUpdateDriverLocation{
|
||||||
|
int orderID = 0;
|
||||||
|
LocationData location;
|
||||||
|
RequestUpdateDriverLocation({this.orderID,this.location});
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> toJson() async{
|
||||||
|
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||||
|
data['OrderID'] = this.orderID;
|
||||||
|
data['Latitude'] = "${this.location.latitude}";
|
||||||
|
data['Longitude'] = "${this.location.longitude}";
|
||||||
|
|
||||||
|
Map profile = await AppSharedPreferences().getObject(USER_PROFILE);
|
||||||
|
AuthenticatedUser doctorProfile = AuthenticatedUser.fromJson(profile);
|
||||||
|
data['DriverID'] = doctorProfile?.iD;
|
||||||
|
data['UserID'] = '${doctorProfile?.iD}';
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
class ResponseInitiateOrderDelivery{
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,141 @@
|
|||||||
|
import 'dart:collection';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:driverapp/config/config.dart';
|
||||||
|
import 'package:driverapp/config/shared_pref_kay.dart';
|
||||||
|
import 'package:driverapp/core/model/StatusModel.dart';
|
||||||
|
import 'package:driverapp/core/model/order_delivey/request_initiate_order_delivery.dart';
|
||||||
|
import 'package:driverapp/core/model/order_delivey/request_validate_delivery.dart';
|
||||||
|
import 'package:driverapp/core/model/orders/pending_orders_res_model.dart';
|
||||||
|
import 'package:driverapp/core/model/update_driver_location/request_update_driver_location.dart';
|
||||||
|
import 'package:driverapp/core/service/base_service.dart';
|
||||||
|
import 'package:driverapp/uitl/app_shared_preferences.dart';
|
||||||
|
import 'package:driverapp/uitl/utils.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:latlong/latlong.dart';
|
||||||
|
import 'package:location/location.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class DeliveryTrackingServices extends BaseService {
|
||||||
|
var _distanceFilter = 20; // [Meters] (Call update API if distance covered from last location is greater then 'value' )
|
||||||
|
|
||||||
|
|
||||||
|
Future<ResponseModel> initiateOrderDelivery(PendingOrdersRes order) async {
|
||||||
|
hasError = false;
|
||||||
|
|
||||||
|
var testNumber = "";
|
||||||
|
ResponseModel result;
|
||||||
|
// var orderRequest = RequestInitiateOrderDelivery(orderNo: order.ePharmacyOrderNo, mobileNumber: testNumber == "" ? order.mobileNumber : testNumber);
|
||||||
|
var fullUrl = BASE_URL + INITIATE_DELIVERY + "/${order.ePharmacyOrderNo}/${user.iD}";
|
||||||
|
await baseAppClient.simpleGet(fullUrl,
|
||||||
|
onSuccess: (dynamic response, int statusCode) {
|
||||||
|
result = ResponseModel(isSuccessful: true,message: null, data: response);
|
||||||
|
startLocationUpdate(order.ePharmacyOrderNo);
|
||||||
|
|
||||||
|
}, onFailure: (String error, int statusCode) {
|
||||||
|
result = ResponseModel(isSuccessful: false,message: error,data: null);
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<ResponseModel> validateDelivery(PendingOrdersRes order, String pinCode) async{
|
||||||
|
hasError = false;
|
||||||
|
var request = RequestValidateDelivery(orderNo: order.ePharmacyOrderNo, pinCode: pinCode);
|
||||||
|
|
||||||
|
ResponseModel result;
|
||||||
|
await baseAppClient.post(VERIFY_DELIVERY,
|
||||||
|
onSuccess: (dynamic response, int statusCode) {
|
||||||
|
result = ResponseModel(isSuccessful: true,message: null, data: response);
|
||||||
|
}, onFailure: (String error, int statusCode) {
|
||||||
|
result = ResponseModel(isSuccessful: false,message: error,data: null);
|
||||||
|
}, body: request.toJson());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
_updateDriverLocation(int orderID, LocationData location) async {
|
||||||
|
if(location != null){
|
||||||
|
debugPrint("Updating driver location");
|
||||||
|
var jsonBody = await RequestUpdateDriverLocation(orderID: orderID, location: location).toJson();
|
||||||
|
await baseAppClient.post(UPDATE_DRIVER_LOCATION,
|
||||||
|
onSuccess: (dynamic response, int statusCode) {
|
||||||
|
|
||||||
|
}, onFailure: (String errorMessage, int statusCode) {
|
||||||
|
if(statusCode == 200){
|
||||||
|
// Server responded but check failed (stop updating location)
|
||||||
|
// stopLocationUpdate(orderID);
|
||||||
|
// Show error message that you received in response
|
||||||
|
}
|
||||||
|
}, body: jsonBody);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Map _currentRunnings = Map<String,Future>();
|
||||||
|
Future<Object> startLocationUpdate(int orderID, {int frequencyInSeconds = 3}) async {
|
||||||
|
if (_currentRunnings[orderID.toString()] == null){
|
||||||
|
_currentRunnings[orderID.toString()] = Future.doWhile(() async{
|
||||||
|
|
||||||
|
await Future.delayed(Duration(seconds: frequencyInSeconds));
|
||||||
|
var valid = _currentRunnings.containsKey(orderID.toString());
|
||||||
|
if(valid){
|
||||||
|
Utils.possibleToGetLocation((value) async{
|
||||||
|
if(value){
|
||||||
|
var location = await Utils.getLocation();
|
||||||
|
if (_haveEnoughLocationUpdate(location))
|
||||||
|
await _updateDriverLocation(orderID, location);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return valid;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedPreferences.getInstance().then((pref){
|
||||||
|
pref.setStringList(ACTIVE_DELIVERIES, _currentRunnings.keys.toList());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isActiveDeliveringOrder(int ePharmacyOrderNo){
|
||||||
|
return _currentRunnings.containsKey(ePharmacyOrderNo.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> getActiveDeliveringOrders(){
|
||||||
|
return _currentRunnings.keys.toList(growable: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
setActiveDeliveringOrders(List<String> orders){
|
||||||
|
orders.forEach((element) {
|
||||||
|
if(!_currentRunnings.containsKey(element)){
|
||||||
|
_currentRunnings[element] = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
clearActiveDeliveringOrders(){
|
||||||
|
_currentRunnings.clear();
|
||||||
|
SharedPreferences.getInstance().then((pref){
|
||||||
|
pref.setStringList(ACTIVE_DELIVERIES, _currentRunnings.keys.toList());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
stopLocationUpdate(int orderID){
|
||||||
|
_currentRunnings.remove(orderID.toString());
|
||||||
|
SharedPreferences.getInstance().then((pref){
|
||||||
|
pref.setStringList(ACTIVE_DELIVERIES, _currentRunnings.keys.toList());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
LocationData _lastLocation;
|
||||||
|
bool _haveEnoughLocationUpdate(LocationData location){
|
||||||
|
_lastLocation = _lastLocation ?? location;
|
||||||
|
var distanceCovered = Utils.distanceBetween(_lastLocation, location, LengthUnit.Meter);
|
||||||
|
// debugPrint("distance: $distanceCovered");
|
||||||
|
return (distanceCovered > _distanceFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,453 @@
|
|||||||
|
import 'package:driverapp/app-icons/driver_app_icons.dart';
|
||||||
|
import 'package:driverapp/config/config.dart';
|
||||||
|
import 'package:driverapp/config/size_config.dart';
|
||||||
|
import 'package:driverapp/core/model/authentication/login_request.dart';
|
||||||
|
import 'package:driverapp/core/model/orders/pending_orders_res_model.dart';
|
||||||
|
import 'package:driverapp/core/service/delivery_tracking_services.dart';
|
||||||
|
import 'package:driverapp/core/viewModels/authentication_view_model.dart';
|
||||||
|
import 'package:driverapp/core/viewModels/orders_view_model.dart';
|
||||||
|
import 'package:driverapp/core/viewModels/project_view_model.dart';
|
||||||
|
import 'package:driverapp/locator.dart';
|
||||||
|
import 'package:driverapp/pages/authentication/reset_password_page.dart';
|
||||||
|
import 'package:driverapp/pages/delivery/delivery_confirmed_page.dart';
|
||||||
|
import 'package:driverapp/uitl/app_toast.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/others/app_scaffold_widget.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';
|
||||||
|
import 'package:sweetalert/sweetalert.dart';
|
||||||
|
|
||||||
|
import 'forget_password_page.dart';
|
||||||
|
|
||||||
|
// ignore: must_be_immutable
|
||||||
|
class DeliveryVerificationPage extends StatelessWidget {
|
||||||
|
|
||||||
|
final PendingOrdersRes order;
|
||||||
|
DeliveryVerificationPage({this.order});
|
||||||
|
|
||||||
|
ProjectViewModel _projectViewModel;
|
||||||
|
OrdersViewModel _ordersViewModel;
|
||||||
|
final formKey = GlobalKey<FormState>();
|
||||||
|
Map formValues = {
|
||||||
|
'digit1': null,
|
||||||
|
'digit2': null,
|
||||||
|
'digit3': null,
|
||||||
|
'digit4': null,
|
||||||
|
};
|
||||||
|
|
||||||
|
FocusNode focusD1 = FocusNode();
|
||||||
|
FocusNode focusD2 = FocusNode();
|
||||||
|
FocusNode focusD3 = FocusNode();
|
||||||
|
FocusNode focusD4 = FocusNode();
|
||||||
|
var model;
|
||||||
|
TextEditingController digit1 = TextEditingController(text: "");
|
||||||
|
TextEditingController digit2 = TextEditingController(text: "");
|
||||||
|
TextEditingController digit3 = TextEditingController(text: "");
|
||||||
|
TextEditingController digit4 = TextEditingController(text: "");
|
||||||
|
|
||||||
|
bool _isLoading = false;
|
||||||
|
|
||||||
|
SizedBox buildSizedBox([double height = 20]) {
|
||||||
|
return SizedBox(
|
||||||
|
height: height,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
BuildContext _context;
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
_context = context;
|
||||||
|
_projectViewModel = Provider.of(context);
|
||||||
|
_ordersViewModel = Provider.of(context);
|
||||||
|
|
||||||
|
String validateCodeDigit(value) {
|
||||||
|
if (value.isEmpty) {
|
||||||
|
return 'Please enter your Password';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return AnimatedSwitcher(
|
||||||
|
duration: Duration(milliseconds: 2000),
|
||||||
|
child: AppScaffold(
|
||||||
|
isShowAppBar: false,
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
FractionallySizedBox(
|
||||||
|
widthFactor: 0.80,
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
height: 30,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
child: Icon(
|
||||||
|
DriverApp.deliverd_icon,
|
||||||
|
size: 150,
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
),
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
top: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
"Verification",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
letterSpacing: 1,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 30,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Form(
|
||||||
|
key: formKey,
|
||||||
|
child: Container(
|
||||||
|
width: SizeConfig.realScreenWidth * 0.90,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 20),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.end,
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
child: Text(
|
||||||
|
TranslationBase.of(context)
|
||||||
|
.enterCustomerVerificationCodeMsg,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13,
|
||||||
|
color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
buildSizedBox(30),
|
||||||
|
Center(
|
||||||
|
child: FractionallySizedBox(
|
||||||
|
widthFactor: 0.80,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceAround,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
width: 55,
|
||||||
|
height: 55,
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
textInputAction:
|
||||||
|
TextInputAction.next,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: SizeConfig
|
||||||
|
.textMultiplier *
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
focusNode: focusD1,
|
||||||
|
controller: digit1,
|
||||||
|
enableInteractiveSelection: false,
|
||||||
|
showCursor: false,
|
||||||
|
maxLength: 1,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
keyboardType:
|
||||||
|
TextInputType.number,
|
||||||
|
decoration:
|
||||||
|
buildInputDecoration(
|
||||||
|
context),
|
||||||
|
onSaved: (val) {
|
||||||
|
formValues[
|
||||||
|
'digit1'] = val;
|
||||||
|
},
|
||||||
|
validator: validateCodeDigit,
|
||||||
|
onFieldSubmitted: (_) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(focusD2);
|
||||||
|
},
|
||||||
|
onChanged: (val) => val.isNotEmpty
|
||||||
|
? FocusScope.of(context).requestFocus(focusD2)
|
||||||
|
: FocusScope.of(context).requestFocus(focusD1)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: 55,
|
||||||
|
height: 55,
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
focusNode: focusD2,
|
||||||
|
controller: digit2,
|
||||||
|
enableInteractiveSelection: false,
|
||||||
|
showCursor: false,
|
||||||
|
maxLength: 1,
|
||||||
|
textInputAction:
|
||||||
|
TextInputAction.next,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: SizeConfig
|
||||||
|
.textMultiplier *
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
keyboardType:
|
||||||
|
TextInputType.number,
|
||||||
|
decoration:
|
||||||
|
buildInputDecoration(
|
||||||
|
context),
|
||||||
|
validator: validateCodeDigit,
|
||||||
|
onSaved: (val) {
|
||||||
|
formValues[
|
||||||
|
'digit2'] = val;
|
||||||
|
},
|
||||||
|
onFieldSubmitted: (_) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(focusD3);
|
||||||
|
},
|
||||||
|
onChanged: (val) => val.isNotEmpty
|
||||||
|
? FocusScope.of(context).requestFocus(focusD3)
|
||||||
|
: FocusScope.of(context).requestFocus(focusD1)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: 55,
|
||||||
|
height: 55,
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
focusNode: focusD3,
|
||||||
|
controller: digit3,
|
||||||
|
enableInteractiveSelection: false,
|
||||||
|
showCursor: false,
|
||||||
|
maxLength: 1,
|
||||||
|
textInputAction: TextInputAction.next,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: SizeConfig
|
||||||
|
.textMultiplier * 3,
|
||||||
|
),
|
||||||
|
keyboardType:
|
||||||
|
TextInputType.number,
|
||||||
|
decoration:
|
||||||
|
buildInputDecoration(
|
||||||
|
context),
|
||||||
|
validator: validateCodeDigit,
|
||||||
|
onSaved: (val) {
|
||||||
|
formValues[
|
||||||
|
'digit3'] = val;
|
||||||
|
},
|
||||||
|
onFieldSubmitted: (_) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(focusD4);
|
||||||
|
},
|
||||||
|
onChanged: (val) => val.isNotEmpty
|
||||||
|
? FocusScope.of(context).requestFocus(focusD4)
|
||||||
|
: FocusScope.of(context).requestFocus(focusD2),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
Container(
|
||||||
|
width: 55,
|
||||||
|
height: 55,
|
||||||
|
color: Colors.transparent,
|
||||||
|
child: Center(
|
||||||
|
child: TextFormField(
|
||||||
|
focusNode: focusD4,
|
||||||
|
controller: digit4,
|
||||||
|
enableInteractiveSelection: false,
|
||||||
|
showCursor: false,
|
||||||
|
maxLength: 1,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: SizeConfig
|
||||||
|
.textMultiplier *
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
keyboardType:
|
||||||
|
TextInputType.number,
|
||||||
|
decoration:
|
||||||
|
buildInputDecoration(
|
||||||
|
context),
|
||||||
|
validator: validateCodeDigit,
|
||||||
|
onSaved: (val) {
|
||||||
|
formValues[
|
||||||
|
'digit4'] = val;
|
||||||
|
},
|
||||||
|
onFieldSubmitted: (_) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(focusD4);
|
||||||
|
},
|
||||||
|
onChanged: (val) => val.isNotEmpty
|
||||||
|
? FocusScope.of(context).requestFocus(focusD4)
|
||||||
|
: FocusScope.of(context).requestFocus(focusD3)
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
buildSizedBox(20),
|
||||||
|
// ShowTimerText(model: model),
|
||||||
|
])))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.all(10),
|
||||||
|
height: MediaQuery.of(context).size.height * 0.22,
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SecondaryButton(
|
||||||
|
label: "Verify Receiver",
|
||||||
|
onTap: () {
|
||||||
|
_verifyCustomer();
|
||||||
|
},
|
||||||
|
disabled: _isLoading,
|
||||||
|
loading: _isLoading,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
// Row(
|
||||||
|
// mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
// children: <Widget>[
|
||||||
|
// InkWell(
|
||||||
|
// onTap: () {
|
||||||
|
// Navigator.pushReplacement(
|
||||||
|
// context,
|
||||||
|
// MaterialPageRoute(
|
||||||
|
// builder: (context) =>
|
||||||
|
// ForgetPasswordPage()),
|
||||||
|
// );
|
||||||
|
// },
|
||||||
|
// child: InkWell(
|
||||||
|
// onTap: () async {
|
||||||
|
// await _ordersViewModel.resendOtpToReceiver(order);
|
||||||
|
// },
|
||||||
|
// child: Text(
|
||||||
|
// "Resend OPT?",
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 14,
|
||||||
|
// color: Theme.of(context).primaryColor),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
TextStyle buildTextStyle() {
|
||||||
|
return TextStyle(
|
||||||
|
fontSize: SizeConfig.textMultiplier * 3,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
InputDecoration buildInputDecoration(BuildContext context) {
|
||||||
|
return InputDecoration(
|
||||||
|
filled: true,
|
||||||
|
fillColor: Colors.white,
|
||||||
|
// ts/images/password_icon.png
|
||||||
|
contentPadding: EdgeInsets.only(top: 30, bottom: 30),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||||
|
borderSide: BorderSide(color: Colors.grey),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||||
|
borderSide: BorderSide(color: Theme.of(context).primaryColor, width: 2),
|
||||||
|
),
|
||||||
|
errorBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||||
|
borderSide: BorderSide(color: Theme.of(context).errorColor, width: 2),
|
||||||
|
),
|
||||||
|
focusedErrorBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||||
|
borderSide: BorderSide(color: Theme.of(context).errorColor, width: 2),
|
||||||
|
),
|
||||||
|
counterText: "",
|
||||||
|
errorStyle: TextStyle(height: 0.0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
_verifyCustomer() async {
|
||||||
|
if (formKey.currentState.validate()) {
|
||||||
|
final pinCode = digit1.text + digit2.text + digit3.text + digit4.text;
|
||||||
|
formKey.currentState.save();
|
||||||
|
|
||||||
|
SweetAlert.show(_context, subtitle: "Please wait...", style: SweetAlertStyle.loading);
|
||||||
|
var results = await _ordersViewModel.validateDelivery(order, pinCode);
|
||||||
|
if (results != null && results.isSuccessful) {
|
||||||
|
results = await _ordersViewModel.updateOrderStatus(orderNo: order.orderID, status: DeliveryStatus.delivered);
|
||||||
|
popWithDelay(context: _context, seconds: 0.2, callback: (){
|
||||||
|
if(results.isSuccessful){
|
||||||
|
_goToDeliveryDoneConfirmation();
|
||||||
|
}else{
|
||||||
|
Utils.showErrorToast(results.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}else{
|
||||||
|
Navigator.of(_context).pop();
|
||||||
|
Utils.showErrorToast(results.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_goToDeliveryDoneConfirmation(){
|
||||||
|
locator<DeliveryTrackingServices>().stopLocationUpdate(order.ePharmacyOrderNo); // Stop Driver Location update for Order
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
_context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => DeliveryConfirmedPage(order),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,242 @@
|
|||||||
|
import 'package:driverapp/config/config.dart';
|
||||||
|
import 'package:driverapp/core/enum/viewstate.dart';
|
||||||
|
import 'package:driverapp/core/model/orders/next_order_request_model.dart';
|
||||||
|
import 'package:driverapp/core/model/orders/pending_orders_res_model.dart';
|
||||||
|
import 'package:driverapp/core/service/orders_service.dart';
|
||||||
|
import 'package:driverapp/core/viewModels/orders_view_model.dart';
|
||||||
|
import 'package:driverapp/locator.dart';
|
||||||
|
import 'package:driverapp/pages/base/base_view.dart';
|
||||||
|
import 'package:driverapp/root_page.dart';
|
||||||
|
import 'package:driverapp/uitl/utils.dart';
|
||||||
|
import 'package:driverapp/widgets/buttons/secondary_button.dart';
|
||||||
|
import 'package:driverapp/widgets/delivery/customer_brief_card.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:location/location.dart';
|
||||||
|
|
||||||
|
import '../../uitl/translations_delegate_base.dart';
|
||||||
|
import '../../widgets/others/app_scaffold_widget.dart';
|
||||||
|
import 'information_page.dart';
|
||||||
|
|
||||||
|
class DeliveryCancelRejectedPage extends StatelessWidget {
|
||||||
|
final PendingOrdersRes item;
|
||||||
|
|
||||||
|
DeliveryCancelRejectedPage(this.item);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return BaseView<OrdersViewModel>(
|
||||||
|
builder: (_, model, w) => AppScaffold(
|
||||||
|
isAppBarGradient: true,
|
||||||
|
isShowAppBar: true,
|
||||||
|
appBarColor: Theme.of(context).primaryColor,
|
||||||
|
arrowColor: Colors.white,
|
||||||
|
titleColor: Colors.white,
|
||||||
|
body: SafeArea(
|
||||||
|
child: Container(
|
||||||
|
//
|
||||||
|
child: ListView(
|
||||||
|
children: <Widget>[
|
||||||
|
Stack(
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
decoration: BoxDecoration(gradient: LINEAR_GRADIENT),
|
||||||
|
height: MediaQuery.of(context).orientation ==
|
||||||
|
Orientation.portrait
|
||||||
|
? MediaQuery.of(context).size.width * 1
|
||||||
|
: MediaQuery.of(context).size.width * 1,
|
||||||
|
child: Stack(
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
height: MediaQuery.of(context).orientation ==
|
||||||
|
Orientation.portrait
|
||||||
|
? MediaQuery.of(context).size.width * 0.7
|
||||||
|
: MediaQuery.of(context).size.width * 0.5,
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
top: MediaQuery.of(context).size.width * 0.14,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white10, shape: BoxShape.circle),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(
|
||||||
|
Icons.check_circle,
|
||||||
|
color: Colors.white,
|
||||||
|
size: 75,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height:
|
||||||
|
MediaQuery.of(context).size.width * 0.03,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
'Delivery Confirmed',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height:
|
||||||
|
MediaQuery.of(context).size.width * 0.01,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
TranslationBase.of(context).confirmationSent,
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 13,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Container(
|
||||||
|
// width: MediaQuery.of(context).size.width,
|
||||||
|
// height: MediaQuery.of(context).size.width,
|
||||||
|
// ),
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
height: MediaQuery.of(context).orientation ==
|
||||||
|
Orientation.landscape
|
||||||
|
? MediaQuery.of(context).size.width * 0.6
|
||||||
|
: MediaQuery.of(context).size.width * 1.0,
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
top: MediaQuery.of(context).orientation ==
|
||||||
|
Orientation.portrait
|
||||||
|
? MediaQuery.of(context).size.width * 0.70
|
||||||
|
: MediaQuery.of(context).size.width * 0.60,
|
||||||
|
),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Theme
|
||||||
|
.of(context)
|
||||||
|
.scaffoldBackgroundColor,
|
||||||
|
borderRadius: BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(80),
|
||||||
|
topRight: Radius.circular(80)),
|
||||||
|
),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MediaQuery.of(context).orientation ==
|
||||||
|
Orientation.landscape
|
||||||
|
? MainAxisAlignment.center
|
||||||
|
: MainAxisAlignment.end,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
bottom: MediaQuery.of(context).size.width * 0.00,
|
||||||
|
),
|
||||||
|
child: Padding(
|
||||||
|
padding: MediaQuery.of(context).orientation ==
|
||||||
|
Orientation.landscape
|
||||||
|
? EdgeInsets.only(top: 60.0)
|
||||||
|
: EdgeInsets.only(top: 30.0),
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
// TODO return add note when its needed
|
||||||
|
// FlatButton.icon(
|
||||||
|
// padding: EdgeInsets.all(14.0),
|
||||||
|
// color: Colors.orangeAccent,
|
||||||
|
// shape: RoundedRectangleBorder(
|
||||||
|
// borderRadius: BorderRadius.circular(10.0),
|
||||||
|
// ),
|
||||||
|
// label: Text(
|
||||||
|
// TranslationBase.of(context).addNoteBtn,
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: Colors.white, fontSize: 20.0),
|
||||||
|
// ),
|
||||||
|
// icon: Icon(
|
||||||
|
// Icons.mode_edit,
|
||||||
|
// color: Colors.white,
|
||||||
|
// ),
|
||||||
|
// onPressed: () {},
|
||||||
|
// ),
|
||||||
|
// SizedBox(
|
||||||
|
// height: MediaQuery.of(context).size.width *
|
||||||
|
// 0.00, //20,
|
||||||
|
// ),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 30.0),
|
||||||
|
child: Container(
|
||||||
|
margin: EdgeInsets.all(10),
|
||||||
|
child: SecondaryButton(
|
||||||
|
label: TranslationBase.of(context)
|
||||||
|
.nextDelivery,
|
||||||
|
loading:
|
||||||
|
model.state == ViewState.BusyLocal,
|
||||||
|
onTap: () {
|
||||||
|
getNextOrder(context, model);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
top: MediaQuery.of(context).orientation ==
|
||||||
|
Orientation.portrait
|
||||||
|
? MediaQuery.of(context).size.width * 0.6
|
||||||
|
: MediaQuery.of(context).size.width * 0.4,
|
||||||
|
),
|
||||||
|
child: CustomerBriefCard(
|
||||||
|
customerOrderId: item.orderID,
|
||||||
|
pharmacyOrderId: item.ePharmacyOrderNo,
|
||||||
|
customerFirstName: item.firstName,
|
||||||
|
customerLastName: item.lastName,
|
||||||
|
mobileNo: item.mobileNumber,
|
||||||
|
totalPayment: item.amount,
|
||||||
|
distanceInKilometers: item.distanceInKilometers,
|
||||||
|
showDistance: false,
|
||||||
|
deliveryTime: item.orderCreatedOn),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getNextOrder(BuildContext context, OrdersViewModel model) async {
|
||||||
|
model.setState(ViewState.BusyLocal);
|
||||||
|
LocationData loc = await Utils.getLocation();
|
||||||
|
NextOrderRequestModel nextOrderRequestModel = NextOrderRequestModel(
|
||||||
|
pageIndex: 0,
|
||||||
|
pageSize: 0,
|
||||||
|
latitude: loc.latitude.toString(), // "46.621730",
|
||||||
|
longitude: loc.longitude.toString(), // "24.797682",
|
||||||
|
searchKey: "");
|
||||||
|
await model.nextOrder(nextOrderRequestModel);
|
||||||
|
if (model.state == ViewState.ErrorLocal) {
|
||||||
|
Utils.showErrorToast(model.error);
|
||||||
|
} else {
|
||||||
|
if (model.nextOrdersList != null && model.nextOrdersList.length == 0) {
|
||||||
|
Utils.showErrorToast("No Items in the list");
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => RootPage(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
InformationPage(item: model.nextOrdersList[0]),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
|
class Logs{
|
||||||
|
static save(String log){
|
||||||
|
SharedPreferences.getInstance().then((_prefs) async{
|
||||||
|
var jsonString = _prefs.getString("LOG") ?? "[]";
|
||||||
|
var list = json.decode(jsonString) as List;
|
||||||
|
list.add("Running... ${DateTime.now()}");
|
||||||
|
_prefs.setString("LOG", json.encode(list));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue