ocbo-esign-mobile/lib/pages/validate_page.dart

100 lines
3.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:ocbo_esign_validator/widgets/text_widget.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: 88, left: 16, right: 16),
child: Column(
children: [
Container(
padding: EdgeInsets.only(top: 8, bottom: 8, left: 20, right: 20),
decoration: BoxDecoration(
color: Color.fromARGB(149, 16, 22, 28),
borderRadius: BorderRadius.circular(8),
),
child: TextWidget(text: 'Scan OCBO e-Sign QR Code', size: 14, bold: true),
),
const Gap(50),
SizedBox(
height: 350,
child: ClipRRect(
borderRadius: BorderRadius.circular(20), // Adjust the radius as needed
child: MobileScanner(
fit: BoxFit.cover,
onDetect: (BarcodeCapture capture) {
final List<Barcode> barcodes = capture.barcodes;
if (barcodes.isNotEmpty && barcodes.first.rawValue != null) {
setState(() {
qrResult = barcodes.first.rawValue!;
});
}
},
),
),
),
const Gap(40),
Container(
padding: EdgeInsets.all(0),
width: 120,
height: 120,
decoration: BoxDecoration(
border: Border.all(
color: Color.fromRGBO(59, 169, 62, 1),
width: 2,
), // Background color of the container
borderRadius: BorderRadius.circular(99), // Optional: rounded corners
),
child: Icon(Icons.thumb_up, color: const Color.fromRGBO(59, 169, 62, 1), size: 80),
),
const Gap(16),
const TextWidget(text: 'Verified', size: 20, bold: true, color: Color.fromRGBO(59, 169, 62, 1)),
const Gap(16),
TextWidget(text: qrResult, size: 20, bold: true),
],
),
),
),
),
);
}
}