use texticonbutton for scan and export, use global bool to enable local json config
parent
a99fed7fa2
commit
6d53158b64
|
@ -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,11 @@ 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/round_button_widget.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});
|
||||||
|
@ -32,25 +35,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),
|
||||||
ElevatedButton(
|
if (!settingsProvider.scanning)
|
||||||
style: ElevatedButton.styleFrom(
|
TextIconButton(
|
||||||
textStyle: const TextStyle(fontSize: 20)),
|
text: 'Export',
|
||||||
onPressed: () => loadJSON(context),
|
onPressed: ExportService().exportData,
|
||||||
child: const Text('Read JSON'),
|
iconData: Icons.upload),
|
||||||
),
|
if (globals.useLocalConfig && !settingsProvider.scanning)
|
||||||
const SizedBox(height: 30),
|
ElevatedButton(
|
||||||
ElevatedButton(
|
style: ElevatedButton.styleFrom(
|
||||||
style: ElevatedButton.styleFrom(
|
textStyle: const TextStyle(fontSize: 20)),
|
||||||
textStyle: const TextStyle(fontSize: 20)),
|
onPressed: () => loadJSON(context),
|
||||||
onPressed: export,
|
child: const Text('Read JSON'),
|
||||||
child: const Text('Export'),
|
),
|
||||||
)
|
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ 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';
|
||||||
import 'buttons/round_button_widget.dart';
|
import 'buttons/round_button_widget.dart';
|
||||||
|
@ -77,9 +78,9 @@ class MyScanner extends StatelessWidget {
|
||||||
color: Colors.white.withOpacity(0.4))),
|
color: Colors.white.withOpacity(0.4))),
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
: RoundButton(
|
: TextIconButton(
|
||||||
|
text: "Scan",
|
||||||
onPressed: () => settingsProvider.scanning = true,
|
onPressed: () => settingsProvider.scanning = true,
|
||||||
iconData: Icons.qr_code_scanner_outlined,
|
iconData: Icons.qr_code_scanner_outlined);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue