Compare commits
No commits in common. "5584af0fb763588bdc1794dc317a97dcc294f0ff" and "6a565815fc4b715de15153030e656434136a8433" have entirely different histories.
5584af0fb7
...
6a565815fc
6 changed files with 81 additions and 152 deletions
|
|
@ -1,10 +1,6 @@
|
|||
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';
|
||||
|
||||
|
|
@ -17,28 +13,14 @@ class ApprovalPage extends StatefulWidget {
|
|||
|
||||
class _ApprovalPageState extends State<ApprovalPage> {
|
||||
late String blocUser = '';
|
||||
late List<dynamic> _applicationList = [];
|
||||
late List<dynamic> _nameList = [];
|
||||
|
||||
Future<String> _getUser() async {
|
||||
final user = await blocGetUser(context);
|
||||
return user;
|
||||
}
|
||||
|
||||
Future<void> _getListForApprovalElectrical() async {
|
||||
final response = await getApi('get-listopapproval-electrical', null, null);
|
||||
|
||||
_applicationList = response["result"];
|
||||
_nameList = response["result2"];
|
||||
}
|
||||
|
||||
void _initUser() async {
|
||||
final user = await _getUser();
|
||||
await _getListForApprovalElectrical();
|
||||
|
||||
setState(() {
|
||||
blocUser = user;
|
||||
});
|
||||
blocUser = await _getUser();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -70,60 +52,18 @@ class _ApprovalPageState extends State<ApprovalPage> {
|
|||
child: Column(
|
||||
children: [
|
||||
const Gap(76),
|
||||
Column(
|
||||
Row(
|
||||
children: [
|
||||
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(16),
|
||||
const ImageWidget(imagePath: 'assets/logo.png', size: 32, measureByHeight: true),
|
||||
const Gap(8),
|
||||
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),
|
||||
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),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,13 +1,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_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';
|
||||
|
|
@ -24,7 +22,7 @@ class LoginPage extends StatefulWidget {
|
|||
class _LoginPageState extends State<LoginPage> {
|
||||
final _passwordController = TextEditingController();
|
||||
final _approver = dotenv.env['HEAD']!;
|
||||
final _approverId = dotenv.env['HEADID']!;
|
||||
// final _approverId = dotenv.env['HEADID']!;
|
||||
late ValueNotifier<String> passwordNotifier;
|
||||
|
||||
@override
|
||||
|
|
@ -36,58 +34,58 @@ class _LoginPageState extends State<LoginPage> {
|
|||
});
|
||||
}
|
||||
|
||||
Future<bool> _checkConnection() async {
|
||||
try {
|
||||
final connection = await getApi('check-connection', null, null);
|
||||
return connection["result"];
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Future<bool> _checkConnection() async {
|
||||
// try {
|
||||
// final connection = await getApi('check-connection', null, null);
|
||||
// return connection["result"];
|
||||
// } catch (e) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<String> _getPassword(String employeeid) async {
|
||||
try {
|
||||
final response = await getApi('get-password', employeeid, null);
|
||||
return (response["result"]);
|
||||
} catch (e) {
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
// Future<String> _getPassword(String employeeid) async {
|
||||
// try {
|
||||
// final response = await getApi('get-password', employeeid, null);
|
||||
// return (response["result"]);
|
||||
// } catch (e) {
|
||||
// return "0";
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<String> _securePassword(String password) async {
|
||||
final firstHash = sha1.string(password);
|
||||
final secondHash = sha384.string(firstHash.toString());
|
||||
final thirdHash = sha1.string(secondHash.toString());
|
||||
// Future<String> _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() {}
|
||||
|
||||
|
|
@ -137,28 +135,28 @@ class _LoginPageState extends State<LoginPage> {
|
|||
InputWidget(controller: _passwordController, password: true),
|
||||
const Gap(24),
|
||||
|
||||
ValueListenableBuilder<String>(
|
||||
valueListenable: passwordNotifier,
|
||||
builder: (context, password, child) {
|
||||
return ButtonWidget(
|
||||
text: password.isNotEmpty ? 'Login' : 'Required password',
|
||||
onPressed: password.isNotEmpty ? _login : _ignoreButton,
|
||||
disabled: password.isEmpty,
|
||||
);
|
||||
},
|
||||
),
|
||||
// ValueListenableBuilder<String>(
|
||||
// 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<String>(
|
||||
valueListenable: passwordNotifier,
|
||||
builder: (context, password, child) {
|
||||
return ButtonWidget(
|
||||
text: _passwordController.text.isNotEmpty
|
||||
? "Stop typing, login not ready"
|
||||
: 'Not yet functional',
|
||||
onPressed: _ignoreButton,
|
||||
disabled: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ class BarcodeScannerScreen extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
||||
final Color _redColorShade = const Color(0x33562626);
|
||||
final Color _redColor = const Color(0xCCEB5873);
|
||||
final Color _redColorShade = const Color.fromRGBO(86, 38, 38, 0.2);
|
||||
final Color _redColor = const Color.fromRGBO(235, 88, 115, 0.8);
|
||||
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<BarcodeScannerScreen> {
|
|||
_qrResult = 'invalid';
|
||||
});
|
||||
|
||||
Future.delayed(Duration(seconds: 8), () {
|
||||
Future.delayed(Duration(seconds: 3), () {
|
||||
setState(() {
|
||||
_qrResult = '';
|
||||
});
|
||||
|
|
@ -74,7 +74,7 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
_scanning = true;
|
||||
});
|
||||
|
||||
final value = "Use OCBO e-Sig Validator - scanid=0918d59e";
|
||||
final value = "Use OCBO e-Sign Validator - scanid=0918d59e";
|
||||
|
||||
if (value.contains('OCBO e-Sign')) {
|
||||
final qr = value.substring(35);
|
||||
|
|
@ -153,7 +153,7 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
Container(
|
||||
padding: EdgeInsets.only(top: 8, bottom: 8, left: 20, right: 20),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color.fromRGBO(9, 13, 16, 0.722),
|
||||
color: const Color.fromRGBO(9, 13, 16, 0.725),
|
||||
borderRadius: BorderRadius.circular(32),
|
||||
),
|
||||
child: const TextWidget(text: 'Scan OCBO e-Sign QR Code', size: 14, bold: true),
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ class ButtonWidget extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: const Color.fromRGBO(250, 250, 250, 1),
|
||||
backgroundColor: disabled ? const Color.fromRGBO(13, 109, 253, 0.435) : const Color.fromRGBO(13, 109, 253, 0.8),
|
||||
foregroundColor: const Color.fromRGBO(250, 250, 250, 1), // text color
|
||||
backgroundColor: disabled ? const Color.fromARGB(112, 13, 109, 253) : const Color(0xff0d6efd),
|
||||
elevation: disabled ? 0 : 4,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8), // rounded corners
|
||||
|
|
|
|||
|
|
@ -41,14 +41,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
bottom_bar:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: bottom_bar
|
||||
sha256: a2c96d8be21ab6173ac95bae3bcb2beb4c9a4cae7d82674f5551303986e121bf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.5"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ dependencies:
|
|||
vibration: ^3.1.4
|
||||
intl: ^0.20.2
|
||||
loading_animation_widget: ^1.3.0
|
||||
bottom_bar: ^2.0.5
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue