request_create.dart 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. import 'package:cached_network_image/cached_network_image.dart';
  2. import 'package:easy_localization/easy_localization.dart';
  3. import 'package:flutter/foundation.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_cache_manager/flutter_cache_manager.dart';
  6. import 'package:flutter_datetime_picker_plus/flutter_datetime_picker_plus.dart';
  7. import 'package:image_picker/image_picker.dart';
  8. import 'package:loading_indicator/loading_indicator.dart';
  9. import 'package:provider/provider.dart';
  10. import 'package:searchfield/searchfield.dart';
  11. import 'package:telnow_mobile_new/src/injector/injector.dart';
  12. import 'package:telnow_mobile_new/src/layouts/functions/request.dart';
  13. import 'package:telnow_mobile_new/src/layouts/components/template.dart';
  14. import 'package:telnow_mobile_new/src/storage/sharedpreferences/shared_preferences_manager.dart';
  15. import 'package:telnow_mobile_new/src/utils/U.dart';
  16. import 'package:telnow_mobile_new/src/utils/cache_manager.dart';
  17. import 'package:telnow_mobile_new/src/utils/provider.dart';
  18. // import 'package:flutter_barcode_scanner/flutter_barcode_scanner.dart';
  19. import 'package:toggle_switch/toggle_switch.dart';
  20. class MobReqCreatePage extends StatefulWidget {
  21. Map<String, dynamic> user;
  22. Map<String, dynamic> request;
  23. final bool fromSearch;
  24. MobReqCreatePage({required this.user, required this.request, this.fromSearch = false, super.key});
  25. @override
  26. State<MobReqCreatePage> createState() => _MobReqCreatePageState();
  27. }
  28. getColorScheme(val){
  29. var color;
  30. switch (val){
  31. case 0: color = Color(0xFF4FB66C); break;
  32. case 50: color = Color(0xFFFFA800); break;
  33. case 100: color = Color(0xFFC9223B); break;
  34. default: color = Color(0xFF4FB66C);
  35. }
  36. return color;
  37. }
  38. class _MobReqCreatePageState extends State<MobReqCreatePage> {
  39. final RequestFunction reqFunc = RequestFunction();
  40. final SharedPreferencesManager sharedPreferencesManager = locator<SharedPreferencesManager>();
  41. TextEditingController controllerDate = new TextEditingController()..text = '';
  42. TextEditingController controllerDateString = new TextEditingController()..text = '';
  43. TextEditingController controllerNote = new TextEditingController()..text = '';
  44. TextEditingController controllerLocation = new TextEditingController()..text = '';
  45. TextEditingController controllerUserId = new TextEditingController()..text = '';
  46. TextEditingController controllerReferenceNumber = new TextEditingController()..text = '';
  47. FocusNode focusNodeLocation = new FocusNode();
  48. double _currentSliderValue = 0;
  49. Color sliderColor = getColorScheme(0);
  50. @override
  51. void initState() {
  52. Provider.of<CreateSerModule>(context, listen: false).reset();
  53. WidgetsBinding.instance.addPostFrameCallback((_) {
  54. if(widget.request['scanToRequest']) Provider.of<CreateSerModule>(context, listen: false).setLocationType(2);
  55. Provider.of<CreateSerModule>(context, listen: false).setDefaultLocation(widget.user['_isRelated'] ? sharedPreferencesManager.getString(SharedPreferencesManager.keyScoope) == 'INSIDE' ? widget.user['_2ndLocation'] : widget.user['location'] : widget.user['location']);
  56. });
  57. reqFunc.getSuggestionLocation(context);
  58. U.getOtherLabelList(context);
  59. switch (widget.request['requestPriority']){
  60. case 'RENDAH': _currentSliderValue = 0; break;
  61. case 'NORMAL': _currentSliderValue = 50; break;
  62. case 'TINGGI': _currentSliderValue = 100; break;
  63. }
  64. sliderColor = getColorScheme(_currentSliderValue);
  65. // TODO: implement initState
  66. super.initState();
  67. }
  68. @override
  69. Widget build(BuildContext context) {
  70. final FocusNode inputIdFocusNode = FocusNode();
  71. var imageWidth = ((U.bodyWidth(context)-32)/5)-5;
  72. return Scaffold(
  73. backgroundColor: backgroundColor,
  74. appBar: appBarTemplate(context: context, exc: false, title: widget.request[U.langColumn(context, 'subject')]),
  75. body: Column(
  76. children: [
  77. divider(),
  78. Expanded(
  79. child: Container(
  80. alignment: Alignment.topCenter,
  81. width: U.bodyWidth(context),
  82. child: SingleChildScrollView(
  83. padding: EdgeInsets.all(16),
  84. child: Column(
  85. crossAxisAlignment: CrossAxisAlignment.start,
  86. children: [
  87. Container(
  88. margin: EdgeInsets.only(bottom: 21),
  89. width: double.infinity, height: U.bodyWidth(context)/(kIsWeb?2.1:1.7),
  90. decoration: widget.request['_mobileImage'] != null ? BoxDecoration(
  91. color: Color(0xff292D32).withValues(alpha: 0.1),
  92. borderRadius: BorderRadius.all(Radius.circular(12)),
  93. image: DecorationImage(
  94. image: CachedNetworkImageProvider(widget.request['_mobileImage']+'?bridge-cache=true', cacheManager: CacheManager(CacheMan.config(widget.request['_mobileImage']))),
  95. fit: BoxFit.cover,
  96. ),
  97. ) : BoxDecoration(
  98. color: Colors.black12,
  99. borderRadius: BorderRadius.all(Radius.circular(12)),
  100. ),
  101. child: widget.request['_mobileImage'] == null ? Center(child: Text("noImage".tr(), style: TextStyle(fontStyle: FontStyle.italic, color: Colors.black38), textAlign: TextAlign.center,)) : Container(),
  102. ),
  103. Container(
  104. padding: EdgeInsets.all(16),
  105. margin: EdgeInsets.only(bottom: 21),
  106. width: double.infinity,
  107. child: Column(
  108. crossAxisAlignment: CrossAxisAlignment.start,
  109. children: [
  110. Text(widget.request[U.langColumn(context, '_requestGroupDescription')]??'', style: TextStyle(color: textColor, fontWeight: FontWeight.w500), overflow: TextOverflow.ellipsis),
  111. dashed(),
  112. Text(widget.request[U.langColumn(context, 'subjectDescription')], style: TextStyle(color: textColor, fontSize: 13, fontWeight: FontWeight.w300), maxLines: 3, overflow: TextOverflow.ellipsis)
  113. ],
  114. ),
  115. decoration: BoxDecoration(
  116. border: Border.all(color: textColor.withValues(alpha: 0.15)),
  117. borderRadius: BorderRadius.all(Radius.circular(12))
  118. ),
  119. ),
  120. widget.request['autoResponse'] ? infoContainer('autoResponseText'.tr()) : Column(
  121. crossAxisAlignment: CrossAxisAlignment.start,
  122. children: [
  123. Text('yourLocation'.tr(), style: TextStyle(color: textColor, fontWeight: FontWeight.w600)),
  124. // SizedBox(height: 6.0,),
  125. !widget.request['scanToRequest'] ? GestureDetector(
  126. child: Container(
  127. margin: EdgeInsets.only(top: 8),
  128. padding: EdgeInsets.symmetric(vertical: 12, horizontal: 15),
  129. child: Row(
  130. crossAxisAlignment: CrossAxisAlignment.center,
  131. children: [
  132. U.iconsax('location', color: textColor, size: 20),
  133. SizedBox(width: 15),
  134. Expanded(child: Column(
  135. crossAxisAlignment: CrossAxisAlignment.start,
  136. children: [
  137. Text('defaultLocation'.tr(), style: TextStyle(color: textColor, fontSize: 12, fontWeight: FontWeight.w300)),
  138. SizedBox(height: 5),
  139. Text(Provider.of<CreateSerModule>(context).defaultLocation(), style: TextStyle(color: textColor), maxLines: 2, overflow: TextOverflow.ellipsis)
  140. ],
  141. ))
  142. ],
  143. ),
  144. decoration: BoxDecoration(
  145. color: Provider.of<CreateSerModule>(context).locationType()==1?primaryColor.withValues(alpha: 0.15):Colors.white,
  146. border: Border.all(color: Provider.of<CreateSerModule>(context).locationType()==1?primaryColor:textColor.withValues(alpha: 0.15)),
  147. borderRadius: BorderRadius.only(topLeft: Radius.circular(12), topRight: Radius.circular(12))
  148. ),
  149. ),
  150. onTap: (){
  151. if(!widget.request['scanToRequest']) Provider.of<CreateSerModule>(context, listen: false).setLocationType(1);
  152. },
  153. ) : Container(),
  154. GestureDetector(
  155. child: Container(
  156. margin: EdgeInsets.only(bottom: 21, top: widget.request['scanToRequest'] ? 8 : 0),
  157. padding: EdgeInsets.symmetric(vertical: 12, horizontal: 15),
  158. decoration: BoxDecoration(
  159. color: Provider.of<CreateSerModule>(context).locationType()==2?primaryColor.withValues(alpha: 0.15):Colors.white,
  160. border: Border.all(color: Provider.of<CreateSerModule>(context).locationType()==2?primaryColor:textColor.withValues(alpha: 0.15)),
  161. borderRadius: widget.request['scanToRequest'] ? BorderRadius.all(Radius.circular(12.0)) : BorderRadius.only(bottomLeft: Radius.circular(12), bottomRight: Radius.circular(12))
  162. ),
  163. child: Row(
  164. crossAxisAlignment: CrossAxisAlignment.center,
  165. children: [
  166. U.iconsax('location', color: Color(0xffD91B1B), size: 20),
  167. SizedBox(width: 15),
  168. Expanded(
  169. child: Column(
  170. crossAxisAlignment: CrossAxisAlignment.start,
  171. children: [
  172. Text(widget.request['scanToRequest'] ? "findQRcode".tr() : 'specifyAnotherLocation'.tr(), style: TextStyle(color: textColor, fontSize: 12, fontWeight: FontWeight.w300)),
  173. SizedBox(height: 5),
  174. GestureDetector(
  175. child: SizedBox(
  176. width: double.infinity,
  177. child: SearchField(
  178. focusNode: focusNodeLocation,
  179. suggestions: Provider.of<CreateSerModule>(context).suggestion().map((e) => SearchFieldListItem(e, child: Padding(
  180. padding: EdgeInsets.symmetric(vertical: 5, horizontal: 13),
  181. child: Text(e, style: TextStyle(fontSize: 14, color: Colors.black)),
  182. ))).toList(),
  183. controller: controllerLocation,
  184. enabled: (!kIsWeb && widget.request['scanToRequest']) || Provider.of<CreateSerModule>(context).locationType() == 1 ? false : true,
  185. readOnly: (!kIsWeb && widget.request['scanToRequest']) || Provider.of<CreateSerModule>(context).locationType() == 1 ? true : false,
  186. searchInputDecoration: SearchInputDecoration(
  187. hintText: widget.request['scanToRequest'] && !kIsWeb ? 'pleaseScan'.tr() : 'placeholderLocation'.tr(),
  188. hintStyle: TextStyle(color: textColor.withValues(alpha: 0.5), fontSize: 14),
  189. filled: true,
  190. fillColor: backgroundColor,
  191. hoverColor: Colors.black.withValues(alpha: 0.1),
  192. contentPadding: EdgeInsets.all(13),
  193. border: InputBorder.none,
  194. disabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide(color: Color(0xff262626).withValues(alpha: 0.5))),
  195. enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide(color: Color(0xff262626).withValues(alpha: 0.5))),
  196. focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: const BorderSide(color: primaryColor)),
  197. isDense: true
  198. ),
  199. maxSuggestionsInViewPort: 3,
  200. itemHeight: 40,
  201. ),
  202. ),
  203. onTap: ()async{
  204. Provider.of<CreateSerModule>(context, listen: false).setLocationType(2);
  205. if(!kIsWeb && widget.request['scanToRequest']){
  206. try {
  207. // String barcode = await FlutterBarcodeScanner.scanBarcode('#ff6666', 'Cancel', true, ScanMode.QR);
  208. // var decrypted = U.decodeBase64Url(barcode);
  209. // controllerLocation.text = decrypted.split('#')[1];
  210. } catch (e) {
  211. showError(context, 'messageInvalidCode'.tr());
  212. }
  213. }
  214. },
  215. onTapCancel: () => print(" "),
  216. ),
  217. ],
  218. ),
  219. )
  220. ],
  221. ),
  222. ),
  223. onTap: (){
  224. Provider.of<CreateSerModule>(context, listen: false).setLocationType(2);
  225. },
  226. ),
  227. widget.user['roomAttendant'] ? Container(
  228. margin: EdgeInsets.only(bottom: 32),
  229. child: Column(
  230. crossAxisAlignment: CrossAxisAlignment.start,
  231. children: [
  232. Text(U.otherLabelList()['main-${context.locale.toString()}']??'someone_else'.tr(), style: TextStyle(color: textColor, fontWeight: FontWeight.w600)),
  233. SizedBox(height: 12),
  234. Row(
  235. children: [
  236. Container(
  237. child: ToggleSwitch(
  238. cornerRadius: 20,
  239. minWidth: 20,
  240. minHeight: 20,
  241. borderWidth: 2,
  242. activeBgColors: [[Colors.white], [Colors.white]],
  243. inactiveBgColor: Provider.of<CreateSerModule>(context).others() == 0 ? disabledColor : primaryColor,
  244. initialLabelIndex: Provider.of<CreateSerModule>(context).others(),
  245. totalSwitches: 2,
  246. radiusStyle: true,
  247. onToggle: (index) {
  248. if(index == 1) {
  249. FocusScope.of(context).requestFocus(inputIdFocusNode);
  250. } else {
  251. FocusScope.of(context).unfocus();
  252. }
  253. Provider.of<CreateSerModule>(context, listen: false).setOthers(index);
  254. },
  255. ),
  256. decoration: BoxDecoration(color: Provider.of<CreateSerModule>(context).others() == 0 ? disabledColor : primaryColor, borderRadius: BorderRadius.all(Radius.circular(20))),
  257. ),
  258. SizedBox(width: 8),
  259. Expanded(child: Text(Provider.of<CreateSerModule>(context).others() == 0 ? 'reqForMySelf'.tr() : 'reqForOthers'.tr(), style: TextStyle(color: textColor, fontSize: 12), maxLines: 2, overflow: TextOverflow.ellipsis))
  260. ],
  261. ),
  262. Provider.of<CreateSerModule>(context).others()==1?Container(
  263. margin: EdgeInsets.only(top: 12),
  264. width: double.infinity,
  265. child: TextField(
  266. controller: controllerUserId,
  267. focusNode: inputIdFocusNode,
  268. style: const TextStyle(fontSize: 14, color: Colors.black),
  269. autofocus: Provider.of<CreateSerModule>(context).others() == 1 ? true : false,
  270. readOnly: false,
  271. decoration: InputDecoration(
  272. hintText: U.otherLabelList()['placeholder-${context.locale.toString()}']??'typeId'.tr(),
  273. hintStyle: TextStyle(color: textColor.withValues(alpha: 0.5), fontSize: 14),
  274. filled: true,
  275. fillColor: backgroundColor,
  276. hoverColor: Colors.black.withValues(alpha: 0.1),
  277. contentPadding: EdgeInsets.all(13),
  278. border: InputBorder.none,
  279. enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide(color: Color(0xff262626).withValues(alpha: 0.5))),
  280. focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: const BorderSide(color: primaryColor)),
  281. isDense: true
  282. ),
  283. ),
  284. ):Container()
  285. ],
  286. ),
  287. ):Container(),
  288. widget.request['noteFormat'] == 'DATE' ? Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
  289. Text("askScheduleTime".tr(), style: TextStyle(color: textColor, fontWeight: FontWeight.w600)),
  290. SizedBox(height: 8,),
  291. TextField(
  292. controller: controllerDate,
  293. style: TextStyle(fontSize: 14, color: Colors.black),
  294. readOnly: true,
  295. decoration: InputDecoration(
  296. hintText: 'selectDate'.tr(),
  297. hintStyle: TextStyle(color: textColor.withValues(alpha: 0.5), fontSize: 14),
  298. filled: true,
  299. fillColor: backgroundColor,
  300. hoverColor: Colors.black.withValues(alpha: 0.1),
  301. contentPadding: EdgeInsets.all(13),
  302. prefixIcon: Padding(padding: EdgeInsets.only(left: 13, right: 13), child: U.iconsax('calendar-edit', color: textColor, size: 24)),
  303. border: InputBorder.none,
  304. enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide(color: Color(0xff262626).withValues(alpha: 0.5))),
  305. focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: const BorderSide(color: primaryColor)),
  306. isDense: true
  307. ),
  308. onTap: () {
  309. DatePicker.showDateTimePicker(context, showTitleActions: true,
  310. minTime: DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day, DateTime.now().hour, DateTime.now().minute),
  311. onConfirm: (date) {
  312. try {
  313. setState(() {
  314. controllerDate.text = DateFormat('dd MMM yyyy HH:mm:ss', 'id').format(date);
  315. controllerDateString.text = DateFormat('ddMMyyyy HHmm', 'id').format(date);
  316. });
  317. } catch (e) {
  318. print(e.toString());
  319. }
  320. }, currentTime: DateTime.now(), locale: LocaleType.id
  321. );
  322. },
  323. ),
  324. SizedBox(height: 32,)
  325. ],) : Container(),
  326. Column(
  327. crossAxisAlignment: CrossAxisAlignment.start,
  328. children: [
  329. Text('addImage'.tr(), style: TextStyle(color: textColor, fontWeight: FontWeight.w600)),
  330. SizedBox(height: 8),
  331. Provider.of<CreateSerModule>(context).images().length > 0 ? Row(
  332. children: [
  333. Row(
  334. children: List.generate(Provider.of<CreateSerModule>(context).images().length, (i){
  335. return GestureDetector(
  336. child: Container(
  337. width: imageWidth, height: imageWidth, alignment: Alignment.topRight,
  338. margin: EdgeInsets.only(right: i == 4 ? 0 : 6),
  339. child: Transform.translate(
  340. offset: Offset(3, -3),
  341. child: GestureDetector(
  342. child: Container(
  343. padding: EdgeInsets.all(3),
  344. child: Icon(Icons.close_rounded, color: Colors.white, size: 18),
  345. decoration: BoxDecoration(color: Colors.black54, border: Border.all(color: Colors.white, width: 2), borderRadius: BorderRadius.all(Radius.circular(50))),
  346. ),
  347. onTap: ()=>Provider.of<CreateSerModule>(context, listen: false).removeImages(i),
  348. ),
  349. ),
  350. decoration: BoxDecoration(
  351. color: Colors.black12, borderRadius: BorderRadius.all(Radius.circular(5)), border: Border.all(color: Colors.black26, width: 0.5),
  352. image: DecorationImage(image: MemoryImage(Provider.of<CreateSerModule>(context).images()[i]), fit: BoxFit.cover)
  353. ),
  354. ),
  355. onTap: ()=>navigateTo(context, PhotoPreviewGallery(title: 'image'.tr(), imageList: Provider.of<CreateSerModule>(context, listen: false).images(), startIndex: i, isUrl: false))
  356. );
  357. }),
  358. ),
  359. Provider.of<CreateSerModule>(context).images().length < 5 ? GestureDetector(
  360. child: Container(
  361. width: imageWidth, height: imageWidth, alignment: Alignment.center,
  362. child: Provider.of<CreateSerModule>(context).setLoadingEffect() ? SizedBox(
  363. height: 30,
  364. child: LoadingIndicator(
  365. indicatorType: Indicator.ballPulseRise,
  366. colors: U.defaultRainbowColors(),
  367. strokeWidth: 1,
  368. backgroundColor: Colors.black.withValues(alpha: 0),
  369. pathBackgroundColor: Colors.black,
  370. ),
  371. ) : Icon(Icons.add_rounded, color: Colors.black26, size: 40),
  372. decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(5)), border: Border.all(color: Colors.black26, width: 2)),
  373. ),
  374. onTap: ()=>pickupImageNew(),
  375. ) : Container(),
  376. ],
  377. ) : GestureDetector(
  378. child: Container(
  379. padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
  380. decoration: BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(10)), border: Border.all(color: Color(0xFF078C84)), color: Color(0xFFFFFFFF).withValues(alpha: 0.2)),
  381. child: Row(
  382. children: [
  383. U.iconsax('image', color: primaryColor, size: 30),
  384. SizedBox(width: 8,),
  385. Expanded(child: Text('addImageMsg'.tr(), style: TextStyle(color: textColor, fontSize: 12, fontWeight: FontWeight.w300), maxLines: 2, overflow: TextOverflow.ellipsis)),
  386. ],
  387. ),
  388. ),
  389. onTap: ()=>pickupImageNew(),
  390. ),
  391. U.newServerVersion(1736473802) ? Column(
  392. crossAxisAlignment: CrossAxisAlignment.start,
  393. children: [
  394. SizedBox(height: 32),
  395. Text('changePriority'.tr(), style: TextStyle(color: textColor, fontWeight: FontWeight.w600)),
  396. SizedBox(height: 12),
  397. Container(
  398. height: 32,
  399. decoration: BoxDecoration(
  400. color: Colors.white,
  401. borderRadius: BorderRadius.circular(25.0),
  402. border: Border.all(
  403. width: 3.0,
  404. color: Colors.transparent,
  405. ),
  406. gradient: LinearGradient(
  407. colors: [
  408. Color(0xFF4FB66C).withValues(alpha: 1),
  409. Color(0xFFFFA800).withValues(alpha: 1),
  410. Color(0xFFC9223B).withValues(alpha: 1),
  411. ],
  412. begin: Alignment.topLeft,
  413. end: Alignment.bottomRight,
  414. ),
  415. ),
  416. child: Container(
  417. decoration: BoxDecoration(
  418. color: Colors.white,
  419. borderRadius: BorderRadius.circular(25.0),
  420. ),
  421. child: SliderTheme(
  422. data: SliderThemeData(
  423. inactiveTrackColor: Colors.white,
  424. ),
  425. child: Slider(
  426. activeColor: sliderColor,
  427. value: _currentSliderValue,
  428. max:100,
  429. divisions: 2,
  430. onChanged: (double value) {
  431. setState(() {
  432. _currentSliderValue = value;
  433. sliderColor = getColorScheme(value);
  434. });
  435. },
  436. ),
  437. ),
  438. ),
  439. ),
  440. SizedBox(height: 4,),
  441. Center(
  442. child: Row(
  443. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  444. children: [
  445. Text('priorityLow'.tr(), style: TextStyle(fontSize: 12),),
  446. Text('priorityNormal'.tr(), style: TextStyle(fontSize: 12)),
  447. Text('priorityHigh'.tr(), style: TextStyle(fontSize: 12)),
  448. ],
  449. )
  450. )
  451. ],
  452. ) : SizedBox(),
  453. U.newServerVersion(1741166029) ? Column(
  454. crossAxisAlignment: CrossAxisAlignment.start,
  455. children: [
  456. SizedBox(height: 32),
  457. Text('referenceNumber'.tr(), style: TextStyle(color: textColor, fontWeight: FontWeight.w600)),
  458. SizedBox(height: 8),
  459. SizedBox(
  460. width: double.infinity,
  461. child: TextField(
  462. controller: controllerReferenceNumber,
  463. style: TextStyle(fontSize: 14, color: Colors.black),
  464. decoration: InputDecoration(
  465. hintText: 'enterTicketNumber'.tr(),
  466. hintStyle: TextStyle(color: textColor.withValues(alpha: 0.5), fontSize: 14),
  467. filled: true,
  468. fillColor: backgroundColor,
  469. hoverColor: Colors.black.withValues(alpha: 0.1),
  470. contentPadding: EdgeInsets.all(13),
  471. prefixIcon: Padding(padding: EdgeInsets.only(left: 13, right: 13), child: U.iconsax('ticket', color: textColor, size: 24)),
  472. border: InputBorder.none,
  473. enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide(color: Color(0xff262626).withValues(alpha: 0.5))),
  474. focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: const BorderSide(color: primaryColor)),
  475. isDense: true
  476. ),
  477. ),
  478. )
  479. ],
  480. ) : SizedBox(),
  481. ],
  482. ),
  483. ],
  484. ),
  485. widget.request['canNotCancel'] ? Padding(
  486. padding: EdgeInsets.only(top: 21),
  487. child: infoContainer('canNotCancel1'.tr()),
  488. ) : Container()
  489. ],
  490. ),
  491. ),
  492. ),
  493. ),
  494. divider(),
  495. Container(
  496. alignment: Alignment.bottomCenter,
  497. width: U.bodyWidth(context), color: Colors.white,
  498. padding: EdgeInsets.symmetric(vertical: 10, horizontal: 16),
  499. child: Column(
  500. children: [
  501. widget.request['autoResponse'] ? Container() : Container(
  502. margin: EdgeInsets.only(bottom: 10),
  503. width: double.infinity,
  504. child: TextField(
  505. controller: controllerNote,
  506. style: TextStyle(fontSize: 14, color: Colors.black),
  507. minLines: 1,
  508. maxLines: 3,
  509. keyboardType: widget.request['noteFormat'] == 'NUMBER' ? TextInputType.number : null,
  510. decoration: InputDecoration(
  511. hintText: 'placeholderNote'.tr(),
  512. hintStyle: TextStyle(color: textColor.withValues(alpha: 0.5), fontSize: 14),
  513. filled: true,
  514. fillColor: backgroundColor,
  515. hoverColor: Colors.black.withValues(alpha: 0.1),
  516. contentPadding: EdgeInsets.all(13),
  517. prefixIcon: Padding(padding: EdgeInsets.only(left: 13, right: 13), child: U.iconsax('edit-2', color: textColor, size: 24)),
  518. border: InputBorder.none,
  519. enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: BorderSide(color: Color(0xff262626).withValues(alpha: 0.5))),
  520. focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(12), borderSide: const BorderSide(color: primaryColor)),
  521. isDense: true
  522. ),
  523. ),
  524. ),
  525. buttonTemplate(text: 'buttonSendRequest'.tr(), action: () async{
  526. if ((Provider.of<CreateSerModule>(context, listen: false).locationType() == 2 && controllerLocation.text.trim().isNotEmpty) || (Provider.of<CreateSerModule>(context, listen: false).locationType() == 1 && Provider.of<CreateSerModule>(context, listen: false).defaultLocation() != '')) {
  527. if (controllerNote.text.length <= 128) {
  528. if (widget.user['roomAttendant'] && Provider.of<CreateSerModule>(context, listen: false).others() == 1){
  529. if (controllerUserId.text.trim().isNotEmpty){
  530. if (controllerDateString.text.trim().isEmpty && widget.request['noteFormat'] == 'DATE'){
  531. showError(context, 'dateRequired'.tr());
  532. } else {
  533. reqFunc.sendRequestToOthers(context, widget, controllerUserId, controllerNote, controllerReferenceNumber, controllerLocation, controllerDateString, _currentSliderValue);
  534. }
  535. } else {
  536. showError(context, 'idRequired'.tr());
  537. }
  538. } else if (controllerDateString.text.trim().isNotEmpty && widget.request['noteFormat'] == 'DATE'){
  539. dialogSendLater();
  540. } else {
  541. reqFunc.sendRequest(context, widget, controllerNote, controllerReferenceNumber, controllerLocation, controllerDateString, _currentSliderValue);
  542. }
  543. } else {
  544. showError(context, 'lengthMax'.tr());
  545. }
  546. } else {
  547. showError(context, 'locRequired'.tr()+(!kIsWeb && widget.request['scanToRequest']?' ${'pleaseScan'.tr()}.':''));
  548. }
  549. })
  550. ],
  551. ),
  552. )
  553. ],
  554. ),
  555. );
  556. }
  557. dialogSendLater(){
  558. showDialog(
  559. context: context,
  560. builder: (contexts) => AlertDialog(
  561. title: Text('sendingOpt'.tr(), style: TextStyle(color: textColor, fontSize: 16, fontWeight: FontWeight.w500)),
  562. titlePadding: EdgeInsets.all(20),
  563. contentPadding: EdgeInsets.fromLTRB(20, 4, 20, 28),
  564. content: Column(
  565. mainAxisSize: MainAxisSize.min,
  566. children: [
  567. Text('sendingOptMsg'.tr(), style: TextStyle(fontSize: 14, color: textColor)),
  568. SizedBox(height: 12),
  569. Row(
  570. children: [
  571. Expanded(
  572. child: GestureDetector(
  573. child: Container(
  574. padding: EdgeInsets.symmetric(vertical: 20),
  575. child: Column(
  576. mainAxisSize: MainAxisSize.min,
  577. children: [
  578. U.iconsax('timer-start', color: Colors.white, size: 30),
  579. SizedBox(height: 9),
  580. Text('scheduled'.tr(), style: TextStyle(color: Colors.white, fontSize: 14))
  581. ],
  582. ),
  583. decoration: BoxDecoration(
  584. borderRadius: BorderRadius.all(Radius.circular(12)),
  585. gradient: LinearGradient(
  586. begin: Alignment.topLeft, end: Alignment.bottomRight,
  587. colors: [
  588. Color(0xff131480).withValues(alpha: 0.56), Color(0xff131480).withValues(alpha: 0.90), Color(0xff131480).withValues(alpha: 0.75)
  589. ]
  590. )
  591. ),
  592. ),
  593. onTap: (){
  594. navigateBack(contexts);
  595. Provider.of<CreateSerModule>(context, listen: false).setSendLater(true);
  596. reqFunc.sendRequest(context, widget, controllerNote, controllerReferenceNumber, controllerLocation, controllerDateString, _currentSliderValue);
  597. },
  598. ),
  599. ),
  600. SizedBox(width: 16),
  601. Expanded(
  602. child: GestureDetector(
  603. child: Container(
  604. padding: EdgeInsets.symmetric(vertical: 20),
  605. child: Column(
  606. mainAxisSize: MainAxisSize.min,
  607. children: [
  608. U.iconsax('star-1', color: Colors.white, size: 30),
  609. SizedBox(height: 9),
  610. Text('sendNow'.tr(), style: TextStyle(color: Colors.white, fontSize: 14))
  611. ],
  612. ),
  613. decoration: BoxDecoration(
  614. borderRadius: BorderRadius.all(Radius.circular(12)),
  615. gradient: LinearGradient(
  616. begin: Alignment.topLeft, end: Alignment.bottomRight,
  617. colors: [
  618. Color(0xff078C84).withValues(alpha: 0.56), Color(0xff078C84).withValues(alpha: 0.90), Color(0xff078C84).withValues(alpha: 0.75)
  619. ]
  620. )
  621. ),
  622. ),
  623. onTap: (){
  624. navigateBack(contexts);
  625. reqFunc.sendRequest(context, widget, controllerNote, controllerReferenceNumber, controllerLocation, controllerDateString, _currentSliderValue);
  626. },
  627. ),
  628. ),
  629. ],
  630. ),
  631. SizedBox(height: 12),
  632. divider(),
  633. SizedBox(height: 12),
  634. Container(
  635. padding: EdgeInsets.all(3),
  636. decoration: BoxDecoration(
  637. color: Color(0xffCCA600).withValues(alpha: 0.2),
  638. borderRadius: BorderRadius.all(Radius.circular(3))
  639. ),
  640. child: Text('scheduledMsg'.tr(), style: TextStyle(color: textColor, fontSize: 12, fontWeight: FontWeight.w300)),
  641. )
  642. ],
  643. ),
  644. ),
  645. );
  646. }
  647. pickupImageNew() async{
  648. if(Provider.of<CreateSerModule>(context, listen: false).images().length < 5){
  649. if (kIsWeb) {
  650. await reqFunc.getImageNew(context, ImageSource.gallery).then((img){
  651. img != null ? Provider.of<CreateSerModule>(context, listen: false).setImages(img) : (){};
  652. });
  653. } else{
  654. showModalBottomSheet<void>(
  655. context: context,
  656. backgroundColor: Colors.white,
  657. builder: (BuildContext context) {
  658. return Column(
  659. mainAxisSize: MainAxisSize.min,
  660. children: <Widget>[
  661. Padding(
  662. padding: const EdgeInsets.only(top: 15, bottom: 15),
  663. child: Center(
  664. child: Text('selectPicture'.tr(), style: TextStyle(color: textColor, fontWeight: FontWeight.w600)),
  665. ),
  666. ),
  667. divider(),
  668. ListTile(
  669. leading: Icon(Icons.image),
  670. title: Text('fromGallery'.tr(), style: TextStyle(color: textColor)),
  671. onTap: () async{
  672. var image = await reqFunc.getImageNew(context, ImageSource.gallery);
  673. Provider.of<CreateSerModule>(context, listen: false).setImages(image);
  674. Navigator.of(context).pop();
  675. },
  676. ),
  677. ListTile(
  678. leading: Icon(Icons.camera),
  679. title: Text('fromCamera'.tr(), style: TextStyle(color: textColor)),
  680. onTap: () async{
  681. var image = await reqFunc.getImageNew(context, ImageSource.camera);
  682. Provider.of<CreateSerModule>(context, listen: false).setImages(image);
  683. Navigator.of(context).pop();
  684. },
  685. )
  686. ],
  687. );
  688. }
  689. );
  690. }
  691. }
  692. }
  693. }