RAHomeViewController.m 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142
  1. //
  2. // RAHomeViewController.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/6/1.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RAHomeViewController.h"
  9. //#import "RAOrderDetailViewController.h"
  10. #import "RAProgressHUD.h"
  11. //#import "ApexDriverUploadListVC.h"
  12. //#import "RAHomeMoreViewController.h"
  13. #import <UserNotifications/UserNotifications.h>
  14. //#import "UIScrollView+Empty.h"
  15. #import "RAEmptyView.h"
  16. #import "RAHomeHeaderView.h"
  17. //#import "RAMessageViewController.h"
  18. //#import "RASettingViewController.h"
  19. #import <CoreLocation/CoreLocation.h>
  20. //#import "RABadgeButton.h"
  21. #import "const.h"
  22. #import "RADataProvider.h"
  23. #import "RASingleton.h"
  24. //#import "ResultISFCell.h"
  25. #import "ResultCustomerCell.h"
  26. //#import "ResultACICell.h"
  27. //#import "ResultACEM1Cell.h"
  28. //#import "ResultBaseModel.h"
  29. //#import "ResultACIModel.h"
  30. //#import "ResulteManifestCell.h"
  31. //#import "ResulteManifestModel.h"
  32. //#import "ResultACEM1Model.h"
  33. //#import "ResultISFModel.h"
  34. #import "ResultCustomerModel.h"
  35. #import "ResultViewController.h"
  36. #import "HomeDashEmptyCell.h"
  37. #import "FunctionSettingViewController.h"
  38. #import "HomeDashISFCellP.h"
  39. #import "HomeDashISFModelP.h"
  40. #import "HomeDashACEM1CellP.h"
  41. #import "HomeDashACEM1ModelP.h"
  42. #import "HomeDashACICellP.h"
  43. #import "HomeDashACIModelP.h"
  44. #import "HomeDasheManifestCellP.h"
  45. #import "HomeDasheManifestModelP.h"
  46. #import "HomeDashISFCellE.h"
  47. #import "HomeDashISFModelE.h"
  48. #import "HomeDashACEM1CellE.h"
  49. #import "HomeDashACEM1ModelE.h"
  50. #import "HomeDashACICellE.h"
  51. #import "HomeDashACIModelE.h"
  52. #import "HomeDasheManifestCellE.h"
  53. #import "HomeDasheManifestModelE.h"
  54. #import "RAUtils.h"
  55. #import "TFNavigationController.h"
  56. @implementation RAHomeSectionModel
  57. - (instancetype)init {
  58. if (self = [super init]) {
  59. }
  60. return self;
  61. }
  62. - (void)setValue:(id)value forUndefinedKey:(NSString *)key {
  63. }
  64. - (void)setOrders:(NSArray *)orders {
  65. NSMutableArray *orderArr = [NSMutableArray array];
  66. for (int i = 0; i < orders.count; i++)
  67. {
  68. NSDictionary *item = [orders objectAtIndex:i];
  69. switch (self.type) {
  70. case DashResultTypeEmpty:
  71. {
  72. ResultBaseModel *model = [ResultBaseModel new];
  73. [model setValuesForKeysWithDictionary:item];
  74. model.type=self.type;
  75. [orderArr addObject:model];
  76. }
  77. break;
  78. case DashResultTypeACIPending:
  79. {
  80. HomeDashACIModelP *model = [HomeDashACIModelP new];
  81. [model setValuesForKeysWithDictionary:item];
  82. model.type=self.type;
  83. [orderArr addObject:model];
  84. }
  85. break;
  86. case DashResultTypeeManifestPending:
  87. {
  88. HomeDasheManifestModelP *model = [HomeDasheManifestModelP new];
  89. [model setValuesForKeysWithDictionary:item];
  90. model.type=self.type;
  91. [orderArr addObject:model];
  92. }
  93. break;
  94. case DashResultTypeISFPending:
  95. {
  96. HomeDashISFModelP *model = [HomeDashISFModelP new];
  97. [model setValuesForKeysWithDictionary:item];
  98. model.type=self.type;
  99. [orderArr addObject:model];
  100. // ResultISFModel *model = [ResultISFModel new];
  101. // [model setValuesForKeysWithDictionary:item];
  102. // [orderArr addObject:model];
  103. }
  104. break;
  105. case DashResultTypeACEM1Pending:
  106. {
  107. HomeDashACEM1ModelP *model = [HomeDashACEM1ModelP new];
  108. [model setValuesForKeysWithDictionary:item];
  109. model.type=self.type;
  110. [orderArr addObject:model];
  111. }
  112. break;
  113. case DashResultTypeACIError:
  114. {
  115. HomeDashACIModelE *model = [HomeDashACIModelE new];
  116. [model setValuesForKeysWithDictionary:item];
  117. model.type=self.type;
  118. [orderArr addObject:model];
  119. }
  120. break;
  121. case DashResultTypeeManifestError:
  122. {
  123. HomeDasheManifestModelE *model = [HomeDasheManifestModelE new];
  124. [model setValuesForKeysWithDictionary:item];
  125. model.type=self.type;
  126. [orderArr addObject:model];
  127. }
  128. break;
  129. case DashResultTypeISFError:
  130. {
  131. HomeDashISFModelE *model = [HomeDashISFModelE new];
  132. [model setValuesForKeysWithDictionary:item];
  133. model.type=self.type;
  134. [orderArr addObject:model];
  135. // ResultISFModel *model = [ResultISFModel new];
  136. // [model setValuesForKeysWithDictionary:item];
  137. // [orderArr addObject:model];
  138. }
  139. break;
  140. case DashResultTypeACEM1Error:
  141. {
  142. HomeDashACEM1ModelE *model = [HomeDashACEM1ModelE new];
  143. [model setValuesForKeysWithDictionary:item];
  144. model.type=self.type;
  145. [orderArr addObject:model];
  146. }
  147. break;
  148. // case ResultTypeCustomer:
  149. // {
  150. // ResultCustomerModel *model = [ResultCustomerModel new];
  151. // [model setValuesForKeysWithDictionary:item];
  152. // [orderArr addObject:model];
  153. // }
  154. // break;
  155. // case ApexResultTypeAirBooking: {
  156. // ApexResultAirBookingModel *model = [ApexResultAirBookingModel new];
  157. // [model setValuesForKeysWithDictionary:item];
  158. // [modelsArr addObject:model];
  159. // }
  160. // break;
  161. // case ApexResultTypeBLInfo: {
  162. // ApexResultBLInfoModel *model = [ApexResultBLInfoModel new];
  163. // [model setValuesForKeysWithDictionary:item];
  164. // [modelsArr addObject:model];
  165. // }
  166. // break;
  167. //// case ApexResultTypeAirAwbInfo: {
  168. //// ApexResultAirAwbInfoModel *model = [ApexResultAirAwbInfoModel new];
  169. //// [model setValuesForKeysWithDictionary:item];
  170. //// [modelsArr addObject:model];
  171. //// }
  172. //// break;
  173. // case ApexResultTypeContainer: {
  174. // ApexResultContainerModel *model = [ApexResultContainerModel new];
  175. // [model setValuesForKeysWithDictionary:item];
  176. // [modelsArr addObject:model];
  177. // }
  178. // break;
  179. // case ApexResultTypeDocument: {
  180. // ApexResultDocumentModel *model = [ApexResultDocumentModel new];
  181. // [model setValuesForKeysWithDictionary:item];
  182. // [modelsArr addObject:model];
  183. // }
  184. // break;
  185. default:
  186. break;
  187. }
  188. }
  189. if (orders.count==0)
  190. {
  191. // NSDictionary *order = [orders objectAtIndex:i];
  192. ResultBaseModel *dashModel = [ResultBaseModel new];
  193. // [dashModel setValuesForKeysWithDictionary:order];
  194. [orderArr addObject:dashModel];
  195. }
  196. // {
  197. //
  198. //
  199. //
  200. //
  201. // NSDictionary *order = [orders objectAtIndex:i];
  202. // ResultBaseModel *dashModel = [ResultBaseModel new];
  203. // [dashModel setValuesForKeysWithDictionary:order];
  204. // [orderArr addObject:dashModel];
  205. // }
  206. _orders = orderArr;
  207. }
  208. //- (void)setBackendFlagCount:(NSInteger)backendFlagCount {
  209. // _backendFlagCount = backendFlagCount;
  210. //
  211. // if (self.delegate && [self.delegate respondsToSelector:@selector(refreshUI)]) {
  212. // [self.delegate refreshUI];
  213. // }
  214. //}
  215. - (ResultBaseModel *)dashModelForIndex:(NSInteger)index {
  216. return [self.orders objectAtIndex:index];
  217. }
  218. - (NSInteger)ordersCount {
  219. return self.orders.count;
  220. }
  221. - (NSInteger)orderModelIndexForID:(NSString *)orderID {
  222. __block NSInteger curIndex = -1;;
  223. // [self.orders enumerateObjectsUsingBlock:^(DashboardModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  224. // if ([obj.orderID isEqualToString:orderID]) {
  225. // curIndex = idx;
  226. // return ;
  227. // }
  228. // }];
  229. return curIndex;
  230. }
  231. - (BOOL)hasMoreOrder {
  232. return self.totalCount > 0;
  233. }
  234. - (ResultBaseModel *)modelForOrder:(NSString *)orderId {
  235. if (!orderId) {
  236. return nil;
  237. }
  238. __block ResultBaseModel *model = nil;
  239. // [self.orders enumerateObjectsUsingBlock:^(DashboardModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  240. // if ([obj.orderID isEqualToString:orderId]) {
  241. // model = obj;
  242. // }
  243. // }];
  244. return model;
  245. }
  246. @end
  247. #pragma mark - View Controller
  248. @interface RAHomeViewController () <RAHomeHeaderDelegate>
  249. @property (nonatomic,strong) NSMutableArray <RAHomeSectionModel *> *sectionArray;
  250. @property (nonatomic,strong) NSIndexPath *currentIndexPath;
  251. @property (nonatomic,strong) UIRefreshControl *refreshControl;
  252. @property (nonatomic,assign) NSUInteger messageCount;///<未读消息数量
  253. @end
  254. @implementation RAHomeViewController
  255. + (instancetype)viewControllerFromStoryboard {
  256. RAHomeViewController *homeVC = [[UIStoryboard storyboardWithName:@"Home" bundle:nil] instantiateViewControllerWithIdentifier:[self storyboardID]];
  257. return homeVC;
  258. }
  259. - (void)viewDidLoad {
  260. [super viewDidLoad];
  261. // Do any additional setup after loading the view.
  262. self.label_cache.text = NSLocalizedString(@"cache content", nil);
  263. [self.label_cache sizeToFit];
  264. self.label_cache.layer.borderColor=SecondaryColor.CGColor;
  265. self.label_cache.layer.borderWidth = 1.0f;
  266. self.label_cache.layer.cornerRadius = 5.0f;
  267. self.label_cache.layer.masksToBounds = YES;
  268. // [self checkActivation];
  269. [self checkPermission];
  270. [self clearNavigationbar];
  271. [self configureNavigationBar];
  272. [self configureTable];
  273. [self registNotification];
  274. // [self loadData];
  275. self.reloadFlag=true;
  276. [self checkActivation];
  277. }
  278. - (void) checkActivation
  279. {
  280. if(!RASingleton.sharedInstance.active)
  281. {
  282. NSString * msg=@"Our customer service will contact you to assist you complete the user activation.";
  283. // [RAUtils message_alert:msg title:@"Message" controller:self];
  284. [RAUtils message_box:@"Message" message:msg completion:^{
  285. }];
  286. }
  287. }
  288. - (void)viewWillAppear:(BOOL)animated {
  289. [super viewWillAppear:animated];
  290. [self.headerView reloadUI];
  291. [self clearNavigationbar];
  292. [self configureNavigationBar];
  293. }
  294. - (void)viewDidAppear:(BOOL)animated {
  295. [super viewDidAppear:animated];
  296. if (self.reloadFlag) {
  297. [self loadData];
  298. self.reloadFlag = !self.reloadFlag;
  299. }
  300. }
  301. - (void)dealloc {
  302. [[NSNotificationCenter defaultCenter] removeObserver:self];
  303. }
  304. - (void)didReceiveMemoryWarning {
  305. [super didReceiveMemoryWarning];
  306. // Dispose of any resources that can be recreated.
  307. }
  308. #pragma mark - Configure
  309. - (void)configureTable {
  310. if (@available(iOS 11, *)) {
  311. self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  312. }
  313. // else {
  314. // self.automaticallyAdjustsScrollViewInsets = NO;
  315. // }
  316. self.tableView.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
  317. self.tableView.tableFooterView = [UIView new];
  318. self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
  319. UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
  320. [refresh addTarget:self action:@selector(refreshControlValueChanged:) forControlEvents:UIControlEventValueChanged];
  321. [self.tableView addSubview:refresh];
  322. self.refreshControl = refresh;
  323. // self.homeOrderTableView.emptyDataViewManualsize = true;
  324. // empty
  325. // self.homeOrderTableView setempty
  326. // __weak typeof(self) weakSelf = self;
  327. // self.homeOrderTableView.emptyView = [RAEmptyView emptyViewWithTapBlk:^(id sender) {
  328. // [weakSelf loadData];
  329. // }];
  330. // Header
  331. self.headerView = [RAHomeHeaderView homeHeader];
  332. // self.headerView.onSetFunctions=^(void)
  333. // {
  334. // [self.tableView reloadData];
  335. // };
  336. __block typeof(self) blockself = self;
  337. self.headerView.onSetCompany=^(void)
  338. {
  339. [blockself loadData];
  340. };
  341. self.headerView.delegate = self;
  342. self.tableView.tableHeaderView = self.headerView;
  343. // self.emptyReloadview =[[UIView alloc] initWithFrame:CGRectMake(200, 200, 300, 300)];
  344. //// self.emptyReloadview.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
  345. //// [self.homeOrderTableView addSubview:self.emptyContentview];
  346. // [self.homeOrderTableView insertSubview:self.emptyReloadview atIndex:0];
  347. //
  348. // self.emptyReloadview.backgroundColor = [UIColor redColor];
  349. // self.emptyReloadview.hidden = NO;
  350. // [self.homeOrderTableView bringSubviewToFront:self.emptyReloadview];
  351. __weak typeof(self) weakSelf = self;
  352. RAEmptyView* ev = [RAEmptyView emptyViewWithTapBlk:^(id sender) {
  353. [weakSelf loadData];
  354. }];
  355. self.Reloadview = ev;
  356. [self.tableView addSubview:ev];
  357. // CGRect tvrect = self.homeOrderTableView.frame;
  358. // CGRect hvrect = self.homeOrderTableView.tableHeaderView.frame;
  359. ev.hidden = YES;
  360. // ev.translatesAutoresizingMaskIntoConstraints = false;
  361. // NSLayoutConstraint *centerYConstraint =
  362. // [NSLayoutConstraint constraintWithItem:ev
  363. // attribute:NSLayoutAttributeCenterY
  364. // relatedBy:NSLayoutRelationEqual
  365. // toItem:self.homeOrderTableView
  366. // attribute:NSLayoutAttributeCenterY
  367. // multiplier:1.0
  368. // constant:0.0];
  369. // [self.homeOrderTableView addConstraint:centerYConstraint];
  370. //
  371. ev.center = self.tableView.center;
  372. [self.tableView registerNib:[UINib nibWithNibName:@"HomeDashACICellP" bundle:nil] forCellReuseIdentifier:HomeDashACICellP.identifier];
  373. [self.tableView registerNib:[UINib nibWithNibName:@"HomeDashEmptyCell" bundle:nil] forCellReuseIdentifier:HomeDashEmptyCell.identifier];
  374. [self.tableView registerNib:[UINib nibWithNibName:@"HomeDasheManifestCellP" bundle:nil] forCellReuseIdentifier:HomeDasheManifestCellP.identifier];
  375. [self.tableView registerNib:[UINib nibWithNibName:@"HomeDashACEM1CellP" bundle:nil] forCellReuseIdentifier:HomeDashACEM1CellP.identifier];
  376. // [self.tableView registerNib:[UINib nibWithNibName:@"ResultCustomerCell" bundle:nil] forCellReuseIdentifier:ResultCustomerCell.identifier];
  377. // [self.tableView registerNib:[UINib nibWithNibName:@"ResultISFCell" bundle:nil] forCellReuseIdentifier:ResultISFCell.identifier];
  378. [self.tableView registerNib:[UINib nibWithNibName:@"HomeDashISFCellP" bundle:nil] forCellReuseIdentifier:HomeDashISFCellP.identifier];
  379. [self.tableView registerNib:[UINib nibWithNibName:@"HomeDashISFCellE" bundle:nil] forCellReuseIdentifier:HomeDashISFCellE.identifier];
  380. [self.tableView registerNib:[UINib nibWithNibName:@"HomeDashACICellE" bundle:nil] forCellReuseIdentifier:HomeDashACICellE.identifier];
  381. [self.tableView registerNib:[UINib nibWithNibName:@"HomeDasheManifestCellE" bundle:nil] forCellReuseIdentifier:HomeDasheManifestCellE.identifier];
  382. [self.tableView registerNib:[UINib nibWithNibName:@"HomeDashACEM1CellE" bundle:nil] forCellReuseIdentifier:HomeDashACEM1CellE.identifier];
  383. }
  384. - (void)updateViewConstraints
  385. {
  386. [super updateViewConstraints];
  387. //
  388. // //约束条件
  389. // //redview在垂直方向上距离边界为50
  390. // UIView* dv= self.emptyReloadview;
  391. // dv.translatesAutoresizingMaskIntoConstraints=NO;
  392. // NSLayoutConstraint *constraint1 = [NSLayoutConstraint constraintWithItem:dv attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.homeOrderTableView attribute:NSLayoutAttributeTop multiplier:1 constant:0];
  393. // NSLayoutConstraint *constraint2 = [NSLayoutConstraint constraintWithItem:dv attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.homeOrderTableView attribute:NSLayoutAttributeBottom multiplier:1 constant:0];
  394. //
  395. // NSLayoutConstraint *constraint3 = [NSLayoutConstraint constraintWithItem:dv attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.homeOrderTableView attribute:NSLayoutAttributeLeft multiplier:1 constant:0];
  396. //
  397. // NSLayoutConstraint *constraint4 = [NSLayoutConstraint constraintWithItem:dv attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.homeOrderTableView attribute:NSLayoutAttributeRight multiplier:1 constant:0];
  398. //
  399. // [self.homeOrderTableView addConstraint:constraint1];
  400. // [self.homeOrderTableView addConstraint:constraint2];
  401. // [self.homeOrderTableView addConstraint:constraint3];
  402. // [self.homeOrderTableView addConstraint:constraint4];
  403. }
  404. - (void)clearNavigationbar {
  405. self.tabBarController.navigationItem.leftBarButtonItem = nil;
  406. self.tabBarController.navigationItem.leftBarButtonItems = nil;
  407. self.tabBarController.navigationItem.titleView = nil;
  408. self.tabBarController.navigationItem.title = nil;
  409. self.tabBarController.navigationItem.rightBarButtonItem = nil;
  410. self.tabBarController.navigationItem.rightBarButtonItems = nil;
  411. }
  412. - (void)configureNavigationBar {
  413. // self.tabBarController.navigationItem.title = @"navigatiion title";
  414. UIImage *logo = [[UIImage imageNamed:@"navigate_logo"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  415. // UIImage *logo = [[UIImage imageNamed:@"apexlogo-2"] imageWithRenderingMode:UIImageRenderingModeAutomatic];
  416. UIBarButtonItem *logoItem = [[UIBarButtonItem alloc] initWithImage:logo landscapeImagePhone:logo style:UIBarButtonItemStylePlain target:nil action:nil];
  417. // logoItem.enabled = NO;
  418. self.tabBarController.navigationItem.leftBarButtonItem = logoItem;
  419. // UIBarButtonItem *welcomeItem =[[UIBarButtonItem alloc] initWithTitle:[NSString stringWithFormat:@"Welcome: %@",RASingleton.sharedInstance.firstName] menu:nil];
  420. UIBarButtonItem *functionSettingItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_setting"] style:UIBarButtonItemStylePlain target:self action:@selector(settingClick:)];
  421. // welcomeItem.enabled = NO;
  422. self.tabBarController.navigationItem.rightBarButtonItem =functionSettingItem;
  423. TFNavigationController* ranav= (TFNavigationController*)self.navigationController;
  424. [ranav setupColor];
  425. //
  426. // UIBarButtonItem *uploadListItem =[[UIBarButtonItem alloc] initWithTitle:[NSString stringWithFormat:@"Welcome: %@",RASingleton.sharedInstance.firstName] menu:nil];
  427. ////
  428. // self.tabBarController.navigationItem.rightBarButtonItem =uploadListItem;
  429. // uploadListItem= [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"action_setting"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  430. // style:UIBarButtonItemStylePlain
  431. // target:self
  432. // action:@selector(uploadListItemClick:)];
  433. //
  434. // self.navigationItem.rightBarButtonItems = @[uploadListItem];
  435. // [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationRequestUploadCount object:nil];
  436. //
  437. // self.title = [NSString stringWithFormat:@"Welcome: %@",RASingleton.sharedInstance.firstName];
  438. }
  439. - (void)settingClick:(id)sender {
  440. // self.presenter.dirty = YES;
  441. // NSString *module_name = [self.params objectForKey:@"module_name"];
  442. FunctionSettingViewController *ViewController = [[UIStoryboard storyboardWithName:@"Home" bundle:nil]
  443. instantiateViewControllerWithIdentifier:@"FunctionSettingViewController"];
  444. // ViewController.function_name = module_name;
  445. // ViewController.behavior = BEHAVIOR_RESULT;
  446. // ViewController.forNewResult = YES;
  447. // ViewController.maxDisplayCount = ResultMaxDispalyAdditionCount;
  448. // self.parent
  449. ViewController.onSave = ^(NSArray* functions){
  450. [self.headerView set_FunctionButtons:[functions mutableCopy]];
  451. // self.functionButtons =[functions mutableCopy];
  452. // [self.functionButtons addObject:@{@"name": @"...",@"icon": @"ic_more",@"type": @"panel_setting"}];
  453. [self.tableView reloadData];
  454. //+0.5);
  455. };
  456. [self.navigationController pushViewController:ViewController animated:YES];
  457. }
  458. - (void)registNotification {
  459. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:RA_NOTIFICATION_LOGOUT object:nil];
  460. // [RASingleton.sharedInstance writeLog:[NSString stringWithFormat:@"%s",__func__]];
  461. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNewOrderNotification:) name:RANotificationHandleOrder object:nil];
  462. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveReloadNotification:) name:RANotificationReloadHome object:nil];
  463. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveCheckDetailNofitication:) name:RANotificationCheckDetail object:nil];
  464. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveUploadFinishNotification:) name:RANotificationChangeUpload object:nil];
  465. }
  466. - (void)handleNotification:(NSNotification *)notification {
  467. // NSAssert(true, @"setup does not implement");
  468. // AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  469. if ([notification.name isEqualToString:RA_NOTIFICATION_LOGOUT]) {
  470. // [appDelegate Logout];
  471. // [(LoginViewController *)self.logoutbar.firstObject clear];
  472. self.reloadFlag = true;
  473. // [self.navigationController.navigationBar setHidden:true];
  474. //
  475. }
  476. }
  477. - (void)checkPermission {
  478. CLAuthorizationStatus locationAuthoriztionAstatus = [CLLocationManager authorizationStatus];
  479. [[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
  480. UNAuthorizationStatus notificationAuthorizationStatus = settings.authorizationStatus;
  481. BOOL enableLocation = locationAuthoriztionAstatus != kCLAuthorizationStatusRestricted && locationAuthoriztionAstatus != kCLAuthorizationStatusDenied;
  482. BOOL enableRemoteNotification = notificationAuthorizationStatus != UNAuthorizationStatusDenied;
  483. if (!enableLocation | !enableRemoteNotification) {
  484. NSMutableString *msg = [NSMutableString stringWithString:NSLocalizedString(@"you should open", nil)];
  485. if (!enableLocation) {
  486. [msg appendString:NSLocalizedString(@" location permissions", nil)];
  487. }
  488. if (!enableRemoteNotification) {
  489. if (!enableLocation) {
  490. [msg appendString:NSLocalizedString(@" and notification permissions", nil)];
  491. } else {
  492. [msg appendString:NSLocalizedString(@" notification permissions", nil)];
  493. }
  494. }
  495. dispatch_async(dispatch_get_main_queue(), ^{
  496. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Warning", nil) message:msg preferredStyle:UIAlertControllerStyleAlert];
  497. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Ok", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  498. NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
  499. if ([[UIApplication sharedApplication] canOpenURL:url]) {
  500. // [[UIApplication sharedApplication] openURL:url];
  501. [[UIApplication sharedApplication] openURL:url options:@{UIApplicationOpenURLOptionUniversalLinksOnly : @NO} completionHandler:nil];
  502. }
  503. }];
  504. [alertVC addAction:okAction];
  505. [self presentViewController:alertVC animated:YES completion:nil];
  506. });
  507. }
  508. }];
  509. }
  510. #pragma mark - Private
  511. //- (void)_checkOrder:(NSString *)orderId {
  512. // if (orderId) {
  513. //
  514. // for (RAHomeSectionModel *section in self.sectionArray) {
  515. //
  516. // ResultBaseModel *model = [section modelForOrder:orderId];
  517. // dispatch_async(dispatch_get_main_queue(), ^{
  518. //
  519. //// if (model && model.backendFlag) {
  520. //// if (section.backendFlagCount > 0) {
  521. //// section.backendFlagCount = section.backendFlagCount - 1;
  522. //// }
  523. //// model.backendFlag = NO;
  524. //// self.messageCount = self.messageCount - 1;
  525. //// }
  526. // });
  527. // }
  528. //
  529. // }
  530. //}
  531. - (void)_updateUploadItem:(UIBarButtonItem *)item withUploadCount:(NSUInteger)count {
  532. item.tintColor = WhiteColor;
  533. // if (item) {
  534. //
  535. // if (count > 0) {
  536. // item.tintColor = UIColorFromRGB(0x299D4D);
  537. // } else {
  538. // item.tintColor = ApexDriverWhiteColor;
  539. // }
  540. // }
  541. }
  542. #pragma mark - Action
  543. - (void)uploadListItemClick:(UIBarButtonItem *)sender {
  544. // ApexDriverUploadListVC *vc = [ApexDriverUploadListVC viewControllerFromStoryboard];
  545. // [self.navigationController pushViewController:vc animated:YES];
  546. }
  547. - (void)logoutItemClick:(UIBarButtonItem *)sender {
  548. // // show progress
  549. // RAProgressHUD *hud = [RAProgressHUD showHUDOnView:self.view];
  550. //
  551. // dispatch_async(dispatch_get_global_queue(0, 0), ^{
  552. //
  553. // [RADataProvider logout];
  554. //
  555. // dispatch_async(dispatch_get_main_queue(), ^{
  556. //
  557. // // dismiss progress
  558. // [hud dismiss];
  559. //
  560. // [RASingleton.sharedInstance logout];
  561. // [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationLogout object:nil];
  562. //
  563. // });
  564. //
  565. // });
  566. }
  567. - (void)refreshControlValueChanged:(UIRefreshControl *)refresh {
  568. self.currentIndexPath = nil;
  569. [self loadData];
  570. }
  571. #pragma mark - Setter
  572. - (void)setHeaderView:(RAHomeHeaderView *)headerView {
  573. _headerView = headerView;
  574. }
  575. - (void)setMessageCount:(NSUInteger)messageCount {
  576. _messageCount = messageCount;
  577. dispatch_async(dispatch_get_main_queue(), ^{
  578. self.headerView.existNewMessage = messageCount > 0;
  579. });
  580. }
  581. #pragma mark - Getter
  582. - (NSMutableArray *)sectionArray {
  583. if (!_sectionArray) {
  584. _sectionArray = [NSMutableArray array];
  585. }
  586. return _sectionArray;
  587. }
  588. - (RAHomeSectionModel *)modelForSection:(NSInteger)section {
  589. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  590. return sectionModel;
  591. }
  592. - (NSUInteger)orderSectionCount {
  593. return self.sectionArray.count;
  594. }
  595. - (NSUInteger)orderCountForSection:(NSInteger)section {
  596. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  597. return [sectionModel ordersCount];
  598. }
  599. - ( ResultBaseModel*)dashModelForIndexPath:(NSIndexPath *)indexPath {
  600. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:indexPath.section];
  601. return [sectionModel dashModelForIndex:indexPath.row];
  602. }
  603. - (NSString *)titleForSection:(NSInteger)section {
  604. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  605. return sectionModel.title;
  606. }
  607. - (BOOL)hasMoreOrderForSection:(NSInteger)section {
  608. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  609. return [sectionModel hasMoreOrder];
  610. }
  611. //- (NSInteger)backendCountForSection:(NSInteger)section {
  612. // RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  613. // return sectionModel.backendFlagCount;
  614. //}
  615. #pragma mark - Set/Update
  616. //
  617. //- (void)setBackendFlagCount:(NSInteger)count forSection:(NSInteger)section {
  618. // RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  619. // sectionModel.backendFlagCount = count;
  620. //}
  621. //
  622. //- (void)decreaseBackendFlagCountForSection:(NSInteger)section {
  623. // RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  624. // NSInteger count = sectionModel.backendFlagCount;
  625. // sectionModel.backendFlagCount = --count;
  626. //}
  627. - (void)setHeaderDelegate:(id<RAHomeSectionModelDelegate>)delegate forSection:(NSInteger)section {
  628. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  629. sectionModel.delegate = delegate;
  630. }
  631. #pragma mark - Data
  632. - (void)loadData {
  633. self.label_cache.hidden=true;
  634. if (self.loading) {
  635. return;
  636. }
  637. self.loading = YES;
  638. // [self.homeOrderTableView hideEmpty];
  639. self.Reloadview.hidden = true;
  640. // show progress
  641. RAProgressHUD *hud = [RAProgressHUD showHUDOnView:self.view];
  642. __weak typeof(self) weakSelf = self;
  643. [RADataProvider LoadHome:^(NSMutableDictionary *result) {
  644. NSDictionary *json = result;
  645. // DebugLog(result);
  646. // dismiss progress
  647. [hud dismiss];
  648. if (weakSelf.refreshControl.isRefreshing) {
  649. [weakSelf.refreshControl endRefreshing];
  650. }
  651. if (weakSelf) {
  652. __strong typeof(weakSelf) strongSelf = weakSelf;
  653. // header
  654. // BOOL driverAvailable = [[json objectForKey:@"driver_available"] boolValue];
  655. //// strongSelf.headerView.availabel = driverAvailable;
  656. // NSInteger newCount = [[json objectForKey:@"new_count"] integerValue];
  657. // NSInteger processingCount = [[json objectForKey:@"processing_count"] integerValue];
  658. // NSInteger finishCount = [[json objectForKey:@"finish_count"] integerValue];
  659. // NSInteger messageCount = [[json objectForKey:@"message_count"] integerValue];
  660. // strongSelf.headerView.NewOrderCount = newCount;
  661. // strongSelf.headerView.ProcessingOrderCount = processingCount;
  662. // strongSelf.headerView.FinishOrderCount = finishCount;
  663. // strongSelf.messageCount = messageCount;
  664. int result = [[json objectForKey:@"result"] intValue];
  665. if (result == RESULT_TRUE) {
  666. // int badge = [json[@"badge"] intValue];
  667. // [UIApplication sharedApplication].applicationIconBadgeNumber=badge;
  668. NSMutableDictionary* totaljson=json[@"total"];
  669. NSString* headertext = @"<center><font size=5 color=white><b>In 30 Days</b>";
  670. // NSString * htmlString = headertext;
  671. //
  672. // NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
  673. //
  674. //// UILabel * myLabel = [[UILabel alloc] initWithFrame:self.view.bounds];  myLabel.attributedText = attrStr;
  675. //
  676. // CGRect rect0=[attrStr boundingRectWithSize:self.headerView.labelTotal.frame.size options:nil context:nil];
  677. // CGRect rect1 = CGRectZero;
  678. // CGRect rect2 = CGRectZero;
  679. // CGRect rect3 = CGRectZero;
  680. // CGRect rect4 = CGRectZero;
  681. // CGRect rect5 = CGRectZero;
  682. if(totaljson[@"acem1"] !=nil)
  683. {
  684. NSString* acem1=[NSString stringWithFormat:@" ACE-M1:&nbsp;<font color=yellow>%d</font>",[totaljson[@"acem1"] intValue]];
  685. headertext=[headertext stringByAppendingString:acem1];
  686. // NSString * htmlString = acem1;
  687. //
  688. // NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
  689. //
  690. // // UILabel * myLabel = [[UILabel alloc] initWithFrame:self.view.bounds];  myLabel.attributedText = attrStr;
  691. //
  692. // rect1=[attrStr boundingRectWithSize:self.headerView.labelTotal.frame.size options:nil context:nil];
  693. }
  694. //
  695. if(totaljson[@"isf"]!=nil)
  696. {
  697. NSString* isf=[NSString stringWithFormat:@" ISF:&nbsp;<font color=yellow>%d</font>",[totaljson[@"isf"] intValue]];
  698. headertext=[headertext stringByAppendingString:isf];
  699. // NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
  700. //
  701. // // UILabel * myLabel = [[UILabel alloc] initWithFrame:self.view.bounds];  myLabel.attributedText = attrStr;
  702. //
  703. // rect2=[attrStr boundingRectWithSize:self.headerView.labelTotal.frame.size options:nil context:nil];
  704. }
  705. //
  706. if(totaljson[@"aci"]!=nil)
  707. {
  708. NSString* aci=[NSString stringWithFormat:@" ACI:&nbsp;<font color=yellow>%d</font>",[totaljson[@"aci"] intValue]];
  709. headertext=[headertext stringByAppendingString:aci];
  710. // NSString * htmlString = acem1;
  711. //
  712. // NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
  713. //
  714. // // UILabel * myLabel = [[UILabel alloc] initWithFrame:self.view.bounds];  myLabel.attributedText = attrStr;
  715. //
  716. // rect3=[attrStr boundingRectWithSize:self.headerView.labelTotal.frame.size options:nil context:nil];
  717. }
  718. //
  719. if(totaljson[@"emanifest"] !=nil)
  720. {
  721. NSString* eman=[NSString stringWithFormat:@" eManifest:&nbsp;<font color=yellow>%d</font>",[totaljson[@"emanifest"] intValue]];
  722. headertext=[headertext stringByAppendingString:eman];
  723. // NSString * htmlString = acem1;
  724. //
  725. // NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
  726. //
  727. // // UILabel * myLabel = [[UILabel alloc] initWithFrame:self.view.bounds];  myLabel.attributedText = attrStr;
  728. //
  729. // rect4=[attrStr boundingRectWithSize:self.headerView.labelTotal.frame.size options:nil context:nil];
  730. }
  731. headertext=[headertext stringByAppendingString:@"</font></center>"];
  732. // self.logLabel.text = [log stringByAppendingString:@"\n"];
  733. //
  734. // CGSize bestsize=[self.logLabel sizeThatFits:self.logLabel.frame.size];
  735. // NSString * htmlString1= [NSString stringWithFormat:@"<center><font size=5 color=white><b>This Month</b> ACE-M1:&nbsp;<font color=yellow>%d</font> ISF:&nbsp;<font color=yellow>%d</font> ACI:&nbsp;<font color=yellow>%d</font> eManifest:&nbsp;<font color=yellow>%d</font></font></center>",[totaljson[@"acem1"] intValue],[totaljson[@"isf"] intValue],[totaljson[@"aci"] intValue],[totaljson[@"emanifest"] intValue]];
  736. NSAttributedString * attrStr1 = [[NSAttributedString alloc]
  737. initWithData:[headertext dataUsingEncoding:NSUnicodeStringEncoding]
  738. options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }
  739. documentAttributes:nil
  740. error:nil];
  741. self.headerView.labelTotal.attributedText=attrStr1;
  742. BOOL requiredLocation = [[json objectForKey:@"requiredLocation"] boolValue];
  743. [RASingleton sharedInstance].requiredBackgroundLocation = requiredLocation;
  744. NSArray *sectionArray = [json objectForKey:@"sections"];
  745. NSMutableArray *tmpSectionArr = [NSMutableArray array];
  746. strongSelf.currentIndexPath = nil;
  747. for (int i = 0; i < sectionArray.count; i++) {
  748. NSDictionary *section = [sectionArray objectAtIndex:i];
  749. RAHomeSectionModel *sectionModel = [RAHomeSectionModel new];
  750. sectionModel.section = i;
  751. sectionModel.type = [section[@"type"] intValue];
  752. [sectionModel setValuesForKeysWithDictionary:section];
  753. [tmpSectionArr addObject:sectionModel];
  754. if (strongSelf.currentOrderID.length > 0) {
  755. NSInteger idx = [sectionModel orderModelIndexForID:self.currentOrderID];
  756. if (idx > -1) {
  757. strongSelf.currentIndexPath = [NSIndexPath indexPathForRow:idx inSection:i];
  758. }
  759. }
  760. }
  761. strongSelf.sectionArray = tmpSectionArr;
  762. [strongSelf.tableView reloadData];
  763. if (strongSelf.currentIndexPath) {
  764. // [strongSelf.homeOrderTableView scrollToRowAtIndexPath:self.currentIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
  765. [strongSelf.tableView selectRowAtIndexPath:strongSelf.currentIndexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
  766. } else {
  767. }
  768. if([json[@"iscache"] boolValue]==true)
  769. {
  770. self.label_cache.hidden=false;
  771. }
  772. } else {
  773. [strongSelf.sectionArray removeAllObjects];
  774. strongSelf.tableView.contentOffset = CGPointZero;
  775. [strongSelf.tableView reloadData];
  776. // process error
  777. NSString *msg = [json objectForKey:@"err_msg"];
  778. // [strongSelf showAlert:msg];
  779. [strongSelf showAlertTilte:NSLocalizedString(@"Warning", nil) message:msg];
  780. }
  781. }
  782. weakSelf.loading = NO;
  783. if (weakSelf.orderSectionCount == 0) {
  784. // [weakSelf.homeOrderTableView showEmpty];
  785. self.Reloadview.hidden = false;
  786. } else {
  787. // [weakSelf.homeOrderTableView hideEmpty];
  788. self.Reloadview.hidden = true;
  789. }
  790. }];
  791. }
  792. //
  793. //- (void)updateDriverAvailable:(BOOL)available {
  794. //
  795. // // show progress
  796. // RAProgressHUD *hud = [RAProgressHUD showHUDOnView:self.view];
  797. //
  798. // __weak typeof(self) weakSelf = self;
  799. // dispatch_async(dispatch_get_global_queue(0, 0), ^{
  800. //
  801. // NSDictionary *json = [RADataProvider updateDriverAvailable:available];
  802. // dispatch_async(dispatch_get_main_queue(), ^{
  803. //
  804. // [hud dismiss];
  805. //
  806. // int result = [[json objectForKey:@"result"] intValue];
  807. // if (result == RESULT_TRUE) {
  808. //
  809. // weakSelf.headerView.availabel = available;
  810. //
  811. // } else {
  812. //
  813. // NSString *msg = [json objectForKey:@"err_msg"];
  814. // [weakSelf showAlertTilte:NSLocalizedString(@"Warning", nil) message:msg];
  815. // }
  816. // });
  817. //
  818. // });
  819. //
  820. //}
  821. #pragma mark - Controller Action
  822. - (void)pushDetailViewControllerForModel:(ResultBaseModel *)model {
  823. // [self pushDetailViewControllerForOrderID:model.orderID type:model.status type2:model.order_type2 statusNo:model.status_no];
  824. }
  825. //- (void)pushDetailViewControllerForOrderID:(NSString *)orderID type:(NSInteger)type type2:(NSString *)type2 statusNo:(NSString *)statusNo {
  826. //
  827. // if (!orderID) {
  828. // return;
  829. // }
  830. // RAOrderDetailViewController *detailVC = [RAOrderDetailViewController viewControllerFromStoryboard];
  831. // detailVC.orderID = orderID;
  832. // detailVC.orderType = type;
  833. // detailVC.orderType2 = type2;
  834. // detailVC.status_no = statusNo;
  835. // [self.navigationController pushViewController:detailVC animated:YES];
  836. //}
  837. //- (void)showMoreControllerWithTitle:(NSString *)title Type:(RAOrderStatus)type {
  838. //
  839. //// RAHomeMoreViewController *homeMoreVC = [RAHomeMoreViewController viewControllerFromStoryboard];
  840. //// homeMoreVC.title = title;
  841. //// homeMoreVC.type = type;
  842. ////
  843. //// __weak typeof(self) weakSelf = self;
  844. //// homeMoreVC.backendFlagOrderClickBlk = ^{
  845. //// weakSelf.reloadFlag = YES;
  846. //// };
  847. ////
  848. //// [self.navigationController pushViewController:homeMoreVC animated:YES];
  849. //}
  850. - (void)showMoreOrderForSection:(NSInteger)section {
  851. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  852. if(sectionModel.more ==nil)
  853. return;
  854. NSMutableDictionary* params = [[sectionModel.more valueForKey:@"param"] mutableCopy];
  855. [params setValue:[sectionModel.more valueForKey:@"sub_type"] forKey:@"sub_type"];
  856. // resultViewController.params =params;
  857. // [self.navigationController pushViewController:resultViewController animated:YES];
  858. // AMResultViewController *resultVC = [[AMResultViewController alloc] initWithNibName:@"Result" bundle:nil];
  859. // resultVC.params = params;
  860. // [self.navigationController pushViewController:resultVC animated:YES];
  861. ResultViewController *vc = [ResultViewController resultViewController:params];
  862. [self.navigationController pushViewController:vc animated:YES];
  863. // [self showMoreControllerWithTitle:sectionModel.title Type:sectionModel.type];
  864. }
  865. #pragma mark - Nofitication Selector
  866. //
  867. //- (void)receiveNewOrderNotification:(NSNotification *)notification {
  868. // [self loadData];
  869. //}
  870. //
  871. //- (void)receiveReloadNotification:(NSNotification *)notification {
  872. // [self loadData];
  873. //}
  874. //
  875. //- (void)receiveCheckDetailNofitication:(NSNotification *)notification {
  876. ////
  877. //// NSDictionary *userInfo = [notification userInfo];
  878. //// if (userInfo) {
  879. //// NSString *orderId = [userInfo objectForKey:@"order_id"];
  880. //// if (orderId) {
  881. //// [self _checkOrder:orderId];
  882. //// }
  883. //// }
  884. ////
  885. //}
  886. - (void)receiveUploadFinishNotification:(NSNotification *)notification {
  887. NSUInteger count = [notification.userInfo[@"upload_count"] integerValue];
  888. UIBarButtonItem *item = self.navigationItem.rightBarButtonItem;
  889. [self _updateUploadItem:item withUploadCount:count];
  890. }
  891. #pragma mark - Header Delegate
  892. - (void)signoutClick:(UIButton *)sender {
  893. [self logoutItemClick:nil];
  894. }
  895. //
  896. //- (void)settingClick:(UIButton *)sender {
  897. //// dispatch_async(dispatch_get_main_queue(), ^{
  898. //// RASettingViewController *settingVC = [RASettingViewController viewControllerFromStoryboard];
  899. //// [self.navigationController pushViewController:settingVC animated:YES];
  900. //// });
  901. //}
  902. //
  903. //- (void)availableClick:(UIButton *)sender {
  904. //
  905. // NSString *msg = [NSString localizedStringWithFormat:NSLocalizedString(@"are you sure to change status to %@", nil),self.headerView.availabel ? NSLocalizedString(@"Unavailable", nil) : NSLocalizedString(@"Available", nil)];
  906. // UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Warning", nil) message:msg preferredStyle:UIAlertControllerStyleAlert];
  907. //
  908. // UIAlertAction *yesAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"YES", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  909. // [self updateDriverAvailable:!self.headerView.availabel];
  910. // }];
  911. //
  912. // UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  913. //
  914. // }];
  915. //
  916. //
  917. // [alertVC addAction:cancelAction];
  918. // [alertVC addAction:yesAction];
  919. //
  920. // [self presentViewController:alertVC animated:YES completion:nil];
  921. //}
  922. //- (void)messageClick:(UIButton *)sender {
  923. // RAMessageViewController *messageVC = [RAMessageViewController viewControllerFromStoryboard];
  924. // [self.navigationController pushViewController:messageVC animated:YES];
  925. //}
  926. //- (void)newOrderClick:(id)sender {
  927. //
  928. //// [self showMoreControllerWithTitle:NSLocalizedString(@"New Order", nil) Type:RAOrderStatusNew];
  929. //}
  930. //
  931. //- (void)processingOrderClick:(id)sender {
  932. //
  933. //// [self showMoreControllerWithTitle:NSLocalizedString(@"Processing Order", nil) Type:RAOrderStatusProcessing];
  934. //}
  935. //
  936. //- (void)finishedOrderClick:(id)sender {
  937. //
  938. //// [self showMoreControllerWithTitle:NSLocalizedString(@"Finished Order", nil) Type:RAOrderStatusFinish];
  939. //}
  940. @end