parking service
parent
4adc2916b4
commit
895c09efa4
@ -0,0 +1,172 @@
|
||||
class QRParkingModel {
|
||||
Null totalRecords;
|
||||
Null nRowID;
|
||||
int qRParkingID;
|
||||
String description;
|
||||
String descriptionN;
|
||||
Null qRCompare;
|
||||
Null qRValue;
|
||||
String imagePath;
|
||||
bool isActive;
|
||||
int parkingID;
|
||||
int branchID;
|
||||
int companyID;
|
||||
int buildingID;
|
||||
int rowID;
|
||||
int gateID;
|
||||
int floorID;
|
||||
Null imagePath1;
|
||||
int createdBy;
|
||||
String createdOn;
|
||||
Null editedBy;
|
||||
Null editedOn;
|
||||
String parkingDescription;
|
||||
String parkingDescriptionN;
|
||||
String gateDescription;
|
||||
String gateDescriptionN;
|
||||
String branchDescription;
|
||||
String branchDescriptionN;
|
||||
String companyDescription;
|
||||
String companyDescriptionN;
|
||||
String rowDescription;
|
||||
String rowDescriptionN;
|
||||
String floorDescription;
|
||||
String floorDescriptionN;
|
||||
String buildingDescription;
|
||||
String buildingDescriptionN;
|
||||
String qRParkingCode;
|
||||
String parkingCode;
|
||||
double latitude;
|
||||
double longitude;
|
||||
String qRImageStr;
|
||||
|
||||
QRParkingModel(
|
||||
{this.totalRecords,
|
||||
this.nRowID,
|
||||
this.qRParkingID,
|
||||
this.description,
|
||||
this.descriptionN,
|
||||
this.qRCompare,
|
||||
this.qRValue,
|
||||
this.imagePath,
|
||||
this.isActive,
|
||||
this.parkingID,
|
||||
this.branchID,
|
||||
this.companyID,
|
||||
this.buildingID,
|
||||
this.rowID,
|
||||
this.gateID,
|
||||
this.floorID,
|
||||
this.imagePath1,
|
||||
this.createdBy,
|
||||
this.createdOn,
|
||||
this.editedBy,
|
||||
this.editedOn,
|
||||
this.parkingDescription,
|
||||
this.parkingDescriptionN,
|
||||
this.gateDescription,
|
||||
this.gateDescriptionN,
|
||||
this.branchDescription,
|
||||
this.branchDescriptionN,
|
||||
this.companyDescription,
|
||||
this.companyDescriptionN,
|
||||
this.rowDescription,
|
||||
this.rowDescriptionN,
|
||||
this.floorDescription,
|
||||
this.floorDescriptionN,
|
||||
this.buildingDescription,
|
||||
this.buildingDescriptionN,
|
||||
this.qRParkingCode,
|
||||
this.parkingCode,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.qRImageStr});
|
||||
|
||||
QRParkingModel.fromJson(Map<String, dynamic> json) {
|
||||
totalRecords = json['TotalRecords'];
|
||||
nRowID = json['nRowID'];
|
||||
qRParkingID = json['QRParkingID'];
|
||||
description = json['Description'];
|
||||
descriptionN = json['DescriptionN'];
|
||||
qRCompare = json['QRCompare'];
|
||||
qRValue = json['QRValue'];
|
||||
imagePath = json['ImagePath'];
|
||||
isActive = json['IsActive'];
|
||||
parkingID = json['ParkingID'];
|
||||
branchID = json['BranchID'];
|
||||
companyID = json['CompanyID'];
|
||||
buildingID = json['BuildingID'];
|
||||
rowID = json['RowID'];
|
||||
gateID = json['GateID'];
|
||||
floorID = json['FloorID'];
|
||||
imagePath1 = json['ImagePath1'];
|
||||
createdBy = json['CreatedBy'];
|
||||
createdOn = json['CreatedOn'];
|
||||
editedBy = json['EditedBy'];
|
||||
editedOn = json['EditedOn'];
|
||||
parkingDescription = json['ParkingDescription'];
|
||||
parkingDescriptionN = json['ParkingDescriptionN'];
|
||||
gateDescription = json['GateDescription'];
|
||||
gateDescriptionN = json['GateDescriptionN'];
|
||||
branchDescription = json['BranchDescription'];
|
||||
branchDescriptionN = json['BranchDescriptionN'];
|
||||
companyDescription = json['CompanyDescription'];
|
||||
companyDescriptionN = json['CompanyDescriptionN'];
|
||||
rowDescription = json['RowDescription'];
|
||||
rowDescriptionN = json['RowDescriptionN'];
|
||||
floorDescription = json['FloorDescription'];
|
||||
floorDescriptionN = json['FloorDescriptionN'];
|
||||
buildingDescription = json['BuildingDescription'];
|
||||
buildingDescriptionN = json['BuildingDescriptionN'];
|
||||
qRParkingCode = json['QRParkingCode'];
|
||||
parkingCode = json['ParkingCode'];
|
||||
latitude = json['Latitude'];
|
||||
longitude = json['Longitude'];
|
||||
qRImageStr = json['QRImageStr'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['TotalRecords'] = this.totalRecords;
|
||||
data['nRowID'] = this.nRowID;
|
||||
data['QRParkingID'] = this.qRParkingID;
|
||||
data['Description'] = this.description;
|
||||
data['DescriptionN'] = this.descriptionN;
|
||||
data['QRCompare'] = this.qRCompare;
|
||||
data['QRValue'] = this.qRValue;
|
||||
data['ImagePath'] = this.imagePath;
|
||||
data['IsActive'] = this.isActive;
|
||||
data['ParkingID'] = this.parkingID;
|
||||
data['BranchID'] = this.branchID;
|
||||
data['CompanyID'] = this.companyID;
|
||||
data['BuildingID'] = this.buildingID;
|
||||
data['RowID'] = this.rowID;
|
||||
data['GateID'] = this.gateID;
|
||||
data['FloorID'] = this.floorID;
|
||||
data['ImagePath1'] = this.imagePath1;
|
||||
data['CreatedBy'] = this.createdBy;
|
||||
data['CreatedOn'] = this.createdOn;
|
||||
data['EditedBy'] = this.editedBy;
|
||||
data['EditedOn'] = this.editedOn;
|
||||
data['ParkingDescription'] = this.parkingDescription;
|
||||
data['ParkingDescriptionN'] = this.parkingDescriptionN;
|
||||
data['GateDescription'] = this.gateDescription;
|
||||
data['GateDescriptionN'] = this.gateDescriptionN;
|
||||
data['BranchDescription'] = this.branchDescription;
|
||||
data['BranchDescriptionN'] = this.branchDescriptionN;
|
||||
data['CompanyDescription'] = this.companyDescription;
|
||||
data['CompanyDescriptionN'] = this.companyDescriptionN;
|
||||
data['RowDescription'] = this.rowDescription;
|
||||
data['RowDescriptionN'] = this.rowDescriptionN;
|
||||
data['FloorDescription'] = this.floorDescription;
|
||||
data['FloorDescriptionN'] = this.floorDescriptionN;
|
||||
data['BuildingDescription'] = this.buildingDescription;
|
||||
data['BuildingDescriptionN'] = this.buildingDescriptionN;
|
||||
data['QRParkingCode'] = this.qRParkingCode;
|
||||
data['ParkingCode'] = this.parkingCode;
|
||||
data['Latitude'] = this.latitude;
|
||||
data['Longitude'] = this.longitude;
|
||||
data['QRImageStr'] = this.qRImageStr;
|
||||
return data;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
import 'package:diplomaticquarterapp/config/config.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/qr/qr_parking_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
||||
|
||||
class QrService extends BaseService {
|
||||
List<QRParkingModel> qRParkingList = List();
|
||||
|
||||
Future getQRParkingByID(int qRParkingID) async {
|
||||
Map<String, dynamic> body = Map();
|
||||
body['QRParkingID'] = qRParkingID;
|
||||
await baseAppClient.post(GET_QR_PARKING,
|
||||
onSuccess: (dynamic response, int statusCode) {
|
||||
response['List_SWP_QRParkingModel'].forEach((item) {
|
||||
qRParkingList.add(QRParkingModel.fromJson(item));
|
||||
});
|
||||
}, onFailure: (String error, int statusCode) {
|
||||
hasError = true;
|
||||
super.error = error;
|
||||
}, body: body);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:barcode_scan/platform_wrapper.dart';
|
||||
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/qr/qr_parking_model.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/qr_service.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
||||
import '../../locator.dart';
|
||||
|
||||
class QrViewModel extends BaseViewModel {
|
||||
QrService _qrService = locator<QrService>();
|
||||
bool isSavePark = false;
|
||||
QRParkingModel qrParkingModel;
|
||||
|
||||
readQr() async {
|
||||
var result = await BarcodeScanner.scan();
|
||||
var data = json.decode(result.rawContent);
|
||||
var qRParkingID = data['QRParkingID'];
|
||||
setState(ViewState.BusyLocal);
|
||||
await _qrService.getQRParkingByID(qRParkingID);
|
||||
if (_qrService.hasError) {
|
||||
error = _qrService.error;
|
||||
setState(ViewState.ErrorLocal);
|
||||
} else {
|
||||
if (_qrService.qRParkingList.length > 0) {
|
||||
qrParkingModel = _qrService.qRParkingList[0];
|
||||
await sharedPref.setObject(IS_GO_TO_PARKING, qrParkingModel);
|
||||
isSavePark = true;
|
||||
setState(ViewState.Idle);
|
||||
} else {
|
||||
error = "Invalid Qr Code";
|
||||
setState(ViewState.ErrorLocal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getIsSaveParking() async {
|
||||
setState(ViewState.Busy);
|
||||
var parking = await sharedPref.getObject(IS_GO_TO_PARKING);
|
||||
if (parking != null) {
|
||||
isSavePark = true;
|
||||
qrParkingModel = QRParkingModel.fromJson(parking);
|
||||
}
|
||||
setState(ViewState.Busy);
|
||||
}
|
||||
|
||||
clearParking() async {
|
||||
setState(ViewState.Busy);
|
||||
await sharedPref.setObject(IS_GO_TO_PARKING, null);
|
||||
isSavePark = false;
|
||||
qrParkingModel = null;
|
||||
setState(ViewState.Idle);
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
import 'package:diplomaticquarterapp/pages/AlHabibMedicalService/parking_page.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AllHabibMedicalService extends StatefulWidget {
|
||||
@override
|
||||
_AllHabibMedicalServiceState createState() => _AllHabibMedicalServiceState();
|
||||
}
|
||||
|
||||
class _AllHabibMedicalServiceState extends State<AllHabibMedicalService> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppScaffold(
|
||||
isShowAppBar: true,
|
||||
appBarTitle: TranslationBase.of(context).alhabiServices,
|
||||
body: ListView(
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
onTap: ()=> Navigator.push(context, FadePage(page: ParkingPage())),
|
||||
child: Container(
|
||||
height: 50,
|
||||
margin: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.rectangle,
|
||||
borderRadius: BorderRadius.circular(7),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Texts(
|
||||
TranslationBase.of(context).parking,
|
||||
fontSize: 16,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,211 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/qr_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/buttons/secondary_button.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:maps_launcher/maps_launcher.dart';
|
||||
|
||||
class ParkingPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseView<QrViewModel>(
|
||||
onModelReady: (model) => model.getIsSaveParking(),
|
||||
builder: (_, model, widget) => AppScaffold(
|
||||
isShowAppBar: true,
|
||||
appBarTitle: TranslationBase.of(context).parking,
|
||||
body: SingleChildScrollView(
|
||||
padding: EdgeInsets.all(12),
|
||||
child: !model.isSavePark
|
||||
? Column(
|
||||
children: <Widget>[
|
||||
Texts(
|
||||
TranslationBase.of(context).parkingTitle,
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 15,
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Image.asset(
|
||||
'assets/images/timeline_bg.png',
|
||||
width: double.infinity,
|
||||
)
|
||||
],
|
||||
)
|
||||
: Column(
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Image.asset(
|
||||
'assets/images/timeline_bg.png',
|
||||
height: 150,
|
||||
fit: BoxFit.cover,
|
||||
)),
|
||||
SizedBox(
|
||||
width: 15,
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
height: 150,
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
shape: BoxShape.rectangle),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Texts(model.qrParkingModel.parkingDescriptionN),
|
||||
Divider(
|
||||
height: 3,
|
||||
),
|
||||
Texts(model.qrParkingModel.rowDescriptionN)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
shape: BoxShape.rectangle),
|
||||
height: 70,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Texts(TranslationBase.of(context).showMyPark),
|
||||
Texts(model.qrParkingModel.floorDescriptionN),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
shape: BoxShape.rectangle),
|
||||
padding: EdgeInsets.all(8),
|
||||
width: double.infinity,
|
||||
height: 70,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Texts(TranslationBase.of(context).gate),
|
||||
Texts(model.qrParkingModel.gateDescriptionN),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
shape: BoxShape.rectangle),
|
||||
padding: EdgeInsets.all(8),
|
||||
width: double.infinity,
|
||||
height: 70,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Texts(TranslationBase.of(context).building),
|
||||
Texts(model.qrParkingModel.buildingDescriptionN),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.white,
|
||||
shape: BoxShape.rectangle),
|
||||
width: double.infinity,
|
||||
height: 70,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Texts(TranslationBase.of(context).branch),
|
||||
Texts(model.qrParkingModel.branchDescriptionN),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 15,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
bottomSheet: !model.isSavePark
|
||||
? Container(
|
||||
height: MediaQuery.of(context).size.height * 0.10,
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.9,
|
||||
child: SecondaryButton(
|
||||
onTap: () async {
|
||||
model.readQr();
|
||||
},
|
||||
label: TranslationBase.of(context).readBarcode,
|
||||
loading: model.state == ViewState.BusyLocal,
|
||||
textColor: Theme.of(context).backgroundColor),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: Container(
|
||||
height: MediaQuery.of(context).size.height * 0.15,
|
||||
width: double.infinity,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.9,
|
||||
child: SecondaryButton(
|
||||
onTap: () async {
|
||||
MapsLauncher.launchCoordinates(
|
||||
model.qrParkingModel.latitude,
|
||||
model.qrParkingModel.longitude,
|
||||
);
|
||||
},
|
||||
disabled: model.qrParkingModel.longitude == 0,
|
||||
label: TranslationBase.of(context).showMyPark,
|
||||
textColor: Theme.of(context).backgroundColor),
|
||||
),
|
||||
SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
InkWell(
|
||||
onTap: () => model.clearParking(),
|
||||
child: Texts(
|
||||
TranslationBase.of(context).clearMyData,
|
||||
color: Colors.red,
|
||||
decoration: TextDecoration.underline,
|
||||
))
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue