Compare commits
4 commits
fd33a67b47
...
89fdcce613
| Author | SHA1 | Date | |
|---|---|---|---|
| 89fdcce613 | |||
| bb4cbcabe7 | |||
| c5e0b439ad | |||
| be352aa263 |
12 changed files with 226 additions and 51 deletions
14
lib/blocs/qr/functions/bloc_getqr.dart
Normal file
14
lib/blocs/qr/functions/bloc_getqr.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:ocbo_esign_mobile/blocs/qr/qr_bloc.dart';
|
||||
import 'package:ocbo_esign_mobile/blocs/qr/qr_event.dart';
|
||||
|
||||
Future<String> blocGetQr(BuildContext context) async {
|
||||
try {
|
||||
final qrBloc = context.read<QrBloc>();
|
||||
qrBloc.add(QrGetValue());
|
||||
return qrBloc.state.value;
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
14
lib/blocs/qr/functions/bloc_setqr.dart
Normal file
14
lib/blocs/qr/functions/bloc_setqr.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:ocbo_esign_mobile/blocs/qr/qr_bloc.dart';
|
||||
import 'package:ocbo_esign_mobile/blocs/qr/qr_event.dart';
|
||||
|
||||
Future<bool> blocSetQr(BuildContext context, String value) async {
|
||||
try {
|
||||
final qrBloc = context.read<QrBloc>();
|
||||
qrBloc.add(QrSetValue(value));
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
14
lib/blocs/qr/qr_bloc.dart
Normal file
14
lib/blocs/qr/qr_bloc.dart
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:ocbo_esign_mobile/blocs/qr/qr_event.dart';
|
||||
import 'package:ocbo_esign_mobile/blocs/qr/qr_state.dart';
|
||||
|
||||
class QrBloc extends Bloc<QrEvent, QrState> {
|
||||
QrBloc() : super(QrState('')) {
|
||||
on<QrSetValue>((event, emit) {
|
||||
emit(QrState(event.value));
|
||||
});
|
||||
on<QrGetValue>((event, emit) {
|
||||
emit(state);
|
||||
});
|
||||
}
|
||||
}
|
||||
8
lib/blocs/qr/qr_event.dart
Normal file
8
lib/blocs/qr/qr_event.dart
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
abstract class QrEvent {}
|
||||
|
||||
class QrSetValue extends QrEvent {
|
||||
final String value;
|
||||
QrSetValue(this.value);
|
||||
}
|
||||
|
||||
class QrGetValue extends QrEvent {}
|
||||
5
lib/blocs/qr/qr_state.dart
Normal file
5
lib/blocs/qr/qr_state.dart
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class QrState {
|
||||
final String value;
|
||||
|
||||
QrState(this.value);
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:dio_smart_retry/dio_smart_retry.dart';
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ class IndexPage extends StatelessWidget {
|
|||
child: Column(
|
||||
children: [
|
||||
const Gap(88),
|
||||
const ImageWidget(imagePath: 'assets/logo.webp', size: 140, measureByHeight: false),
|
||||
const Gap(24),
|
||||
const ImageWidget(imagePath: 'assets/logo.webp', size: 160, measureByHeight: false),
|
||||
const Gap(20),
|
||||
const TextWidget(
|
||||
text: "OCBO e-Sign",
|
||||
color: Color.fromARGB(255, 244, 243, 243),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import 'package:ocbo_esign_mobile/widgets/box_widget.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';
|
||||
import 'package:ocbo_esign_mobile/widgets/login_box_widget.dart';
|
||||
import 'package:ocbo_esign_mobile/widgets/text_widget.dart';
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
|
|
@ -121,7 +122,7 @@ class _LoginPageState extends State<LoginPage> {
|
|||
const Gap(88),
|
||||
const ImageWidget(imagePath: 'assets/logo.webp', size: 100, measureByHeight: true),
|
||||
const Gap(58),
|
||||
BoxWidget(
|
||||
LoginBoxWidget(
|
||||
title: 'Login',
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,43 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:developer';
|
||||
|
||||
class ValidateDetailPage extends StatelessWidget {
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.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';
|
||||
import 'package:ocbo_esign_mobile/widgets/input_widget.dart';
|
||||
import 'package:ocbo_esign_mobile/widgets/text_widget.dart';
|
||||
|
||||
class ValidateDetailPage extends StatefulWidget {
|
||||
const ValidateDetailPage({super.key});
|
||||
|
||||
@override
|
||||
State<ValidateDetailPage> createState() => _ValidateDetailPageState();
|
||||
}
|
||||
|
||||
class _ValidateDetailPageState extends State<ValidateDetailPage> {
|
||||
final _searchController = TextEditingController();
|
||||
late double _total = 0;
|
||||
|
||||
void _getTotalSigned() async {
|
||||
final name = await blocGetQr(context);
|
||||
final response = await getApi('get-transactions-count', name, null);
|
||||
log(name.toString());
|
||||
log(response.toString());
|
||||
final total = response['result'];
|
||||
|
||||
setState(() {
|
||||
_total = double.parse(total);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_getTotalSigned();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
|
@ -23,6 +58,45 @@ class ValidateDetailPage extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
),
|
||||
child: SizedBox(
|
||||
width: MediaQuery.of(context).size.width - 90,
|
||||
child: Column(
|
||||
children: [
|
||||
const Gap(88),
|
||||
InputWidget(controller: _searchController, password: false, placeholder: 'Specify Application Number'),
|
||||
const Gap(24),
|
||||
BoxWidget(
|
||||
circular: 16,
|
||||
content: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
TextWidget(text: _total.toString(), size: 64, bold: true),
|
||||
TextWidget(text: 'Total Signed Applications', size: 16),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Gap(16),
|
||||
const BoxWidget(
|
||||
circular: 16,
|
||||
content: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
TextWidget(text: '23-000123', size: 24, bold: true),
|
||||
TextWidget(text: 'Total Signed Applications', size: 20),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:mobile_scanner/mobile_scanner.dart';
|
||||
import 'package:ocbo_esign_mobile/blocs/qr/functions/bloc_setqr.dart';
|
||||
import 'package:ocbo_esign_mobile/functions/get_api.dart';
|
||||
import 'package:ocbo_esign_mobile/widgets/button_widget.dart';
|
||||
import 'package:ocbo_esign_mobile/widgets/text_widget.dart';
|
||||
|
|
@ -59,37 +62,50 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
}
|
||||
}
|
||||
|
||||
// void tryQR() async {
|
||||
// final value = "Use OCBO e-Sign Validator - scanid=0918d59e";
|
||||
void tryQR() async {
|
||||
final value = "Use OCBO e-Sign Validator - scanid=0918d59e";
|
||||
|
||||
// if (value.contains('OCBO e-Sign')) {
|
||||
// final qr = value.substring(35);
|
||||
// final response = await getApi('check-qr', qr, null);
|
||||
// final result = response["result"].toString();
|
||||
if (value.contains('OCBO e-Sign')) {
|
||||
final qr = value.substring(35);
|
||||
final response = await getApi('check-qr', qr, null);
|
||||
final result = response["result"]?.toString();
|
||||
log('result: $result');
|
||||
|
||||
// if (result != '') {
|
||||
// setState(() {
|
||||
// qrResult = result;
|
||||
// });
|
||||
// } else {
|
||||
// setState(() {
|
||||
// qrResult = 'result';
|
||||
// });
|
||||
// }
|
||||
// } else {
|
||||
// setState(() {
|
||||
// qrResult = 'invalid';
|
||||
// });
|
||||
if (result != null) {
|
||||
setState(() {
|
||||
qrResult = result;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
qrResult = 'non-exist';
|
||||
});
|
||||
|
||||
// Future.delayed(Duration(seconds: 3), () {
|
||||
// setState(() {
|
||||
// qrResult = '';
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
Future.delayed(Duration(seconds: 3), () {
|
||||
setState(() {
|
||||
qrResult = '';
|
||||
});
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setState(() {
|
||||
qrResult = 'invalid';
|
||||
});
|
||||
|
||||
void gotoDetails() {
|
||||
Future.delayed(Duration(seconds: 3), () {
|
||||
setState(() {
|
||||
qrResult = '';
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void updateBlockQr() async {
|
||||
await blocSetQr(context, qrResult);
|
||||
}
|
||||
|
||||
void gotoDetails() async {
|
||||
log('qr $qrResult');
|
||||
updateBlockQr();
|
||||
context.push('/details');
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +180,7 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
),
|
||||
),
|
||||
const Gap(24),
|
||||
// ButtonWidget(text: 'Try API', disabled: false, onPressed: tryQR),
|
||||
ButtonWidget(text: 'Try API', disabled: false, onPressed: tryQR),
|
||||
if (qrResult.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
|
|
@ -201,7 +217,7 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
TextWidget(text: 'Not valid OCBO e-Sign QR', bold: true, size: 20, color: redColor),
|
||||
],
|
||||
)
|
||||
else if (qrResult != 'non-exist')
|
||||
else if (qrResult == 'non-exist')
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
|
|
|
|||
|
|
@ -3,37 +3,25 @@ import 'package:gap/gap.dart';
|
|||
import 'package:ocbo_esign_mobile/widgets/text_widget.dart';
|
||||
|
||||
class BoxWidget extends StatelessWidget {
|
||||
final String title;
|
||||
final Widget content;
|
||||
final double? circular;
|
||||
// final double? titleSize;
|
||||
|
||||
const BoxWidget({super.key, required this.title, required this.content});
|
||||
const BoxWidget({super.key, required this.content, this.circular = 8});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderRadius: BorderRadius.circular(circular ?? 8),
|
||||
color: Color.fromRGBO(16, 22, 28, 0.584),
|
||||
border: Border.all(color: const Color.fromRGBO(41, 60, 78, 0.914)),
|
||||
),
|
||||
width: MediaQuery.of(context).size.width - 30,
|
||||
// height: MediaQuery.of(context).size.height / 2.2,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (title.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [TextWidget(text: title, bold: true, size: 24)],
|
||||
),
|
||||
const Gap(16),
|
||||
],
|
||||
),
|
||||
Padding(padding: const EdgeInsets.all(16), child: content),
|
||||
],
|
||||
children: [Padding(padding: const EdgeInsets.all(16), child: content)],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
40
lib/widgets/login_box_widget.dart
Normal file
40
lib/widgets/login_box_widget.dart
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:ocbo_esign_mobile/widgets/text_widget.dart';
|
||||
|
||||
class LoginBoxWidget extends StatelessWidget {
|
||||
final String title;
|
||||
final Widget content;
|
||||
|
||||
const LoginBoxWidget({super.key, required this.title, required this.content});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
color: Color.fromRGBO(16, 22, 28, 0.584),
|
||||
border: Border.all(color: const Color.fromRGBO(41, 60, 78, 0.914)),
|
||||
),
|
||||
width: MediaQuery.of(context).size.width - 30,
|
||||
// height: MediaQuery.of(context).size.height / 2.2,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (title.isNotEmpty)
|
||||
Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [TextWidget(text: title, bold: true, size: 24)],
|
||||
),
|
||||
const Gap(16),
|
||||
],
|
||||
),
|
||||
Padding(padding: const EdgeInsets.all(16), child: content),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue