request_create.dart 42 KB

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