menu_history.dart 35 KB

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