ocbo-esign-mobile/lib/pages/application_info_page.dart

139 lines
4.5 KiB
Dart

import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
import 'package:ocbo_esign_mobile/blocs/application/functions/bloc_getapplication.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/text_widget.dart';
class ApplicationInfoPage extends StatefulWidget {
const ApplicationInfoPage({super.key});
@override
State<ApplicationInfoPage> createState() => _ApplicationInfoPageState();
}
class _ApplicationInfoPageState extends State<ApplicationInfoPage> {
late String _applicationNo = '';
late String _name = '';
late String _month = '';
late String _day = '';
late String _year = '';
void _getInfo() async {
late String applicationBloc = '';
late String qrBloc = '';
if (context.mounted) {
applicationBloc = await blocGetApplication(context);
// ignore: use_build_context_synchronously
qrBloc = await blocGetQr(context);
}
final id = await getApi('get-esignid-byname', qrBloc, null);
final response = await getApi('get-infoapproval-electrical', applicationBloc, id["result"].toString());
setState(() {
_applicationNo = applicationBloc;
_name = response["result"].toString();
_month = response["result2"].toString();
_day = response["result3"].toString();
_year = response["result4"].toString();
});
}
@override
void initState() {
_getInfo();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Container(
padding: EdgeInsets.only(left: 16, right: 16),
alignment: Alignment.center,
height: MediaQuery.of(context).size.height,
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color.fromRGBO(37, 25, 44, 1),
Color.fromRGBO(22, 33, 44, 1),
Color.fromRGBO(22, 33, 44, 1),
Color.fromRGBO(22, 33, 44, 1),
Color.fromRGBO(25, 46, 41, 1),
],
),
),
child: Column(
children: [
const Gap(88),
BoxWidget(
circular: 16,
content: Center(child: TextWidget(text: _applicationNo, bold: true)),
),
const Gap(16),
BoxWidget(
circular: 16,
content: Center(child: TextWidget(text: _name, bold: false, size: 16)),
),
const Gap(8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
BoxWidget(
circular: 16,
width: 180,
padding: EdgeInsets.all(0),
content: Center(
child: Column(
children: [
const TextWidget(
text: 'Approved Date',
bold: false,
size: 8,
color: Color.fromRGBO(255, 255, 255, 0.8),
),
const Gap(4),
TextWidget(text: _month, bold: false, size: 16),
TextWidget(text: _day, bold: true, size: 48),
TextWidget(text: _year, bold: false, size: 16),
],
),
),
),
BoxWidget(
circular: 16,
width: 180,
padding: EdgeInsets.all(0),
content: Center(
child: Column(
children: [
const TextWidget(
text: 'Printed Date',
bold: false,
size: 8,
color: Color.fromRGBO(255, 255, 255, 0.8),
),
const Gap(4),
TextWidget(text: _month, bold: false, size: 16),
TextWidget(text: _day, bold: true, size: 48),
TextWidget(text: _year, bold: false, size: 16),
],
),
),
),
],
),
],
),
),
);
}
}