Skip to content

Commit

Permalink
Merge branch 'address-info'
Browse files Browse the repository at this point in the history
  • Loading branch information
amitash-217 committed May 7, 2023
2 parents 49e529c + 006c87a commit bb128db
Show file tree
Hide file tree
Showing 27 changed files with 1,521 additions and 600 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ linux/
macos/
plugins/
*.env
newbuild.sh

# IntelliJ related
*.iml
Expand Down Expand Up @@ -55,4 +56,5 @@ heresdk-explore-flutter-4.13.0.0.3315.tar.gz
/android/app/google-services.json
firebase_rules.txt
lib/firebase_options.dart
ios/firebase_app_id_file.json
ios/firebase_app_id_file.json
/book ambulance
42 changes: 42 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* Requires the Docker Pipeline plugin */
pipeline {
agent {
docker {
image 'am271/flutter-apk-builder:heresdk'
}
}
stages {
stage('extract-sdk') {
steps {
sh '''
sudo chown $UID:$GID -R $(pwd)
mkdir -p plugins/here_sdk
tar xzf /home/developer/heresdk-explore-flutter.tar.gz -C plugins/here_sdk
'''
}
}
stage('build') {
environment {
CREDS = credentials('navigation-credentials')
FIREBASE_CREDS = credentials('navigation-firebase-options')
}
steps {
sh '''
cat ${CREDS} > credentials.env
cat ${FIREBASE_CREDS} > lib/firebase_options.dart
flutter pub get
flutter build apk --debug
'''
}
}
stage('upload-apk') {
environment {
APITOKEN = credentials('navigation-api-token')
NGROK_URL = credentials('navigation-ngrok-url')
}
steps {
sh 'newbuild.sh'
}
}
}
}
Binary file added assets/ambulance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 50 additions & 24 deletions lib/ambulance_form.dart
Original file line number Diff line number Diff line change
@@ -1,33 +1,42 @@
import 'dart:convert';
import 'package:AmbiNav/app_screen_ui.dart';
import 'package:AmbiNav/grid.dart';
import 'package:AmbiNav/main.dart';
import 'package:AmbiNav/map_functions.dart';
import 'package:AmbiNav/services.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:crypto/crypto.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:hive_flutter/adapters.dart';

// User defined ambulance form widget
class AmbulanceForm extends StatefulWidget {
Services sobj;
AmbulanceForm({super.key, required this.sobj});
@override
AmbulanceFormState createState() {
return AmbulanceFormState();
}

String generateFormHash(String name, String age, String hospital) {
var bytes = utf8.encode(name + age + hospital);
var hash = sha256.convert(bytes);
return hash.toString();
}
}

// The form state class
class AmbulanceFormState extends State<AmbulanceForm> {
// a global key to validate form and identify widget
final _formKey = GlobalKey<FormState>();
final appTitle = 'Book an Ambulance';
// final AppScreen aobj = AppScreen();
TextEditingController patient_name = TextEditingController();
TextEditingController age = TextEditingController();
TextEditingController preferred_hosp = TextEditingController();
String? gender;

String generateFormHash(String name, String age, String hospital) {
var bytes = utf8.encode(name + age + hospital);
var hash = sha256.convert(bytes);
return hash.toString();
}

@override
Widget build(BuildContext context) {
return MaterialApp(
Expand Down Expand Up @@ -90,32 +99,49 @@ class AmbulanceFormState extends State<AmbulanceForm> {
child: new ElevatedButton(
child: const Text("Submit"),
onPressed: () async {
Services.ref =
FirebaseDatabase.instance.ref("Bookings");
//call to hashing function
String hashvalue = AmbulanceForm().generateFormHash(
patient_name.text, age.text, preferred_hosp.text);
Services.ref.update({
hashvalue: {
"patient_name": patient_name.text,
"age": age.text,
"preferred_hospital": preferred_hosp.text,
"gender": gender,
"user_location": {
"lat": Services.userLocation.latitude,
"lon": Services.userLocation.longitude,
}
}
});
_book();
//listen to firebase to plot path on user side
// ref.set({
// "patient_name": patient_name.text,
// "age": age.text,
// "preferred_hospital": preferred_hosp.text
// });
widget.sobj.goToUserLoc();
MapServices.mapController.camera.zoomTo(20);
while (MapServices.mapController.camera.boundingBox ==
null) {}
print("Grid is to be drawn after submit!");
Grid grid = Grid();
grid.isBooking = true;
Fluttertoast.showToast(msg: "Grid is shown");
Navigator.pop(context);
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: ((context) => AppScreen(
sobj: sobj,
grid: grid,
))));
// Fluttertoast.showToast(msg: "hahahah");
// grid.getGrid(true);
},
))
],
),
)));
}

void _book() async {
var box = await Hive.openBox('booking');
// GeoCoordinates userLoc = await MapServices().getCurrentLoc();

String hashvalue =
generateFormHash(patient_name.text, age.text, preferred_hosp.text);

box.put('name', patient_name.text);
box.put('age', age.text);
box.put('preferred_hosp', preferred_hosp.text);
box.put('gender', gender!);
box.put('lat', sobj.userLocation!.latitude);
box.put('lon', sobj.userLocation!.longitude);
box.put('hash', hashvalue);
}
}
Loading

0 comments on commit bb128db

Please sign in to comment.