Driver location update on order deliver in progress...

ZohaibIqbalKambrani
Zohaib Iqbal Kambrani 5 years ago
parent 0522cb4dcb
commit 9d10eda89c

@ -24,8 +24,7 @@
to determine the Window background behind the Flutter UI. --> to determine the Window background behind the Flutter UI. -->
<meta-data <meta-data
android:name="io.flutter.embedding.android.NormalTheme" android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" android:resource="@style/NormalTheme" />
/>
<!-- Displays an Android View that continues showing the launch screen <!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual screen fades out. A splash screen is useful to avoid any visual

@ -2,26 +2,23 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
/// End points /// End points
const BASE_URL = 'https://hmgwebservices.com/Services'; const isUAT = true;
const BASE_URL = 'https://${isUAT ? "uat." : ""}hmgwebservices.com/Services';
const PING_SERVICE = '/Services/Weather.svc/REST/CheckConnectivity';
const GET_PROJECT = '/Lists.svc/REST/GetProject'; const GET_PROJECT = '/Lists.svc/REST/GetProject';
const LOGIN = "/Authentication.svc/REST/CheckDriverAuthentication"; const LOGIN = "/Authentication.svc/REST/CheckDriverAuthentication";
const GET_OPT = const GET_OPT = "/Patients.svc/REST/PatientER_Delivery_SendSMSForForgetPassword";
"/Patients.svc/REST/PatientER_Delivery_SendSMSForForgetPassword"; const CHECK_ACTIVATION_CODE = "/Patients.svc/REST/PatientER_Delivery_CheckActivationCodeForForgetPassword";
const CHECK_ACTIVATION_CODE = const CHANGE_FORGOT_PASSWORD = "/Patients.svc/REST/PatientER_Delivery_ChangeForgetedPasswordForDriver";
"/Patients.svc/REST/PatientER_Delivery_CheckActivationCodeForForgetPassword";
const CHANGE_FORGOT_PASSWORD =
"/Patients.svc/REST/PatientER_Delivery_ChangeForgetedPasswordForDriver";
const GET_ALL_ORDERS = '/Patients.svc/REST/PatientER_Delivery_GetAllOrder'; const GET_ALL_ORDERS = '/Patients.svc/REST/PatientER_Delivery_GetAllOrder';
const SCAN_QR = '/Patients.svc/REST/PatientER_Delivery_OrderInsert'; const SCAN_QR = '/Patients.svc/REST/PatientER_Delivery_OrderInsert';
const UPDATE_ORDER_STATUS = const UPDATE_ORDER_STATUS = '/Patients.svc/REST/PatientER_Delivery_UpdateOrderStatus';
'/Patients.svc/REST/PatientER_Delivery_UpdateOrderStatus';
const NEXT_ORDER = "/Patients.svc/REST/PatientER_Delivery_NextOrder"; const NEXT_ORDER = "/Patients.svc/REST/PatientER_Delivery_NextOrder";
const UPDATE_DRIVER_LOCATION = "/Patients.svc/REST/PatientER_DriverLocation_Insert";
const GET_ALL_DELIVERD_ORDER = const GET_ALL_DELIVERD_ORDER = '/Patients.svc/REST/PatientER_Delivery_GetAllDeliverdOrder';
'/Patients.svc/REST/PatientER_Delivery_GetAllDeliverdOrder'; const GET_ALL_ORDERS_STATUS = '/Patients.svc/REST/PatientER_Delivery_GetAllOrderstatus';
const GET_ALL_ORDERS_STATUS =
'/Patients.svc/REST/PatientER_Delivery_GetAllOrderstatus';
/// Body Constant /// Body Constant
const CHANNEL = 9; const CHANNEL = 9;

