history_detail.dart 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. import 'package:easy_localization/easy_localization.dart';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_linkify/flutter_linkify.dart';
  5. import 'package:provider/provider.dart';
  6. import 'package:telnow_mobile_new/src/layouts/functions/detail.dart';
  7. import 'package:telnow_mobile_new/src/layouts/mobile/history_forum.dart';
  8. import 'package:telnow_mobile_new/src/layouts/components/template.dart';
  9. import 'package:telnow_mobile_new/src/utils/U.dart';
  10. import 'package:telnow_mobile_new/src/utils/provider.dart';
  11. import 'package:telnow_mobile_new/src/utils/ui_service.dart';
  12. import 'package:timelines_plus/timelines_plus.dart';
  13. import 'package:url_launcher/url_launcher.dart';
  14. class MobHistoryDetailPage extends StatefulWidget {
  15. final int index;
  16. const MobHistoryDetailPage({required this.index, super.key});
  17. @override
  18. State<MobHistoryDetailPage> createState() => _MobHistoryDetailPageState();
  19. }
  20. class _MobHistoryDetailPageState extends State<MobHistoryDetailPage> {
  21. final DetailFunction detFunc = DetailFunction();
  22. TextEditingController controllerNote = new TextEditingController()..text = '';
  23. Map<String, dynamic> list = {};
  24. Map<String, dynamic> user = {};
  25. var rating = [
  26. {'key': 1, 'image': "assets/image/icon/very_dissatisfied.png", 'label': 'disatisfied'.tr()},
  27. {'key': 2, 'image': "assets/image/icon/dissatisfied.png", 'label': 'lessSatisfied'.tr()},
  28. {'key': 3, 'image': "assets/image/icon/neutral.png", 'label': 'satisfied'.tr()},
  29. {'key': 4, 'image': "assets/image/icon/satisfied.png", 'label': 'verySatisfied'.tr()},
  30. {'key': 5, 'image': "assets/image/icon/very_satisfied.png", 'label': 'reallyPleased'.tr()},
  31. ];
  32. bool _timeLimit = false;
  33. @override
  34. void initState() {
  35. getData();
  36. // TODO: implement initState
  37. super.initState();
  38. }
  39. getData() async{
  40. var res = await detFunc.getMission(UIService.getLocale(), Provider.of<HistoryModule>(context, listen: false).dataRequests()[widget.index]);
  41. setState((){
  42. user = res['user'];
  43. list = res['list'];
  44. });
  45. // print(list);
  46. // print(list['_parentTicket']);
  47. }
  48. @override
  49. Widget build(BuildContext context) {
  50. return Scaffold(
  51. backgroundColor: backgroundColor,
  52. appBar: appBarTemplate(context: context, title: 'detail'.tr(), action: list.isNotEmpty && list['currentState'] != 'DIPROSES' && list['currentState'] != 'DIANTRIKAN' && !list['autoResponse'] ? [
  53. Center(
  54. child: GestureDetector(
  55. child: Container(
  56. margin: EdgeInsetsDirectional.only(end: 16),
  57. padding: EdgeInsets.fromLTRB(16, 9, 16, 9),
  58. decoration: BoxDecoration(
  59. color: primaryColor.withValues(alpha: 0.1),
  60. border: Border.all(color: primaryColor),
  61. borderRadius: BorderRadius.all(Radius.circular(50))
  62. ),
  63. child: Row(
  64. children: [
  65. Text('forum'.tr(), style: TextStyle(color: primaryColor, fontSize: 14)),
  66. SizedBox(width: 5),
  67. U.iconsax('messages-3', color: primaryColor, size: 20)
  68. ],
  69. ),
  70. ),
  71. onTap: (){
  72. Provider.of<HistoryModule>(context, listen: false).setForumFalse(widget.index);
  73. navigateTo(context, MobHistoryForumPage(data: list));
  74. },
  75. ),
  76. )
  77. ]:null),
  78. body: Column(
  79. children: [
  80. divider(),
  81. Expanded(
  82. child: list.isNotEmpty?Container(
  83. alignment: Alignment.topCenter,
  84. width: U.bodyWidth(context),
  85. child: SingleChildScrollView(
  86. child: Column(
  87. crossAxisAlignment: CrossAxisAlignment.start,
  88. children: [
  89. Padding(
  90. padding: EdgeInsets.symmetric(vertical: 12, horizontal: 16),
  91. child: Column(
  92. crossAxisAlignment: CrossAxisAlignment.start,
  93. children: [
  94. Text(list[U.langColumn(context, 'requestGroupDescription')]??'', style: TextStyle(color: textColor, fontWeight: FontWeight.w600)),
  95. requestTiles(
  96. image: list['_requestImage'] ?? "null",
  97. title: list[U.langColumn(context, 'requestSubject')],
  98. subtitle: list[U.langColumn(context, '_subjectDescription')]??'',
  99. border: true
  100. ),
  101. SizedBox(height: 16),
  102. textHorizontal('ticketNumber'.tr(), list['ticketNo'], copy: true),
  103. SizedBox(height: 16),
  104. user.isNotEmpty?renderRequested():Container(),
  105. textHorizontal('location'.tr(), list['ipphoneExtLocation']),
  106. SizedBox(height: 16),
  107. divider(opacity: 0.05),
  108. SizedBox(height: 16),
  109. list['autoResponse'] ? Column(
  110. crossAxisAlignment: CrossAxisAlignment.start,
  111. children: [
  112. Text('note'.tr(), style: TextStyle(color: textColor)),
  113. SizedBox(height: 5),
  114. list['responseText']!=null&&list['responseText']!=''?Linkify(
  115. text: list['responseText'], style: TextStyle(color: textColor, fontSize: 12, fontWeight: FontWeight.w300),
  116. onOpen: (link) async {
  117. if (await canLaunchUrl(Uri.parse(link.url))) {
  118. await launchUrl(Uri.parse(link.url));
  119. }
  120. },
  121. ):Container(),
  122. list['responseAttachment']!=null&&list['responseAttachment']!=''?list['_isPdf']?GestureDetector(
  123. child: Container(
  124. width: double.infinity,
  125. margin: EdgeInsets.only(top: 8),
  126. child: Center(
  127. child: Column(
  128. children: [
  129. Icon(Icons.picture_as_pdf, color: Colors.deepOrange, size: 50),
  130. Text('seeAttachment'.tr(), style: TextStyle(color: Colors.black45, fontSize: 12))
  131. ],
  132. ),
  133. ),
  134. decoration: BoxDecoration(
  135. border: Border.all(color: Colors.deepOrange),
  136. borderRadius: BorderRadius.all(Radius.circular(12)),
  137. )
  138. ),
  139. onTap: () => kIsWeb ? () async{
  140. Uri _url = Uri.parse(list['_mobileResponseAttachment']);
  141. await canLaunchUrl(_url) ? await launchUrl(_url) : print('Could not launch $_url');
  142. // html.window.open(list['responseAttachment'], '_blank');
  143. } : detFunc.openAttachment(list)
  144. ):GestureDetector(
  145. child: Container(
  146. child:Image.network(list['_mobileResponseAttachment'], fit: BoxFit.cover, width: double.infinity, height: U.bodyWidth(context)/(kIsWeb?2.1:1.7), loadingBuilder:(BuildContext? context, Widget? child,ImageChunkEvent? loadingProgress) {
  147. if (loadingProgress == null) return child!;
  148. return Container(
  149. height: U.bodyWidth(context)/(kIsWeb?2.1:1.7),
  150. child: Center(
  151. child: CircularProgressIndicator(
  152. value: loadingProgress.expectedTotalBytes != null ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes! : null,
  153. ),
  154. ),
  155. );
  156. },
  157. ),
  158. ),
  159. onTap: ()=>navigateTo(context, PhotoPreview('image'.tr(), list['_mobileResponseAttachment'], true))
  160. ):Container()
  161. ],
  162. ) : attachment_new(list),
  163. list['autoResponse'] ? Container() : SizedBox(height: 16),
  164. list['autoResponse'] ? Container() : textVertical('note'.tr(), list['requestNote']!=''?list['requestNote']:'-'),
  165. list['autoResponse'] ? Container() : SizedBox(height: 16),
  166. list['autoResponse'] || list['datetimeScheduled'] == null || list['datetimeScheduled'] == '' ? Container() : Text("${"scheduleMessage".tr()} ${list['datetimeScheduled']}."),
  167. SizedBox(height: 24),
  168. ],
  169. ),
  170. ),
  171. U.newServerVersion(1741166029) && list['_parentTicket'] != null?separator():Container(),
  172. U.newServerVersion(1741166029) && list['_parentTicket'] != null?Padding(
  173. padding: EdgeInsets.symmetric(vertical: 12, horizontal: 16),
  174. child: Column(
  175. crossAxisAlignment: CrossAxisAlignment.start,
  176. children: [
  177. Text('requestReference'.tr(), style: TextStyle(color: textColor, fontWeight: FontWeight.w600)),
  178. SizedBox(height: 16),
  179. textHorizontal('ticketNumber'.tr(), list['_parentTicket']['ticketNo']),
  180. SizedBox(height: 16),
  181. divider(opacity: 0.05),
  182. SizedBox(height: 16),
  183. textHorizontal('subject'.tr(), list['_parentTicket'][U.langColumn(context, 'requestSubject')]),
  184. SizedBox(height: 16),
  185. textHorizontal('note'.tr(), list['_parentTicket']['requestNote']!=null && list['_parentTicket']['requestNote']!=''?list['_parentTicket']['requestNote']:'-'),
  186. SizedBox(height: 16),
  187. divider(opacity: 0.05),
  188. SizedBox(height: 16),
  189. list['_parentTicket']['_activeHoldRequest'] != null ? Row(
  190. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  191. children: [
  192. Text('state'.tr(), style: TextStyle(fontSize: 14, color: textColor)),
  193. Row(
  194. mainAxisAlignment: MainAxisAlignment.end,
  195. children: [
  196. Image(image: AssetImage('assets/image/general/Watch.png'), width: 20, height: 20),
  197. SizedBox(width: 5),
  198. Text('hold'.tr(), style: TextStyle(fontSize: 14, color: primaryColor)),
  199. ],
  200. )
  201. ],
  202. ) : textHorizontal('state'.tr(), U.renderStatus(list['_parentTicket']['currentState'])),
  203. SizedBox(height: 16),
  204. textHorizontal('description'.tr(), list['_parentTicket'][U.langColumn(context, '_subjectDescription')]??''),
  205. SizedBox(height: 16),
  206. ],
  207. ),
  208. ):Container(),
  209. separator(),
  210. list['autoResponse'] ? Container() : Padding(
  211. padding: EdgeInsets.symmetric(vertical: 12, horizontal: 16),
  212. child: Column(
  213. crossAxisAlignment: CrossAxisAlignment.start,
  214. children: [
  215. Text('activity'.tr(), style: TextStyle(color: textColor, fontWeight: FontWeight.w600)),
  216. SizedBox(height: 16),
  217. list['currentState'] != 'DIBATALKAN' && list['currentState'] != 'DIANTRIKAN' && list['currentState'] != 'DIPROSES' && list['_collaboratorDataFilter'].length > 0?Column(
  218. crossAxisAlignment: CrossAxisAlignment.start,
  219. children: [
  220. Text('servant'.tr(), style: TextStyle(color: textColor, fontSize: 14)),
  221. Container(
  222. padding: EdgeInsets.only(top: 10, left: 16),
  223. child: Column(
  224. crossAxisAlignment: CrossAxisAlignment.start,
  225. children: [
  226. Text('1. ${list['servantNameStart']??'-'}', style: TextStyle(color: textColor, fontSize: 14), overflow: TextOverflow.ellipsis),
  227. Column(
  228. crossAxisAlignment: CrossAxisAlignment.start,
  229. children: List.generate(list['_collaboratorDataFilter'].length, (i) {
  230. return Text('${i+2}. ${list['_collaboratorDataFilter'][i]['name']}', style: TextStyle(color: textColor, fontSize: 14), overflow: TextOverflow.ellipsis);
  231. }),
  232. )
  233. ],
  234. ),
  235. )
  236. ],
  237. ) : textHorizontal(
  238. list['currentState'] == 'DIBATALKAN'?'canceledBy'.tr():'servant'.tr(),
  239. list['currentState'] == 'DIBATALKAN'?list['servantNameCancel']??'-':list['currentState'] != 'DIANTRIKAN' && list['currentState'] != 'DIPROSES'?list['servantNameStart']??'-':'-'
  240. ),
  241. SizedBox(height: 16),
  242. divider(opacity: 0.05),
  243. SizedBox(height: 16),
  244. Text('timeline'.tr(), style: TextStyle(color: textColor, fontSize: 14)),
  245. SizedBox(height: 16),
  246. Column(
  247. crossAxisAlignment: CrossAxisAlignment.start,
  248. children: [
  249. timeline('stateRequested'.tr(), list['datetimeRequest'] != null ? convertDate(list['datetimeRequest'], context.locale.toString()) : '-', null, null, current: list['currentState'] == 'DIANTRIKAN' || list['currentState'] == 'DIPROSES', first: true),
  250. list['currentState'] == 'DIMULAI' ? timeline('stateDone'.tr(), list['datetimeStart'] != null ? convertDate(list['datetimeStart'], context.locale.toString()) : '-', list['noteStart'], list['noteStartTranslate'], current: list['currentState'] == 'DIMULAI') : Container(),
  251. !list['autoResponse'] && (list['currentState'] == 'DISELESAIKAN' || list['currentState'] == 'TUNTAS') ? timeline('startDoing'.tr(), list['datetimeStart'] != null ? convertDate(list['datetimeStart'], context.locale.toString()) : '-', list['noteStart'], list['noteStartTranslate']) : Container(),
  252. !list['autoResponse'] && (list['currentState'] == 'DISELESAIKAN' || list['currentState'] == 'TUNTAS') ? timeline('stateFinish'.tr(), list['datetimeFinish'] != null ? convertDate(list['datetimeFinish'], context.locale.toString()) : '-', list['noteFinish'], list['noteFinishTranslate'], current: list['currentState'] == 'DISELESAIKAN' || list['currentState'] == 'TUNTAS') : Container(),
  253. list['autoResponse'] && list['currentState'] == 'TUNTAS' ? timeline('stateFinish'.tr(), list['datetimeComplete'] != null ? convertDate(list['datetimeComplete'], context.locale.toString()) : '-', list['noteComplete'], list['noteCompleteTranslate'], current: list['currentState'] == 'TUNTAS') : Container(),
  254. list['currentState'] == 'DIBATALKAN' ? timeline('stateCanceled'.tr(), list['datetimeCancel'] != null ? convertDate(list['datetimeCancel'], context.locale.toString()) : '-', list['noteCancel'], list['noteCancelTranslate'], current: list['currentState'] == 'DIBATALKAN') : Container(),
  255. ],
  256. ),
  257. suspendPanel(list),
  258. finish_att_new(list),
  259. !list['autoResponse'] && (list['currentState'] == 'TUNTAS' || list['currentState'] == 'DISELESAIKAN') ? Column(
  260. crossAxisAlignment: CrossAxisAlignment.start,
  261. children: [
  262. SizedBox(height: 16),
  263. divider(opacity: 0.05),
  264. U.newServerVersion(1716187681) && list['action'] != null && list['action'].trim() != '' ? Column(
  265. children: [
  266. SizedBox(height: 16),
  267. textHorizontal('action'.tr(), list['action'])
  268. ],
  269. ) : Container(),
  270. SizedBox(height: 16),
  271. Row(
  272. children: [
  273. Text('rate'.tr(), style: TextStyle(color: textColor, fontSize: 14)),
  274. Expanded(
  275. child: list['satisfactionRate'] > 0 ? Row(
  276. mainAxisAlignment: MainAxisAlignment.end,
  277. children: [
  278. Text(rating[list['satisfactionRate']-1]['label'].toString(), style: TextStyle(color: textColor, fontSize: 14), overflow: TextOverflow.ellipsis),
  279. SizedBox(width: 5),
  280. Image(image: AssetImage(rating[list['satisfactionRate']-1]['image'].toString()), width: 25),
  281. ],
  282. ) : Text('unrated'.tr(), style: TextStyle(color: textColor, fontSize: 14), textAlign: TextAlign.end, overflow: TextOverflow.ellipsis),
  283. ),
  284. ],
  285. ),
  286. list['satisfactionRate'] > 0 ? Builder(
  287. builder: (context) {
  288. var aspect = '';
  289. if(context.locale.toString() == 'id' && list['ratingAspectId'] != null){
  290. aspect = list['ratingAspectId'];
  291. } else if(context.locale.toString() == 'en' && list['ratingAspectEn'] != null){
  292. aspect = list['ratingAspectEn'];
  293. } else if(list['ratingAspectOri'] != null){
  294. aspect = list['ratingAspectOri'];
  295. }
  296. return aspect.isNotEmpty ? Column(
  297. children: [
  298. SizedBox(height: 16),
  299. textHorizontal('ratingAspect'.tr(), aspect)
  300. ],
  301. ) : Container();
  302. },
  303. ) : Container(),
  304. ],
  305. ) : Container()
  306. ],
  307. ),
  308. ),
  309. list['autoResponse'] ? Container() : separator(),
  310. ],
  311. ),
  312. ),
  313. ):_timeLimit ? showButton(context) : loadingTemplate(() {if(mounted) setState(()=>_timeLimit=true);},),
  314. ),
  315. divider(color: primaryColor, opacity: 1.0, thickness: 2.0),
  316. list.isEmpty || list['autoResponse'] || list['currentState'] == 'DISELESAIKAN' || list['currentState'] == 'TUNTAS' || list['currentState'] == 'DIBATALKAN' ? Container() : Container(
  317. padding: EdgeInsets.symmetric(vertical: 10, horizontal: 16), color: Colors.white,
  318. child: list['currentState'] == 'DIMULAI' && list['_canNotCancel'] ? Text('canNotCancel2'.tr(), style: TextStyle(color: textColor, fontSize: 14), textAlign: TextAlign.center) : Container(
  319. alignment: Alignment.bottomCenter,
  320. width: U.bodyWidth(context),
  321. child: SafeArea(
  322. child: Column(
  323. children: [
  324. SizedBox(
  325. width: double.infinity,
  326. child: TextField(
  327. controller: controllerNote,
  328. style: const TextStyle(fontSize: 14, color: Colors.black),
  329. maxLength: 128,
  330. decoration: InputDecoration(
  331. counterText: '',
  332. counterStyle: TextStyle(color: Colors.transparent, fontSize: 0),
  333. hintText: 'addNoteCancel'.tr(),
  334. hintStyle: TextStyle(color: textColor.withValues(alpha: 0.5), fontSize: 14),
  335. filled: true,
  336. fillColor: backgroundColor,
  337. hoverColor: Colors.black.withValues(alpha: 0.1),
  338. contentPadding: EdgeInsets.all(13),
  339. prefixIcon: Padding(padding: EdgeInsets.only(left: 13, right: 13), child: U.iconsax('edit-2', color: textColor, size: 24)),
  340. border: InputBorder.none,
  341. enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide(color: Color(0xff262626).withValues(alpha: 0.5))),
  342. focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: const BorderSide(color: primaryColor)),
  343. isDense: true
  344. ),
  345. ),
  346. ),
  347. SizedBox(height: 10),
  348. buttonTemplate(text: 'buttonCancel'.tr(), backgroundColor: textColor.withValues(alpha: 0.1), textColor: textColor.withValues(alpha: 0.75), borderColor: textColor.withValues(alpha: 0.20), action: () => detFunc.cancelRequest(context, list, controllerNote))
  349. ],
  350. ),
  351. ),
  352. ),
  353. )
  354. ],
  355. )
  356. );
  357. }
  358. Widget renderRequested(){
  359. if(list['receptionistId'] != null){
  360. if(user['roomAttendant'] != null && user['roomAttendant'] && user['userId'] != list['informantUserId'] && user['userId'] == list['receptionistId']){
  361. return Column(
  362. children: [
  363. textHorizontal('requestedFor'.tr(), list['informantName']??'-'),
  364. SizedBox(height: 16),
  365. ],
  366. );
  367. }
  368. if(user['userId'] == list['informantUserId'] && user['userId'] != list['receptionistId']){
  369. return Column(
  370. children: [
  371. textHorizontal('requestedBy'.tr(), list['receptionistName']??'-'),
  372. SizedBox(height: 16),
  373. ],
  374. );
  375. }
  376. }
  377. return Container();
  378. }
  379. Widget attachment_new(list){
  380. var imageWidth = ((U.bodyWidth(context)-32)/5)-5;
  381. List imageList = [];
  382. if(list['_attachment'] != null){
  383. for(var i = 1; i <= 5; i++){
  384. if(list['_attachment']['_mobileRequestAtt$i'] != null){
  385. imageList.add({'thumb': list['_attachment']['_mobileRequestThumb$i'], 'image': list['_attachment']['_mobileRequestAtt$i']});
  386. }
  387. }
  388. }
  389. return imageList.length > 0 ? Column(
  390. crossAxisAlignment: CrossAxisAlignment.start,
  391. children: [
  392. Text('image'.tr(), style: TextStyle(color: textColor)),
  393. SizedBox(height: 5),
  394. Row(
  395. children: List.generate(imageList.length, (i){
  396. return GestureDetector(
  397. child: Container(
  398. width: imageWidth, height: imageWidth, alignment: Alignment.topRight,
  399. margin: EdgeInsets.only(right: i == 4 ? 0 : 6),
  400. decoration: BoxDecoration(
  401. color: Colors.black12, borderRadius: BorderRadius.all(Radius.circular(5)), border: Border.all(color: Colors.black26, width: 0.5),
  402. image: imageList[i]['thumb'] != null ? DecorationImage(image: NetworkImage(imageList[i]['thumb']), fit: BoxFit.cover) : DecorationImage(image: AssetImage('assets/image/error/ImageNotFound.png'), fit: BoxFit.cover)
  403. ),
  404. ),
  405. onTap: ()=>navigateTo(context, PhotoPreviewGallery(title: 'image'.tr(), imageList: imageList, startIndex: i))
  406. );
  407. }),
  408. )
  409. ],
  410. ) : textVertical('image'.tr(), 'noImgAttach'.tr());
  411. }
  412. Widget finish_att_new(list){
  413. var imageWidth = ((U.bodyWidth(context)-32)/5)-5;
  414. List imageList = [];
  415. if((list['currentState'] == 'DISELESAIKAN' || list['currentState'] == 'TUNTAS')){
  416. if(list['_attachment'] != null){
  417. for(var i = 1; i <= 5; i++){
  418. if(list['_attachment']['_mobileFinishAtt$i'] != null){
  419. imageList.add({'thumb': list['_attachment']['_mobileFinishThumb$i'], 'image': list['_attachment']['_mobileFinishAtt$i']});
  420. }
  421. }
  422. }
  423. }
  424. return imageList.length > 0 ? Column(
  425. crossAxisAlignment: CrossAxisAlignment.start,
  426. children: [
  427. SizedBox(height: 16),
  428. Text('finishAttachment'.tr(), style: TextStyle(color: textColor)),
  429. SizedBox(height: 8),
  430. Row(
  431. children: List.generate(imageList.length, (i){
  432. return GestureDetector(
  433. child: Container(
  434. width: imageWidth, height: imageWidth, alignment: Alignment.topRight,
  435. margin: EdgeInsets.only(right: i == 4 ? 0 : 6),
  436. decoration: BoxDecoration(
  437. color: Colors.black12, borderRadius: BorderRadius.all(Radius.circular(5)), border: Border.all(color: Colors.black26, width: 0.5),
  438. image: imageList[i]['thumb'] != null ? DecorationImage(image: NetworkImage(imageList[i]['thumb']), fit: BoxFit.cover) : DecorationImage(image: AssetImage('assets/image/error/ImageNotFound.png'), fit: BoxFit.cover)
  439. ),
  440. ),
  441. onTap: ()=>navigateTo(context, PhotoPreviewGallery(title: 'finishAttachment'.tr(), imageList: imageList, startIndex: i))
  442. );
  443. }),
  444. )
  445. ],
  446. ) : Container();
  447. }
  448. Widget suspendPanel(list){
  449. var activeHold = list['_activeHoldRequest'];
  450. var requestHold = list['_holdRequest'];
  451. return Column(
  452. children: [
  453. activeHold != null ? Padding(padding: EdgeInsets.symmetric(vertical: 15), child: divider(opacity: 0.05)) : Container(),
  454. activeHold != null ? Column(
  455. children: [
  456. Row(
  457. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  458. children: [
  459. Text('state'.tr(), style: TextStyle(fontSize: 14, color: textColor)),
  460. Row(
  461. mainAxisAlignment: MainAxisAlignment.end,
  462. children: [
  463. Image(image: AssetImage('assets/image/general/Watch.png'), width: 20, height: 20),
  464. SizedBox(width: 5),
  465. Text('hold'.tr(), style: TextStyle(fontSize: 14, color: primaryColor)),
  466. ],
  467. )
  468. ],
  469. ),
  470. SizedBox(height: 16),
  471. textHorizontal('description'.tr(), activeHold['description'])
  472. ],
  473. ) : Container(),
  474. requestHold == null || requestHold.length == 0 || (requestHold.length == 1 && requestHold[0]['datetimeEnd'] == null) ? Container() : Column(
  475. crossAxisAlignment: CrossAxisAlignment.start,
  476. children: [
  477. Padding(padding: EdgeInsets.symmetric(vertical: 15), child: divider(opacity: 0.05)),
  478. Text('holdHistory'.tr(), style: TextStyle(fontSize: 14, color: Colors.black)),
  479. SizedBox(height: 5),
  480. Column(
  481. children: List.generate(requestHold.length, (i) {
  482. return requestHold[i]['datetimeEnd'] != null ? Container(
  483. padding: EdgeInsets.symmetric(vertical: 5),
  484. child: Row(
  485. crossAxisAlignment: CrossAxisAlignment.start,
  486. children: [
  487. Text('${i+1}.', style: TextStyle(fontSize: 14, color: Colors.black)),
  488. SizedBox(width: 5),
  489. Expanded(
  490. child: Column(
  491. crossAxisAlignment: CrossAxisAlignment.start,
  492. children: [
  493. Text(requestHold[i]['description'], style: TextStyle(fontSize: 14, color: Colors.black), textAlign: TextAlign.start),
  494. SizedBox(height: 3),
  495. Text('${DateFormat('dd MMM yyyy, HH:mm', context.locale.toString()).format(DateTime.parse(requestHold[i]['datetimeStart']))} - ${DateFormat('dd MMM yyyy, HH:mm', context.locale.toString()).format(DateTime.parse(requestHold[i]['datetimeEnd']))}', style: TextStyle(fontSize: 14, color: primaryColor))
  496. ],
  497. ),
  498. )
  499. ],
  500. ),
  501. ) : Container();
  502. }),
  503. )
  504. ],
  505. )
  506. ],
  507. );
  508. }
  509. Widget timeline(label, text, note, noteTranslate, {bool first = false, bool current = false}) {
  510. return TimelineTile(
  511. nodeAlign: TimelineNodeAlign.start,
  512. contents: Container(
  513. margin: EdgeInsets.fromLTRB(16, 10, 16, 10),
  514. child: Row(
  515. children: [
  516. Text(label, style: TextStyle(fontSize: 14, color: textColor.withValues(alpha: 0.85))),
  517. SizedBox(width: 5),
  518. Expanded(
  519. child: Column(
  520. crossAxisAlignment: CrossAxisAlignment.end,
  521. children: [
  522. Text(text, style: TextStyle(fontSize: 13, color: textColor)),
  523. note != null && note != '' ? Text(note, style: TextStyle(fontSize: 12, color: primaryColor), textAlign: TextAlign.right) : Container(),
  524. U.autoTranslate() && noteTranslate != null && noteTranslate != '' && note != noteTranslate ? Container(
  525. margin: EdgeInsets.only(top: 1), decoration: BoxDecoration(border: Border(top: BorderSide(color: primaryColor.withValues(alpha: 0.3)))),
  526. child: Text('($noteTranslate)', style: TextStyle(fontSize: 12, color: primaryColor.withValues(alpha: 0.7), fontStyle: FontStyle.italic), textAlign: TextAlign.right),
  527. ) : Container(),
  528. ],
  529. ),
  530. ),
  531. ],
  532. ),
  533. ),
  534. node: TimelineNode(
  535. indicator: DotIndicator(color: current ? primaryColor : Color(0xffE8E8E8)),
  536. startConnector: SolidLineConnector(color: first ? Colors.transparent : Color(0xffE8E8E8)),
  537. endConnector: SolidLineConnector(color: current ? Colors.transparent : Color(0xffE8E8E8)),
  538. ),
  539. );
  540. }
  541. }