import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:smoke_cess_app/models/mood.dart'; import 'package:smoke_cess_app/models/relapse.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 '../models/sleep.dart'; import '../providers/settings_provider.dart'; import '../globals.dart' as globals; class ScannerPage extends StatelessWidget { const ScannerPage({super.key}); void export() async { List moods = await globals.databaseService.getMoodRecords(); List sleeps = await globals.databaseService.getSleepRecords(); List relapses = await globals.databaseService.getRelapseRecords(); for (Mood mood in moods) { print(mood.toCSV()); } for (Sleep sleep in sleeps) { print(sleep.toCSV()); } for (Relapse relapse in relapses) { print(relapse.toCSV()); } } void loadJSON(BuildContext context) async { var settingsModel = context.read(); await loadSettingsFromLocalJSON(); settingsModel.initSettings(); NotificationService().setAllNotifications(); } @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'), ) ], )); } }