@ -82,4 +82,8 @@ const Map<String, Map<String, String>> localizedValues = {
'en': 'Please Enter your OPT code sent to your phone', 'en': 'Please Enter your OPT code sent to your phone',
'ar': 'الرجاء إدخال رمز OPT الخاص بك المرسل إلى هاتفك' 'ar': 'الرجاء إدخال رمز OPT الخاص بك المرسل إلى هاتفك'
}, },
'startDelivery': {
'en': 'Start Delivery',
'ar': 'Start Delivery'
},
}; };

@ -0,0 +1,10 @@
class RequestInitiateOrderDelivery{
int orderID = 0;
RequestInitiateOrderDelivery({this.orderID});
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['OrderID'] = this.orderID;
return data;
}
}

@ -0,0 +1,15 @@
import 'package:location/location.dart';
class RequestUpdateDriverLocation{
int orderID = 0;
LocationData location;
RequestUpdateDriverLocation({this.orderID,this.location});
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['OrderID'] = this.orderID;
data['Latitude'] = "${this.location.latitude}";
data['Longitude'] = "${this.location.longitude}";
return data;
}
}

@ -0,0 +1,100 @@
import 'dart:collection';
import 'package:driverapp/config/config.dart';
import 'package:driverapp/core/model/initiate_order_delivey/request_initiate_order_delivery.dart';
import 'package:driverapp/core/model/orders/deliverd_order_res_model.dart';
import 'package:driverapp/core/model/orders/next_order_request_model.dart';
import 'package:driverapp/core/model/orders/pending_orders_req_model.dart';
import 'package:driverapp/core/model/orders/pending_orders_res_model.dart';
import 'package:driverapp/core/model/orders/update_order_status_request_model.dart';
import 'package:driverapp/core/model/scan_qr/scan_qr_request_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/utils.dart';
import 'package:flutter/cupertino.dart';
import 'package:latlong/latlong.dart';
import 'package:location/location.dart';
class DeliveryTrackingServices extends BaseService {
var _distanceFilter = 5; // [Meters] (Call update API if distance covered from last location is greater then 'value' )
var initiateOrderDeliveryResponse = null;
Future<Object> initiateOrderDelivery(int orderID) async {
hasError = false;
var order = RequestInitiateOrderDelivery(orderID: orderID);
try {
await baseAppClient.post(PING_SERVICE,
onSuccess: (dynamic response, int statusCode) {
initiateOrderDeliveryResponse = response;
}, onFailure: (String error, int statusCode) {
super.hasError = true;
super.error = error;
}, body: order.toJson());
} catch (e) {
hasError = true;
super.error = error;
throw e;
}
return initiateOrderDeliveryResponse;
}
_updateDriverLocation(int orderID, LocationData location) async {
if(location != null){
debugPrint("Updating driver location");
var order = RequestUpdateDriverLocation(orderID: orderID, location: location);
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: order.toJson());
}
}
List _currentRunnings = List<int>();
Future<Object> startLocationUpdate(int orderID, {int frequencyInSeconds = 3}) async {
_currentRunnings.remove(orderID); // remove existing if its already running
_currentRunnings.add(orderID);
while(_currentRunnings.contains(orderID)){
await Future.delayed(Duration(seconds: frequencyInSeconds));
Utils.possibleToGetLocation((value) async{
if(value){
var location = await Utils.getLocation();
if (_haveEnoughLocationUpdate(location))
await _updateDriverLocation(orderID, location);
}
});
}
}
stopLocationUpdate(int orderID){
_currentRunnings.remove(orderID);
}
LocationData _lastLocation;
bool _haveEnoughLocationUpdate(LocationData location){
if(_lastLocation == null) {
_lastLocation = location;
return true;
}else{
var distanceCovered = Utils.distanceBetween(_lastLocation, location, LengthUnit.Meter);
return (distanceCovered > _distanceFilter);
}
}
}

