update readme
parent
748c1cc585
commit
cd0e44ab30
|
@ -7,6 +7,11 @@ Eine Flutter App, um Teilnehmer einer Studie des [ZI-Mannheim](https://www.zi-ma
|
|||
Vor App-Start:
|
||||
<code>flutter pub get</code>
|
||||
|
||||
### Datenbank
|
||||
|
||||
Auf mobilen Geräten wird eine sqlite Datenbank benutzt. Beim Ausführen als Webapp kann nicht auf den DocumentPath zugegriffen werden, der zum initialisieren der Datenbank benötigt wird, weshalb sqlite nicht benutzt werden kann. Stattdessen kann eine Mock-Datenbank genutzt werden.
|
||||
Dazu muss in [globals.dart](./lib/globals.dart) die <code>DatabaseService databaseService = DatabaseMock();</code> gesetzt werden.
|
||||
|
||||
## App starten
|
||||
|
||||
Die App lässt sich als Android- und iOS App ausführen und zu Debugzwecken ebenfalls als Webapp.
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
library app.globals;
|
||||
|
||||
// ignore: unused_import
|
||||
import 'package:smoke_cess_app/mock/db_mock.dart';
|
||||
import 'package:smoke_cess_app/services/database_service.dart';
|
||||
|
||||
DatabaseService databaseService = DatabaseService.instance;
|
||||
//DatabaseService databaseService = DatabaseMock();
|
||||
|
||||
// set this to read settings from local json file instead of scanning a qr code
|
||||
bool useLocalConfig = true;
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
import 'package:smoke_cess_app/models/mood.dart';
|
||||
import 'package:smoke_cess_app/models/relapse.dart';
|
||||
import 'package:smoke_cess_app/models/sleep.dart';
|
||||
import 'package:smoke_cess_app/models/workout.dart';
|
||||
import 'package:smoke_cess_app/services/database_service.dart';
|
||||
// ignore: depend_on_referenced_packages
|
||||
import 'package:sqflite_common/sqlite_api.dart';
|
||||
|
||||
class DatabaseMock implements DatabaseService {
|
||||
static final DatabaseMock _databaseMock = DatabaseMock._internal();
|
||||
factory DatabaseMock() {
|
||||
return _databaseMock;
|
||||
}
|
||||
DatabaseMock._internal();
|
||||
|
||||
final List<Mood> _moodRecords = [];
|
||||
final List<Sleep> _sleepRecords = [];
|
||||
final List<Relapse> _relapseRecords = [];
|
||||
final List<Workout> _workoutRecords = [];
|
||||
|
||||
@override
|
||||
Future<int> addMood(Mood mood) {
|
||||
_moodRecords.add(mood);
|
||||
return Future.value(1);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> addSleep(Sleep sleep) {
|
||||
_sleepRecords.add(sleep);
|
||||
return Future.value(1);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> addWorkout(Workout workout) {
|
||||
_workoutRecords.add(workout);
|
||||
return Future.value(1);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<int> addRelapse(Relapse relapse) {
|
||||
_relapseRecords.add(relapse);
|
||||
return Future.value(1);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Database> get database => DatabaseService.instance.database;
|
||||
|
||||
@override
|
||||
Future<List<Mood>> getMoodRecords() {
|
||||
return Future.value(_moodRecords);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Sleep>> getSleepRecords() {
|
||||
return Future.value(_sleepRecords);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Relapse>> getRelapseRecords() {
|
||||
return Future.value(_relapseRecords);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Workout>> getWorkoutRecords() {
|
||||
return Future.value(_workoutRecords);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue