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.
 
 
 
 

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