Updated pages
This commit is contained in:
parent
5a05058256
commit
fd33a67b47
5 changed files with 226 additions and 114 deletions
|
|
@ -1,9 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
import 'package:ocbo_esign_mobile/functions/get_api.dart';
|
||||
import 'package:ocbo_esign_mobile/widgets/box_widget.dart';
|
||||
import 'package:ocbo_esign_mobile/widgets/button_widget.dart';
|
||||
import 'package:ocbo_esign_mobile/widgets/text_widget.dart';
|
||||
import 'package:vibration/vibration.dart';
|
||||
|
||||
|
|
@ -25,24 +25,74 @@ class BarcodeScannerScreen extends StatefulWidget {
|
|||
|
||||
class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
||||
late String qrResult = '';
|
||||
late String qrResultSub = '';
|
||||
final Color redColorShade = const Color.fromARGB(26, 225, 82, 103);
|
||||
final Color redColor = const Color.fromARGB(255, 229, 89, 115);
|
||||
final Color greenColorShade = const Color.fromRGBO(69, 191, 73, 0.1);
|
||||
final Color greenColor = const Color.fromRGBO(76, 206, 81, 1);
|
||||
|
||||
void readQr(String value) async {
|
||||
if (value.contains('OCBO e-Sign')) {
|
||||
final response = await getApi('check-qr', value, null);
|
||||
final result = response["result"];
|
||||
final qr = value.substring(35);
|
||||
final response = await getApi('check-qr', qr, null);
|
||||
final result = response["result"].toString();
|
||||
|
||||
if (result != '') {
|
||||
setState(() {
|
||||
qrResult = result;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
qrResult = 'non-exist';
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
qrResult = 'invalid';
|
||||
});
|
||||
|
||||
Future.delayed(Duration(seconds: 3), () {
|
||||
setState(() {
|
||||
qrResult = '';
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// void tryQR() async {
|
||||
// final value = "Use OCBO e-Sign Validator - scanid=0918d59e";
|
||||
|
||||
// if (value.contains('OCBO e-Sign')) {
|
||||
// final qr = value.substring(35);
|
||||
// final response = await getApi('check-qr', qr, null);
|
||||
// final result = response["result"].toString();
|
||||
|
||||
// if (result != '') {
|
||||
// setState(() {
|
||||
// qrResult = result;
|
||||
// });
|
||||
// } else {
|
||||
// setState(() {
|
||||
// qrResult = 'result';
|
||||
// });
|
||||
// }
|
||||
// } else {
|
||||
// setState(() {
|
||||
// qrResult = 'invalid';
|
||||
// });
|
||||
|
||||
// Future.delayed(Duration(seconds: 3), () {
|
||||
// setState(() {
|
||||
// qrResult = '';
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
void gotoDetails() {
|
||||
context.push('/details');
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
|
@ -114,91 +164,109 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
),
|
||||
),
|
||||
const Gap(24),
|
||||
// ButtonWidget(text: 'Try API', disabled: false, onPressed: tryQR),
|
||||
if (qrResult.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
if (qrResult != 'invalid')
|
||||
Row(
|
||||
if (qrResult == 'invalid')
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(0),
|
||||
width: 90,
|
||||
height: 90,
|
||||
width: MediaQuery.of(context).size.width - 160,
|
||||
padding: const EdgeInsets.fromLTRB(8, 16, 8, 26),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color.fromRGBO(69, 191, 73, 0.1),
|
||||
border: Border.all(color: const Color.fromRGBO(69, 191, 73, 1), width: 2),
|
||||
borderRadius: BorderRadius.circular(99), // Optional: rounded corners
|
||||
border: BoxBorder.all(color: redColor),
|
||||
color: redColorShade,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Icon(Icons.check, color: const Color.fromRGBO(69, 191, 73, 1), size: 48),
|
||||
),
|
||||
const Gap(24),
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const TextWidget(
|
||||
text: 'Valid',
|
||||
bold: true,
|
||||
size: 22,
|
||||
color: Color.fromRGBO(69, 191, 73, 1),
|
||||
),
|
||||
const Gap(16),
|
||||
const TextWidget(
|
||||
text: 'QR is a valid OCBO e-Sign',
|
||||
bold: false,
|
||||
size: 14,
|
||||
color: Color.fromRGBO(69, 191, 73, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
const Gap(24),
|
||||
BoxWidget(
|
||||
title: '',
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
child: Column(
|
||||
children: [
|
||||
const TextWidget(text: 'Name', bold: true, size: 14),
|
||||
const Gap(8),
|
||||
TextWidget(text: qrResult, bold: false, size: 14),
|
||||
TextWidget(text: 'Invalid', bold: true, size: 24, color: redColor),
|
||||
const Gap(16),
|
||||
Container(
|
||||
width: 90,
|
||||
height: 90,
|
||||
decoration: BoxDecoration(
|
||||
color: redColorShade,
|
||||
border: Border.all(color: redColor, width: 2),
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
),
|
||||
child: Icon(Icons.close, color: redColor, size: 48),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
TextWidget(text: 'Not valid OCBO e-Sign QR', bold: true, size: 20, color: redColor),
|
||||
],
|
||||
)
|
||||
else if (qrResult != 'non-exist')
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width - 160,
|
||||
padding: const EdgeInsets.fromLTRB(8, 16, 8, 26),
|
||||
decoration: BoxDecoration(
|
||||
border: BoxBorder.all(color: redColor),
|
||||
color: redColorShade,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
TextWidget(text: 'Unregistered', bold: true, size: 24, color: redColor),
|
||||
const Gap(16),
|
||||
Container(
|
||||
width: 90,
|
||||
height: 90,
|
||||
decoration: BoxDecoration(
|
||||
color: redColorShade,
|
||||
border: Border.all(color: redColor, width: 2),
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
),
|
||||
child: Icon(Icons.close, color: redColor, size: 48),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
TextWidget(text: 'OCBO e-Sign QR is not registered', bold: true, size: 20, color: redColor),
|
||||
],
|
||||
)
|
||||
else
|
||||
Row(
|
||||
Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsets.all(0),
|
||||
width: 90,
|
||||
height: 90,
|
||||
width: MediaQuery.of(context).size.width - 160,
|
||||
padding: const EdgeInsets.fromLTRB(8, 16, 8, 26),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color.fromRGBO(206, 74, 77, 0.1),
|
||||
border: Border.all(color: const Color.fromRGBO(206, 74, 77, 1), width: 2),
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
border: BoxBorder.all(color: greenColor),
|
||||
color: greenColorShade,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
TextWidget(text: 'Valid', bold: true, size: 24, color: greenColor),
|
||||
const Gap(16),
|
||||
Container(
|
||||
padding: EdgeInsets.all(0),
|
||||
width: 90,
|
||||
height: 90,
|
||||
decoration: BoxDecoration(
|
||||
color: greenColorShade,
|
||||
border: Border.all(color: greenColor, width: 2),
|
||||
borderRadius: BorderRadius.circular(99),
|
||||
),
|
||||
child: Icon(Icons.check, color: greenColor, size: 48),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Icon(Icons.close, color: const Color.fromRGBO(206, 74, 77, 1), size: 48),
|
||||
),
|
||||
const Gap(24),
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const TextWidget(
|
||||
text: 'Invalid',
|
||||
bold: true,
|
||||
size: 22,
|
||||
color: Color.fromRGBO(206, 74, 77, 1),
|
||||
),
|
||||
const Gap(16),
|
||||
const TextWidget(
|
||||
text: 'QR is a not valid OCBO e-Sign',
|
||||
bold: false,
|
||||
size: 14,
|
||||
color: Color.fromRGBO(206, 74, 77, 1),
|
||||
),
|
||||
],
|
||||
),
|
||||
TextWidget(text: qrResult, bold: true, size: 20, color: greenColor),
|
||||
const Gap(24),
|
||||
ButtonWidget(text: "Show Details", disabled: false, onPressed: gotoDetails),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue