Compare commits
53 Commits
location
...
developmen
| Author | SHA1 | Date |
|---|---|---|
|
|
7b20f789f6 | 4 years ago |
|
|
e772873379 | 4 years ago |
|
|
07e22546b5 | 5 years ago |
|
|
9d10eda89c | 5 years ago |
|
|
0522cb4dcb | 5 years ago |
|
|
786f974bfc | 5 years ago |
|
|
a0328b6fdf | 5 years ago |
|
|
6916cc974a | 5 years ago |
|
|
02763d89d5 | 5 years ago |
|
|
b3598c5e09 | 5 years ago |
|
|
937b73f45f | 5 years ago |
|
|
c4a1791815 | 5 years ago |
|
|
2bc2fb4770 | 5 years ago |
|
|
deb42d4215 | 5 years ago |
|
|
3bc9b4e64a | 5 years ago |
|
|
9b14359cb2 | 5 years ago |
|
|
1356709c66 | 5 years ago |
|
|
a7b300327d | 5 years ago |
|
|
45927ed8f1 | 5 years ago |
|
|
7cd74cbda5 | 5 years ago |
|
|
c2cae941e6 | 5 years ago |
|
|
e6b79e9684 | 5 years ago |
|
|
e40bd96418 | 5 years ago |
|
|
f117eb64a0 | 5 years ago |
|
|
af43ec86ae | 5 years ago |
|
|
371187cbd9 | 5 years ago |
|
|
451bd8315e | 5 years ago |
|
|
a6de42dd05 | 5 years ago |
|
|
7fe3677d1e | 5 years ago |
|
|
3b54d4c13c | 5 years ago |
|
|
8fc13464a8 | 5 years ago |
|
|
3f6b4a2aae | 5 years ago |
|
|
9dfaee792b | 5 years ago |
|
|
38a57ad7c4 | 5 years ago |
|
|
53e444d5b4 | 5 years ago |
|
|
001124b271 | 5 years ago |
|
|
cc3173d269 | 5 years ago |
|
|
bf5a65ba80 | 5 years ago |
|
|
618cb27814 | 5 years ago |
|
|
ed51310a3a | 5 years ago |
|
|
d76b52a486 | 5 years ago |
|
|
12f40c4324 | 5 years ago |
|
|
d7ecd48d6e | 5 years ago |
|
|
b354934ba3 | 5 years ago |
|
|
362def99f0 | 5 years ago |
|
|
2d34d092e5 | 5 years ago |
|
|
566fd360e0 | 5 years ago |
|
|
8d9449a239 | 5 years ago |
|
|
344e379882 | 5 years ago |
|
|
c8ba893042 | 5 years ago |
|
|
e275f8420d | 5 years ago |
|
|
27ad35a4ef | 5 years ago |
|
|
8233dd9b0c | 5 years ago |
|
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 4.0 KiB |
@ -0,0 +1 @@
|
|||||||
|
include ':app'
|
||||||
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
After Width: | Height: | Size: 919 B |
|
After Width: | Height: | Size: 54 KiB |
@ -0,0 +1 @@
|
|||||||
|
5fbd1cb9b58728098d7578fb656a1766
|
||||||
@ -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),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,195 @@
|
|||||||
|
import 'package:driverapp/app-icons/driver_app_icons.dart';
|
||||||
|
import 'package:driverapp/core/viewModels/authentication_view_model.dart';
|
||||||
|
import 'package:driverapp/core/viewModels/project_view_model.dart';
|
||||||
|
import 'package:driverapp/pages/authentication/verification_page.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/input/text_field.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 '../../root_page.dart';
|
||||||
|
|
||||||
|
// ignore: must_be_immutable
|
||||||
|
class ForgetPasswordPage extends StatelessWidget {
|
||||||
|
final forgetPasswordFormKey = GlobalKey<FormState>();
|
||||||
|
int driverID;
|
||||||
|
ProjectViewModel projectViewModel;
|
||||||
|
AuthenticationViewModel authenticationViewModel;
|
||||||
|
|
||||||
|
getOpt(BuildContext context) async {
|
||||||
|
if (forgetPasswordFormKey.currentState.validate()) {
|
||||||
|
forgetPasswordFormKey.currentState.save();
|
||||||
|
await authenticationViewModel.getOpt(driverID);
|
||||||
|
if (authenticationViewModel.isError) {
|
||||||
|
Utils.showErrorToast(authenticationViewModel.error);
|
||||||
|
} else {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => VerificationPage()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
projectViewModel = Provider.of(context);
|
||||||
|
authenticationViewModel = Provider.of(context);
|
||||||
|
|
||||||
|
return AnimatedSwitcher(
|
||||||
|
duration: Duration(microseconds: 350),
|
||||||
|
child: AppScaffold(
|
||||||
|
isShowAppBar: false,
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: <Widget>[
|
||||||
|
FractionallySizedBox(
|
||||||
|
widthFactor: 0.80,
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.25,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
child: Icon(
|
||||||
|
DriverApp.qustion_mark,
|
||||||
|
size: 150,
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
),
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
top: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
"Forgot Password?",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
letterSpacing: 1,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 30,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Form(
|
||||||
|
key: forgetPasswordFormKey,
|
||||||
|
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)
|
||||||
|
.enterForgetIdMsg,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 13, color: Colors.grey),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
child: TextFields(
|
||||||
|
hintText: TranslationBase.of(context).enterId,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
validator: (value) {
|
||||||
|
if (value.isEmpty) {
|
||||||
|
return TranslationBase.of(context)
|
||||||
|
.pleaseEnterYourID;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
onSaved: (value) {
|
||||||
|
driverID = int.parse(value.trim());
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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: TranslationBase.of(context).getOPT,
|
||||||
|
onTap: () async {
|
||||||
|
await getOpt(context);
|
||||||
|
},
|
||||||
|
disabled: authenticationViewModel.isLoading,
|
||||||
|
loading: authenticationViewModel.isLoading,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 30,
|
||||||
|
),
|
||||||
|
SecondaryButton(
|
||||||
|
label: TranslationBase.of(context).cancel,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => RootPage()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
color: Color(0xffE9F1F1),
|
||||||
|
borderColor: Colors.black54,
|
||||||
|
textColor: Theme.of(context).primaryColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,200 @@
|
|||||||
|
import 'package:driverapp/app-icons/driver_app_icons.dart';
|
||||||
|
import 'package:driverapp/core/viewModels/authentication_view_model.dart';
|
||||||
|
import 'package:driverapp/core/viewModels/project_view_model.dart';
|
||||||
|
import 'package:driverapp/root_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/input/text_field.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';
|
||||||
|
|
||||||
|
// ignore: must_be_immutable
|
||||||
|
class RestPasswordPage extends StatelessWidget {
|
||||||
|
final forgetPasswordFormKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
// String password;
|
||||||
|
// String confirmedPassword;
|
||||||
|
ProjectViewModel projectViewModel;
|
||||||
|
AuthenticationViewModel authenticationViewModel;
|
||||||
|
TextEditingController password = TextEditingController(text: "");
|
||||||
|
TextEditingController confirmedPassword = TextEditingController(text: "");
|
||||||
|
|
||||||
|
changePassword(BuildContext context) async {
|
||||||
|
if (forgetPasswordFormKey.currentState.validate()) {
|
||||||
|
forgetPasswordFormKey.currentState.save();
|
||||||
|
await authenticationViewModel.changePassword(
|
||||||
|
password.text, confirmedPassword.text);
|
||||||
|
if (authenticationViewModel.isError) {
|
||||||
|
Utils.showErrorToast(authenticationViewModel.error);
|
||||||
|
} else {
|
||||||
|
AppToast.showSuccessToast(
|
||||||
|
message: "Your Password changed successfully");
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => RootPage()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
projectViewModel = Provider.of(context);
|
||||||
|
authenticationViewModel = Provider.of(context);
|
||||||
|
|
||||||
|
return AnimatedSwitcher(
|
||||||
|
duration: Duration(microseconds: 350),
|
||||||
|
child: AppScaffold(
|
||||||
|
isShowAppBar: false,
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: <Widget>[
|
||||||
|
FractionallySizedBox(
|
||||||
|
widthFactor: 0.80,
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.25,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
child: Icon(
|
||||||
|
DriverApp.qustion_mark,
|
||||||
|
size: 150,
|
||||||
|
color: Theme.of(context).primaryColor,
|
||||||
|
),
|
||||||
|
margin: EdgeInsets.only(
|
||||||
|
top: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: <Widget>[
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
"Rest Password",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
letterSpacing: 1,
|
||||||
|
fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 30,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Form(
|
||||||
|
key: forgetPasswordFormKey,
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
child: TextFields(
|
||||||
|
hintText: "Password",
|
||||||
|
controller: password,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
validator: (value) {
|
||||||
|
if (value.isEmpty) {
|
||||||
|
return "Please enter your password";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
onSaved: (value) {
|
||||||
|
// password = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
child: TextFields(
|
||||||
|
controller: confirmedPassword,
|
||||||
|
hintText: "Confirm Password",
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
validator: (value) {
|
||||||
|
if (value.isEmpty) {
|
||||||
|
return "Please enter your confirm password";
|
||||||
|
}
|
||||||
|
if (confirmedPassword.text != password.text) {
|
||||||
|
return "Password your doesn't match your confirm password";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
onSaved: (value) {
|
||||||
|
// confirmedPassword = value;
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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: "Change Password",
|
||||||
|
onTap: () async {
|
||||||
|
await changePassword(context);
|
||||||
|
},
|
||||||
|
disabled: authenticationViewModel.isLoading,
|
||||||
|
loading: authenticationViewModel.isLoading,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 30,
|
||||||
|
),
|
||||||
|
SecondaryButton(
|
||||||
|
label: TranslationBase.of(context).cancel,
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => RootPage()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
color: Color(0xffE9F1F1),
|
||||||
|
borderColor: Colors.black54,
|
||||||
|
textColor: Theme.of(context).primaryColor,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
))
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,430 @@
|
|||||||
|
import 'package:driverapp/app-icons/driver_app_icons.dart';
|
||||||
|
import 'package:driverapp/config/size_config.dart';
|
||||||
|
import 'package:driverapp/core/model/authentication/login_request.dart';
|
||||||
|
import 'package:driverapp/core/viewModels/authentication_view_model.dart';
|
||||||
|
import 'package:driverapp/core/viewModels/project_view_model.dart';
|
||||||
|
import 'package:driverapp/pages/authentication/reset_password_page.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 'forget_password_page.dart';
|
||||||
|
|
||||||
|
// ignore: must_be_immutable
|
||||||
|
class VerificationPage extends StatelessWidget {
|
||||||
|
LoginRequest loginRequest = LoginRequest();
|
||||||
|
final loginFormKey = GlobalKey<FormState>();
|
||||||
|
ProjectViewModel projectViewModel;
|
||||||
|
AuthenticationViewModel authenticationViewModel;
|
||||||
|
final verifyAccountForm = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
Map verifyAccountFormValue = {
|
||||||
|
'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: "");
|
||||||
|
|
||||||
|
login() async {
|
||||||
|
if (loginFormKey.currentState.validate()) {
|
||||||
|
loginFormKey.currentState.save();
|
||||||
|
await authenticationViewModel.login(loginRequest);
|
||||||
|
if (authenticationViewModel.isError) {
|
||||||
|
Utils.showErrorToast(authenticationViewModel.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SizedBox buildSizedBox([double height = 20]) {
|
||||||
|
return SizedBox(
|
||||||
|
height: height,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
projectViewModel = Provider.of(context);
|
||||||
|
authenticationViewModel = Provider.of(context);
|
||||||
|
// focusD1 = FocusNode();
|
||||||
|
// focusD2 = FocusNode();
|
||||||
|
// focusD3 = FocusNode();
|
||||||
|
// focusD4 = FocusNode();
|
||||||
|
|
||||||
|
String validateCodeDigit(value) {
|
||||||
|
if (value.isEmpty) {
|
||||||
|
return 'Please enter your Password';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return AnimatedSwitcher(
|
||||||
|
duration: Duration(microseconds: 350),
|
||||||
|
child: AppScaffold(
|
||||||
|
isShowAppBar: false,
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
child: Center(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: <Widget>[
|
||||||
|
FractionallySizedBox(
|
||||||
|
widthFactor: 0.80,
|
||||||
|
child: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
height: MediaQuery.of(context).size.height * 0.25,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
child: Icon(
|
||||||
|
DriverApp.exclamation_mark,
|
||||||
|
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: verifyAccountForm,
|
||||||
|
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)
|
||||||
|
.enterVerificationMsg,
|
||||||
|
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.white,
|
||||||
|
child: TextFormField(
|
||||||
|
textInputAction:
|
||||||
|
TextInputAction.next,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: SizeConfig
|
||||||
|
.textMultiplier *
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
focusNode: focusD1,
|
||||||
|
controller: digit1,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
keyboardType:
|
||||||
|
TextInputType.number,
|
||||||
|
decoration:
|
||||||
|
buildInputDecoration(
|
||||||
|
context),
|
||||||
|
onSaved: (val) {
|
||||||
|
verifyAccountFormValue[
|
||||||
|
'digit1'] = val;
|
||||||
|
},
|
||||||
|
validator: validateCodeDigit,
|
||||||
|
onFieldSubmitted: (_) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(focusD2);
|
||||||
|
},
|
||||||
|
onChanged: (val) {
|
||||||
|
if (val.length == 1) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(focusD2);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: 55,
|
||||||
|
height: 55,
|
||||||
|
color: Colors.white,
|
||||||
|
child: TextFormField(
|
||||||
|
focusNode: focusD2,
|
||||||
|
controller: digit2,
|
||||||
|
textInputAction:
|
||||||
|
TextInputAction.next,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: SizeConfig
|
||||||
|
.textMultiplier *
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
keyboardType:
|
||||||
|
TextInputType.number,
|
||||||
|
decoration:
|
||||||
|
buildInputDecoration(
|
||||||
|
context),
|
||||||
|
validator: validateCodeDigit,
|
||||||
|
onSaved: (val) {
|
||||||
|
verifyAccountFormValue[
|
||||||
|
'digit2'] = val;
|
||||||
|
},
|
||||||
|
onFieldSubmitted: (_) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(focusD3);
|
||||||
|
},
|
||||||
|
onChanged: (val) {
|
||||||
|
if (val.length == 1) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(focusD3);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
width: 55,
|
||||||
|
height: 55,
|
||||||
|
color: Colors.white,
|
||||||
|
child: TextFormField(
|
||||||
|
focusNode: focusD3,
|
||||||
|
controller: digit3,
|
||||||
|
textInputAction:
|
||||||
|
TextInputAction.next,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: SizeConfig
|
||||||
|
.textMultiplier *
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
keyboardType:
|
||||||
|
TextInputType.number,
|
||||||
|
decoration:
|
||||||
|
buildInputDecoration(
|
||||||
|
context),
|
||||||
|
validator: validateCodeDigit,
|
||||||
|
onSaved: (val) {
|
||||||
|
verifyAccountFormValue[
|
||||||
|
'digit3'] = val;
|
||||||
|
},
|
||||||
|
onFieldSubmitted: (_) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(focusD4);
|
||||||
|
},
|
||||||
|
onChanged: (val) {
|
||||||
|
if (val.length == 1) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(
|
||||||
|
focusD4);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)),
|
||||||
|
Container(
|
||||||
|
width: 55,
|
||||||
|
height: 55,
|
||||||
|
color: Colors.white,
|
||||||
|
child: TextFormField(
|
||||||
|
focusNode: focusD4,
|
||||||
|
controller: digit4,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: SizeConfig
|
||||||
|
.textMultiplier *
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
keyboardType:
|
||||||
|
TextInputType.number,
|
||||||
|
decoration:
|
||||||
|
buildInputDecoration(
|
||||||
|
context),
|
||||||
|
validator: validateCodeDigit,
|
||||||
|
onSaved: (val) {
|
||||||
|
verifyAccountFormValue[
|
||||||
|
'digit4'] = val;
|
||||||
|
},
|
||||||
|
onFieldSubmitted: (_) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(focusD4);
|
||||||
|
submit(model, context);
|
||||||
|
},
|
||||||
|
onChanged: (val) {
|
||||||
|
if (val.length == 1) {
|
||||||
|
FocusScope.of(context)
|
||||||
|
.requestFocus(
|
||||||
|
focusD4);
|
||||||
|
submit(model, context);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
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",
|
||||||
|
onTap: () {
|
||||||
|
submit(model, context);
|
||||||
|
},
|
||||||
|
disabled: authenticationViewModel.isLoading,
|
||||||
|
loading: authenticationViewModel.isLoading,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 10,
|
||||||
|
),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: <Widget>[
|
||||||
|
InkWell(
|
||||||
|
onTap: () {
|
||||||
|
Navigator.pushReplacement(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) =>
|
||||||
|
ForgetPasswordPage()),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
await authenticationViewModel
|
||||||
|
.getOpt(authenticationViewModel.userId);
|
||||||
|
},
|
||||||
|
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(
|
||||||
|
// ts/images/password_icon.png
|
||||||
|
contentPadding: EdgeInsets.only(top: 30, bottom: 30),
|
||||||
|
enabledBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||||
|
borderSide: BorderSide(color: Colors.black),
|
||||||
|
),
|
||||||
|
focusedBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||||
|
borderSide: BorderSide(color: Theme.of(context).primaryColor),
|
||||||
|
),
|
||||||
|
errorBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||||
|
borderSide: BorderSide(color: Theme.of(context).errorColor),
|
||||||
|
),
|
||||||
|
focusedErrorBorder: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(Radius.circular(10.0)),
|
||||||
|
borderSide: BorderSide(color: Theme.of(context).errorColor),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void submit(AuthenticationViewModel model, BuildContext context) async {
|
||||||
|
if (verifyAccountForm.currentState.validate()) {
|
||||||
|
final activationCode =
|
||||||
|
digit1.text + digit2.text + digit3.text + digit4.text;
|
||||||
|
|
||||||
|
await authenticationViewModel
|
||||||
|
.checkActivationCode(int.parse(activationCode));
|
||||||
|
if (authenticationViewModel.isError) {
|
||||||
|
Utils.showErrorToast(authenticationViewModel.error);
|
||||||
|
} else {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) => RestPasswordPage()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||