provider.dart 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. import 'dart:convert';
  2. import 'dart:typed_data';
  3. import 'package:easy_localization/easy_localization.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:telnow_mobile_new/src/utils/U.dart';
  6. class UserModule with ChangeNotifier {
  7. static String _serialNumber = '';
  8. static Map<String, dynamic> _user = {};
  9. static Map<String, dynamic> _profile = {};
  10. static bool _reset = false;
  11. static bool _dnd = false;
  12. static bool _servantDisplay = false;
  13. static bool _houseKeeping = false;
  14. static String _text = 'req_group'.tr();
  15. String serialNumber() => _serialNumber;
  16. Map<String, dynamic> user() => _user;
  17. Map<String, dynamic> profile() => _profile;
  18. bool resetData() => _reset;
  19. bool dndStatus() => _dnd;
  20. bool servantDisplay() => _servantDisplay;
  21. bool houseKeeping() => _houseKeeping;
  22. String textnya() => _text;
  23. void setList(list) {
  24. _user = list;
  25. notifyListeners();
  26. }
  27. void setProfile(list) {
  28. if(list != null){
  29. _profile = jsonDecode(list);
  30. }
  31. else{
  32. _profile = {};
  33. }
  34. notifyListeners();
  35. }
  36. void setResetData(val) {
  37. _reset = val;
  38. notifyListeners();
  39. }
  40. void setDndStatus(val) {
  41. _dnd = val;
  42. notifyListeners();
  43. }
  44. void setHouseKeeping(val) {
  45. _houseKeeping = val;
  46. notifyListeners();
  47. }
  48. void setSerialNum(number) {
  49. _serialNumber = number;
  50. notifyListeners();
  51. }
  52. void setServantDisplay(val) {
  53. _servantDisplay = val;
  54. notifyListeners();
  55. }
  56. void setText(val) {
  57. _text = val;
  58. notifyListeners();
  59. }
  60. void reset(){
  61. _serialNumber = '';
  62. _text = 'req_group'.tr();
  63. _user = {};
  64. _profile = {};
  65. _reset = false;
  66. _servantDisplay = false;
  67. }
  68. }
  69. //------------------------------------------------------------------------------
  70. class ReqGroupModule with ChangeNotifier {
  71. static List _data = [];
  72. static bool _isLoad = false;
  73. static bool _stopLoad = false;
  74. List data() => _data;
  75. bool isLoad() => _isLoad;
  76. bool stopLoad() => _stopLoad;
  77. void setData(value) {_data = value; notifyListeners();}
  78. void clearData() {_data.clear(); notifyListeners();}
  79. void setIsLoad(value) {_isLoad = value; notifyListeners();}
  80. void setStopLoad(value) {_stopLoad = value; notifyListeners();}
  81. void reset(){
  82. _data = [];
  83. _isLoad = false;
  84. _stopLoad = false;
  85. }
  86. }
  87. class RequestModule with ChangeNotifier {
  88. static List _data = [];
  89. static bool _isLoad = false;
  90. static bool _stopLoad = false;
  91. static bool _isEmpty = false;
  92. static String _placeholder = '';
  93. static String _keyword = '';
  94. List data() => _data;
  95. bool isLoad() => _isLoad;
  96. bool stopLoad() => _stopLoad;
  97. bool isEmpty() => _isEmpty;
  98. String placeholder() => _placeholder;
  99. String keyword() => _keyword;
  100. void setData(value) {_data = value; notifyListeners();}
  101. void clearData() {_data.clear(); notifyListeners();}
  102. void setIsLoad(value) {_isLoad = value; notifyListeners();}
  103. void setStopLoad(value) {_stopLoad = value; notifyListeners();}
  104. void setEmpty(value) {_isEmpty = value; notifyListeners();}
  105. void setPlaceholder(value) {_placeholder = value; notifyListeners();}
  106. void setKeyword(value) {_keyword = value; notifyListeners();}
  107. void reset(){
  108. _data = [];
  109. _isLoad = false;
  110. _stopLoad = false;
  111. _isEmpty = false;
  112. _placeholder = '';
  113. _keyword = '';
  114. }
  115. }
  116. class ServiceModule with ChangeNotifier {
  117. static String _scoopeName = '-';
  118. static dynamic _scoopeValue;
  119. static List _scoope = [];
  120. static bool _initialized = false;
  121. static List _data = [];
  122. static List _quickAct = [];
  123. static List _messages = [];
  124. static bool _isLoaded = false;
  125. static bool _stopLoad = false;
  126. static bool _hideQuickAct = false;
  127. static bool _unreadMessage = false;
  128. static bool _expand = false;
  129. static int _count = 0;
  130. static List? _topMenu;
  131. static List? _reqGroup;
  132. static List _offer = [];
  133. static List _banner = [];
  134. static String _contactCenter = '';
  135. String scoopeName() => _scoopeName;
  136. dynamic scoopeValue() => _scoopeValue;
  137. List scoope() => _scoope;
  138. bool initialized() => _initialized;
  139. List data() => _data;
  140. List quickAct() => _quickAct;
  141. List messages() => _messages;
  142. bool isLoaded() => _isLoaded;
  143. bool stopLoad() => _stopLoad;
  144. bool hideQuickAct() => _hideQuickAct;
  145. bool unreadMessage() => _unreadMessage;
  146. bool expand() => _expand;
  147. int count() => _count;
  148. List? topMenu() => _topMenu;
  149. List? reqGroup() => _reqGroup;
  150. List specialOffer() => _offer;
  151. List banner() => _banner;
  152. String contactCenter() => _contactCenter;
  153. void setInitialized(value) {
  154. _initialized = value;
  155. notifyListeners();
  156. }
  157. void setContactCenter(value) {
  158. _contactCenter = value;
  159. notifyListeners();
  160. }
  161. void setScoopeName(value) {
  162. _scoopeName = value;
  163. notifyListeners();
  164. }
  165. void setScoopeValue(value) {
  166. _scoopeValue = value;
  167. notifyListeners();
  168. }
  169. void setScoope(value) {
  170. _scoope = value;
  171. notifyListeners();
  172. }
  173. bool checkScoope(value) {
  174. return _scoopeValue == value;
  175. }
  176. int getScoopeLength(){
  177. return _scoope.length;
  178. }
  179. void setTopMenu(value) {
  180. _topMenu = value;
  181. notifyListeners();
  182. }
  183. void setReqGroup(value) {
  184. _reqGroup = value;
  185. notifyListeners();
  186. }
  187. void setSpecialOffer(value) {
  188. _offer = value;
  189. notifyListeners();
  190. }
  191. void setBanner(value) {
  192. _banner = value;
  193. notifyListeners();
  194. }
  195. void setData(value) {
  196. _data = value;
  197. notifyListeners();
  198. }
  199. int getDataLength() {
  200. return _data.length;
  201. }
  202. void setQuickAct(value) {
  203. _quickAct = value;
  204. notifyListeners();
  205. }
  206. void setMessage(value) {
  207. _messages = value;
  208. notifyListeners();
  209. }
  210. void setIsLoaded(value) {
  211. _isLoaded = value;
  212. notifyListeners();
  213. }
  214. void setStopLoad(value) {
  215. _stopLoad = value;
  216. notifyListeners();
  217. }
  218. void setHideQuickAct(value) {
  219. _hideQuickAct = value;
  220. notifyListeners();
  221. }
  222. void setUnreadMessage(value) {
  223. _unreadMessage = value;
  224. notifyListeners();
  225. }
  226. void setCount(value) {
  227. _count = value;
  228. notifyListeners();
  229. }
  230. void setExpand(value) {
  231. _expand = value;
  232. notifyListeners();
  233. }
  234. void reset(){
  235. _scoopeName = '-';
  236. _scoopeValue = null;
  237. _scoope = [];
  238. _initialized = false;
  239. _data = [];
  240. _quickAct = [];
  241. _messages = [];
  242. _isLoaded = false;
  243. _stopLoad = false;
  244. _hideQuickAct = false;
  245. _unreadMessage = false;
  246. _expand = false;
  247. _count = 0;
  248. _topMenu = null;
  249. _reqGroup = null;
  250. _offer = [];
  251. _banner = [];
  252. }
  253. }
  254. //------------------------------------------------------------------------------
  255. class HistoryModule with ChangeNotifier {
  256. static int _page = 0;
  257. static bool _isLoadHistory = false;
  258. static bool _stopLoadHistory = false;
  259. static bool _multiSelectMode = false;
  260. static bool _setLoading = false;
  261. static List _selectedIndexes = [];
  262. static List _activeForum = [];
  263. static List _data = [];
  264. static List _pendingData = [];
  265. static int _pressAttention = 0;
  266. static int _selectedFilter = 1;
  267. List dataMisi() => _data;
  268. List dataPending() => _pendingData;
  269. int pressAttention() => _pressAttention;
  270. int selectedFilter() => _selectedFilter;
  271. int page() => _page;
  272. bool isLoadHistory() => _isLoadHistory;
  273. bool stopLoadHistory() => _stopLoadHistory;
  274. bool multiSelectMode() => _multiSelectMode;
  275. bool setLoading() => _setLoading;
  276. List selectedIndexes() => _selectedIndexes;
  277. List activeForum() => _activeForum;
  278. void addSelectedIndexes(i) {
  279. _selectedIndexes.add(i);
  280. notifyListeners();
  281. }
  282. void removeSelectedIndexes(i) {
  283. _selectedIndexes.remove(i);
  284. notifyListeners();
  285. }
  286. void setSelectedIndexes(value) {
  287. _selectedIndexes = value;
  288. notifyListeners();
  289. }
  290. void setPressAttention(value) {
  291. _pressAttention = value;
  292. notifyListeners();
  293. }
  294. void setSelectedFilter(value) {
  295. _selectedFilter = value;
  296. notifyListeners();
  297. }
  298. void setPage(value) {
  299. _page = value;
  300. notifyListeners();
  301. }
  302. void addPage() {
  303. _page++;
  304. notifyListeners();
  305. }
  306. void setLoadHistory(value) {
  307. _isLoadHistory = value;
  308. notifyListeners();
  309. }
  310. void setStopLoadHistory(value) {
  311. _stopLoadHistory = value;
  312. notifyListeners();
  313. }
  314. void setMultiSelectMode(value) {
  315. _multiSelectMode = value;
  316. notifyListeners();
  317. }
  318. void setSetLoading(value) {
  319. _setLoading = value;
  320. notifyListeners();
  321. }
  322. void setMisi(list) {
  323. _data.addAll(list);
  324. notifyListeners();
  325. }
  326. void clearMisi() {
  327. _data.clear();
  328. notifyListeners();
  329. }
  330. void setPendingData(list) {
  331. _pendingData = list;
  332. notifyListeners();
  333. }
  334. void setActiveForum(list) {
  335. _activeForum = list;
  336. notifyListeners();
  337. }
  338. bool checkPressAttention(value){
  339. return _pressAttention == value;
  340. }
  341. int getMisiLength(){
  342. return _data.length;
  343. }
  344. void setSatisfaction(index, rate) {
  345. _data[index]['satisfactionRate'] = rate;
  346. notifyListeners();
  347. }
  348. void cancelMisi(index) {
  349. _data.removeAt(index);
  350. notifyListeners();
  351. }
  352. void setForumFalse(index) {
  353. _data[index]['_hasForum'] = false;
  354. notifyListeners();
  355. }
  356. void reset(){
  357. _page = 0;
  358. _isLoadHistory = false;
  359. _stopLoadHistory = false;
  360. _multiSelectMode = false;
  361. _setLoading = false;
  362. _data = [];
  363. _pendingData = [];
  364. _pressAttention = 0;
  365. _selectedFilter = 1;
  366. _selectedIndexes = [];
  367. _activeForum = [];
  368. }
  369. }
  370. //------------------------------------------------------------------------------
  371. class CreateSerModule with ChangeNotifier{
  372. int _locationType = 1;
  373. Uint8List? _image;
  374. bool _sendLater = false;
  375. bool _setLoadingEffect = false;
  376. int _others = 0;
  377. List _suggestion = [];
  378. List<Uint8List> _images = [];
  379. String _defaultLocation = '';
  380. int locationType() => _locationType;
  381. int others() => _others;
  382. Uint8List? image() => _image;
  383. bool sendLater() => _sendLater;
  384. bool setLoadingEffect() => _setLoadingEffect;
  385. List suggestion() => _suggestion;
  386. List<Uint8List> images() => _images;
  387. String defaultLocation() => _defaultLocation;
  388. void setLocationType(value) {
  389. _locationType = value;
  390. notifyListeners();
  391. }
  392. void setOthers(value) {
  393. _others = value;
  394. notifyListeners();
  395. }
  396. void setImage(value) {
  397. _image = value;
  398. notifyListeners();
  399. }
  400. void setSendLater(value) {
  401. _sendLater = value;
  402. notifyListeners();
  403. }
  404. void setSetLoadingEffect(value) {
  405. _setLoadingEffect = value;
  406. notifyListeners();
  407. }
  408. void setSuggestion(value) {
  409. _suggestion = value;
  410. notifyListeners();
  411. }
  412. void setImages(Uint8List value) {
  413. _images.add(value);
  414. notifyListeners();
  415. }
  416. void removeImages(int index) {
  417. _images.removeAt(index);
  418. notifyListeners();
  419. }
  420. void setDefaultLocation(value) {
  421. _defaultLocation = value;
  422. notifyListeners();
  423. }
  424. void reset(){
  425. _locationType = 1;
  426. _others = 0;
  427. _image = null;
  428. _images = [];
  429. _sendLater = false;
  430. _setLoadingEffect = false;
  431. _suggestion = [];
  432. _defaultLocation = '';
  433. }
  434. }
  435. //------------------------------------------------------------------------------
  436. class MessageModule with ChangeNotifier{
  437. Map<String, dynamic> _user = {};
  438. List _data = [];
  439. bool _firstLoad = false;
  440. bool _isAfterLoad = false;
  441. List _forum = [];
  442. int _selectedTab = 0;
  443. Map<String, dynamic> user() => _user;
  444. List data() => _data;
  445. bool firstLoad() => _firstLoad;
  446. bool isAfterLoad() => _isAfterLoad;
  447. List forum() => _forum;
  448. int activeTab() => _selectedTab;
  449. void setUser(value) {
  450. _user = value;
  451. notifyListeners();
  452. }
  453. void setData(value) {
  454. _data = value;
  455. notifyListeners();
  456. }
  457. void setFirstLoad(value) {
  458. _firstLoad = value;
  459. notifyListeners();
  460. }
  461. void setAfterLoad(value) {
  462. _isAfterLoad = value;
  463. notifyListeners();
  464. }
  465. void reset(){
  466. _user = {};
  467. _data = [];
  468. _firstLoad = false;
  469. _isAfterLoad = false;
  470. _forum = [];
  471. _selectedTab = 0;
  472. }
  473. void setForum(val){
  474. _forum = val;
  475. notifyListeners();
  476. }
  477. void setActiveTab(val){
  478. // print("setActiveTab($val)");
  479. _selectedTab = val;
  480. notifyListeners();
  481. }
  482. }