Updated pages
This commit is contained in:
parent
cf9cdafc6b
commit
9268a3337d
4 changed files with 138 additions and 42 deletions
|
|
@ -5,6 +5,7 @@ import 'package:mobile_scanner/mobile_scanner.dart';
|
|||
import 'package:ocbo_esign_mobile/blocs/qr/functions/bloc_setqr.dart';
|
||||
import 'package:ocbo_esign_mobile/functions/get_api.dart';
|
||||
import 'package:ocbo_esign_mobile/widgets/button_widget.dart';
|
||||
import 'package:ocbo_esign_mobile/widgets/loading_widget.dart';
|
||||
import 'package:ocbo_esign_mobile/widgets/text_widget.dart';
|
||||
import 'package:vibration/vibration.dart';
|
||||
|
||||
|
|
@ -26,13 +27,18 @@ class BarcodeScannerScreen extends StatefulWidget {
|
|||
|
||||
class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
||||
final Color _redColorShade = const Color.fromRGBO(86, 38, 38, 0.2);
|
||||
final Color _redColor = const Color.fromRGBO(235, 88, 115, 0.91);
|
||||
final Color _greenColorShade = const Color.fromARGB(51, 41, 115, 43);
|
||||
final Color _greenColor = const Color.fromRGBO(76, 206, 81, 0.91);
|
||||
final Color _redColor = const Color.fromRGBO(235, 88, 115, 0.8);
|
||||
final Color _greenColorShade = const Color.fromRGBO(41, 115, 43, 0.2);
|
||||
final Color _greenColor = const Color.fromRGBO(76, 206, 81, 0.8);
|
||||
|
||||
late String _qrResult = '';
|
||||
late bool _scanning = false;
|
||||
|
||||
void readQr(String value) async {
|
||||
setState(() {
|
||||
_scanning = true;
|
||||
});
|
||||
|
||||
if (value.contains('OCBO e-Sign')) {
|
||||
final qr = value.substring(35);
|
||||
final response = await getApi('check-qr', qr, null);
|
||||
|
|
@ -40,15 +46,18 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
|
||||
if (result != '') {
|
||||
setState(() {
|
||||
_scanning = false;
|
||||
_qrResult = result;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_scanning = false;
|
||||
_qrResult = 'non-exist';
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
_scanning = false;
|
||||
_qrResult = 'invalid';
|
||||
});
|
||||
|
||||
|
|
@ -61,6 +70,10 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
}
|
||||
|
||||
void tryQR() async {
|
||||
setState(() {
|
||||
_scanning = true;
|
||||
});
|
||||
|
||||
final value = "Use OCBO e-Sign Validator - scanid=0918d59e";
|
||||
|
||||
if (value.contains('OCBO e-Sign')) {
|
||||
|
|
@ -70,10 +83,12 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
_scanning = false;
|
||||
_qrResult = result;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_scanning = false;
|
||||
_qrResult = 'non-exist';
|
||||
});
|
||||
|
||||
|
|
@ -85,6 +100,7 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
}
|
||||
} else {
|
||||
setState(() {
|
||||
_scanning = false;
|
||||
_qrResult = 'invalid';
|
||||
});
|
||||
|
||||
|
|
@ -180,7 +196,14 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
),
|
||||
),
|
||||
const Gap(24),
|
||||
ButtonWidget(text: 'Try API', disabled: false, onPressed: tryQR),
|
||||
// ButtonWidget(text: 'Try API', disabled: false, onPressed: tryQR),
|
||||
if (_scanning)
|
||||
Column(
|
||||
children: [
|
||||
const Gap(16),
|
||||
const LoadingWidget(text: 'Reading QR'),
|
||||
],
|
||||
),
|
||||
if (_qrResult.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue