diff --git a/rescueapp/lib/MyHomePage2.dart b/rescueapp/lib/MyHomePage2.dart new file mode 100644 index 0000000000000000000000000000000000000000..0cb78b90145ff8dacc06493ee7a602bd55f86af3 --- /dev/null +++ b/rescueapp/lib/MyHomePage2.dart @@ -0,0 +1,133 @@ + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:rescueapp/CameraAcess.dart'; + + + +import 'model-patient/patient.dart'; + +class MyHomePage2 extends StatefulWidget { + MyHomePage2({this.patient, this.patientIndex, Key key, this.title}) : super(key: key); + final String title; + final Patient patient; + final int patientIndex; + + @override + _MyHomePageState createState() => _MyHomePageState(); +} +class _MyHomePageState extends State<MyHomePage2> { + bool _isAmbilatory; + final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('KatApp2'), + ), + body: Padding( + padding: EdgeInsets.symmetric(horizontal:40,vertical: 10), + child: Column( + + children: <Widget>[ + SizedBox( + height: 40, + child: Container( + + decoration: BoxDecoration( + color: Colors.grey[500] + ), + alignment: Alignment.center, + child:Text('Ist der Patient gehfähig?' , style: TextStyle(fontSize: 22, color: Colors.blue[900])), + ) + ), + + SizedBox( + height: 40, + + child: Container( + decoration: BoxDecoration( + color: Colors.grey[500] + ), + + alignment: Alignment.center, + child:Text('Nein', style: TextStyle(fontSize: 20, color: Colors.blue [900], backgroundColor: Colors.grey[500])), + )), + SizedBox( + height: 150,), + SizedBox( + height: 50, + + + child: Container( + + alignment: Alignment.center, + + decoration: BoxDecoration( + border: Border( + left: BorderSide(color: Colors.red, width: 2), + right: BorderSide(color: Colors.red, width: 2), + top: BorderSide(color: Colors.red, width: 2), + + ),), + child:Text('Kategorie A', style: TextStyle(fontSize: 22, fontWeight: FontWeight.w700, color: Colors.blue[900], backgroundColor: Colors.white)), + )), + + SizedBox( + height: 50, + width: 500, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + border: Border( + left: BorderSide(color: Colors.red, width: 2), + right: BorderSide(color: Colors.red, width: 2), + bottom: BorderSide(color: Colors.red, width: 2), + + ),), + child:Text('Spontanatmung vorhanden?', style: TextStyle(fontSize: 22, fontWeight: FontWeight.w700, color: Colors.blue[900], backgroundColor: Colors.white)), + )), + SizedBox( + height: 100, + ), + SizedBox( + + child: Container( + width: double.infinity, + alignment: Alignment.center, + child:RaisedButton(child: new Text('Ja'), color: Colors.blue, + onPressed: () { + setState(() { + _isAmbilatory = true; + Navigator.push( + context, + MaterialPageRoute(builder: (context) => CameraAccess()), + ); + }); + }))), + SizedBox( + child: Container( + alignment: Alignment.center, + child:RaisedButton(child: new Text('Nein'), color: Colors.blue, + onPressed: () { + setState(() { + _isAmbilatory = false; + + }); + }))), + SizedBox( + width: 200, + child: Container( + alignment: Alignment.center, + child:ElevatedButton(child: new Text('Zurück'), onPressed: () { + Navigator.pop(context); + }))), + ], + ), + ), + ); +} +} + + + diff --git a/rescueapp/lib/MyHomePage3.dart b/rescueapp/lib/MyHomePage3.dart new file mode 100644 index 0000000000000000000000000000000000000000..43a1785056e2d6855dd5988f18aa44c1cc1e7c97 --- /dev/null +++ b/rescueapp/lib/MyHomePage3.dart @@ -0,0 +1,156 @@ + +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:rescueapp/CameraAcess.dart'; + + + +import 'model-patient/patient.dart'; + +class MyHomePage3 extends StatefulWidget { + MyHomePage3({this.patient, this.patientIndex, Key key, this.title}) : super(key: key); + final String title; + final Patient patient; + final int patientIndex; + + @override + _MyHomePageState createState() => _MyHomePageState(); +} +class _MyHomePageState extends State<MyHomePage3> { + bool _isAmbilatory; + final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text('KatApp2'), + ), + body: Padding( + padding: EdgeInsets.symmetric(horizontal:40,vertical: 10), + child: Column( + + children: <Widget>[ + SizedBox( + height: 40, + child: Container( + + decoration: BoxDecoration( + color: Colors.grey[500] + ), + alignment: Alignment.center, + child:Text('Ist der Patient gehfähig?' , style: TextStyle(fontSize: 22, color: Colors.blue[900])), + ) + ), + + SizedBox( + height: 40, + + child: Container( + decoration: BoxDecoration( + color: Colors.grey[500] + ), + + alignment: Alignment.center, + child:Text('Nein', style: TextStyle(fontSize: 20, color: Colors.blue [900], backgroundColor: Colors.grey[500])), + )), + SizedBox( + height: 40, + + child: Container( + decoration: BoxDecoration( + color: Colors.grey[500] + ), + + alignment: Alignment.center, + child:Text('A:Spontanatmung vorhanden?', style: TextStyle(fontSize: 20, color: Colors.blue [900], backgroundColor: Colors.grey[500])), + )), + SizedBox( + height: 40, + + child: Container( + decoration: BoxDecoration( + color: Colors.grey[500] + ), + + alignment: Alignment.center, + child:Text('Nein', style: TextStyle(fontSize: 20, color: Colors.blue [900], backgroundColor: Colors.grey[500])), + )), + SizedBox( + height: 100,), + + SizedBox( + height: 50, + + + child: Container( + + alignment: Alignment.center, + + decoration: BoxDecoration( + border: Border( + left: BorderSide(color: Colors.red, width: 2), + right: BorderSide(color: Colors.red, width: 2), + top: BorderSide(color: Colors.red, width: 2), + + ),), + child:Text('Kategorie A', style: TextStyle(fontSize: 22, fontWeight: FontWeight.w700, color: Colors.blue[900], backgroundColor: Colors.white)), + )), + + SizedBox( + height: 50, + width: 500, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + border: Border( + left: BorderSide(color: Colors.red, width: 2), + right: BorderSide(color: Colors.red, width: 2), + bottom: BorderSide(color: Colors.red, width: 2), + + ),), + child:Text('Nach Öffnung der Atemwege?', style: TextStyle(fontSize: 22, fontWeight: FontWeight.w700, color: Colors.blue[900], backgroundColor: Colors.white)), + )), + SizedBox( + height: 100, + ), + SizedBox( + + child: Container( + width: double.infinity, + alignment: Alignment.center, + child:RaisedButton(child: new Text('Ja'), color: Colors.blue, + onPressed: () { + setState(() { + _isAmbilatory = true; + Navigator.push( + context, + MaterialPageRoute(builder: (context) => CameraAccess()), + ); + }); + }))), + SizedBox( + child: Container( + alignment: Alignment.center, + child:RaisedButton(child: new Text('Nein'), color: Colors.blue, + onPressed: () { + setState(() { + _isAmbilatory = false; + + }); + }))), + SizedBox( + width: 200, + child: Container( + alignment: Alignment.center, + child:ElevatedButton(child: new Text('Zurück'), onPressed: () { + Navigator.pop(context); + }))), + ], + ), + ), + ); +} +} + + + diff --git a/rescueapp/lib/bloc_patient/patient_bloc.dart b/rescueapp/lib/bloc_patient/patient_bloc.dart new file mode 100644 index 0000000000000000000000000000000000000000..95321ac66646b4bcf812041d02ce4116e008b3f0 --- /dev/null +++ b/rescueapp/lib/bloc_patient/patient_bloc.dart @@ -0,0 +1,36 @@ + + +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:rescueapp/events-patient/add_patient.dart'; +import 'package:rescueapp/events-patient/delete_patient.dart'; +import 'package:rescueapp/events-patient/patient_event.dart'; +import 'package:rescueapp/events-patient/set_patient.dart'; +import 'package:rescueapp/events-patient/update_patient.dart'; +import 'package:rescueapp/model-patient/patient.dart'; + +class PatientBloc extends Bloc<PatientEvent, List<Patient>> { + @override + List<Patient> get initialState => List<Patient>(); +// events wird definiert durch PatientEvent. + // mapEventToState wird aufgerufen um das bestimmte event mit einem bestimmten status zu definieren + @override + Stream<List<Patient>> mapEventToState(PatientEvent event) async* { + if (event is SetPatient) { + yield event.patientList; + } else if (event is AddPatient) { + List<Patient> newState = List.from(state); + if (event.newPatient != null) { + newState.add(event.newPatient); + } + yield newState; + } else if (event is DeletePatient) { + List<Patient> newState = List.from(state); + newState.removeAt(event.patientIndex); + yield newState; + } else if (event is UpdatePatient) { + List<Patient> newState = List.from(state); + newState[event.patientIndex] = event.newPatient; + yield newState; + } + } +} \ No newline at end of file diff --git a/rescueapp/lib/database/database_provide.dart b/rescueapp/lib/database/database_provide.dart new file mode 100644 index 0000000000000000000000000000000000000000..b4f47c1587f2a5a8f60983989745c24897924114 --- /dev/null +++ b/rescueapp/lib/database/database_provide.dart @@ -0,0 +1,108 @@ + +import 'package:path/path.dart'; +import 'package:rescueapp/model-patient/patient.dart'; +import 'package:sqflite/sqflite.dart'; +import 'package:sqflite/sqlite_api.dart'; + +//Einige asynchronous Operationen sind: +// Daten über ein Netzwerk abrufen +// Eine Datenbank zu schreiben +//Asynchronisierung +// Daten aus einem File lesen: Async means that this function is asynchronous and you might need to wait a bit to get its result. +// Await literally means - wait here until this function is finished and you will get its return value. +class DatabaseProvider { + static const String TABLE_PATIENT = "patient"; + static const String COLUMN_ID = "id"; + static const String COLUMN_NAME = "name"; + static const String COLUMN_BIRTHDAY = "geburtsdatum"; + static const String COLUMN_ISAMBILATORY = "isGehfähig"; + static const String COLUMN_IMAGEPATH = "imagePath"; + static const String COLUMN_CATEGORIE = "category"; + +// Constructor + DatabaseProvider._(); + static final DatabaseProvider db = DatabaseProvider._(); + + Database _database; + + Future <Database> get database async { + print("database getter called"); + + if (_database != null) { + return _database; + } + + _database = await createDatabase(); + + return _database; + } + + Future<Database> createDatabase() async { + String dbPath = await getDatabasesPath(); + + return await openDatabase( + join(dbPath, 'patientDB.db'), + version: 1, + onCreate: (Database database, int version) async { + print("Creating patient table"); + + await database.execute( + "CREATE TABLE $TABLE_PATIENT (" + "$COLUMN_ID INTEGER PRIMARY KEY," + "$COLUMN_NAME TEXT," + "$COLUMN_BIRTHDAY TEXT," + "$COLUMN_ISAMBILATORY INTEGER," + "$COLUMN_IMAGEPATH STRING," + "$COLUMN_CATEGORIE STRING," + + + ")", + ); + }, + ); + } + + Future<List<Patient>> getPatients() async { + final db = await database; + + var patients = await db + .query(TABLE_PATIENT, columns: [COLUMN_ID, COLUMN_NAME, COLUMN_IMAGEPATH,COLUMN_BIRTHDAY, COLUMN_ISAMBILATORY, COLUMN_CATEGORIE]); + + List<Patient> patientList = List<Patient>(); + + patients.forEach((currentPatient) { + Patient patient = Patient.fromMap(currentPatient); + + patientList.add(patient); + }); + + return patientList; + } + + Future<Patient> insert(Patient patient) async { + final db = await database; + patient.id = await db.insert(TABLE_PATIENT, patient.toMap()); + return patient; + } + + Future<int> delete(int id) async { + final db = await database; + + return await db.delete( + TABLE_PATIENT, + where: "id = ?", + whereArgs: [id], + ); + } + + Future<int> update(Patient patient) async { + final db = await database; + + return await db.update( + TABLE_PATIENT, + patient.toMap(), + where: "id = ?", + whereArgs: [patient.id], + ); + } +} \ No newline at end of file diff --git a/rescueapp/lib/events-patient/add_patient.dart b/rescueapp/lib/events-patient/add_patient.dart new file mode 100644 index 0000000000000000000000000000000000000000..0401323c339e90ba332e6aa117fecf3bf5222f87 --- /dev/null +++ b/rescueapp/lib/events-patient/add_patient.dart @@ -0,0 +1,10 @@ +import 'package:rescueapp/events-patient/patient_event.dart'; +import 'package:rescueapp/model-patient/patient.dart'; + +class AddPatient extends PatientEvent { + Patient newPatient; + + AddPatient(Patient patient) { + newPatient = patient; + } +} diff --git a/rescueapp/lib/events-patient/delete_patient.dart b/rescueapp/lib/events-patient/delete_patient.dart new file mode 100644 index 0000000000000000000000000000000000000000..f01bc37e564799b9a77db98a189a4369d02cf1e2 --- /dev/null +++ b/rescueapp/lib/events-patient/delete_patient.dart @@ -0,0 +1,9 @@ +import 'package:rescueapp/events-patient/patient_event.dart'; + +class DeletePatient extends PatientEvent { + int patientIndex; + + DeletePatient(int index) { + patientIndex = index; + } +} \ No newline at end of file diff --git a/rescueapp/lib/events-patient/patient_event.dart b/rescueapp/lib/events-patient/patient_event.dart new file mode 100644 index 0000000000000000000000000000000000000000..5859e1eb2a1c7b76980c97fc91768a1fa21a49e7 --- /dev/null +++ b/rescueapp/lib/events-patient/patient_event.dart @@ -0,0 +1 @@ +abstract class PatientEvent {} \ No newline at end of file diff --git a/rescueapp/lib/events-patient/set_patient.dart b/rescueapp/lib/events-patient/set_patient.dart new file mode 100644 index 0000000000000000000000000000000000000000..edc8e899eb4e6bad7f4dd14515f831385e90f951 --- /dev/null +++ b/rescueapp/lib/events-patient/set_patient.dart @@ -0,0 +1,10 @@ +import 'package:rescueapp/events-patient/patient_event.dart'; +import 'package:rescueapp/model-patient/patient.dart'; + +class SetPatient extends PatientEvent { + List<Patient> patientList; + + SetPatient(List<Patient> patient) { + patientList = patient; + } +} \ No newline at end of file diff --git a/rescueapp/lib/events-patient/update_patient.dart b/rescueapp/lib/events-patient/update_patient.dart new file mode 100644 index 0000000000000000000000000000000000000000..3f59f8656fe485bb334f7cc203c4e7c0a38965ad --- /dev/null +++ b/rescueapp/lib/events-patient/update_patient.dart @@ -0,0 +1,14 @@ +import 'package:rescueapp/events-patient/patient_event.dart'; +import 'package:rescueapp/model-patient/patient.dart'; + + + +class UpdatePatient extends PatientEvent { + Patient newPatient; + int patientIndex; + + UpdatePatient(int index, Patient patient) { + newPatient = patient; + patientIndex = index; + } +} \ No newline at end of file diff --git a/rescueapp/lib/main.dart b/rescueapp/lib/main.dart index f668cd5fb7af52abf17907705e84d6a01852cbf4..91c6ac40868c981cc7dfe2998c308ac08e5d9b61 100644 --- a/rescueapp/lib/main.dart +++ b/rescueapp/lib/main.dart @@ -1,5 +1,8 @@ +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'MyHomePage2.dart'; + void main() { runApp(MyApp()); } @@ -11,103 +14,58 @@ class MyApp extends StatelessWidget { return MaterialApp( title: 'KatApp', theme: ThemeData( - // This is the theme of your application. - // - // Try running your application with "flutter run". You'll see the - // application has a blue toolbar. Then, without quitting the app, try - // changing the primarySwatch below to Colors.green and then invoke - // "hot reload" (press "r" in the console where you ran "flutter run", - // or simply save your changes to "hot reload" in a Flutter IDE). - // Notice that the counter didn't reset back to zero; the application - // is not restarted. - primarySwatch: Colors.blue, + primarySwatch: Colors.blue, ), - home: MyHomePage(title: 'KatApp Home Page'), + home: MyHomePage() + //home: MyHomePage(title: 'KatApp Home Page'), ); } } -class MyHomePage extends StatefulWidget { - MyHomePage({Key key, this.title}) : super(key: key); - - // This widget is the home page of your application. It is stateful, meaning - // that it has a State object (defined below) that contains fields that affect - // how it looks. - - // This class is the configuration for the state. It holds the values (in this - // case the title) provided by the parent (in this case the App widget) and - // used by the build method of the State. Fields in a Widget subclass are - // always marked "final". - - final String title; - - @override - _MyHomePageState createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State<MyHomePage> { - int _counter = 0; - - void _incrementCounter() { - setState(() { - // This call to setState tells the Flutter framework that something has - // changed in this State, which causes it to rerun the build method below - // so that the display can reflect the updated values. If we changed - // _counter without calling setState(), then the build method would not be - // called again, and so nothing would appear to happen. - _counter++; - }); - } - +class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { - // This method is rerun every time setState is called, for instance as done - // by the _incrementCounter method above. - // - // The Flutter framework has been optimized to make rerunning build methods - // fast, so that you can just rebuild anything that needs updating rather - // than having to individually change instances of widgets. return Scaffold( appBar: AppBar( - // Here we take the value from the MyHomePage object that was created by - // the App.build method, and use it to set our appbar title. - title: Text(widget.title), + title: Text('KatApp Startseite'), ), - body: Center( - // Center is a layout widget. It takes a single child and positions it - // in the middle of the parent. + + body: Center( child: Column( - // Column is also a layout widget. It takes a list of children and - // arranges them vertically. By default, it sizes itself to fit its - // children horizontally, and tries to be as tall as its parent. - // - // Invoke "debug painting" (press "p" in the console, choose the - // "Toggle Debug Paint" action from the Flutter Inspector in Android - // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) - // to see the wireframe for each widget. - // - // Column has various properties to control how it sizes itself and - // how it positions its children. Here we use mainAxisAlignment to - // center the children vertically; the main axis here is the vertical - // axis because Columns are vertical (the cross axis would be - // horizontal). - mainAxisAlignment: MainAxisAlignment.center, - children: <Widget>[ - Text( - 'You have pushed the button this many times:', - ), - Text( - '$_counter', - style: Theme.of(context).textTheme.headline4, - ), - ], + children: <Widget>[ + SizedBox( + height: 250, + ), + SizedBox( + child: Container ( + child: RaisedButton( + child: Text('ÜBUNG', style: TextStyle(fontSize: 22, color: Colors.white,)), + color: Colors.green, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => MyHomePage2()), + ); + }, + )) + ), + SizedBox ( + height: 20, + ), + SizedBox ( + child: Container ( + child: RaisedButton( + child: Text('REAL',style: TextStyle(fontSize: 22, color: Colors.white)), + color: Colors.red, + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => MyHomePage()), + );} + ) ),), + ], ), ), - floatingActionButton: FloatingActionButton( - onPressed: _incrementCounter, - tooltip: 'Increment', - child: Icon(Icons.add), - ), // This trailing comma makes auto-formatting nicer for build methods. ); } } diff --git a/rescueapp/lib/model-patient/patient.dart b/rescueapp/lib/model-patient/patient.dart new file mode 100644 index 0000000000000000000000000000000000000000..f7ca36ff9cf3895449222faba2d69fc1794a2946 --- /dev/null +++ b/rescueapp/lib/model-patient/patient.dart @@ -0,0 +1,40 @@ +import 'package:rescueapp/database/database_provide.dart'; + +class Patient { + int id; + String name; + String birthday; + bool isAmbilatory; + String imagePath; + String category; + + + Patient({this.id, this.name, this.birthday, this.isAmbilatory, this.imagePath, this.category}); +//converts to map + Map<String, dynamic> toMap() { + var map = <String, dynamic>{ + DatabaseProvider.COLUMN_NAME: name, + DatabaseProvider.COLUMN_BIRTHDAY: birthday, + DatabaseProvider.COLUMN_ISAMBILATORY: isAmbilatory ? 1 : 0, + DatabaseProvider.COLUMN_IMAGEPATH: imagePath, + DatabaseProvider.COLUMN_CATEGORIE: category, + + }; + + if (id != null) { + map[DatabaseProvider.COLUMN_ID] = id; + } + + return map; + } + + Patient.fromMap(Map<String, dynamic> map) { + id = map[DatabaseProvider.COLUMN_ID]; + name = map[DatabaseProvider.COLUMN_NAME]; + birthday = map[DatabaseProvider.COLUMN_BIRTHDAY]; + isAmbilatory = map[DatabaseProvider.COLUMN_ISAMBILATORY] == 1; + imagePath = map[DatabaseProvider.COLUMN_IMAGEPATH]; + category = map[DatabaseProvider.COLUMN_CATEGORIE]; + + } +} \ No newline at end of file diff --git a/rescueapp/pubspec.yaml b/rescueapp/pubspec.yaml index ddda1624f5e6bd259ab2054fe915c6c6d9f48cb5..6999884a488b39d41918fb2430586073bed4451a 100644 --- a/rescueapp/pubspec.yaml +++ b/rescueapp/pubspec.yaml @@ -24,6 +24,15 @@ dependencies: flutter: sdk: flutter + camera: ^0.5.7+2 + image_picker: ^0.6.2+3 + path_provider: + sqflite: ^1.2.0 + path: ^1.6.4 + share: ^0.6.5+4 + shared_preferences: ^0.5.6+1 + video_player: ^0.10.0 + flutter_bloc: ^3.2.0 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.