@ -1,3 +1,4 @@
import 'package:driverapp/core/service/delivery_tracking_services.dart';
import 'package:get_it/get_it.dart'; import 'package:get_it/get_it.dart';
import 'core/service/authentication_service.dart'; import 'core/service/authentication_service.dart';
@ -15,6 +16,7 @@ void setupLocator() {
locator.registerLazySingleton(() => HospitalService()); locator.registerLazySingleton(() => HospitalService());
locator.registerLazySingleton(() => AuthenticationService()); locator.registerLazySingleton(() => AuthenticationService());
locator.registerLazySingleton(() => OrdersService()); locator.registerLazySingleton(() => OrdersService());
locator.registerLazySingleton(() => DeliveryTrackingServices());
/// View Model /// View Model
locator.registerFactory(() => HospitalViewModel()); locator.registerFactory(() => HospitalViewModel());

@ -90,7 +90,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
_authenticationViewModel.user.userName, _authenticationViewModel.user.userName,
style: TextStyle( style: TextStyle(
fontSize: 22.0, fontSize: 22.0,
color: Hexcolor("#343333"), color: HexColor("#343333"),
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
), ),
@ -482,7 +482,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
Text(TranslationBase.of(context).nearestDropOffs, Text(TranslationBase.of(context).nearestDropOffs,
style: TextStyle( style: TextStyle(
fontSize: 18.0, fontSize: 18.0,
color: Hexcolor("#343333"), color: HexColor("#343333"),
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold)),
], ],
), ),

