Flutter app for Asset Management
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

262 regels
12 KiB

  1. import 'package:assetstock/util/dbHandler.dart';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:flutter/material.dart';
  4. import 'util/prefsKey.dart';
  5. import 'main.dart';
  6. import 'util/Models.dart';
  7. import 'package:matrix_gesture_detector/matrix_gesture_detector.dart';
  8. class AssetLogs extends StatefulWidget {
  9. AssetLogs({Key key}) : super(key: key);
  10. @override
  11. _AssetLogsState createState() => _AssetLogsState();
  12. }
  13. class _AssetLogsState extends State<AssetLogs> {
  14. List<Asset> nonAuditedAsset = [];
  15. double widthtb = 900;
  16. double scale=1;
  17. final searchCon = TextEditingController();
  18. final scaleCon = TextEditingController();
  19. String search = '';
  20. fetchData()async{
  21. var dbName = await DBHelper.database.getDbName();
  22. var bUnit = await DBHelper.database.getBUnit();
  23. // result.
  24. var result = await util.JsonDataPostRaw({"bUnit":bUnit,"dbName" : dbName , "redirect" : "FALSE" , "auditedData" : "FALSE"}, "${prefs.getString(keyClass.hostAddress)??"http://172.16.4.144:3000"}/admin/data/dbDetail");
  25. if(result['STATUS']!=0){
  26. var arrayList = result['DATA']['nonAuditedData'];
  27. nonAuditedAsset.clear();
  28. for(int i = 0 ; i <arrayList.length ; i++){
  29. // print(arrayList[i]);
  30. nonAuditedAsset.add(Asset.fromJson(arrayList[i]));
  31. }
  32. setState(() {
  33. });
  34. }
  35. else{
  36. print(result);
  37. util.showToast('ALERT', "Can't reach the server.");
  38. Navigator.pop(context);
  39. }
  40. }
  41. @override
  42. void initState() {
  43. fetchData();
  44. scaleCon.text = scale.toStringAsFixed(2);
  45. super.initState();
  46. }
  47. @override
  48. Widget build(BuildContext context) {
  49. return Scaffold(
  50. resizeToAvoidBottomInset: false,
  51. body: Container(
  52. padding: EdgeInsets.only(top: 10),
  53. color: Colors.grey.withOpacity(0.3),
  54. child: Column(
  55. children: [
  56. Expanded(
  57. flex: 2,
  58. child: Container(
  59. alignment: Alignment.bottomCenter,
  60. padding: const EdgeInsets.all(8.0),
  61. child: Container(
  62. decoration: BoxDecoration(
  63. color: Colors.white,
  64. borderRadius: BorderRadius.circular(20),
  65. ),
  66. // padding: EdgeInsets.all(8),
  67. child: TextField(
  68. controller: searchCon,
  69. onSubmitted: (value)async{
  70. setState(() {
  71. search = value;
  72. // searchCon.text = value;
  73. });
  74. // await loadAsset(loading: true);
  75. },
  76. decoration: InputDecoration(
  77. border: InputBorder.none,
  78. focusedBorder: InputBorder.none,
  79. enabledBorder: InputBorder.none,
  80. errorBorder: InputBorder.none,
  81. disabledBorder: InputBorder.none,
  82. suffixIcon: InkWell(
  83. onTap: ()async{
  84. var result = await util.scan();
  85. if(result['STATUS']==1){
  86. searchCon.text = result['DATA'];
  87. search = searchCon.text;
  88. // await loadAsset();
  89. setState(() {
  90. });
  91. }
  92. },
  93. child: Icon(Icons.center_focus_strong,color: Colors.blueGrey,)),
  94. contentPadding: EdgeInsets.only(left: 10,right: 10,top: 15,bottom: 15),
  95. hintText: "Search Tag Number"
  96. ),
  97. ),
  98. ),
  99. ),
  100. ),
  101. Expanded(
  102. flex:1,
  103. child: Padding(
  104. padding: EdgeInsets.all(5),
  105. child: Row(
  106. children: [
  107. Expanded(
  108. flex:7,
  109. child: Container(
  110. alignment: Alignment.centerLeft,
  111. child: Text('Non-Audited Asset : ${nonAuditedAsset.length} asset(s)'),
  112. ),
  113. ),
  114. Expanded(
  115. flex: 1,
  116. child: Container(
  117. child: Text('Scale : ')
  118. ),
  119. ),
  120. Expanded(
  121. flex: 1,
  122. child: Container(padding: EdgeInsets.only(bottom: 5.0),child: TextField(
  123. controller: scaleCon,
  124. keyboardType: TextInputType.number,
  125. onSubmitted: (value){
  126. try{
  127. scale = double.parse(value);
  128. if(scale>=1.00&&scale<=3.00){
  129. setState(() {
  130. widthtb = 900 *scale;
  131. });
  132. }
  133. else{
  134. util.showToast('ERROR', 'Scale must be between 1.00 - 3.00');
  135. }
  136. }
  137. catch(e){
  138. util.showToast('ERROR', 'Scale must be between 1.00 - 3.00');
  139. }
  140. },
  141. ))),
  142. ],
  143. ),
  144. ),
  145. ),
  146. Expanded(
  147. flex:18,
  148. child: Container(
  149. color: Colors.white,
  150. child: ListView(
  151. scrollDirection: Axis.horizontal,
  152. children: [
  153. Container(
  154. child: Column(
  155. children: [
  156. Container(
  157. decoration: BoxDecoration(
  158. border: Border.all(width: 1.0)
  159. ),
  160. width: widthtb,
  161. child: Row(
  162. children: [
  163. Container(padding: EdgeInsets.only(left: 5.0),width: widthtb*0.035,child: Text('No',style: TextStyle(fontWeight: FontWeight.bold),)),
  164. Container(width: widthtb*0.09,child: Text('Tag Number',style: TextStyle(fontWeight: FontWeight.bold))),
  165. Container(width: widthtb*0.24,child: Text('Asset Desc',style: TextStyle(fontWeight: FontWeight.bold))),
  166. Container(width: widthtb*0.24,child: Text('PIC',style: TextStyle(fontWeight: FontWeight.bold))),
  167. Container(width: widthtb*0.13,child: Text('Gedung',style: TextStyle(fontWeight: FontWeight.bold))),
  168. Container(width: widthtb*0.125,child: Text('Lantai',style: TextStyle(fontWeight: FontWeight.bold))),
  169. Container(width: widthtb*0.13,child: Text('Ruang',style: TextStyle(fontWeight: FontWeight.bold))),
  170. ],
  171. ),
  172. ),
  173. Expanded(
  174. child: MatrixGestureDetector(
  175. onMatrixUpdate: (m,t,s,r){
  176. scale = MatrixGestureDetector.decomposeToValues(m).scale+1;
  177. if(scale>3)scale=3;
  178. setState(() {
  179. scaleCon.text = scale.toStringAsFixed(2);
  180. widthtb = 900 *scale;
  181. // scaleheighttb = 0.04*scale;
  182. });
  183. },
  184. child: Container(
  185. decoration: BoxDecoration(
  186. border: Border.all(width: 1.0)
  187. ),
  188. width: widthtb,
  189. child: ListView.builder(
  190. padding: EdgeInsets.all(0.0),
  191. itemCount: nonAuditedAsset.length,
  192. itemBuilder: (context,index){
  193. Asset idxAsset = nonAuditedAsset[index];
  194. if(search!=''){
  195. if(idxAsset.tag_number.toUpperCase().contains(search.toUpperCase())) return Container(
  196. decoration: BoxDecoration(
  197. border: Border(bottom: BorderSide(width: 0.8))
  198. ),
  199. child: Row(
  200. children: [
  201. Container(padding: EdgeInsets.only(left: 5.0),width: widthtb*0.035,child: Text('${index+1}')),
  202. Container(width: widthtb*0.09,child: Text(idxAsset.tag_number)),
  203. Container(width: widthtb*0.24,child: Text(idxAsset.asset_desc)),
  204. Container(width: widthtb*0.24,child: Text(idxAsset.pic)),
  205. Container(width: widthtb*0.13,child: Text(idxAsset.gedung)),
  206. Container(width: widthtb*0.125,child: Text(idxAsset.lantai)),
  207. Container(width: widthtb*0.13,child: Text(idxAsset.ruangan)),
  208. ],
  209. ),
  210. );
  211. else return Container();
  212. }
  213. else{
  214. return Container(
  215. decoration: BoxDecoration(
  216. border: Border(bottom: BorderSide(width: 0.8))
  217. ),
  218. child: Row(
  219. children: [
  220. Container(padding: EdgeInsets.only(left: 5.0),width: widthtb*0.035,child: Text('${index+1}')),
  221. Container(width: widthtb*0.09,child: Text(idxAsset.tag_number)),
  222. Container(width: widthtb*0.24,child: Text(idxAsset.asset_desc)),
  223. Container(width: widthtb*0.24,child: Text(idxAsset.pic)),
  224. Container(width: widthtb*0.13,child: Text(idxAsset.gedung)),
  225. Container(width: widthtb*0.125,child: Text(idxAsset.lantai)),
  226. Container(width: widthtb*0.13,child: Text(idxAsset.ruangan)),
  227. ],
  228. ),
  229. );
  230. }
  231. }),
  232. ),
  233. ),
  234. ),
  235. ],
  236. ),
  237. ),
  238. ],
  239. ),
  240. )
  241. ),
  242. ],
  243. ),
  244. ),
  245. floatingActionButton: FloatingActionButton.extended(
  246. onPressed: (){
  247. },
  248. icon: Icon(Icons.sync),
  249. label: Text("Sync Approval"),
  250. ),
  251. );
  252. }
  253. }