From ea51af0eb99118f0703ed2cbd68bd6c65b91dc44 Mon Sep 17 00:00:00 2001 From: Patrick Alvin Alcala Date: Fri, 6 Feb 2026 18:48:13 +0800 Subject: [PATCH] Updated pages --- lib/pages/index_page.dart | 2 +- lib/pages/login_page.dart | 39 +++-- lib/pages/validate_detail_page.dart | 234 +++++++++++----------------- lib/pages/validate_page.dart | 105 +++++++------ 4 files changed, 168 insertions(+), 212 deletions(-) diff --git a/lib/pages/index_page.dart b/lib/pages/index_page.dart index 21121e9..1992525 100644 --- a/lib/pages/index_page.dart +++ b/lib/pages/index_page.dart @@ -61,7 +61,7 @@ class IndexPage extends StatelessWidget { ], ), ), - const Gap(184), + const Gap(168), Row( mainAxisAlignment: MainAxisAlignment.center, spacing: 32, diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart index 5adcbd7..c9feb51 100644 --- a/lib/pages/login_page.dart +++ b/lib/pages/login_page.dart @@ -1,12 +1,11 @@ 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:ocbo_esign_mobile/widgets/box_widget.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'; @@ -23,7 +22,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 @@ -53,13 +52,13 @@ class _LoginPageState extends State { // } // } - 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(); @@ -79,14 +78,14 @@ class _LoginPageState extends State { // } // } - 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() {} diff --git a/lib/pages/validate_detail_page.dart b/lib/pages/validate_detail_page.dart index 7bfafce..fba5374 100644 --- a/lib/pages/validate_detail_page.dart +++ b/lib/pages/validate_detail_page.dart @@ -1,7 +1,7 @@ -import 'dart:developer'; - import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; +import 'package:go_router/go_router.dart'; +import 'package:ocbo_esign_mobile/blocs/application/functions/bloc_setapplication.dart'; import 'package:ocbo_esign_mobile/blocs/qr/functions/bloc_getqr.dart'; import 'package:ocbo_esign_mobile/functions/get_api.dart'; import 'package:ocbo_esign_mobile/widgets/box_widget.dart'; @@ -22,11 +22,19 @@ class _ValidateDetailPageState extends State { final NumberFormat formatter = NumberFormat('#,###.##'); final dateFormatter = DateFormat('yyyy-MM-dd'); // final Color greenColor = const Color(0xFF4CCE51); + late bool isLoading = false; late int _total = 0; late List _applicationList = []; late List _dateList = []; + late List _timeList = []; + late String _name = ''; + late int _count = 0; void _getTotalSigned() async { + setState(() { + isLoading = true; + }); + final name = await blocGetQr(context); final responseCount = await getApi('get-transactions-count', name, null); final total = responseCount['result']; @@ -34,21 +42,62 @@ class _ValidateDetailPageState extends State { final response = await getApi('get-transactions', name, null); final applicationNoList = response['result']; final dateList = response['result2']; + final timeList = response['result3']; + + _name = name; setState(() { + isLoading = false; _total = double.parse(total).toInt(); + _count = applicationNoList.length; _applicationList = applicationNoList; _dateList = dateList; + _timeList = timeList; }); } + void _filterSigned(String application) async { + final response = await getApi('get-transactions-filter', _name, application); + final applicationNoList = response['result']; + final dateList = response['result2']; + final timeList = response['result3']; + + setState(() { + // isLoading = false; + // _total = double.parse(total).toInt(); + _count = applicationNoList.length; + _applicationList = applicationNoList; + _dateList = dateList; + _timeList = timeList; + }); + } + + void _onTextChanged() { + _filterSigned(_searchController.text); + } + + void _gotoInfo() { + context.push('/info'); + } + + void _showDetails(String application) async { + await blocSetApplication(context, application); + _gotoInfo(); + } + @override void initState() { _getTotalSigned(); - + _searchController.addListener(_onTextChanged); super.initState(); } + @override + void dispose() { + _searchController.removeListener(_onTextChanged); + super.dispose(); + } + @override Widget build(BuildContext context) { return Scaffold( @@ -73,162 +122,63 @@ class _ValidateDetailPageState extends State { width: MediaQuery.of(context).size.width - 112, child: Column( children: [ - const Gap(88), + const Gap(72), BoxWidget( circular: 16, content: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - Column( - children: [ - TextWidget(text: formatter.format(_total), size: 50, bold: true), - const TextWidget(text: 'Total Signed Applications', size: 16), - ], - ), + isLoading + ? TextWidget(text: 'Loading Data, please wait', size: 20, bold: false) + : Column( + children: [ + TextWidget(text: formatter.format(_total), size: 50, bold: true), + const TextWidget(text: 'Total Signed Applications', size: 16), + ], + ), ], ), ), const Gap(16), - ClipRRect( - // borderRadius: BorderRadius.circular(36), - child: InputWidget( - controller: _searchController, - password: false, - placeholder: 'Search Application Number', - ), - ), - const Gap(24), - - // ListView( - // scrollDirection: Axis.horizontal, - // padding: EdgeInsets.symmetric(horizontal: 16), - // children: [ - // // BoxWidget( - // // alignment: CrossAxisAlignment.center, - // // circular: 16, - // // content: Row( - // // children: [ - // // const ImageWidget(imagePath: 'assets/esign.webp', size: 48, measureByHeight: true), - // // const Gap(16), - // // Column( - // // crossAxisAlignment: CrossAxisAlignment.start, - // // children: [ - // // TextWidget(text: '23-000123', size: 18, bold: true), - // // const Gap(4), - // // TextWidget(text: 'Total Signed Applications', size: 12), - // // ], - // // ), - // // ], - // // ), - // // ), - // ], - // ), + InputWidget(controller: _searchController, password: false, placeholder: 'Filter Application Number'), + const Gap(16), Expanded( + flex: 1, child: ListView.builder( - itemCount: _total, + padding: EdgeInsets.only(bottom: 16), + itemCount: _count, itemBuilder: (BuildContext context, int index) { - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - BoxWidget( - alignment: CrossAxisAlignment.center, - 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: 190, - child: TextWidget(text: '8990 Housing Development Corporation', size: 10), - ), - const Gap(4), - TextWidget(text: _dateList[index], size: 10, opacity: 0.8), - ], - ), - ], - ), + return InkWell( + onTap: () => _showDetails(_applicationList[index]), + child: BoxWidget( + alignment: CrossAxisAlignment.center, + 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: 'Date Signed: ${_dateList[index]}', size: 10, opacity: 1), + ), + const Gap(4), + TextWidget(text: 'Time: ${_timeList[index]}', size: 10, opacity: 1), + const Gap(4), + TextWidget(text: 'Tap to show details', size: 9, opacity: 0.6), + ], + ), + ], ), - const Gap(8), - ], + ), ); }, ), ), - - // Column( - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // BoxWidget( - // alignment: CrossAxisAlignment.center, - // circular: 16, - // content: Row( - // children: [ - // const ImageWidget(imagePath: 'assets/esign.webp', size: 48, measureByHeight: true), - // const Gap(16), - // Column( - // crossAxisAlignment: CrossAxisAlignment.start, - // children: [ - // TextWidget(text: '23-000123', size: 18, bold: true), - // const Gap(4), - // TextWidget(text: 'Total Signed Applications', size: 12), - // ], - // ), - // ], - // ), - // ), - // // const Gap(8), - // // BoxWidget( - // // alignment: CrossAxisAlignment.center, - // // circular: 16, - // // content: Row( - // // children: [ - // // const ImageWidget(imagePath: 'assets/esign.webp', size: 48, measureByHeight: true), - // // const Gap(16), - // // Column( - // // crossAxisAlignment: CrossAxisAlignment.start, - // // children: [ - // // TextWidget(text: '23-000123', size: 18, bold: true), - // // const Gap(4), - // // TextWidget(text: 'Total Signed Applications', size: 12), - // // const Gap(4), - // // Expanded( - // // child: Row( - // // mainAxisAlignment: MainAxisAlignment.end, - // // children: [TextWidget(text: 'Dates', size: 8)], - // // ), - // // ), - // // ], - // // ), - // // ], - // // ), - // // ), - // // const Gap(8), - // // BoxWidget( - // // alignment: CrossAxisAlignment.center, - // // circular: 16, - // // content: Row( - // // children: [ - // // const ImageWidget(imagePath: 'assets/esign.webp', size: 48, measureByHeight: true), - // // const Gap(16), - // // Column( - // // crossAxisAlignment: CrossAxisAlignment.start, - // // children: [ - // // TextWidget(text: '23-000123', size: 18, bold: true), - // // const Gap(4), - // // TextWidget(text: 'Total Signed Applications', size: 12), - // // ], - // // ), - // // ], - // // ), - // // ), - // ], - // ), ], ), ), diff --git a/lib/pages/validate_page.dart b/lib/pages/validate_page.dart index 225d635..f89d0e8 100644 --- a/lib/pages/validate_page.dart +++ b/lib/pages/validate_page.dart @@ -1,5 +1,3 @@ -import 'dart:developer'; - import 'package:flutter/material.dart'; import 'package:gap/gap.dart'; import 'package:go_router/go_router.dart'; @@ -27,12 +25,12 @@ class BarcodeScannerScreen extends StatefulWidget { } class _BarcodeScannerScreenState extends State { - late String qrResult = ''; - late String qrResultSub = ''; - final Color redColorShade = const Color.fromARGB(26, 225, 82, 103); - final Color redColor = const Color.fromARGB(255, 229, 89, 115); - final Color greenColorShade = const Color.fromRGBO(69, 191, 73, 0.1); - final Color greenColor = const Color.fromRGBO(76, 206, 81, 1); + 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); + + late String _qrResult = ''; void readQr(String value) async { if (value.contains('OCBO e-Sign')) { @@ -42,21 +40,21 @@ class _BarcodeScannerScreenState extends State { if (result != '') { setState(() { - qrResult = result; + _qrResult = result; }); } else { setState(() { - qrResult = 'non-exist'; + _qrResult = 'non-exist'; }); } } else { setState(() { - qrResult = 'invalid'; + _qrResult = 'invalid'; }); Future.delayed(Duration(seconds: 3), () { setState(() { - qrResult = ''; + _qrResult = ''; }); }); } @@ -72,38 +70,42 @@ class _BarcodeScannerScreenState extends State { if (result != null) { setState(() { - qrResult = result; + _qrResult = result; }); } else { setState(() { - qrResult = 'non-exist'; + _qrResult = 'non-exist'; }); Future.delayed(Duration(seconds: 3), () { setState(() { - qrResult = ''; + _qrResult = ''; }); }); } } else { setState(() { - qrResult = 'invalid'; + _qrResult = 'invalid'; }); Future.delayed(Duration(seconds: 3), () { setState(() { - qrResult = ''; + _qrResult = ''; }); }); } } void updateBlockQr() async { - await blocSetQr(context, qrResult); + await blocSetQr(context, _qrResult); } void gotoDetails() { updateBlockQr(); + setState(() { + _qrResult = ''; + }); + context.push('/details'); } @@ -140,7 +142,7 @@ class _BarcodeScannerScreenState extends State { ), child: const TextWidget(text: 'Scan OCBO e-Sign QR Code', size: 14, bold: true), ), - const Gap(24), + const Gap(16), Container( decoration: BoxDecoration( borderRadius: BorderRadius.circular(36), @@ -158,8 +160,8 @@ class _BarcodeScannerScreenState extends State { // ), // ], ), - height: 330, - width: 340, + height: 308, + width: 318, child: ClipRRect( borderRadius: BorderRadius.circular(36), // Adjust the radius as needed child: MobileScanner( @@ -178,11 +180,11 @@ class _BarcodeScannerScreenState extends State { ), ), const Gap(24), - ButtonWidget(text: 'Try API', disabled: false, onPressed: tryQR), - if (qrResult.isNotEmpty) + // ButtonWidget(text: 'Try API', disabled: false, onPressed: tryQR), + if (_qrResult.isNotEmpty) Column( children: [ - if (qrResult == 'invalid') + if (_qrResult == 'invalid') Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -190,32 +192,32 @@ class _BarcodeScannerScreenState extends State { width: 220, padding: const EdgeInsets.fromLTRB(0, 16, 0, 32), decoration: BoxDecoration( - border: BoxBorder.all(color: redColor), - color: redColorShade, + border: BoxBorder.all(color: _redColor), + color: _redColorShade, borderRadius: BorderRadius.circular(32), ), child: Column( children: [ - TextWidget(text: 'Invalid', bold: true, size: 24, color: redColor), + TextWidget(text: 'Invalid', bold: true, size: 24, color: _redColor), const Gap(16), Container( width: 90, height: 90, decoration: BoxDecoration( - color: redColorShade, - border: Border.all(color: redColor, width: 2), + color: _redColorShade, + border: Border.all(color: _redColor, width: 2), borderRadius: BorderRadius.circular(99), ), - child: Icon(Icons.close, color: redColor, size: 48), + child: Icon(Icons.close, color: _redColor, size: 48), ), ], ), ), const Gap(16), - TextWidget(text: 'Not valid OCBO e-Sign QR', bold: true, size: 20, color: redColor), + TextWidget(text: 'QR Detected is not OCBO e-Sign', bold: true, size: 20, color: _redColor), ], ) - else if (qrResult == 'non-exist') + else if (_qrResult == 'non-exist') Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -223,29 +225,34 @@ class _BarcodeScannerScreenState extends State { width: 220, padding: const EdgeInsets.fromLTRB(0, 16, 0, 32), decoration: BoxDecoration( - border: BoxBorder.all(color: redColor), - color: redColorShade, + border: BoxBorder.all(color: _redColor), + color: _redColorShade, borderRadius: BorderRadius.circular(32), ), child: Column( children: [ - TextWidget(text: 'Unregistered', bold: true, size: 24, color: redColor), + TextWidget(text: 'Unregistered', bold: true, size: 24, color: _redColor), const Gap(16), Container( width: 90, height: 90, decoration: BoxDecoration( - color: redColorShade, - border: Border.all(color: redColor, width: 2), + color: _redColorShade, + border: Border.all(color: _redColor, width: 2), borderRadius: BorderRadius.circular(99), ), - child: Icon(Icons.close, color: redColor, size: 48), + child: Icon(Icons.close, color: _redColor, size: 48), ), ], ), ), const Gap(16), - TextWidget(text: 'OCBO e-Sign QR is not registered', bold: true, size: 20, color: redColor), + TextWidget( + text: 'OCBO e-Sign QR is not registered', + bold: true, + size: 20, + color: _redColor, + ), ], ) else @@ -256,32 +263,32 @@ class _BarcodeScannerScreenState extends State { width: 220, padding: const EdgeInsets.fromLTRB(0, 16, 0, 32), decoration: BoxDecoration( - border: BoxBorder.all(color: greenColor), - color: greenColorShade, + border: BoxBorder.all(color: _greenColor), + color: _greenColorShade, borderRadius: BorderRadius.circular(32), ), child: Column( children: [ - TextWidget(text: 'Valid', bold: true, size: 24, color: greenColor), + TextWidget(text: 'Valid', bold: true, size: 24, color: _greenColor), const Gap(16), Container( padding: EdgeInsets.all(0), width: 90, height: 90, decoration: BoxDecoration( - color: greenColorShade, - border: Border.all(color: greenColor, width: 2), + color: _greenColorShade, + border: Border.all(color: _greenColor, width: 2), borderRadius: BorderRadius.circular(99), ), - child: Icon(Icons.check, color: greenColor, size: 48), + child: Icon(Icons.check, color: _greenColor, size: 48), ), ], ), ), - const Gap(24), - TextWidget(text: qrResult, bold: true, size: 20, color: greenColor), - const Gap(24), - ButtonWidget(text: "Check Signed Applications", disabled: false, onPressed: gotoDetails), + const Gap(16), + TextWidget(text: _qrResult, bold: true, size: 18, color: _greenColor), + const Gap(16), + ButtonWidget(text: "Validate Applications", disabled: false, onPressed: gotoDetails), ], ), ],