@ -1,10 +1,18 @@
import 'dart:convert';
import 'dart:io';
import 'package:android_intent/android_intent.dart';
import 'package:driverapp/app-icons/driver_app_icons.dart'; import 'package:driverapp/app-icons/driver_app_icons.dart';
import 'package:driverapp/config/config.dart'; import 'package:driverapp/config/config.dart';
import 'package:driverapp/core/enum/viewstate.dart'; import 'package:driverapp/core/enum/viewstate.dart';
import 'package:driverapp/core/model/orders/pending_orders_req_model.dart';
import 'package:driverapp/core/model/orders/pending_orders_res_model.dart'; import 'package:driverapp/core/model/orders/pending_orders_res_model.dart';
import 'package:driverapp/core/model/orders/update_order_status_request_model.dart'; import 'package:driverapp/core/model/orders/update_order_status_request_model.dart';
import 'package:driverapp/core/service/delivery_tracking_services.dart';
import 'package:driverapp/core/viewModels/orders_view_model.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/pages/base/base_view.dart';
import 'package:driverapp/uitl/app_shared_preferences.dart';
import 'package:driverapp/uitl/translations_delegate_base.dart'; import 'package:driverapp/uitl/translations_delegate_base.dart';
import 'package:driverapp/uitl/utils.dart'; import 'package:driverapp/uitl/utils.dart';
import 'package:driverapp/widgets/bottom_sheet/action_sheet_button.dart'; import 'package:driverapp/widgets/bottom_sheet/action_sheet_button.dart';
@ -19,136 +27,31 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart'; import 'package:hexcolor/hexcolor.dart';
import 'package:maps_launcher/maps_launcher.dart'; import 'package:maps_launcher/maps_launcher.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'delivery_confirmed_page.dart'; import 'delivery_confirmed_page.dart';
// ignore: must_be_immutable
class InformationPage extends StatelessWidget { class InformationPage extends StatefulWidget {
final PendingOrdersRes item; final PendingOrdersRes item;
InformationPage({this.item});
@override
State<StatefulWidget> createState() => _InformationPageState();
}
// ignore: must_be_immutable
class _InformationPageState extends State<InformationPage> {
int _orderStatus; int _orderStatus;
PendingOrdersRes _item;
bool _isDeliveryStarted = false;
InformationPage({this.item});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
showDeliveryOptions(OrdersViewModel model) { _item = widget.item;
showModalBottomSheet(
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
isScrollControlled: true,
context: context,
builder: (BuildContext bc) {
return FractionallySizedBox(
heightFactor: 0.35,
child: ListView(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 10,
),
Center(
child: Texts(
TranslationBase.of(context).selectAction,
color: Colors.black,
fontSize: 22,
),
),
SizedBox(
height: 10,
),
FractionallySizedBox(
widthFactor: MediaQuery.of(context).orientation ==
Orientation.portrait
? 0.9
: 0.98,
child: Container(
height: MediaQuery.of(context).size.height * 0.45,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
width: double.infinity,
child: ListView(
children: <Widget>[
Column(
children: <Widget>[
SizedBox(
height: 3,
child: Container(
color: Hexcolor("#D5D5D5"),
),
),
SizedBox(
height: 15,
),
ActionSheetButton(
label:
TranslationBase.of(context).delivered,
icon: DriverApp.deliverd_icon,
onTap: () {
selectAction(context, 2, model);
},
),
SizedBox(height: 15),
// ActionSheetButton(
// label: TranslationBase.of(context)
// .deliveredAccepted,
// icon: DriverApp.not_available,
// onTap: () {
// selectAction(context, 4, model);
// },
// ),
// SizedBox(height: 15),
ActionSheetButton(
label: TranslationBase.of(context)
.deliveredRejected,
icon: DriverApp.rejected_icon,
onTap: () {
selectAction(context, 3, model);
},
),
SizedBox(height: 15),
// ActionSheetButton(
// label: TranslationBase.of(context).canceled,
// icon: DriverApp.not_reachable_icon,
// onTap: () {
// selectAction(context, 6, model);
// },
// ),
// SizedBox(height: 15),
],
),
],
),
),
)
],
),
),
],
),
);
});
}
return BaseView<OrdersViewModel>( return BaseView<OrdersViewModel>(
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
@ -175,12 +78,12 @@ class InformationPage extends StatelessWidget {
child: Container( child: Container(
width: MediaQuery.of(context).size.width * 1.0, width: MediaQuery.of(context).size.width * 1.0,
height: MediaQuery.of(context).orientation == height: MediaQuery.of(context).orientation ==
Orientation.portrait Orientation.portrait
? MediaQuery.of(context).size.height * 0.70 ? MediaQuery.of(context).size.height * 0.70
: MediaQuery.of(context).size.height * 1.7, : MediaQuery.of(context).size.height * 1.7,
margin: EdgeInsets.only( margin: EdgeInsets.only(
top: MediaQuery.of(context).orientation == top: MediaQuery.of(context).orientation ==
Orientation.portrait Orientation.portrait
? MediaQuery.of(context).size.width * 0.23 ? MediaQuery.of(context).size.width * 0.23
: MediaQuery.of(context).size.width * 0.13), : MediaQuery.of(context).size.width * 0.13),
decoration: BoxDecoration( decoration: BoxDecoration(
@ -192,88 +95,53 @@ class InformationPage extends StatelessWidget {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[ children: <Widget>[
SizedBox( Visibility(
height: MediaQuery.of(context).orientation == visible: _isDeliveryStarted,
Orientation.portrait child: Padding(
? MediaQuery.of(context).size.height * 0.10 padding: MediaQuery.of(context).orientation ==
: MediaQuery.of(context).size.height * 0.29, Orientation.portrait
//MediaQuery.of(context).size.width * 0.005, ? EdgeInsets.only(top: 60.0)
), : EdgeInsets.only(top: 15.0),
Padding( child: Row(
padding: MediaQuery.of(context).orientation == mainAxisAlignment: MainAxisAlignment.center,
Orientation.portrait children: <Widget>[
? EdgeInsets.only(top: 60.0) DeliveryInfoButton(
: EdgeInsets.only(top: 15.0), btnColor: Colors.white, //Color(0xffED1C24),
child: Row( btnIcon: Icon(DriverApp.location_1,
mainAxisAlignment: MainAxisAlignment.center, size: MediaQuery.of(context)
children: <Widget>[ .orientation ==
DeliveryInfoButton( Orientation.portrait
btnColor: Colors.white, //Color(0xffED1C24),
btnIcon: Icon(DriverApp.location_1,
size: MediaQuery.of(context)
.orientation ==
Orientation.portrait
? 50
: 90,
color: Color(0xffED1C24)),
btnName:
TranslationBase.of(context).location,
btnFunction: () {
MapsLauncher.launchCoordinates(
item.latitude, item.longitude);
},
),
//TODO: return it back when it needed
// DeliveryInfoButton(
// btnColor: Colors.white, //Color(0xFF61B260),
// btnIcon: Icon(
// DriverApp.whatsapp,
// size:
// MediaQuery.of(context).orientation ==
// Orientation.portrait
// ? 50
// : 90,
// color: Color(0xFF5EA34A),
// ),
// btnName: 'Whatsapp',
// btnFunction: () {},
// ),
// DeliveryInfoButton(
// btnColor: Colors.white, //Color(0xFFFCB657),
// btnIcon: Icon(
// DriverApp.message,
// size:
// MediaQuery.of(context).orientation ==
// Orientation.portrait
// ? 50
// : 90,
// color: Color(0xffFFA540),
// ),
// btnName: TranslationBase.of(context).sms,
// btnFunction: () {},
// ),
DeliveryInfoButton(
btnColor: Colors.white,
//Theme.of(context).primaryColor,
btnIcon: Icon(
DriverApp.call,
size:
MediaQuery.of(context).orientation ==
Orientation.portrait
? 50 ? 50
: 90, : 90,
color: Theme.of(context).primaryColor, color: Color(0xffED1C24)),
btnName:
TranslationBase.of(context).location,
btnFunction: () {
openMapIntent(_item);
// MapsLauncher.launchCoordinates(
// _item.latitude, _item.longitude);
},
), ),
btnName: TranslationBase.of(context).call, DeliveryInfoButton(
btnFunction: () => btnColor: Colors.white,
launch("tel://" + item.mobileNumber), //Theme.of(context).primaryColor,
), btnIcon: Icon(
], DriverApp.call,
size:
MediaQuery.of(context).orientation ==
Orientation.portrait
? 50
: 90,
color: Theme.of(context).primaryColor,
),
btnName: TranslationBase.of(context).call,
btnFunction: () =>
launch("tel://" + _item.mobileNumber),
),
],
),
), ),
), ),
SizedBox(
height: MediaQuery.of(context).size.width * 0.08,
),
Container( Container(
margin: EdgeInsets.only( margin: EdgeInsets.only(
left: MediaQuery.of(context).size.width * 0.05, left: MediaQuery.of(context).size.width * 0.05,
@ -300,15 +168,15 @@ class InformationPage extends StatelessWidget {
padding: const EdgeInsets.only(left: 10), padding: const EdgeInsets.only(left: 10),
child: Column( child: Column(
children: List.generate( children: List.generate(
item.itemsQuantitiesList != null _item.itemsQuantitiesList != null
? item.itemsQuantitiesList.length ? _item.itemsQuantitiesList.length
: 0, (index) { : 0, (index) {
return packageContent( return packageContent(
packageName: item packageName: _item
.itemsQuantitiesList[index] .itemsQuantitiesList[index]
.itemName .itemName
.toString(), .toString(),
packageCount: item packageCount: _item
.itemsQuantitiesList[index] .itemsQuantitiesList[index]
.quantity .quantity
.toString(), .toString(),
@ -324,14 +192,19 @@ class InformationPage extends StatelessWidget {
), ),
Container( Container(
margin: MediaQuery.of(context).orientation == margin: MediaQuery.of(context).orientation ==
Orientation.portrait Orientation.portrait
? EdgeInsets.all(8.0) ? EdgeInsets.all(8.0)
: EdgeInsets.symmetric(horizontal: 12.0), : EdgeInsets.symmetric(horizontal: 12.0),
child: SecondaryButton( child: SecondaryButton(
label: label:
TranslationBase.of(context).clientReached, TranslationBase.of(context).clientReached,
onTap: () { onTap: () {
showDeliveryOptions(model); locator<DeliveryTrackingServices>()
.initiateOrderDelivery(_item.orderID)
.then((results){
setState(() => _isDeliveryStarted = true);
// showDeliveryOptions(model);
});
}, },
), ),
), ),
@ -340,16 +213,16 @@ class InformationPage extends StatelessWidget {
), ),
), ),
CustomerBriefCard( CustomerBriefCard(
customerOrderId: item.orderID, customerOrderId: _item.orderID,
pharmacyOrderId: item.ePharmacyOrderNo, pharmacyOrderId: _item.ePharmacyOrderNo,
customerFirstName: item.firstName, customerFirstName: _item.firstName,
customerLastName: item.lastName, customerLastName: _item.lastName,
mobileNo: item.mobileNumber, mobileNo: _item.mobileNumber,
totalPayment: item.amount, totalPayment: _item.amount,
deliveryTime: item.orderCreatedOn, deliveryTime: _item.orderCreatedOn,
longitude: item.longitude, longitude: _item.longitude,
latitude: item.latitude, latitude: _item.latitude,
distanceInKilometers: item.distanceInKilometers, distanceInKilometers: _item.distanceInKilometers,
), ),
], ],
), ),
@ -361,6 +234,128 @@ class InformationPage extends StatelessWidget {
); );
} }
showDeliveryOptions(OrdersViewModel model) {
showModalBottomSheet(
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
isScrollControlled: true,
context: context,
builder: (BuildContext bc) {
return FractionallySizedBox(
heightFactor: 0.35,
child: ListView(
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
height: 10,
),
Center(
child: Texts(
TranslationBase.of(context).selectAction,
color: Colors.black,
fontSize: 22,
),
),
SizedBox(
height: 10,
),
FractionallySizedBox(
widthFactor: MediaQuery.of(context).orientation ==
Orientation.portrait
? 0.9
: 0.98,
child: Container(
height: MediaQuery.of(context).size.height * 0.45,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(50.0),
topRight: Radius.circular(50.0),
),
),
width: double.infinity,
child: ListView(
children: <Widget>[
Column(
children: <Widget>[
SizedBox(
height: 3,
child: Container(
color: HexColor("#D5D5D5"),
),
),
SizedBox(
height: 15,
),
ActionSheetButton(
label:
TranslationBase.of(context).delivered,
icon: DriverApp.deliverd_icon,
onTap: () {
selectAction(context, 2, model);
},
),
SizedBox(height: 15),
// ActionSheetButton(
// label: TranslationBase.of(context)
// .deliveredAccepted,
// icon: DriverApp.not_available,
// onTap: () {
// selectAction(context, 4, model);
// },
// ),
// SizedBox(height: 15),
ActionSheetButton(
label: TranslationBase.of(context)
.deliveredRejected,
icon: DriverApp.rejected_icon,
onTap: () {
selectAction(context, 3, model);
},
),
SizedBox(height: 15),
// ActionSheetButton(
// label: TranslationBase.of(context).canceled,
// icon: DriverApp.not_reachable_icon,
// onTap: () {
// selectAction(context, 6, model);
// },
// ),
// SizedBox(height: 15),
],
),
],
),
),
)
],
),
),
],
),
);
});
}
selectAction(BuildContext context, orderStatus, OrdersViewModel model) { selectAction(BuildContext context, orderStatus, OrdersViewModel model) {
String orderStatusText; String orderStatusText;
this._orderStatus = orderStatus; this._orderStatus = orderStatus;
@ -397,11 +392,11 @@ class InformationPage extends StatelessWidget {
updateOrderStatus(BuildContext context, OrdersViewModel model) async { updateOrderStatus(BuildContext context, OrdersViewModel model) async {
UpdateOrderStatusRequestModel updateOrderStatusRequestModel = UpdateOrderStatusRequestModel updateOrderStatusRequestModel =
UpdateOrderStatusRequestModel( UpdateOrderStatusRequestModel(
deliveryOrderID: item.orderID, deliveryOrderID: _item.orderID,
deliveryOrderStatus: _orderStatus, deliveryOrderStatus: _orderStatus,
rejectionReason: "NO Reason", rejectionReason: "NO Reason",
cancleReason: ""); cancleReason: "");
await model.updateOrderStatus(updateOrderStatusRequestModel); await model.updateOrderStatus(updateOrderStatusRequestModel);
if (model.state == ViewState.ErrorLocal) { if (model.state == ViewState.ErrorLocal) {
Utils.showErrorToast(model.error); Utils.showErrorToast(model.error);
@ -420,9 +415,28 @@ class InformationPage extends StatelessWidget {
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => builder: (context) =>
DeliveryConfirmedPage(item), DeliveryConfirmedPage(_item),
), ),
); );
} }
} }
openMapIntent(PendingOrdersRes order) async{
Utils.getLocation().then((locationData){
if(locationData != null){
var url = "https://www.google.com/maps/dir/?api=1&destination=24.701833,46.697642&travelmode=driving&dir_action=navigate";
if (Platform.isAndroid) {
var intent = AndroidIntent(action: 'action_view',data: url,package: 'com.google.android.apps.maps');
intent.launch();
}else {
print(url);
}
// Start updating server wit your current location
locator<DeliveryTrackingServices>().startLocationUpdate(order.orderID);
}
});
}
} }

@ -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));
});
}
}

