|
- import 'package:assetstock/util/dbHandler.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'util/prefsKey.dart';
- import 'main.dart';
- import 'util/Models.dart';
- import 'package:matrix_gesture_detector/matrix_gesture_detector.dart';
-
- class AssetLogs extends StatefulWidget {
- AssetLogs({Key key}) : super(key: key);
-
- @override
- _AssetLogsState createState() => _AssetLogsState();
- }
-
- class _AssetLogsState extends State<AssetLogs> {
- List<Asset> nonAuditedAsset = [];
- double widthtb = 900;
- double scale=1;
- final searchCon = TextEditingController();
- final scaleCon = TextEditingController();
- String search = '';
- fetchData()async{
- var dbName = await DBHelper.database.getDbName();
- // result.
- var result = await util.JsonDataPostRaw({"dbName" : dbName , "redirect" : "FALSE" , "auditedData" : "FALSE"}, "${prefs.getString(keyClass.hostAddress)??"http://172.16.4.144:3000"}/admin/data/dbDetail");
- if(result['STATUS']!='ERROR'){
- var arrayList = result['DATA']['nonAuditedData'];
- nonAuditedAsset.clear();
- for(int i = 0 ; i <arrayList.length ; i++){
- // print(arrayList[i]);
- nonAuditedAsset.add(Asset.fromJson(arrayList[i]));
- }
- setState(() {
-
- });
- }
- else{
- util.showToast('ALERT', "Can't reach the server.");
- Navigator.pop(context);
- }
- }
-
- @override
- void initState() {
- fetchData();
- scaleCon.text = scale.toStringAsFixed(2);
- super.initState();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- resizeToAvoidBottomInset: false,
- body: Container(
- padding: EdgeInsets.only(top: 10),
- color: Colors.grey.withOpacity(0.3),
- child: Column(
- children: [
- Expanded(
- flex: 2,
- child: Container(
- alignment: Alignment.bottomCenter,
- padding: const EdgeInsets.all(8.0),
- child: Container(
- decoration: BoxDecoration(
- color: Colors.white,
- borderRadius: BorderRadius.circular(20),
- ),
- // padding: EdgeInsets.all(8),
- child: TextField(
- controller: searchCon,
- onSubmitted: (value)async{
- setState(() {
- search = value;
- // searchCon.text = value;
- });
- // await loadAsset(loading: true);
- },
- decoration: InputDecoration(
- border: InputBorder.none,
- focusedBorder: InputBorder.none,
- enabledBorder: InputBorder.none,
- errorBorder: InputBorder.none,
- disabledBorder: InputBorder.none,
- suffixIcon: InkWell(
- onTap: ()async{
- var result = await util.scan();
- if(result['STATUS']==1){
- searchCon.text = result['DATA'];
- search = searchCon.text;
- // await loadAsset();
- setState(() {
-
- });
- }
- },
- child: Icon(Icons.center_focus_strong,color: Colors.blueGrey,)),
- contentPadding: EdgeInsets.only(left: 10,right: 10,top: 15,bottom: 15),
- hintText: "Search Tag Number"
- ),
- ),
- ),
- ),
- ),
- Expanded(
- flex:1,
- child: Padding(
- padding: EdgeInsets.all(5),
- child: Row(
- children: [
- Expanded(
- flex:7,
- child: Container(
- alignment: Alignment.centerLeft,
- child: Text('Non-Audited Asset : ${nonAuditedAsset.length} asset(s)'),
- ),
- ),
- Expanded(
- flex: 1,
- child: Container(
- child: Text('Scale : ')
- ),
- ),
- Expanded(
- flex: 1,
- child: Container(padding: EdgeInsets.only(bottom: 5.0),child: TextField(
- controller: scaleCon,
- keyboardType: TextInputType.number,
- onSubmitted: (value){
- try{
- scale = double.parse(value);
- if(scale>=1.00&&scale<=3.00){
- setState(() {
-
- widthtb = 900 *scale;
- });
- }
- else{
- util.showToast('ERROR', 'Scale must be between 1.00 - 3.00');
- }
- }
- catch(e){
- util.showToast('ERROR', 'Scale must be between 1.00 - 3.00');
- }
- },
- ))),
- ],
- ),
- ),
- ),
- Expanded(
- flex:18,
- child: Container(
- color: Colors.white,
- child: ListView(
- scrollDirection: Axis.horizontal,
- children: [
- Container(
- child: Column(
- children: [
- Container(
- decoration: BoxDecoration(
- border: Border.all(width: 1.0)
- ),
- width: widthtb,
- child: Row(
- children: [
- Container(padding: EdgeInsets.only(left: 5.0),width: widthtb*0.035,child: Text('No',style: TextStyle(fontWeight: FontWeight.bold),)),
- Container(width: widthtb*0.09,child: Text('Tag Number',style: TextStyle(fontWeight: FontWeight.bold))),
- Container(width: widthtb*0.24,child: Text('Asset Desc',style: TextStyle(fontWeight: FontWeight.bold))),
- Container(width: widthtb*0.24,child: Text('PIC',style: TextStyle(fontWeight: FontWeight.bold))),
- Container(width: widthtb*0.13,child: Text('Gedung',style: TextStyle(fontWeight: FontWeight.bold))),
- Container(width: widthtb*0.125,child: Text('Lantai',style: TextStyle(fontWeight: FontWeight.bold))),
- Container(width: widthtb*0.13,child: Text('Ruang',style: TextStyle(fontWeight: FontWeight.bold))),
-
- ],
- ),
- ),
- Expanded(
- child: MatrixGestureDetector(
- onMatrixUpdate: (m,t,s,r){
- scale = MatrixGestureDetector.decomposeToValues(m).scale+1;
- if(scale>3)scale=3;
- setState(() {
- scaleCon.text = scale.toStringAsFixed(2);
- widthtb = 900 *scale;
- // scaleheighttb = 0.04*scale;
- });
- },
- child: Container(
- decoration: BoxDecoration(
- border: Border.all(width: 1.0)
- ),
- width: widthtb,
- child: ListView.builder(
- padding: EdgeInsets.all(0.0),
- itemCount: nonAuditedAsset.length,
- itemBuilder: (context,index){
- Asset idxAsset = nonAuditedAsset[index];
- if(search!=''){
- if(idxAsset.tag_number.toUpperCase().contains(search.toUpperCase())) return Container(
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(width: 0.8))
- ),
- child: Row(
- children: [
- Container(padding: EdgeInsets.only(left: 5.0),width: widthtb*0.035,child: Text('${index+1}')),
- Container(width: widthtb*0.09,child: Text(idxAsset.tag_number)),
- Container(width: widthtb*0.24,child: Text(idxAsset.asset_desc)),
- Container(width: widthtb*0.24,child: Text(idxAsset.pic)),
- Container(width: widthtb*0.13,child: Text(idxAsset.gedung)),
- Container(width: widthtb*0.125,child: Text(idxAsset.lantai)),
- Container(width: widthtb*0.13,child: Text(idxAsset.ruangan)),
- ],
- ),
- );
- else return Container();
- }
- else{
- return Container(
- decoration: BoxDecoration(
- border: Border(bottom: BorderSide(width: 0.8))
- ),
- child: Row(
- children: [
- Container(padding: EdgeInsets.only(left: 5.0),width: widthtb*0.035,child: Text('${index+1}')),
- Container(width: widthtb*0.09,child: Text(idxAsset.tag_number)),
- Container(width: widthtb*0.24,child: Text(idxAsset.asset_desc)),
- Container(width: widthtb*0.24,child: Text(idxAsset.pic)),
- Container(width: widthtb*0.13,child: Text(idxAsset.gedung)),
- Container(width: widthtb*0.125,child: Text(idxAsset.lantai)),
- Container(width: widthtb*0.13,child: Text(idxAsset.ruangan)),
- ],
- ),
- );
- }
- }),
- ),
- ),
- ),
- ],
- ),
- ),
- ],
- ),
- )
- ),
- ],
- ),
- ),
- );
- }
- }
|