okay that's it bye

This commit is contained in:
Kima 2024-11-13 20:51:24 +01:00
parent 3708b917c4
commit 414755c777
3 changed files with 39 additions and 36 deletions

View File

@ -59,8 +59,8 @@ Future<void> syncAll(BuildContext context) {
tasks = [ tasks = [
// refresh login // refresh login
syncStatus(() async { syncStatus(() async {
print(user.user?.accessTokenExpire); // print(user.user?.accessTokenExpire);
print('${user.user?.accessToken ?? "no token"} - ACCESS TOKEN'); // print('${user.user?.accessToken ?? "no token"} - ACCESS TOKEN');
if (user.user == null) return; if (user.user == null) return;
if (user.user!.accessTokenExpire.isBefore(DateTime.now())) { if (user.user!.accessTokenExpire.isBefore(DateTime.now())) {

View File

@ -135,6 +135,7 @@ extension SettingsLocalization on String {
"camera_perm_error": "camera_perm_error":
"Camera permission is required to scan QR codes.", "Camera permission is required to scan QR codes.",
"invalid_qr_code": "Invalid QR code!", "invalid_qr_code": "Invalid QR code!",
"success": "Success!",
}, },
"hu_hu": { "hu_hu": {
"heads_up": "Figyelem!", "heads_up": "Figyelem!",
@ -268,6 +269,7 @@ extension SettingsLocalization on String {
"camera_perm_error": "camera_perm_error":
"A kamera engedély szükséges a QR kódok beolvasásához.", "A kamera engedély szükséges a QR kódok beolvasásához.",
"invalid_qr_code": "Érvénytelen QR kód!", "invalid_qr_code": "Érvénytelen QR kód!",
"success": "Siker!",
}, },
"de_de": { "de_de": {
"heads_up": "Achtung!", "heads_up": "Achtung!",
@ -401,6 +403,7 @@ extension SettingsLocalization on String {
"camera_perm_error": "camera_perm_error":
"Kameraberechtigung ist erforderlich, um QR-Codes zu scannen.", "Kameraberechtigung ist erforderlich, um QR-Codes zu scannen.",
"invalid_qr_code": "Ungültiger QR-Code!", "invalid_qr_code": "Ungültiger QR-Code!",
"success": "Erfolg!",
}, },
}; };

View File

@ -20,8 +20,6 @@ class _CodeScannerScreenState extends State<CodeScannerScreen> {
QRViewController? controller; QRViewController? controller;
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
// In order to get hot reload to work we need to pause the camera if the platform
// is android, or resume the camera if the platform is iOS.
@override @override
void reassemble() { void reassemble() {
super.reassemble(); super.reassemble();
@ -65,38 +63,15 @@ class _CodeScannerScreenState extends State<CodeScannerScreen> {
], ],
), ),
body: _buildQrView(context), body: _buildQrView(context),
// body: Column(
// children: <Widget>[
// Expanded(flex: 4, child: _buildQrView(context)),
// // Expanded(
// // flex: 1,
// // child: FittedBox(
// // fit: BoxFit.contain,
// // child: Column(
// // mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// // children: <Widget>[
// // if (result != null)
// // Text(
// // 'Barcode Type: ${describeEnum(result!.format)} Data: ${result!.code}')
// // else
// // const Text('Scan a code'),
// // ],
// // ),
// // ),
// // )
// ],
// ),
); );
} }
Widget _buildQrView(BuildContext context) { Widget _buildQrView(BuildContext context) {
// For this example we check how width or tall the device is and change the scanArea and overlay accordingly.
var scanArea = (MediaQuery.of(context).size.width < 400 || var scanArea = (MediaQuery.of(context).size.width < 400 ||
MediaQuery.of(context).size.height < 400) MediaQuery.of(context).size.height < 400)
? 150.0 ? 150.0
: 280.0; : 280.0;
// To ensure the Scanner view is properly sizes after rotation
// we need to listen for Flutter SizeChanged notification and update controller
return QRView( return QRView(
key: qrKey, key: qrKey,
onQRViewCreated: _onQRViewCreated, onQRViewCreated: _onQRViewCreated,
@ -116,14 +91,13 @@ class _CodeScannerScreenState extends State<CodeScannerScreen> {
this.controller = controller; this.controller = controller;
}); });
controller.scannedDataStream.listen((scanData) { controller.scannedDataStream.listen((scanData) {
controller.pauseCamera(); // controller.pauseCamera();
if (result?.code == scanData.code) return;
setState(() { setState(() {
result = scanData; result = scanData;
}); });
Navigator.of(context).pop();
if (scanData.code != null) { if (scanData.code != null) {
if (scanData.code!.startsWith('qw://')) { if (scanData.code!.startsWith('qw://')) {
// String data = scanData.code!.replaceFirst('qw://', ''); // String data = scanData.code!.replaceFirst('qw://', '');
@ -131,29 +105,55 @@ class _CodeScannerScreenState extends State<CodeScannerScreen> {
// TODO: this qr shit // TODO: this qr shit
} else if (scanData.code!.startsWith('https://') || } else if (scanData.code!.startsWith('https://') ||
scanData.code!.startsWith('http://')) { scanData.code!.startsWith('http://')) {
Uri uri = Uri.parse(scanData.code!.replaceFirst('http', 'https')); Uri uri =
Uri.parse(scanData.code!.replaceFirst('http://', 'https://'));
// print(uri);
if (uri.host.contains('refilc.hu') || if (uri.host.contains('refilc.hu') ||
uri.host.contains('refilcapp.hu') || uri.host.contains('refilcapp.hu') ||
uri.host.contains('filc.one')) { uri.host.contains('filc.one')) {
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
content: Text("success".i18n,
style: const TextStyle(color: Colors.white)),
backgroundColor: const Color(0xFF00A900),
context: context,
));
// launch refilc url
Future.delayed(const Duration(seconds: 1), () {
Navigator.of(context).pop();
launchUrl(uri, mode: LaunchMode.inAppBrowserView); launchUrl(uri, mode: LaunchMode.inAppBrowserView);
});
} else { } else {
// show invalid code error
// Navigator.of(context).pop();
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar( ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
content: Text("invalid_qr_code".i18n, content: Text("invalid_qr_code".i18n,
style: const TextStyle(color: Colors.white)), style: const TextStyle(color: Colors.white)),
backgroundColor: AppColors.of(context).red, backgroundColor: AppColors.of(context).red,
context: context, context: context,
)); ));
controller.resumeCamera();
} }
} else {
// show invalid code error
// Navigator.of(context).pop();
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
content: Text("invalid_qr_code".i18n,
style: const TextStyle(color: Colors.white)),
backgroundColor: AppColors.of(context).red,
context: context,
));
controller.resumeCamera();
} }
// log(scanData.code);
// Provider.of<SyncProvider>(context, listen: false).syncAll(context);
} }
}); });
} }
void _onPermissionSet(BuildContext context, QRViewController ctrl, bool p) { void _onPermissionSet(BuildContext context, QRViewController ctrl, bool p) {
// log('${DateTime.now().toIso8601String()}_onPermissionSet $p');
if (!p) { if (!p) {
ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar( ScaffoldMessenger.of(context).showSnackBar(CustomSnackBar(
content: Text("camera_perm_error".i18n, content: Text("camera_perm_error".i18n,