@ -108,6 +108,9 @@ class TranslationBase {
String get clientReached => String get clientReached =>
localizedValues['clientReached'][locale.languageCode]; localizedValues['clientReached'][locale.languageCode];
String get startDelivery =>
localizedValues['startDelivery'][locale.languageCode];
String get addNoteBtn => localizedValues['addNoteBtn'][locale.languageCode]; String get addNoteBtn => localizedValues['addNoteBtn'][locale.languageCode];
String get nextDelivery => String get nextDelivery =>

@ -5,6 +5,7 @@ import 'package:driverapp/pages/setting/request_permission_page.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:latlong/latlong.dart';
import 'package:location/location.dart'; import 'package:location/location.dart';
import 'app_shared_preferences.dart'; import 'app_shared_preferences.dart';
@ -49,7 +50,24 @@ class Utils {
FocusScope.of(context).unfocus(); FocusScope.of(context).unfocus();
} }
static getLocation() async { static double distanceBetween(LocationData point1, LocationData point2, LengthUnit unit){
var distance = Distance();
num dist = distance.as(
unit,
LatLng(point1.latitude,point1.longitude),
LatLng(point2.latitude,point2.longitude)
);
return dist;
}
static possibleToGetLocation(Function(bool) completion) async{
Location location = new Location();
var serviceEnabled = await location.serviceEnabled();
var hasPermission = await location.hasPermission() == PermissionStatus.granted;
completion(serviceEnabled && hasPermission);
}
static Future<LocationData> getLocation() async {
Location location = new Location(); Location location = new Location();
LocationData currentLocation; LocationData currentLocation;
bool _serviceEnabled; bool _serviceEnabled;
@ -104,8 +122,8 @@ class Utils {
// open setting page // open setting page
} else { } else {
currentLocation = await location.getLocation(); currentLocation = await location.getLocation();
return currentLocation;
} }
return currentLocation;
} }
static formatStringToPascalCase(String name) { static formatStringToPascalCase(String name) {

@ -19,7 +19,7 @@ class ActionSheetButton extends StatelessWidget {
: MediaQuery.of(context).size.height * 0.14, : MediaQuery.of(context).size.height * 0.14,
decoration: BoxDecoration(boxShadow: [ decoration: BoxDecoration(boxShadow: [
BoxShadow( BoxShadow(
color: Hexcolor("#DBE5E6"), color: HexColor("#DBE5E6"),
spreadRadius: 15, spreadRadius: 15,
blurRadius: 15, blurRadius: 15,
offset: Offset(0, 7), offset: Offset(0, 7),
@ -66,7 +66,7 @@ class ActionSheetButton extends StatelessWidget {
style: TextStyle( style: TextStyle(
fontSize: 22.0, fontSize: 22.0,
fontFamily: "Metropolis-Bold", fontFamily: "Metropolis-Bold",
color: Hexcolor("##1A1818")), color: HexColor("##1A1818")),
), ),
) )
], ],

@ -25,7 +25,7 @@ class CustomBottomSheet extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Hexcolor("#D5D5D5"), color: HexColor("#D5D5D5"),
borderRadius: BorderRadius.circular(3.0)), borderRadius: BorderRadius.circular(3.0)),
width: 200, width: 200,
height: 7.0, height: 7.0,

@ -103,7 +103,7 @@ class _ButtonState extends State<Button> with TickerProviderStateMixin {
: 19), : 19),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10.0)), borderRadius: BorderRadius.all(Radius.circular(10.0)),
color: Hexcolor('#515b5d'), color: HexColor('#515b5d'),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(
color: Color.fromRGBO( color: Color.fromRGBO(

@ -194,7 +194,7 @@ class _SecondaryButtonState extends State<SecondaryButton>
widget.color != null ? null : LINEAR_GRADIENT, widget.color != null ? null : LINEAR_GRADIENT,
color: widget.color != null color: widget.color != null
? widget.color ? widget.color
: Hexcolor("#000000"), : HexColor("#000000"),
), ),
), ),
), ),

