cpd_2022_zi/lib/pages/scanner_page.dart

58 lines
1.7 KiB
Dart

import 'package:awesome_dialog/awesome_dialog.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.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/notification_service.dart';
import 'package:smoke_cess_app/widgets/scanner.dart';
import '../providers/settings_provider.dart';
class ScannerPage extends StatelessWidget {
const ScannerPage({super.key});
void export() async {
ExportService exportService = ExportService();
exportService.exportData();
}
void loadJSON(BuildContext context) async {
var settingsModel = context.read<SettingsProvider>();
await loadSettingsFromLocalJSON();
settingsModel.initSettings();
NotificationService().setAllNotifications();
if (context.mounted) {
AwesomeDialog(
context: context,
dialogType: DialogType.success,
title: 'Geschafft',
desc: 'Die Einstellung wurden erfolgreich gespeichert',
).show();
}
}
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const MyScanner(),
const SizedBox(height: 30),
ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20)),
onPressed: () => loadJSON(context),
child: const Text('Read JSON'),
),
const SizedBox(height: 30),
ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(fontSize: 20)),
onPressed: export,
child: const Text('Export'),
)
],
));
}
}