From 57ea482f661ae995cd6ee48be90b10c92e6c6dc2 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Mon, 23 Feb 2026 17:01:57 +0800 Subject: [PATCH] Updated pages --- lib/pages/approval_page.dart | 78 ++++++++++++++++++--- lib/pages/login_page.dart | 132 ++++++++++++++++++----------------- lib/pages/validate_page.dart | 10 +-- 3 files changed, 141 insertions(+), 79 deletions(-) diff --git a/lib/pages/approval_page.dart b/lib/pages/approval_page.dart index ee7bd83..37d39e6 100644 --- a/lib/pages/approval_page.dart +++ b/lib/pages/approval_page.dart @@ -1,6 +1,10 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; import 'package:ocbo_esign_mobile/blocs/user/functions/bloc_getuser.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/image_widget.dart'; import 'package:ocbo_esign_mobile/widgets/text_widget.dart'; @@ -13,14 +17,28 @@ class ApprovalPage extends StatefulWidget { class _ApprovalPageState extends State { late String blocUser = ''; + late List _applicationList = []; + late List _nameList = []; Future _getUser() async { final user = await blocGetUser(context); return user; } + Future _getListForApprovalElectrical() async { + final response = await getApi('get-listopapproval-electrical', null, null); + + _applicationList = response["result"]; + _nameList = response["result2"]; + } + void _initUser() async { - blocUser = await _getUser(); + final user = await _getUser(); + await _getListForApprovalElectrical(); + + setState(() { + blocUser = user; + }); } @override @@ -52,18 +70,60 @@ class _ApprovalPageState extends State { child: Column( children: [ const Gap(76), - Row( + Column( children: [ - const Gap(16), - const ImageWidget(imagePath: 'assets/logo.png', size: 32, measureByHeight: true), + BoxWidget( + padding: const EdgeInsets.only(bottom: 8), + content: Center( + child: Column( + children: [ + TextWidget(text: _applicationList.length.toString(), size: 32, bold: true), + const Gap(4), + const TextWidget(text: 'Ready to Sign and Approve Applications', size: 12, bold: false), + ], + ), + ), + ), const Gap(8), - TextWidget(text: blocUser, size: 16, bold: true), - const MaxGap(80), - Icon(Icons.menu, size: 20, color: Colors.white), + Expanded( + flex: 1, + child: ListView.builder( + padding: EdgeInsets.only(bottom: 16), + itemCount: _applicationList.length, + itemBuilder: (BuildContext context, int index) { + return InkWell( + // onTap: () => _showDetails(_applicationList[index]), + child: BoxWidget( + alignment: CrossAxisAlignment.start, + circular: 16, + content: Row( + children: [ + // const ImageWidget(imagePath: 'assets/esign-check.webp', size: 40, measureByHeight: true), + const Gap(16), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextWidget(text: _applicationList[index], size: 18, bold: true), + const Gap(4), + SizedBox(width: 180, child: TextWidget(text: _nameList[index], size: 10, opacity: 1)), + const Gap(4), + const TextWidget(text: 'Tap to show details', size: 9, opacity: 0.6), + ], + ), + ], + ), + ), + ); + }, + ), + ), + // // 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), + // 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 c9feb51..3db7cd1 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -1,11 +1,13 @@ +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_mobile/blocs/user/functions/bloc_setuser.dart'; -// import 'package:ocbo_esign_mobile/functions/get_api.dart'; -// import 'package:ocbo_esign_mobile/functions/modal.dart'; +import 'package:go_router/go_router.dart'; +import 'package:hashlib/hashlib.dart'; +import 'package:ocbo_esign_mobile/blocs/user/functions/bloc_setuser.dart'; +import 'package:ocbo_esign_mobile/functions/get_api.dart'; +import 'package:ocbo_esign_mobile/functions/modal.dart'; import 'package:ocbo_esign_mobile/widgets/button_widget.dart'; import 'package:ocbo_esign_mobile/widgets/image_widget.dart'; import 'package:ocbo_esign_mobile/widgets/input_widget.dart'; @@ -22,7 +24,7 @@ class LoginPage extends StatefulWidget { class _LoginPageState extends State { final _passwordController = TextEditingController(); final _approver = dotenv.env['HEAD']!; - // final _approverId = dotenv.env['HEADID']!; + final _approverId = dotenv.env['HEADID']!; late ValueNotifier passwordNotifier; @override @@ -34,58 +36,58 @@ class _LoginPageState extends State { }); } - // Future _checkConnection() async { - // try { - // final connection = await getApi('check-connection', null, null); - // return connection["result"]; - // } catch (e) { - // return false; - // } - // } + Future _checkConnection() async { + try { + final connection = await getApi('check-connection', null, null); + return connection["result"]; + } catch (e) { + return false; + } + } - // Future _getPassword(String employeeid) async { - // try { - // final response = await getApi('get-password', employeeid, null); - // return (response["result"]); - // } catch (e) { - // return "0"; - // } - // } + Future _getPassword(String employeeid) async { + try { + final response = await getApi('get-password', employeeid, null); + return (response["result"]); + } catch (e) { + return "0"; + } + } - // Future _securePassword(String password) async { - // final firstHash = sha1.string(password); - // final secondHash = sha384.string(firstHash.toString()); - // final thirdHash = sha1.string(secondHash.toString()); + Future _securePassword(String password) async { + final firstHash = sha1.string(password); + final secondHash = sha384.string(firstHash.toString()); + final thirdHash = sha1.string(secondHash.toString()); - // return thirdHash.toString(); - // } + return thirdHash.toString(); + } - // void _login() async { - // final connected = await _checkConnection(); + void _login() async { + final connected = await _checkConnection(); - // if (connected) { - // final employeeid = _approverId; - // final dbpassword = await _getPassword(employeeid); - // final hashPassword = await _securePassword(_passwordController.text); + if (connected) { + final employeeid = _approverId; + final dbpassword = await _getPassword(employeeid); + final hashPassword = await _securePassword(_passwordController.text); - // if (context.mounted) { - // if (dbpassword == hashPassword) { - // _setLogin(); - // } else { - // _showDialog(); - // } - // } - // } - // } + if (context.mounted) { + if (dbpassword == hashPassword) { + _setLogin(); + } else { + _showDialog(); + } + } + } + } - // void _setLogin() { - // blocSetUser(context, _approver); - // context.push('/approval'); - // } + void _setLogin() { + blocSetUser(context, _approver); + context.push('/approval'); + } - // void _showDialog() { - // showModal(context, 'Error', 'Invalid password, try again.', true); - // } + void _showDialog() { + showModal(context, 'Error', 'Invalid password, try again.', true); + } void _ignoreButton() {} @@ -135,28 +137,28 @@ class _LoginPageState extends State { InputWidget(controller: _passwordController, password: true), const Gap(24), - // ValueListenableBuilder( - // valueListenable: passwordNotifier, - // builder: (context, password, child) { - // return ButtonWidget( - // text: password.isNotEmpty ? 'Login' : 'Required password', - // onPressed: password.isNotEmpty ? _login : _ignoreButton, - // disabled: password.isEmpty, - // ); - // }, - // ), ValueListenableBuilder( valueListenable: passwordNotifier, builder: (context, password, child) { return ButtonWidget( - text: _passwordController.text.isNotEmpty - ? "Stop typing, login not ready" - : 'Not yet functional', - onPressed: _ignoreButton, - disabled: true, + text: password.isNotEmpty ? 'Login' : 'Required password', + onPressed: password.isNotEmpty ? _login : _ignoreButton, + disabled: password.isEmpty, ); }, ), + // ValueListenableBuilder( + // valueListenable: passwordNotifier, + // builder: (context, password, child) { + // return ButtonWidget( + // text: _passwordController.text.isNotEmpty + // ? "Stop typing, login not ready" + // : 'Not yet functional', + // onPressed: _ignoreButton, + // disabled: true, + // ); + // }, + // ), ], ), ), diff --git a/lib/pages/validate_page.dart b/lib/pages/validate_page.dart index d28cb28..9c10b9e 100644 --- a/lib/pages/validate_page.dart +++ b/lib/pages/validate_page.dart @@ -26,8 +26,8 @@ class BarcodeScannerScreen extends StatefulWidget { } class _BarcodeScannerScreenState extends State { - final Color _redColorShade = const Color.fromRGBO(86, 38, 38, 0.2); - final Color _redColor = const Color.fromRGBO(235, 88, 115, 0.8); + final Color _redColorShade = const Color(0x33562626); + final Color _redColor = const Color(0xCCEB5873); final Color _greenColorShade = const Color.fromRGBO(41, 115, 43, 0.2); final Color _greenColor = const Color.fromRGBO(76, 206, 81, 0.8); @@ -61,7 +61,7 @@ class _BarcodeScannerScreenState extends State { _qrResult = 'invalid'; }); - Future.delayed(Duration(seconds: 3), () { + Future.delayed(Duration(seconds: 8), () { setState(() { _qrResult = ''; }); @@ -74,7 +74,7 @@ class _BarcodeScannerScreenState extends State { _scanning = true; }); - final value = "Use OCBO e-Sign Validator - scanid=0918d59e"; + final value = "Use OCBO e-Sig Validator - scanid=0918d59e"; if (value.contains('OCBO e-Sign')) { final qr = value.substring(35); @@ -153,7 +153,7 @@ class _BarcodeScannerScreenState extends State { Container( padding: EdgeInsets.only(top: 8, bottom: 8, left: 20, right: 20), decoration: BoxDecoration( - color: const Color.fromRGBO(9, 13, 16, 0.725), + color: const Color.fromRGBO(9, 13, 16, 0.722), borderRadius: BorderRadius.circular(32), ), child: const TextWidget(text: 'Scan OCBO e-Sign QR Code', size: 14, bold: true),