Compare commits
No commits in common. 'development' and 'merge_into_dev_9/13_final' have entirely different histories.
developmen
...
merge_into
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 544 B |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 442 B |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 721 B |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 1.4 KiB |
@ -1 +0,0 @@
|
|||||||
include ':app'
|
|
||||||
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 919 B |
|
Before Width: | Height: | Size: 54 KiB |
@ -1 +0,0 @@
|
|||||||
5fbd1cb9b58728098d7578fb656a1766
|
|
||||||
@ -1,6 +1,5 @@
|
|||||||
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';
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
class ResponseModel<T>{
|
|
||||||
bool isSuccessful = false;
|
|
||||||
String message;
|
|
||||||
T data;
|
|
||||||
|
|
||||||
isSuccessfull(Function(bool) callback){
|
|
||||||
callback(isSuccessful);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResponseModel({this.message, this.isSuccessful, this.data});
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
class ResponseInitiateOrderDelivery{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
class ResponseInitiateOrderDelivery{
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,141 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,453 +0,0 @@
|
|||||||
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),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,195 +0,0 @@
|
|||||||
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,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,200 +0,0 @@
|
|||||||
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,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
))
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,430 +0,0 @@
|
|||||||
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()),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,242 +0,0 @@
|
|||||||
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,84 @@
|
|||||||
|
import 'package:driverapp/pages/delivery/delivery_confirmed_page.dart';
|
||||||
|
import 'package:driverapp/pages/delivery/information_page.dart';
|
||||||
|
import 'package:driverapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:driverapp/widgets/bottom_navigation/bottom_nav_bar.dart';
|
||||||
|
import 'package:driverapp/widgets/drawer/app_drawer_widget.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'home_page.dart';
|
||||||
|
|
||||||
|
class LandingPage extends StatefulWidget {
|
||||||
|
@override
|
||||||
|
_LandingPageState createState() => _LandingPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _LandingPageState extends State<LandingPage> {
|
||||||
|
int currentTab = 0;
|
||||||
|
PageController pageController;
|
||||||
|
|
||||||
|
_changeCurrentTab(int tab) {
|
||||||
|
setState(() {
|
||||||
|
currentTab = tab;
|
||||||
|
pageController.jumpToPage(tab);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
pageController = PageController(keepPage: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
elevation: 0,
|
||||||
|
textTheme: TextTheme(
|
||||||
|
headline6:
|
||||||
|
TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
title: Text(getText(currentTab).toUpperCase()),
|
||||||
|
leading: Builder(
|
||||||
|
builder: (BuildContext context) {
|
||||||
|
return IconButton(
|
||||||
|
icon: Icon(Icons.menu),
|
||||||
|
color: Colors.white,
|
||||||
|
onPressed: () => Scaffold.of(context).openDrawer(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
centerTitle: true,
|
||||||
|
),
|
||||||
|
drawer: SafeArea(child: AppDrawer()),
|
||||||
|
extendBody: true,
|
||||||
|
body: PageView(
|
||||||
|
physics: NeverScrollableScrollPhysics(),
|
||||||
|
controller: pageController,
|
||||||
|
children: [
|
||||||
|
HomePage(),
|
||||||
|
InformationPage(null),
|
||||||
|
DeliveryConfirmedPage(null),
|
||||||
|
Container()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
bottomNavigationBar: BottomNavBar(changeIndex: _changeCurrentTab),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getText(currentTab) {
|
||||||
|
switch (currentTab) {
|
||||||
|
case 0:
|
||||||
|
return TranslationBase.of(context).home;
|
||||||
|
case 1:
|
||||||
|
return 'new One';
|
||||||
|
case 2:
|
||||||
|
return TranslationBase.of(context).booking;
|
||||||
|
case 3:
|
||||||
|
return TranslationBase.of(context).mySchedule;
|
||||||
|
case 4:
|
||||||
|
return TranslationBase.of(context).services;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,14 +0,0 @@
|
|||||||
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));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||