164 lines
6.5 KiB
Dart
164 lines
6.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
import 'package:gap/gap.dart';
|
|
import 'package:mobile_scanner/mobile_scanner.dart';
|
|
import 'package:ocbo_esign_validator/widgets/box_widget.dart';
|
|
import 'package:ocbo_esign_validator/widgets/text_widget.dart';
|
|
import 'package:vibration/vibration.dart';
|
|
|
|
class ValidatePage extends StatelessWidget {
|
|
const ValidatePage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return const MaterialApp(debugShowCheckedModeBanner: false, home: BarcodeScannerScreen());
|
|
}
|
|
}
|
|
|
|
class BarcodeScannerScreen extends StatefulWidget {
|
|
const BarcodeScannerScreen({super.key});
|
|
|
|
@override
|
|
State<BarcodeScannerScreen> createState() => _BarcodeScannerScreenState();
|
|
}
|
|
|
|
class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|
late String qrResult = '';
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
resizeToAvoidBottomInset: false,
|
|
body: Container(
|
|
alignment: Alignment.center,
|
|
height: MediaQuery.of(context).size.height,
|
|
decoration: const BoxDecoration(
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
Color.fromRGBO(39, 26, 47, 1),
|
|
Color.fromRGBO(22, 33, 44, 1),
|
|
Color.fromRGBO(22, 33, 44, 1),
|
|
Color.fromRGBO(24, 45, 40, 1),
|
|
],
|
|
),
|
|
),
|
|
child: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(top: 70, left: 16, right: 16),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.only(top: 8, bottom: 8, left: 20, right: 20),
|
|
decoration: BoxDecoration(
|
|
color: const Color.fromRGBO(9, 13, 16, 0.623),
|
|
borderRadius: BorderRadius.circular(32),
|
|
),
|
|
child: const TextWidget(text: 'Scan OCBO e-Sign QR Code', size: 14, bold: true),
|
|
),
|
|
const Gap(24),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(24),
|
|
boxShadow: [
|
|
const BoxShadow(
|
|
color: Color.fromRGBO(5, 5, 8, 0.341),
|
|
blurRadius: 8.0,
|
|
offset: Offset(4, 4), // left and up
|
|
),
|
|
const BoxShadow(
|
|
color: Color.fromRGBO(92, 71, 97, 0.373),
|
|
blurRadius: 8.0,
|
|
offset: Offset(-4, -4), // right and down
|
|
),
|
|
],
|
|
),
|
|
height: 330,
|
|
width: 340,
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(24), // Adjust the radius as needed
|
|
child: MobileScanner(
|
|
fit: BoxFit.cover,
|
|
onDetect: (BarcodeCapture capture) async {
|
|
final List<Barcode> barcodes = capture.barcodes;
|
|
if (barcodes.isNotEmpty && barcodes.first.rawValue != null) {
|
|
setState(() {
|
|
qrResult = barcodes.first.rawValue!;
|
|
});
|
|
|
|
if (await Vibration.hasVibrator()) {
|
|
Vibration.vibrate(duration: 100);
|
|
}
|
|
}
|
|
},
|
|
),
|
|
),
|
|
),
|
|
const Gap(40),
|
|
if (qrResult.isNotEmpty)
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 16, right: 16),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
children: [
|
|
Container(
|
|
padding: EdgeInsets.all(0),
|
|
width: 90,
|
|
height: 90,
|
|
decoration: BoxDecoration(
|
|
color: const Color.fromRGBO(69, 191, 73, 0.1),
|
|
border: Border.all(color: Color.fromRGBO(69, 191, 73, 1), width: 2),
|
|
borderRadius: BorderRadius.circular(99), // Optional: rounded corners
|
|
),
|
|
child: Icon(Icons.thumb_up, color: const Color.fromRGBO(69, 191, 73, 1), size: 48),
|
|
),
|
|
const Gap(32),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
const TextWidget(
|
|
text: 'Verified',
|
|
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: 16,
|
|
color: Color.fromRGBO(69, 191, 73, 1),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
const Gap(32),
|
|
BoxWidget(
|
|
title: '',
|
|
content: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
TextWidget(text: 'Name', bold: true, size: 14),
|
|
const Gap(8),
|
|
TextWidget(text: dotenv.env['HEAD']!, bold: false, size: 14),
|
|
const Gap(16),
|
|
TextWidget(text: 'Role:', bold: true, size: 14),
|
|
const Gap(8),
|
|
TextWidget(text: 'APPROVER', bold: false, size: 14),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|