menu_history.dart 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. import 'package:easy_localization/easy_localization.dart';
  2. import 'package:easy_refresh/easy_refresh.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:lazy_load_scrollview/lazy_load_scrollview.dart';
  5. import 'package:provider/provider.dart';
  6. import 'package:telnow_mobile_new/src/api/api_auth_provider.dart';
  7. import 'package:telnow_mobile_new/src/layouts/functions/history.dart';
  8. import 'package:telnow_mobile_new/src/layouts/mobile/history_detail.dart';
  9. import 'package:telnow_mobile_new/src/layouts/mobile/history_detail_pending.dart';
  10. import 'package:telnow_mobile_new/src/layouts/components/template.dart';
  11. import 'package:telnow_mobile_new/src/layouts/mobile/history_rating.dart';
  12. import 'package:telnow_mobile_new/src/utils/U.dart';
  13. import 'package:telnow_mobile_new/src/utils/provider.dart';
  14. class MobHistoryPage extends StatefulWidget {
  15. const MobHistoryPage({super.key});
  16. @override
  17. State<MobHistoryPage> createState() => _MobHistoryPageState();
  18. }
  19. class _MobHistoryPageState extends State<MobHistoryPage> with TickerProviderStateMixin {
  20. final HistoryFunction hisFunc = HistoryFunction();
  21. late AnimationController _animationController;
  22. var rating = [
  23. {'key': 1, 'image': "assets/image/icon/very_dissatisfied.png", 'label': 'disatisfied'.tr()},
  24. {'key': 2, 'image': "assets/image/icon/dissatisfied.png", 'label': 'lessSatisfied'.tr()},
  25. {'key': 3, 'image': "assets/image/icon/neutral.png", 'label': 'satisfied'.tr()},
  26. {'key': 4, 'image': "assets/image/icon/satisfied.png", 'label': 'verySatisfied'.tr()},
  27. {'key': 5, 'image': "assets/image/icon/very_satisfied.png", 'label': 'reallyPleased'.tr()},
  28. ];
  29. @override
  30. void initState() {
  31. Provider.of<HistoryModule>(context, listen: false).reset();
  32. _animationController = new AnimationController(vsync: this, duration: Duration(seconds: 1));
  33. _animationController.repeat(reverse: true);
  34. WidgetsBinding.instance.addPostFrameCallback((_) {
  35. hisFunc.getActiveForum(context);
  36. });
  37. // TODO: implement initState
  38. super.initState();
  39. }
  40. @override
  41. void dispose() {
  42. _animationController.dispose();
  43. super.dispose();
  44. }
  45. @override
  46. Widget build(BuildContext context) {
  47. return Provider.of<UserModule>(context).resetData() ? RefreshPage(() {
  48. Provider.of<UserModule>(context, listen: false).setResetData(false);
  49. hisFunc.getActiveForum(context);
  50. }) : Scaffold(
  51. backgroundColor: backgroundColor,
  52. appBar: AppBar(
  53. elevation: 0,
  54. bottomOpacity: 0,
  55. backgroundColor: backgroundColor,
  56. titleSpacing: 16,
  57. title: Text('history'.tr(), style: TextStyle(color: textColor, fontSize: 17, fontWeight: FontWeight.w500), overflow: TextOverflow.ellipsis),
  58. actions: Provider.of<HistoryModule>(context).multiSelectMode() ? [
  59. Center(
  60. child: GestureDetector(
  61. child: Container(
  62. margin: EdgeInsets.only(right: 16),
  63. padding: EdgeInsets.fromLTRB(16, 9, 16, 9),
  64. child: Row(
  65. children: [
  66. Text('delete'.tr(), style: TextStyle(color: primaryColor, fontSize: 14)),
  67. SizedBox(width: 5),
  68. U.iconsax('trash', color: primaryColor, size: 20)
  69. ],
  70. ),
  71. decoration: BoxDecoration(
  72. color: primaryColor.withValues(alpha: 0.1), border: Border.all(color: primaryColor), borderRadius: BorderRadius.all(Radius.circular(50))),
  73. ),
  74. onTap: () => hisFunc.deleteData(context),
  75. ),
  76. )
  77. ] : null,
  78. ),
  79. body: Column(
  80. children: [
  81. divider(),
  82. Column(
  83. crossAxisAlignment: CrossAxisAlignment.start,
  84. children: [
  85. SizedBox(height: 16),
  86. Row(
  87. children: [
  88. GestureDetector(
  89. child: Container(
  90. margin: EdgeInsets.only(left: 16),
  91. padding: EdgeInsets.symmetric(vertical: 5, horizontal: 16),
  92. child: Text('ongoing'.tr(), style: TextStyle(color: Provider.of<HistoryModule>(context).selectedFilter() == 1 ? textColor : textColor.withValues(alpha: 0.65), fontSize: 16)),
  93. decoration: BoxDecoration(
  94. color: Colors.white,
  95. border: Border(bottom: BorderSide(color: Provider.of<HistoryModule>(context).selectedFilter() == 1 ? primaryColor : primaryColor.withValues(alpha: 0.3), width: Provider.of<HistoryModule>(context).selectedFilter() == 1 ? 2 : 1))),
  96. ),
  97. onTap: () {
  98. if (!Provider.of<HistoryModule>(context, listen: false).isLoadHistory()) {
  99. Provider.of<HistoryModule>(context, listen: false).setPressAttention(0);
  100. Provider.of<HistoryModule>(context, listen: false).setSelectedFilter(1);
  101. hisFunc.onRefresh(context);
  102. }
  103. },
  104. ),
  105. GestureDetector(
  106. child: Container(
  107. padding: EdgeInsets.symmetric(vertical: 5, horizontal: 16),
  108. child: Text('done'.tr(), style: TextStyle(color: Provider.of<HistoryModule>(context).selectedFilter() == 0 ? textColor : textColor.withValues(alpha: 0.65), fontSize: 16)),
  109. decoration: BoxDecoration(color: Colors.white, border: Border(bottom: BorderSide(color: Provider.of<HistoryModule>(context).selectedFilter() == 0 ? primaryColor : primaryColor.withValues(alpha: 0.3), width: Provider.of<HistoryModule>(context).selectedFilter() == 0 ? 2 : 1))),
  110. ),
  111. onTap: () {
  112. if (!Provider.of<HistoryModule>(context, listen: false).isLoadHistory()) {
  113. Provider.of<HistoryModule>(context, listen: false).setPressAttention(0);
  114. Provider.of<HistoryModule>(context, listen: false).setSelectedFilter(0);
  115. hisFunc.onRefresh(context);
  116. }
  117. },
  118. ),
  119. ],
  120. ),
  121. SizedBox(height: 20),
  122. Provider.of<HistoryModule>(context).selectedFilter() == 0 ? doneFilter() : ongoingFilter(),
  123. SizedBox(height: 20),
  124. ],
  125. ),
  126. Expanded(
  127. child: Provider.of<UserModule>(context).user().isNotEmpty ? Container(
  128. alignment: Alignment.topCenter,
  129. width: U.bodyWidth(context),
  130. child: LazyLoadScrollView(
  131. onEndOfPage: () => hisFunc.getMission(context),
  132. scrollOffset: 500,
  133. child: EasyRefresh(
  134. header: MaterialHeader(clamping: true, color: primaryColor),
  135. onRefresh: ()=>hisFunc.onRefresh(context),
  136. child: Provider.of<HistoryModule>(context).selectedFilter() == 0 ? doneContainer() : ongoingContainer(),
  137. ),
  138. ),
  139. ) : Provider.of<UserModule>(context).resetData() ? Container() : loadingTemplate(),
  140. )
  141. ],
  142. ),
  143. );
  144. }
  145. Widget ongoingFilter() {
  146. return SingleChildScrollView(
  147. scrollDirection: Axis.horizontal,
  148. child: Row(
  149. children: List.generate(hisFunc.ongoingList.length, (i) {
  150. return GestureDetector(
  151. child: Container(
  152. margin: EdgeInsets.only(left: 16),
  153. padding: EdgeInsets.symmetric(vertical: 8, horizontal: 16),
  154. child: Text(hisFunc.ongoingList[i]['title'], style: TextStyle(color: Provider.of<HistoryModule>(context).checkPressAttention(hisFunc.ongoingList[i]['value']) ? Colors.white : textColor, fontSize: 16)),
  155. decoration: BoxDecoration(
  156. color: Provider.of<HistoryModule>(context).checkPressAttention(hisFunc.ongoingList[i]['value']) ? primaryColor : Color(0xffF2F8F7),
  157. border: Border.all(color: Provider.of<HistoryModule>(context).checkPressAttention(hisFunc.ongoingList[i]['value']) ? primaryColor : Color(0xffBEC1C1)),
  158. borderRadius: BorderRadius.all(Radius.circular(50))),
  159. ),
  160. onTap: () {
  161. if (!Provider.of<HistoryModule>(context, listen: false).isLoadHistory()) {
  162. if (Provider.of<HistoryModule>(context, listen: false).checkPressAttention(hisFunc.ongoingList[i]['value'])) {
  163. Provider.of<HistoryModule>(context, listen: false).setPressAttention(0);
  164. hisFunc.onRefresh(context);
  165. } else {
  166. Provider.of<HistoryModule>(context, listen: false).setPressAttention(hisFunc.ongoingList[i]['value']);
  167. hisFunc.onRefresh(context);
  168. }
  169. }
  170. },
  171. );
  172. }),
  173. ),
  174. );
  175. }
  176. Widget ongoingContainer() {
  177. return SingleChildScrollView(
  178. child: Column(
  179. children: [
  180. U.newServerVersion(1709864293) && !U.getInternetStatus() ? Column(
  181. children: List.generate(Provider.of<HistoryModule>(context).dataPending().length, (i) {
  182. return GestureDetector(
  183. child: Container(
  184. padding: EdgeInsets.all(16),
  185. child: Column(
  186. children: [
  187. Row(
  188. children: [
  189. imageTiles(imageUrl: Provider.of<HistoryModule>(context).dataPending()[i]['image'] ?? "null"),
  190. SizedBox(width: 16),
  191. Expanded(
  192. child: Column(
  193. crossAxisAlignment: CrossAxisAlignment.start,
  194. children: [
  195. Text(Provider.of<HistoryModule>(context).dataPending()[i]['title'], style: TextStyle(color: textColor, fontWeight: FontWeight.w500), overflow: TextOverflow.ellipsis),
  196. SizedBox(height: 6),
  197. Text(Provider.of<HistoryModule>(context).dataPending()[i][U.langColumn(context, 'sub')], style: TextStyle(color: textColor), overflow: TextOverflow.ellipsis),
  198. SizedBox(height: 6),
  199. Text(convertDate(Provider.of<HistoryModule>(context).dataPending()[i]['datetimeRequest'], context.locale.toString()), style: TextStyle(color: textColor, fontSize: 13, fontWeight: FontWeight.w300)),
  200. ],
  201. ),
  202. )
  203. ],
  204. ),
  205. SizedBox(height: 16),
  206. divider(),
  207. Container(
  208. width: double.infinity,
  209. margin: EdgeInsets.only(top: 16),
  210. child: Row(
  211. children: [
  212. Container(
  213. width: 25, height: 25,
  214. decoration: BoxDecoration(image: DecorationImage(image: AssetImage('assets/image/general/Hourglass.png'), fit: BoxFit.cover)),
  215. ),
  216. SizedBox(width: 8),
  217. Expanded(child: Text('pending_info_tiles'.tr(), style: TextStyle(color: textColor, fontSize: 14), overflow: TextOverflow.ellipsis))
  218. ],
  219. ),
  220. )
  221. ],
  222. ),
  223. decoration: BoxDecoration(color: Colors.white, border: Border(bottom: BorderSide(color: Color(0xffF3F3F3), width: 8))),
  224. ),
  225. onTap: () {
  226. if(!U.getInternetStatus()){
  227. navigateTo(context, MobHistoryDetailPendingPage(data: Provider.of<HistoryModule>(context, listen: false).dataPending()[i])).then((val) {
  228. val = val??false;
  229. if(val) hisFunc.onRefresh(context);
  230. });
  231. }
  232. else{
  233. hisFunc.onRefresh(context);
  234. }
  235. },
  236. );
  237. }),
  238. ) : Container(),
  239. Column(
  240. children: List.generate(Provider.of<HistoryModule>(context).dataMisi().length, (i) {
  241. return GestureDetector(
  242. child: Container(
  243. padding: EdgeInsets.all(16),
  244. child: Column(
  245. children: [
  246. Row(
  247. children: [
  248. imageTiles(imageUrl: Provider.of<HistoryModule>(context).dataMisi()[i]['_requestImage'] ?? "null"),
  249. SizedBox(width: 16),
  250. Expanded(
  251. child: Column(
  252. crossAxisAlignment: CrossAxisAlignment.start,
  253. children: [
  254. Text(Provider.of<HistoryModule>(context).dataMisi()[i][U.langColumn(context, 'requestGroupDescription')], style: TextStyle(color: textColor, fontWeight: FontWeight.w500), overflow: TextOverflow.ellipsis),
  255. SizedBox(height: 6),
  256. Text(Provider.of<HistoryModule>(context).dataMisi()[i][U.langColumn(context, 'requestSubject')], style: TextStyle(color: textColor), overflow: TextOverflow.ellipsis),
  257. SizedBox(height: 6),
  258. renderRequested(Provider.of<HistoryModule>(context).dataMisi()[i]),
  259. Text(convertDate(Provider.of<HistoryModule>(context).dataMisi()[i]['datetimeRequest'], context.locale.toString()), style: TextStyle(color: textColor, fontSize: 13, fontWeight: FontWeight.w300)),
  260. ],
  261. ),
  262. )
  263. ],
  264. ),
  265. Provider.of<HistoryModule>(context).dataMisi()[i]['currentState'] == 'DIMULAI' || Provider.of<HistoryModule>(context).dataMisi()[i]['_hasForum'] ? Column(
  266. crossAxisAlignment: CrossAxisAlignment.start,
  267. children: [
  268. SizedBox(height: 16),
  269. divider(),
  270. ],
  271. ) : Container(),
  272. Provider.of<HistoryModule>(context).dataMisi()[i]['_activeHoldRequest'] != null ? Container(
  273. width: double.infinity,
  274. margin: EdgeInsets.only(top: 16),
  275. child: Row(
  276. children: [
  277. Container(
  278. width: 25, height: 25,
  279. decoration: BoxDecoration(image: DecorationImage(image: AssetImage('assets/image/general/Watch.png'), fit: BoxFit.cover)),
  280. ),
  281. SizedBox(width: 8),
  282. Expanded(child: Text(Provider.of<HistoryModule>(context).dataMisi()[i]['_activeHoldRequest']['description'], style: TextStyle(color: textColor, fontSize: 14), overflow: TextOverflow.ellipsis))
  283. ],
  284. ),
  285. ) : Provider.of<HistoryModule>(context).dataMisi()[i]['currentState'] == 'DIMULAI' ? Container(
  286. width: double.infinity,
  287. margin: EdgeInsets.only(top: 16),
  288. child: Row(
  289. children: [
  290. Container(
  291. width: 25, height: 25,
  292. decoration: BoxDecoration(
  293. border: Border.all(color: primaryColor),
  294. borderRadius: BorderRadius.all(Radius.circular(25)),
  295. image: DecorationImage(image: AssetImage('assets/image/general/Avatar.jpg'), fit: BoxFit.cover)),
  296. ),
  297. SizedBox(width: 8),
  298. Expanded(child: Text(Provider.of<HistoryModule>(context).dataMisi()[i]['servantNameStart'] + 'isWorking'.tr(), style: TextStyle(color: textColor, fontSize: 14), overflow: TextOverflow.ellipsis))
  299. ],
  300. ),
  301. ) : Container(),
  302. !Provider.of<HistoryModule>(context).dataMisi()[i]['autoResponse'] && Provider.of<HistoryModule>(context).dataMisi()[i]['_hasForum'] && Provider.of<HistoryModule>(context).dataMisi()[i]['_forumMsg'] != null ? Container(
  303. width: double.infinity,
  304. margin: EdgeInsets.only(top: 16),
  305. child: Row(
  306. children: [
  307. FadeTransition(opacity: _animationController, child: U.iconsax('messages-3', color: primaryColor)),
  308. SizedBox(width: 8),
  309. Expanded(child: Text('“${Provider.of<HistoryModule>(context).dataMisi()[i]['_forumMsg']}”', style: TextStyle(color: textColor.withValues(alpha: 0.75), fontSize: 14, fontStyle: FontStyle.italic), overflow: TextOverflow.ellipsis,))
  310. ],
  311. ),
  312. )
  313. : Container(),
  314. ],
  315. ),
  316. decoration: BoxDecoration(color: Colors.white, border: Border(bottom: BorderSide(color: Color(0xffF3F3F3), width: 8))),
  317. ),
  318. onTap: () => navigateTo(context, MobHistoryDetailPage(index: i)).then((val) {
  319. val = val??false;
  320. if(val) Provider.of<HistoryModule>(context, listen: false).cancelMisi(i);
  321. }),
  322. );
  323. }),
  324. ),
  325. !Provider.of<HistoryModule>(context).stopLoadHistory() || (Provider.of<HistoryModule>(context).isLoadHistory() && Provider.of<HistoryModule>(context).page() > 0)
  326. ? Container(margin: EdgeInsets.only(top: Provider.of<HistoryModule>(context).page() > 0 ? 0 : 50), child: loadingTemplate())
  327. : Provider.of<HistoryModule>(context).dataMisi().length == 0 && Provider.of<HistoryModule>(context).dataPending().length == 0
  328. ? NoDataPage()
  329. : Container(),
  330. ],
  331. ),
  332. );
  333. }
  334. Widget doneFilter() {
  335. return Row(
  336. children: List.generate(hisFunc.doneList.length, (i) {
  337. return GestureDetector(
  338. child: Container(
  339. margin: EdgeInsets.only(left: 16),
  340. padding: EdgeInsets.symmetric(vertical: 8, horizontal: 16),
  341. child: Text(hisFunc.doneList[i]['title'], style: TextStyle(color: Provider.of<HistoryModule>(context).checkPressAttention(hisFunc.doneList[i]['value']) ? Colors.white : textColor, fontSize: 16)),
  342. decoration: BoxDecoration(
  343. color: Provider.of<HistoryModule>(context).checkPressAttention(hisFunc.doneList[i]['value']) ? primaryColor : Color(0xffF2F8F7),
  344. border: Border.all(color: Provider.of<HistoryModule>(context).checkPressAttention(hisFunc.doneList[i]['value']) ? primaryColor : Color(0xffBEC1C1)),
  345. borderRadius: BorderRadius.all(Radius.circular(50))),
  346. ),
  347. onTap: () {
  348. if (!Provider.of<HistoryModule>(context, listen: false).isLoadHistory()) {
  349. if (Provider.of<HistoryModule>(context, listen: false).checkPressAttention(hisFunc.doneList[i]['value'])) {
  350. Provider.of<HistoryModule>(context, listen: false).setPressAttention(0);
  351. hisFunc.onRefresh(context);
  352. } else {
  353. Provider.of<HistoryModule>(context, listen: false).setPressAttention(hisFunc.doneList[i]['value']);
  354. hisFunc.onRefresh(context);
  355. }
  356. }
  357. },
  358. );
  359. }),
  360. );
  361. }
  362. Widget doneContainer() {
  363. return SingleChildScrollView(
  364. child: Column(
  365. children: [
  366. Column(
  367. children: List.generate(Provider.of<HistoryModule>(context).dataMisi().length, (i) {
  368. return GestureDetector(
  369. child: Container(
  370. padding: EdgeInsets.all(16),
  371. child: Column(
  372. children: [
  373. Row(
  374. // crossAxisAlignment: CrossAxisAlignment.start,
  375. children: [
  376. imageTiles(imageUrl: Provider.of<HistoryModule>(context).dataMisi()[i]['_requestImage'] ?? "null"),
  377. SizedBox(width: 16),
  378. Expanded(
  379. child: Column(
  380. crossAxisAlignment: CrossAxisAlignment.start,
  381. children: [
  382. Text(Provider.of<HistoryModule>(context).dataMisi()[i][U.langColumn(context, 'requestGroupDescription')],
  383. style: TextStyle(color: textColor, fontWeight: FontWeight.w500), overflow: TextOverflow.ellipsis),
  384. SizedBox(height: 6),
  385. Text(Provider.of<HistoryModule>(context).dataMisi()[i][U.langColumn(context, 'requestSubject')], style: TextStyle(color: textColor), overflow: TextOverflow.ellipsis),
  386. SizedBox(height: 6),
  387. renderRequested(Provider.of<HistoryModule>(context).dataMisi()[i]),
  388. Row(
  389. crossAxisAlignment: CrossAxisAlignment.start,
  390. children: [
  391. Text(convertDate(Provider.of<HistoryModule>(context).dataMisi()[i]['datetimeRequest'], context.locale.toString()),
  392. style: TextStyle(color: textColor, fontSize: 13, fontWeight: FontWeight.w300)),
  393. Text(
  394. ' - ${Provider.of<HistoryModule>(context).dataMisi()[i]['currentState'] == 'DISELESAIKAN' || Provider.of<HistoryModule>(context).dataMisi()[i]['currentState'] == 'TUNTAS' ? 'stateFinish'.tr() : 'stateCancel'.tr()}',
  395. style: TextStyle(
  396. color: Provider.of<HistoryModule>(context).dataMisi()[i]['currentState'] == 'DISELESAIKAN' ||
  397. Provider.of<HistoryModule>(context).dataMisi()[i]['currentState'] == 'TUNTAS'
  398. ? primaryColor
  399. : Color(0xffD81010),
  400. fontSize: 13,
  401. fontWeight: FontWeight.w300))
  402. ],
  403. )
  404. ],
  405. ),
  406. )
  407. ],
  408. ),
  409. SizedBox(height: 16),
  410. divider(),
  411. SizedBox(height: 16),
  412. Row(
  413. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  414. children: [
  415. !Provider.of<HistoryModule>(context).dataMisi()[i]['autoResponse'] && Provider.of<HistoryModule>(context).dataMisi()[i]['servantIdentityStart'] != '#system' && (Provider.of<HistoryModule>(context).dataMisi()[i]['currentState'] == 'TUNTAS' || Provider.of<HistoryModule>(context).dataMisi()[i]['currentState'] == 'DISELESAIKAN') ? Container(
  416. child: hisFunc.askForRate(Provider.of<HistoryModule>(context, listen: true).dataMisi()[i]) ? GestureDetector(
  417. child: Container(
  418. padding: EdgeInsets.symmetric(vertical: 4, horizontal: 16),
  419. child: Text('rateReq'.tr(), style: TextStyle(color: secondaryColor, fontSize: 14), overflow: TextOverflow.ellipsis),
  420. decoration: BoxDecoration(
  421. color: Colors.white,
  422. border: Border.all(color: secondaryColor),
  423. borderRadius: BorderRadius.all(Radius.circular(50))),
  424. ),
  425. onTap: () {
  426. U.newServerVersion(1716279633) ? navigateTo(context, MobHistoryRatingPage(Provider.of<HistoryModule>(context, listen: false).dataMisi()[i])).then((tempRating) {
  427. if(tempRating != null){
  428. Provider.of<HistoryModule>(context, listen: false).setSatisfaction(i, tempRating);
  429. }
  430. }) : rateMission(context, Provider.of<HistoryModule>(context, listen: false).dataMisi()[i], i);
  431. },
  432. ) : !hisFunc.isAutoResponse(Provider.of<HistoryModule>(context).dataMisi()[i]) ? Row(
  433. children: [
  434. Image(image: AssetImage(rating[Provider.of<HistoryModule>(context).dataMisi()[i]['satisfactionRate'] - 1]['image'].toString()), width: 25),
  435. SizedBox(width: 5),
  436. Text(rating[Provider.of<HistoryModule>(context).dataMisi()[i]['satisfactionRate'] - 1]['label'].toString(), style: TextStyle(color: textColor, fontSize: 14), overflow: TextOverflow.ellipsis),
  437. ],
  438. ) : Container(),
  439. ) : message(Provider.of<HistoryModule>(context).dataMisi()[i]['_hasForum'], Provider.of<HistoryModule>(context).dataMisi()[i]['_forumMsg'] ?? "null"),
  440. GestureDetector(
  441. child: Container(
  442. padding: EdgeInsets.symmetric(vertical: 4, horizontal: 16),
  443. child: Text('reqAgain'.tr(), style: TextStyle(color: primaryColor, fontSize: 14)),
  444. decoration: BoxDecoration(color: Colors.white, border: Border.all(color: primaryColor), borderRadius: BorderRadius.all(Radius.circular(50))),
  445. ),
  446. onTap: () => hisFunc.requestAgainAction(context, i),
  447. )
  448. ],
  449. ),
  450. (!Provider.of<HistoryModule>(context).dataMisi()[i]['autoResponse'] && Provider.of<HistoryModule>(context).dataMisi()[i]['servantIdentityStart'] != '#system' && (Provider.of<HistoryModule>(context).dataMisi()[i]['currentState'] == 'TUNTAS' || Provider.of<HistoryModule>(context).dataMisi()[i]['currentState'] == 'DISELESAIKAN')) ? message(Provider.of<HistoryModule>(context).dataMisi()[i]['_hasForum'], Provider.of<HistoryModule>(context).dataMisi()[i]['_forumMsg'] ?? "null", top: 16) : Container()
  451. ],
  452. ),
  453. decoration: BoxDecoration(
  454. color: Provider.of<HistoryModule>(context).selectedIndexes().contains(i) ? primaryColor.withValues(alpha: 0.05) : Colors.white,
  455. border: Border(bottom: BorderSide(color: Color(0xffF3F3F3), width: 8))),
  456. ),
  457. onTap: () {
  458. if (Provider.of<HistoryModule>(context, listen: false).multiSelectMode()) {
  459. hisFunc.selectedController(context, i);
  460. } else {
  461. navigateTo(context, MobHistoryDetailPage(index: i));
  462. }
  463. },
  464. onLongPress: () => hisFunc.selectedController(context, i),
  465. );
  466. })),
  467. !Provider.of<HistoryModule>(context).stopLoadHistory() || (Provider.of<HistoryModule>(context).isLoadHistory() && Provider.of<HistoryModule>(context).page() > 0)
  468. ? Container(margin: EdgeInsets.only(top: Provider.of<HistoryModule>(context).page() > 0 ? 0 : 50), child: loadingTemplate())
  469. : Provider.of<HistoryModule>(context).dataMisi().length == 0
  470. ? NoDataPage()
  471. : Container(),
  472. ],
  473. ),
  474. );
  475. }
  476. Widget renderRequested(list){
  477. if(list['receptionistId'] != null){
  478. var user = Provider.of<UserModule>(context, listen: false).user();
  479. if(user['roomAttendant'] && user['userId'] != list['informantUserId'] && user['userId'] == list['receptionistId']){
  480. return Column(
  481. crossAxisAlignment: CrossAxisAlignment.start,
  482. children: [
  483. Text('${'requestedFor'.tr()}: ${list['informantName']??'-'}' ,style: TextStyle(color: textColor, fontSize: 13, fontWeight: FontWeight.w300)),
  484. SizedBox(height: 6),
  485. ],
  486. );
  487. }
  488. if(user['userId'] == list['informantUserId'] && user['userId'] != list['receptionistId']){
  489. return Column(
  490. crossAxisAlignment: CrossAxisAlignment.start,
  491. children: [
  492. Text('${'requestedBy'.tr()}: ${list['receptionistName']??''}' ,style: TextStyle(color: textColor, fontSize: 13, fontWeight: FontWeight.w300)),
  493. SizedBox(height: 6),
  494. ],
  495. );
  496. }
  497. }
  498. return Container();
  499. }
  500. Widget message(bool _hasForum, String _forumMsg, {double top = 0}) {
  501. return _hasForum ? Container(
  502. margin: EdgeInsets.only(top: top),
  503. child: Row(
  504. children: [
  505. FadeTransition(opacity: _animationController, child: U.iconsax('messages-3', color: primaryColor)),
  506. SizedBox(width: 8),
  507. Text('“$_forumMsg”',
  508. style: TextStyle(color: textColor.withValues(alpha: 0.75), fontSize: 14, fontStyle: FontStyle.italic),
  509. overflow: TextOverflow.ellipsis),
  510. ],
  511. ),
  512. ) : Container();
  513. }
  514. rateMission(BuildContext context, list, index) {
  515. showModalBottomSheet(
  516. context: context,
  517. backgroundColor: Colors.transparent,
  518. isScrollControlled: true,
  519. builder: (contexts) {
  520. int tempRating = 0;
  521. String description = '';
  522. return StatefulBuilder(
  523. builder: (contextt, setStates) {
  524. return Container(
  525. decoration: BoxDecoration(color: secondaryColor, borderRadius: BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24))),
  526. child: Column(
  527. mainAxisSize: MainAxisSize.min,
  528. crossAxisAlignment: CrossAxisAlignment.start,
  529. children: [
  530. Padding(
  531. padding: EdgeInsets.symmetric(vertical: 12, horizontal: 16),
  532. child: Column(
  533. crossAxisAlignment: CrossAxisAlignment.start,
  534. children: [
  535. Text(list[U.langColumn(context, 'requestSubject')], style: TextStyle(color: Colors.white, fontSize: 14, fontWeight: FontWeight.w600)),
  536. SizedBox(height: 4),
  537. Text(convertDate(list['datetimeRequest'], context.locale.toString()), style: TextStyle(color: Colors.white, fontSize: 12, fontWeight: FontWeight.w300)),
  538. ],
  539. ),
  540. ),
  541. Container(
  542. padding: EdgeInsets.fromLTRB(30, 0, 30, 16),
  543. child: Column(
  544. children: [
  545. Container(
  546. margin: EdgeInsets.all(10),
  547. width: 40,
  548. height: 4,
  549. decoration: BoxDecoration(color: Color(0xff292D32).withValues(alpha: 0.2), borderRadius: BorderRadius.all(Radius.circular(10))),
  550. ),
  551. SizedBox(height: 12),
  552. Text('satisfactionAsk'.tr(), style: TextStyle(fontSize: 16)),
  553. SizedBox(height: 12),
  554. Row(
  555. mainAxisAlignment: MainAxisAlignment.center,
  556. children: List.generate(rating.length, (i) {
  557. return Expanded(
  558. child: GestureDetector(
  559. child: Image(
  560. image: AssetImage(rating[i]['image'].toString()),
  561. color: Colors.white.withValues(alpha: tempRating == rating[i]['key'] ? 1 : 0.3),
  562. colorBlendMode: BlendMode.modulate,
  563. ),
  564. // child: Icon(rating[i]['icon'] as IconData, color: tempRating == rating[i]['key']?rating[i]['color'] as Color:Colors.grey),
  565. onTap: () {
  566. setStates(() {
  567. tempRating = rating[i]['key'] as int;
  568. description = rating[i]['label'] as String;
  569. });
  570. },
  571. ),
  572. );
  573. }),
  574. ),
  575. SizedBox(height: 6),
  576. Text(description, style: TextStyle(color: textColor, fontSize: 14, fontWeight: FontWeight.w300), textAlign: TextAlign.center),
  577. SizedBox(height: 10),
  578. Opacity(
  579. opacity: tempRating > 0 ? 1 : 0,
  580. child: buttonTemplate(text: 'save_rating'.tr(), backgroundColor: secondaryColor, borderColor: secondaryColor, height: 40, action: ()async{
  581. if (tempRating > 0) {
  582. var data = {"ticketNo": list['ticketNo'], "rateSatisfy": tempRating};
  583. var res = await ApiAuthProvider() .postData('/api/requestHistories/rateSatisfy', null, data, contexts);
  584. if (res != null) {
  585. Provider.of<HistoryModule>(context, listen: false).setSatisfaction(index, tempRating);
  586. navigateBack(contexts);
  587. }
  588. }
  589. }),
  590. )
  591. ],
  592. ),
  593. decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(24), topRight: Radius.circular(24))),
  594. )
  595. ],
  596. ),
  597. );
  598. },
  599. );
  600. });
  601. }
  602. }