@ -25,7 +25,7 @@ class CircleContainer extends StatelessWidget {
shape: BoxShape.circle, shape: BoxShape.circle,
color: color, color: color,
border: Border.all( border: Border.all(
color: borderColor ?? Hexcolor("#707070"), width: borderWidth)), color: borderColor ?? HexColor("#707070"), width: borderWidth)),
height: 80, height: 80,
width: 80, width: 80,
), ),

@ -61,7 +61,7 @@ class CustomerBriefCard extends StatelessWidget {
], ],
), ),
child: Container( child: Container(
padding: EdgeInsets.only(left: 30, top: 20, right: 30), padding: EdgeInsets.only(left: 20, top: 20, right: 20),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,

@ -77,7 +77,7 @@ class OrderInfoCard extends StatelessWidget {
order.lastName), order.lastName),
style: TextStyle( style: TextStyle(
fontSize: 18.0, fontSize: 18.0,
color: Hexcolor("#343333"), color: HexColor("#343333"),
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
), ),

@ -67,7 +67,7 @@ class _RoundedContainerState extends State<RoundedContainer> {
boxShadow: widget.showShadow ? [ boxShadow: widget.showShadow ? [
BoxShadow( BoxShadow(
color: Hexcolor("#DBE5E6"), color: HexColor("#DBE5E6"),
spreadRadius: 15, spreadRadius: 15,
blurRadius: 15, blurRadius: 15,
offset: Offset(0, 7), // changes position of shadow offset: Offset(0, 7), // changes position of shadow

@ -56,7 +56,7 @@ dependencies:
# UI Reqs # UI Reqs
dotted_border: 1.0.5 dotted_border: 1.0.5
expandable: ^4.1.4 expandable: ^4.1.4
hexcolor: ^1.0.1 hexcolor: ^1.0.6
# Notification Banner # Notification Banner
dropdown_banner: ^1.4.0 dropdown_banner: ^1.4.0
@ -72,6 +72,10 @@ dependencies:
# location # location
location: ^3.0.2 location: ^3.0.2
# latlong tools
latlong: any
#gradient #gradient
gradient_app_bar: ^0.1.3 gradient_app_bar: ^0.1.3
@ -79,6 +83,9 @@ dependencies:
#Barcode Scanner #Barcode Scanner
flutter_barcode_scanner: ^1.0.1 flutter_barcode_scanner: ^1.0.1
#android_intent
android_intent: any

Loading…
Cancel
Save