diff --git a/lib/pages/approval_page.dart b/lib/pages/approval_page.dart index 3361250..5ba85cc 100644 --- a/lib/pages/approval_page.dart +++ b/lib/pages/approval_page.dart @@ -1,10 +1,71 @@ import 'package:flutter/material.dart'; +import 'package:gap/gap.dart'; +import 'package:ocbo_esign_validator/blocs/user/functions/bloc_getuser.dart'; +import 'package:ocbo_esign_validator/widgets/image_widget.dart'; +import 'package:ocbo_esign_validator/widgets/text_widget.dart'; -class ApprovalPage extends StatelessWidget { +class ApprovalPage extends StatefulWidget { const ApprovalPage({super.key}); + @override + State createState() => _ApprovalPageState(); +} + +class _ApprovalPageState extends State { + late String blocUser = ''; + + Future _getUser() async { + final user = await blocGetUser(context); + return user; + } + + void _initUser() async { + blocUser = await _getUser(); + } + + @override + void initState() { + _initUser(); + super.initState(); + } + @override Widget build(BuildContext context) { - return Scaffold(); + 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: Column( + children: [ + const Gap(76), + Row( + children: [ + const Gap(16), + const ImageWidget(imagePath: 'assets/logo.png', size: 32, measureByHeight: true), + const Gap(8), + TextWidget(text: blocUser, size: 16, bold: true), + const MaxGap(80), + Icon(Icons.menu, size: 20, color: Colors.white), + ], + ), + const Gap(32), + TextWidget(text: blocUser, size: 16, bold: true), + ], + ), + ), + ); } } diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index f6b4a84..0d481d3 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -3,8 +3,11 @@ import 'dart:developer'; 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:hashlib/hashlib.dart'; +import 'package:ocbo_esign_validator/blocs/user/functions/bloc_setuser.dart'; import 'package:ocbo_esign_validator/functions/get_api.dart'; +import 'package:ocbo_esign_validator/functions/modal.dart'; import 'package:ocbo_esign_validator/widgets/box_widget.dart'; import 'package:ocbo_esign_validator/widgets/button_widget.dart'; import 'package:ocbo_esign_validator/widgets/image_widget.dart'; @@ -66,14 +69,26 @@ class _LoginPageState extends State { final employeeid = _approverId; final dbpassword = await _getPassword(employeeid); final hashPassword = await _securePassword(_passwordController.text); - if (dbpassword == hashPassword) { - log('yeah'); - } else { - log('no'); + + if (context.mounted) { + if (dbpassword == hashPassword) { + _setLogin(); + } else { + _showDialog(); + } } } } + void _setLogin() { + blocSetUser(context, _approver); + context.push('/approval'); + } + + void _showDialog() { + showModal(context, 'Error', 'Invalid password, try again.', true); + } + void _ignoreButton() {} @override diff --git a/lib/pages/validate_page.dart b/lib/pages/validate_page.dart index 47b5035..469a866 100644 --- a/lib/pages/validate_page.dart +++ b/lib/pages/validate_page.dart @@ -20,7 +20,7 @@ class BarcodeScannerScreen extends StatefulWidget { } class _BarcodeScannerScreenState extends State { - String barcodeResult = "Point the camera at a barcode"; + late String qrResult = ''; @override Widget build(BuildContext context) { @@ -54,7 +54,7 @@ class _BarcodeScannerScreenState extends State { ), child: TextWidget(text: 'Scan OCBO e-Sign QR Code', size: 14, bold: true), ), - Gap(50), + const Gap(50), SizedBox( height: 350, child: ClipRRect( @@ -65,13 +65,31 @@ class _BarcodeScannerScreenState extends State { final List barcodes = capture.barcodes; if (barcodes.isNotEmpty && barcodes.first.rawValue != null) { setState(() { - barcodeResult = barcodes.first.rawValue!; + 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), ], ), ),