request_create.dart 49 KB

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