Merge branch 'main' into '43-ausklappbares-listitem'
# Conflicts: # lib/widgets/buttons/round_button_widget.dart # lib/widgets/view_form/view_form_page.dartmain
commit
411614f61f
10
README.md
10
README.md
|
@ -14,3 +14,13 @@ Die App lässt sich als Android- und iOS App ausführen und zu Debugzwecken eben
|
||||||
## App bedienen
|
## App bedienen
|
||||||
|
|
||||||
Um die App nutzen zu können, müssen Settings eingelesen werden. Dazu kann entweder ein in die App integrierter QR-Code Scanner (mit dem beigefügten [QR-Code](./gruppe1_QR.png)) benutzt werden, oder zu Debugzwecken mit dem dafür vorgesehenen Button auf der Scannerseite über eine lokale JSON-Datei.
|
Um die App nutzen zu können, müssen Settings eingelesen werden. Dazu kann entweder ein in die App integrierter QR-Code Scanner (mit dem beigefügten [QR-Code](./gruppe1_QR.png)) benutzt werden, oder zu Debugzwecken mit dem dafür vorgesehenen Button auf der Scannerseite über eine lokale JSON-Datei.
|
||||||
|
Es ist zu beachten, dass das verwendete QR-Code Scanner Package für Mobilgeräte optimiert ist. Deshalb kann es zu Abstürzen beim Verwenden des Scanners mit der Web-Version kommen.
|
||||||
|
Beim Verwenden der Web-Version sollten die Settings mit der lokalen JSON-Datei eingelesen werden.
|
||||||
|
Der Button zum Einlesen der lokalen JSON-Datei kann über die Variable <code>bool useLocalConfig</code> in der Datei [globals.dart](./lib/globals.dart) ein- und ausgeblendet werden.
|
||||||
|
|
||||||
|
## Authoren
|
||||||
|
|
||||||
|
- Hinrik Ehrenfried 2012537
|
||||||
|
- Patrick Meßmer 1911768
|
||||||
|
- Kai Mannweiler 2012491
|
||||||
|
- Julian Gegner 1922635
|
||||||
|
|
|
@ -70,5 +70,7 @@ flutter {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
|
implementation 'androidx.window:window:1.0.0'
|
||||||
|
implementation 'androidx.window:window-java:1.0.0'
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,3 +5,6 @@ import 'package:smoke_cess_app/services/database_service.dart';
|
||||||
|
|
||||||
DatabaseService databaseService = DatabaseMock();
|
DatabaseService databaseService = DatabaseMock();
|
||||||
// DatabaseService databaseService = DatabaseService.instance;
|
// DatabaseService databaseService = DatabaseService.instance;
|
||||||
|
|
||||||
|
// set this to read settings from local json file instead of scanning a qr code
|
||||||
|
bool useLocalConfig = false;
|
||||||
|
|
|
@ -4,8 +4,10 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:smoke_cess_app/services/export_service.dart';
|
import 'package:smoke_cess_app/services/export_service.dart';
|
||||||
import 'package:smoke_cess_app/services/settings_service.dart';
|
import 'package:smoke_cess_app/services/settings_service.dart';
|
||||||
import 'package:smoke_cess_app/services/notification_service.dart';
|
import 'package:smoke_cess_app/services/notification_service.dart';
|
||||||
|
import 'package:smoke_cess_app/widgets/buttons/text_icon_button.dart';
|
||||||
import 'package:smoke_cess_app/widgets/scanner.dart';
|
import 'package:smoke_cess_app/widgets/scanner.dart';
|
||||||
import '../providers/settings_provider.dart';
|
import '../providers/settings_provider.dart';
|
||||||
|
import '../globals.dart' as globals;
|
||||||
|
|
||||||
class ScannerPage extends StatelessWidget {
|
class ScannerPage extends StatelessWidget {
|
||||||
const ScannerPage({super.key});
|
const ScannerPage({super.key});
|
||||||
|
@ -16,7 +18,7 @@ class ScannerPage extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadJSON(BuildContext context) async {
|
void loadJSON(BuildContext context) async {
|
||||||
var settingsModel = context.read<SettingsProvider>();
|
SettingsProvider settingsModel = context.read<SettingsProvider>();
|
||||||
await loadSettingsFromLocalJSON();
|
await loadSettingsFromLocalJSON();
|
||||||
settingsModel.initSettings();
|
settingsModel.initSettings();
|
||||||
NotificationService().setAllNotifications();
|
NotificationService().setAllNotifications();
|
||||||
|
@ -32,25 +34,26 @@ class ScannerPage extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
SettingsProvider settingsProvider = context.watch<SettingsProvider>();
|
||||||
|
|
||||||
return Center(
|
return Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const MyScanner(),
|
const MyScanner(),
|
||||||
const SizedBox(height: 30),
|
const SizedBox(height: 30),
|
||||||
|
if (!settingsProvider.scanning)
|
||||||
|
TextIconButton(
|
||||||
|
text: 'Export',
|
||||||
|
onPressed: ExportService().exportData,
|
||||||
|
iconData: Icons.upload),
|
||||||
|
if (globals.useLocalConfig && !settingsProvider.scanning)
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
textStyle: const TextStyle(fontSize: 20)),
|
textStyle: const TextStyle(fontSize: 20)),
|
||||||
onPressed: () => loadJSON(context),
|
onPressed: () => loadJSON(context),
|
||||||
child: const Text('Read JSON'),
|
child: const Text('Read JSON'),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
|
||||||
ElevatedButton(
|
|
||||||
style: ElevatedButton.styleFrom(
|
|
||||||
textStyle: const TextStyle(fontSize: 20)),
|
|
||||||
onPressed: export,
|
|
||||||
child: const Text('Export'),
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,16 @@ import '../models/settings.dart';
|
||||||
class SettingsProvider extends ChangeNotifier {
|
class SettingsProvider extends ChangeNotifier {
|
||||||
Settings? _settings;
|
Settings? _settings;
|
||||||
bool _initialized = false;
|
bool _initialized = false;
|
||||||
|
bool _scanning = false;
|
||||||
|
|
||||||
Settings? get settings => _settings;
|
Settings? get settings => _settings;
|
||||||
bool get initialized => _initialized;
|
bool get initialized => _initialized;
|
||||||
|
bool get scanning => _scanning;
|
||||||
|
|
||||||
|
set scanning(bool value) {
|
||||||
|
_scanning = value;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
SettingsProvider() {
|
SettingsProvider() {
|
||||||
initSettings();
|
initSettings();
|
||||||
|
|
|
@ -8,7 +8,9 @@ String formatTime(int seconds) {
|
||||||
String hours = twoDigits(duration.inHours.remainder(24));
|
String hours = twoDigits(duration.inHours.remainder(24));
|
||||||
String minutes = twoDigits(duration.inMinutes.remainder(60));
|
String minutes = twoDigits(duration.inMinutes.remainder(60));
|
||||||
String formattedSeconds = twoDigits(duration.inSeconds.remainder(60));
|
String formattedSeconds = twoDigits(duration.inSeconds.remainder(60));
|
||||||
if (duration.inDays != 0) formattedTime += '$days:';
|
if (duration.inDays != 0) {
|
||||||
|
formattedTime += '$days Tag ${duration.inDays > 1 ? "e" : ""}, ';
|
||||||
|
}
|
||||||
if (duration.inHours != 0) formattedTime += '$hours:';
|
if (duration.inHours != 0) formattedTime += '$hours:';
|
||||||
formattedTime += '$minutes:';
|
formattedTime += '$minutes:';
|
||||||
formattedTime += formattedSeconds;
|
formattedTime += formattedSeconds;
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class TextIconButton extends StatelessWidget {
|
||||||
|
final String text;
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
final IconData iconData;
|
||||||
|
|
||||||
|
const TextIconButton(
|
||||||
|
{super.key,
|
||||||
|
required this.text,
|
||||||
|
required this.onPressed,
|
||||||
|
required this.iconData});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SizedBox(
|
||||||
|
width: MediaQuery.of(context).size.width * 0.4,
|
||||||
|
child: FloatingActionButton.extended(
|
||||||
|
label: Text(text),
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
|
icon: Icon(
|
||||||
|
iconData,
|
||||||
|
size: 24.0,
|
||||||
|
),
|
||||||
|
onPressed: onPressed,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,43 +1,45 @@
|
||||||
|
import 'package:awesome_dialog/awesome_dialog.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:smoke_cess_app/providers/timer_provider.dart';
|
|
||||||
import 'package:smoke_cess_app/widgets/timer_widget.dart';
|
|
||||||
import 'package:smoke_cess_app/services/date_service.dart';
|
import 'package:smoke_cess_app/services/date_service.dart';
|
||||||
import 'package:smoke_cess_app/services/pages_service.dart';
|
import 'package:smoke_cess_app/services/pages_service.dart';
|
||||||
|
import 'package:smoke_cess_app/widgets/timer_widget.dart';
|
||||||
|
|
||||||
|
import '../../providers/timer_provider.dart';
|
||||||
|
|
||||||
void showTaskDonePopup(BuildContext context, Pages page) async {
|
void showTaskDonePopup(BuildContext context, Pages page) async {
|
||||||
Duration duration = await getTimeTill(page);
|
Duration duration = await getTimeTill(page);
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
await showDialog(
|
AwesomeDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (BuildContext context) {
|
dialogType: DialogType.info,
|
||||||
return ChangeNotifierProvider(
|
body: Column(
|
||||||
create: (context) => TimerProvider(),
|
children: [
|
||||||
child: TaskDonePopup(
|
Text(
|
||||||
duration: duration,
|
'${pages[page]?['title']} schon eingegeben',
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
|
||||||
),
|
),
|
||||||
);
|
const SizedBox(
|
||||||
},
|
height: 10,
|
||||||
);
|
),
|
||||||
}
|
const Text(
|
||||||
}
|
'Nächste Abfrage in',
|
||||||
|
),
|
||||||
class TaskDonePopup extends StatelessWidget {
|
const SizedBox(
|
||||||
final Duration duration;
|
height: 8,
|
||||||
const TaskDonePopup({super.key, required this.duration});
|
),
|
||||||
|
ChangeNotifierProvider(
|
||||||
@override
|
create: (context) => TimerProvider(),
|
||||||
Widget build(BuildContext context) {
|
builder: (context, child) {
|
||||||
TimerProvider timerProvider = context.read<TimerProvider>();
|
TimerProvider timerProvider = context.read<TimerProvider>();
|
||||||
timerProvider.startTimer(duration);
|
timerProvider.startTimer(duration);
|
||||||
return AlertDialog(
|
return TimerWidget(duration: duration);
|
||||||
title: const Text('Schon gemacht'),
|
},
|
||||||
content: Column(
|
),
|
||||||
mainAxisSize: MainAxisSize.min,
|
const SizedBox(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
height: 15,
|
||||||
children: [
|
),
|
||||||
const Text('Nächstes mal wieder:'),
|
],
|
||||||
TimerWidget(duration: duration)
|
)).show();
|
||||||
]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,48 +5,43 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:smoke_cess_app/models/settings.dart';
|
import 'package:smoke_cess_app/models/settings.dart';
|
||||||
import 'package:smoke_cess_app/services/json_service.dart';
|
import 'package:smoke_cess_app/services/json_service.dart';
|
||||||
import 'package:smoke_cess_app/services/settings_service.dart';
|
import 'package:smoke_cess_app/services/settings_service.dart';
|
||||||
|
import 'package:smoke_cess_app/widgets/buttons/text_icon_button.dart';
|
||||||
import '../providers/settings_provider.dart';
|
import '../providers/settings_provider.dart';
|
||||||
import '../services/notification_service.dart';
|
import '../services/notification_service.dart';
|
||||||
|
|
||||||
class MyScanner extends StatefulWidget {
|
class MyScanner extends StatelessWidget {
|
||||||
const MyScanner({super.key});
|
const MyScanner({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => MyScannerState();
|
Widget build(BuildContext context) {
|
||||||
}
|
SettingsProvider settingsProvider = context.watch<SettingsProvider>();
|
||||||
|
|
||||||
class MyScannerState extends State<MyScanner> {
|
|
||||||
bool scanning = false;
|
|
||||||
|
|
||||||
void handleSucces(String? rawValue) {
|
void handleSucces(String? rawValue) {
|
||||||
String qrText = rawValue!;
|
String qrText = rawValue!;
|
||||||
Map<String, dynamic> json = stringToJSON(qrText);
|
Map<String, dynamic> json = stringToJSON(qrText);
|
||||||
Settings settings = Settings.fromJson(json);
|
Settings settings = Settings.fromJson(json);
|
||||||
saveSettings(settings);
|
saveSettings(settings);
|
||||||
var settingsModel = context.read<SettingsProvider>();
|
settingsProvider.initSettings();
|
||||||
settingsModel.initSettings();
|
|
||||||
NotificationService().setAllNotifications();
|
NotificationService().setAllNotifications();
|
||||||
setState(() {
|
settingsProvider.scanning = false;
|
||||||
scanning = false;
|
|
||||||
AwesomeDialog(
|
AwesomeDialog(
|
||||||
context: context,
|
context: context,
|
||||||
dialogType: DialogType.success,
|
dialogType: DialogType.success,
|
||||||
title: 'Geschafft',
|
title: 'Geschafft',
|
||||||
desc: 'Der Code wurde erfolgreich gescannt!',
|
desc: 'Der Code wurde erfolgreich gescannt!',
|
||||||
).show();
|
).show();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleError() {
|
void handleError() {
|
||||||
setState(() {
|
settingsProvider.scanning = false;
|
||||||
scanning = false;
|
|
||||||
AwesomeDialog(
|
AwesomeDialog(
|
||||||
context: context,
|
context: context,
|
||||||
dialogType: DialogType.error,
|
dialogType: DialogType.error,
|
||||||
title: 'Fehler',
|
title: 'Fehler',
|
||||||
desc: 'Der QR-Code war fehlerhaft!',
|
desc: 'Der QR-Code war fehlerhaft!',
|
||||||
).show();
|
).show();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onDetect(capture) {
|
void onDetect(capture) {
|
||||||
|
@ -62,23 +57,29 @@ class MyScannerState extends State<MyScanner> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
return settingsProvider.scanning
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return scanning
|
|
||||||
? Expanded(
|
? Expanded(
|
||||||
child: MobileScanner(
|
child: Stack(
|
||||||
|
alignment: Alignment.center,
|
||||||
|
children: [
|
||||||
|
MobileScanner(
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
controller: MobileScannerController(
|
controller: MobileScannerController(
|
||||||
detectionTimeoutMs: 2000,
|
detectionTimeoutMs: 2000,
|
||||||
),
|
),
|
||||||
onDetect: onDetect))
|
onDetect: onDetect,
|
||||||
: ElevatedButton(
|
),
|
||||||
style: ElevatedButton.styleFrom(
|
ClipRRect(
|
||||||
textStyle: const TextStyle(fontSize: 20)),
|
borderRadius: BorderRadius.circular(20),
|
||||||
onPressed: () {
|
child: Container(
|
||||||
setState(() => scanning = true);
|
height: MediaQuery.of(context).size.height / 3,
|
||||||
},
|
width: MediaQuery.of(context).size.width * 0.8,
|
||||||
child: const Text('Scan QR Code'),
|
color: Colors.white.withOpacity(0.4))),
|
||||||
);
|
],
|
||||||
|
))
|
||||||
|
: TextIconButton(
|
||||||
|
text: "Scan",
|
||||||
|
onPressed: () => settingsProvider.scanning = true,
|
||||||
|
iconData: Icons.qr_code_scanner_outlined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue