cpd_2022_zi/lib/pages/scanner_page.dart

56 lines
1.7 KiB
Dart
Raw Normal View History

2023-02-27 20:30:24 +01:00
import 'package:awesome_dialog/awesome_dialog.dart';
2023-02-17 13:47:52 +01:00
import 'package:flutter/material.dart';
2023-02-27 02:27:42 +01:00
import 'package:provider/provider.dart';
2023-03-02 19:41:13 +01:00
import 'package:smoke_cess_app/services/export_service.dart';
2023-02-26 14:10:06 +01:00
import 'package:smoke_cess_app/services/settings_service.dart';
import 'package:smoke_cess_app/services/notification_service.dart';
2023-02-27 17:00:28 +01:00
import 'package:smoke_cess_app/widgets/scanner.dart';
2023-02-27 02:27:42 +01:00
import '../providers/settings_provider.dart';
2023-02-20 19:32:23 +01:00
2023-02-27 17:00:28 +01:00
class ScannerPage extends StatelessWidget {
2023-02-19 17:54:30 +01:00
const ScannerPage({super.key});
2023-02-17 13:47:52 +01:00
2023-02-27 17:00:28 +01:00
void export() async {
2023-03-02 19:41:13 +01:00
ExportService exportService = ExportService();
exportService.exportData();
2023-02-27 17:00:28 +01:00
}
2023-02-20 19:32:23 +01:00
2023-02-27 17:00:28 +01:00
void loadJSON(BuildContext context) async {
var settingsModel = context.read<SettingsProvider>();
await loadSettingsFromLocalJSON();
settingsModel.initSettings();
NotificationService().setAllNotifications();
2023-02-27 20:30:24 +01:00
AwesomeDialog(
context: context,
dialogType: DialogType.success,
title: 'Geschafft',
desc: 'Die Einstellung wurden erfolgreich gespeichert',
).show();
2023-02-27 17:00:28 +01:00
}
2023-02-20 19:32:23 +01:00
2023-02-17 13:47:52 +01:00
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
2023-02-27 17:00:28 +01:00
const MyScanner(),
2023-02-17 13:47:52 +01:00
const SizedBox(height: 30),
ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20)),
2023-02-27 17:00:28 +01:00
onPressed: () => loadJSON(context),
2023-02-17 13:47:52 +01:00
child: const Text('Read JSON'),
),
const SizedBox(height: 30),
ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20)),
2023-02-27 17:00:28 +01:00
onPressed: export,
child: const Text('Export'),
2023-02-17 13:47:52 +01:00
)
],
));
}
}