feat: complete app
This commit is contained in:
100
lib/screens/admin.dart
Normal file
100
lib/screens/admin.dart
Normal file
@ -0,0 +1,100 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/controller/gamecontroller.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/screens/marker.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/screens/pattern.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/screens/qr.dart';
|
||||
|
||||
void showAdminLoginPopup() {
|
||||
final TextEditingController passwordController = TextEditingController();
|
||||
final GameController c = Get.find();
|
||||
|
||||
Get.dialog(
|
||||
AlertDialog(
|
||||
title: const Text('Admin Login'),
|
||||
content: TextField(
|
||||
controller: passwordController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Enter admin password',
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Get.back();
|
||||
},
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
if (passwordController.text == c.adminPass) {
|
||||
Get.back();
|
||||
Get.to(() => const AdminPage());
|
||||
} else {
|
||||
// Get.back();
|
||||
Get.snackbar(
|
||||
'Error',
|
||||
'Incorrect password',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: const Text('Login'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class AdminPage extends StatelessWidget {
|
||||
const AdminPage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
GameController c = Get.find();
|
||||
return Scaffold(
|
||||
body: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text('Admin Page'),
|
||||
Text('Marker Sequence: ${c.markerSequence}'),
|
||||
Text('Calendar QR Data: ${c.calendarQrData}'),
|
||||
Text('Final Code: ${c.finalCode}'),
|
||||
Text('Admin Password: ${c.adminPass}'),
|
||||
const Text("Go to Challenge directly: "),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.offAll(const MarkerScreen());
|
||||
},
|
||||
child: const Text('Marker'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.offAll(const QrScreen());
|
||||
},
|
||||
child: const Text('Story'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Get.offAll(const PatternScreen());
|
||||
// Add functionality for Pattern button
|
||||
},
|
||||
child: const Text('Pattern'),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
c.qrPageController.stop();
|
||||
},
|
||||
child: const Text('stop qr scanner qr page'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
117
lib/screens/marker.dart
Normal file
117
lib/screens/marker.dart
Normal file
@ -0,0 +1,117 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/controller/gamecontroller.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/scanner_error_widget.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/screens/admin.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/screens/qr.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/util.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
|
||||
class MarkerScreen extends StatelessWidget {
|
||||
const MarkerScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
GameController c = Get.find();
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Lotti\'s Escape Room - Rätsel 1'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.smart_toy_outlined),
|
||||
onPressed: () {
|
||||
showAdminLoginPopup();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Center(
|
||||
child: Text('Zum entsperren, bitte Code eingeben.'),
|
||||
),
|
||||
TextField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Code',
|
||||
),
|
||||
keyboardType: TextInputType.text,
|
||||
controller: c.markerSequenceController,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
if (c.checkMarkerString()) {
|
||||
Get.offAll(const QrScreen());
|
||||
} else {
|
||||
Get.snackbar("Falscher Code",
|
||||
"Der Code '${c.markerSequenceController.text}' ist falsch.");
|
||||
}
|
||||
},
|
||||
child: const Text('Code eingeben'),
|
||||
),
|
||||
Container(
|
||||
height: 400,
|
||||
child: MobileScanner(
|
||||
fit: BoxFit.contain,
|
||||
controller: c.markerPageScannerController,
|
||||
errorBuilder: (context, error, child) {
|
||||
return ScannerErrorWidget(error: error);
|
||||
},
|
||||
overlayBuilder: (context, constraints) {
|
||||
return Align(
|
||||
alignment: Alignment.center,
|
||||
child: Container(
|
||||
height: 60,
|
||||
width: 200,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.white,
|
||||
width: 3,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
));
|
||||
},
|
||||
onDetect: (barcodes) {
|
||||
if (barcodes.barcodes.isNotEmpty) {
|
||||
for (var barcode in barcodes.barcodes) {
|
||||
if (barcode.rawValue == null) {
|
||||
continue;
|
||||
}
|
||||
playBeepSound();
|
||||
if (c.markerNumbersToDeclaration.keys
|
||||
.contains(barcode.rawValue)) {
|
||||
c.markerSequenceController.text =
|
||||
"${c.markerSequenceController.text}${c.markerNumbersToDeclaration[barcode.rawValue]}";
|
||||
} else {
|
||||
Get.snackbar("Unbekannter Code",
|
||||
"Der Code '${barcode.rawValue}' konnte nicht erkannt werden.\nProbiere es doch nochmal :)");
|
||||
}
|
||||
c.markerPageScannerController.stop();
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
// start scanner
|
||||
if (c.markerPageScannerController.value.isRunning) {
|
||||
c.markerPageScannerController.stop();
|
||||
} else {
|
||||
c.markerPageScannerController.start();
|
||||
}
|
||||
},
|
||||
child: const Text('Barcode\nscannen'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
28
lib/screens/pattern.dart
Normal file
28
lib/screens/pattern.dart
Normal file
@ -0,0 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/controller/gamecontroller.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/scanned_barcode_label.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/scanner_error_widget.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/screens/admin.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/util.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
|
||||
class PatternScreen extends StatelessWidget {
|
||||
const PatternScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
GameController c = Get.find();
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
child: Scaffold(
|
||||
body: Image.asset(
|
||||
'assets/images/pattern.jpg', // Replace with your image path
|
||||
fit: BoxFit.contain,
|
||||
width: double.infinity,
|
||||
height: double.infinity,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
106
lib/screens/qr.dart
Normal file
106
lib/screens/qr.dart
Normal file
@ -0,0 +1,106 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/controller/gamecontroller.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/scanned_barcode_label.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/scanner_error_widget.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/screens/admin.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/screens/pattern.dart';
|
||||
import 'package:lottis_birthday_escaperoom_app/util.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
|
||||
class QrScreen extends StatelessWidget {
|
||||
const QrScreen({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
GameController c = Get.find();
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Lotti\'s Escape Room - Rätsel 2'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.smart_toy_outlined),
|
||||
onPressed: () {
|
||||
showAdminLoginPopup();
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(c.storyTitle, style: Theme.of(context).textTheme.titleLarge),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
height: 600,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
c.story,
|
||||
style: const TextStyle(fontSize: 20),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Center(
|
||||
child: Text('Zum entsperren, bitte QR Code scannen.'),
|
||||
),
|
||||
Container(
|
||||
height: 300,
|
||||
child: MobileScanner(
|
||||
fit: BoxFit.contain,
|
||||
controller: c.qrPageController,
|
||||
errorBuilder: (context, error, child) {
|
||||
return ScannerErrorWidget(error: error);
|
||||
},
|
||||
overlayBuilder: (context, constraints) {
|
||||
return Align(
|
||||
alignment: Alignment.center,
|
||||
child: Container(
|
||||
height: 200,
|
||||
width: 200,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.white,
|
||||
width: 3,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
));
|
||||
},
|
||||
onDetect: (barcodes) {
|
||||
if (barcodes.barcodes.isNotEmpty) {
|
||||
for (var barcode in barcodes.barcodes) {
|
||||
if (barcode.rawValue == null) {
|
||||
continue;
|
||||
}
|
||||
playBeepSound();
|
||||
if (barcode.rawValue == c.calendarQrData) {
|
||||
c.qrPageController.stop();
|
||||
Get.offAll(PatternScreen());
|
||||
} else {
|
||||
Get.snackbar("Falscher Code",
|
||||
"Der Code '${barcode.rawValue}' ist falsch.");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user