RAHomeViewController.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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. @implementation RAHomeSectionModel
  21. - (instancetype)init {
  22. if (self = [super init]) {
  23. }
  24. return self;
  25. }
  26. - (void)setOrders:(NSArray *)orders {
  27. NSMutableArray *orderArr = [NSMutableArray array];
  28. for (int i = 0; i < orders.count; i++) {
  29. NSDictionary *order = [orders objectAtIndex:i];
  30. RAHomeOrderModel *orderModel = [RAHomeOrderModel new];
  31. [orderModel setValuesForKeysWithDictionary:order];
  32. [orderArr addObject:orderModel];
  33. }
  34. _orders = orderArr;
  35. }
  36. - (void)setBackendFlagCount:(NSInteger)backendFlagCount {
  37. _backendFlagCount = backendFlagCount;
  38. if (self.delegate && [self.delegate respondsToSelector:@selector(refreshUI)]) {
  39. [self.delegate refreshUI];
  40. }
  41. }
  42. - (RAHomeOrderModel *)orderModelForIndex:(NSInteger)index {
  43. return [self.orders objectAtIndex:index];
  44. }
  45. - (NSInteger)ordersCount {
  46. return self.orders.count;
  47. }
  48. - (NSInteger)orderModelIndexForID:(NSString *)orderID {
  49. __block NSInteger curIndex = -1;;
  50. [self.orders enumerateObjectsUsingBlock:^(RAHomeOrderModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  51. if ([obj.orderID isEqualToString:orderID]) {
  52. curIndex = idx;
  53. return ;
  54. }
  55. }];
  56. return curIndex;
  57. }
  58. - (BOOL)hasMoreOrder {
  59. return self.totalCount > self.ordersCount;
  60. }
  61. - (RAHomeOrderModel *)modelForOrder:(NSString *)orderId {
  62. if (!orderId) {
  63. return nil;
  64. }
  65. __block RAHomeOrderModel *model = nil;
  66. [self.orders enumerateObjectsUsingBlock:^(RAHomeOrderModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  67. if ([obj.orderID isEqualToString:orderId]) {
  68. model = obj;
  69. }
  70. }];
  71. return model;
  72. }
  73. @end
  74. #pragma mark - View Controller
  75. @interface RAHomeViewController () <RAHomeHeaderDelegate>
  76. @property (nonatomic,strong) NSMutableArray <RAHomeSectionModel *> *sectionArray;
  77. @property (nonatomic,strong) NSIndexPath *currentIndexPath;
  78. @property (nonatomic,strong) UIRefreshControl *refreshControl;
  79. @property (nonatomic,assign) NSUInteger messageCount;///<未读消息数量
  80. @end
  81. @implementation RAHomeViewController
  82. + (instancetype)viewControllerFromStoryboard {
  83. RAHomeViewController *homeVC = [[UIStoryboard storyboardWithName:@"Home" bundle:nil] instantiateViewControllerWithIdentifier:[self storyboardID]];
  84. return homeVC;
  85. }
  86. - (void)viewDidLoad {
  87. [super viewDidLoad];
  88. // Do any additional setup after loading the view.
  89. [self checkPermission];
  90. [self configureNavigationBar];
  91. [self configureTable];
  92. [self registNotification];
  93. [self loadData];
  94. }
  95. - (void)viewWillAppear:(BOOL)animated {
  96. [super viewWillAppear:animated];
  97. }
  98. - (void)viewDidAppear:(BOOL)animated {
  99. [super viewDidAppear:animated];
  100. if (self.reloadFlag) {
  101. [self loadData];
  102. self.reloadFlag = !self.reloadFlag;
  103. }
  104. }
  105. - (void)dealloc {
  106. [[NSNotificationCenter defaultCenter] removeObserver:self];
  107. }
  108. - (void)didReceiveMemoryWarning {
  109. [super didReceiveMemoryWarning];
  110. // Dispose of any resources that can be recreated.
  111. }
  112. #pragma mark - Configure
  113. - (void)configureTable {
  114. if (@available(iOS 11, *)) {
  115. self.homeOrderTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  116. } else {
  117. self.automaticallyAdjustsScrollViewInsets = NO;
  118. }
  119. self.homeOrderTableView.backgroundColor = [UIColor colorWithRed:0.9 green:0.9 blue:0.9 alpha:1];
  120. self.homeOrderTableView.tableFooterView = [UIView new];
  121. self.homeOrderTableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
  122. UIRefreshControl *refresh = [[UIRefreshControl alloc] init];
  123. [refresh addTarget:self action:@selector(refreshControlValueChanged:) forControlEvents:UIControlEventValueChanged];
  124. [self.homeOrderTableView addSubview:refresh];
  125. self.refreshControl = refresh;
  126. // empty
  127. __weak typeof(self) weakSelf = self;
  128. self.homeOrderTableView.emptyView = [RAEmptyView emptyViewWithTapBlk:^(id sender) {
  129. [weakSelf loadData];
  130. }];
  131. // Header
  132. self.headerView = [RAHomeHeaderView homeHeader];
  133. self.headerView.delegate = self;
  134. self.homeOrderTableView.tableHeaderView = self.headerView;
  135. }
  136. - (void)configureNavigationBar {
  137. UIImage *logo = [[UIImage imageNamed:@"apex_logo"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
  138. // UIImage *logo = [[UIImage imageNamed:@"apexlogo-2"] imageWithRenderingMode:UIImageRenderingModeAutomatic];
  139. UIBarButtonItem *logoItem = [[UIBarButtonItem alloc] initWithImage:logo landscapeImagePhone:logo style:UIBarButtonItemStylePlain target:nil action:nil];
  140. // logoItem.enabled = NO;
  141. self.navigationItem.leftBarButtonItem = logoItem;
  142. UIBarButtonItem *uploadListItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"upload_list"] imageWithRenderingMode:UIImageRenderingModeAutomatic]
  143. style:UIBarButtonItemStylePlain
  144. target:self
  145. action:@selector(uploadListItemClick:)];
  146. self.navigationItem.rightBarButtonItems = @[uploadListItem];
  147. // UIBarButtonItem *logoutItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"logout"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
  148. // style:UIBarButtonItemStylePlain
  149. // target:self
  150. // action:@selector(logoutItemClick:)];
  151. //
  152. // self.navigationItem.rightBarButtonItems = @[logoutItem,uploadListItem];
  153. self.title = [NSString stringWithFormat:@"%@ %@",RASingleton.sharedInstance.user,RASingleton.sharedInstance.firstName];
  154. }
  155. - (void)registNotification {
  156. // [RASingleton.sharedInstance writeLog:[NSString stringWithFormat:@"%s",__func__]];
  157. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNewOrderNotification:) name:RANotificationHandleOrder object:nil];
  158. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveReloadNotification:) name:RANotificationReloadHome object:nil];
  159. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveCheckDetailNofitication:) name:RANotificationCheckDetail object:nil];
  160. }
  161. - (void)checkPermission {
  162. CLAuthorizationStatus locationAuthoriztionAstatus = [CLLocationManager authorizationStatus];
  163. [[UNUserNotificationCenter currentNotificationCenter] getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
  164. UNAuthorizationStatus notificationAuthorizationStatus = settings.authorizationStatus;
  165. BOOL enableLocation = locationAuthoriztionAstatus != kCLAuthorizationStatusRestricted && locationAuthoriztionAstatus != kCLAuthorizationStatusDenied;
  166. BOOL enableRemoteNotification = notificationAuthorizationStatus != UNAuthorizationStatusDenied;
  167. if (!enableLocation | !enableRemoteNotification) {
  168. NSMutableString *msg = [NSMutableString stringWithString:NSLocalizedString(@"you should open", nil)];
  169. if (!enableLocation) {
  170. [msg appendString:NSLocalizedString(@" location permissions", nil)];
  171. }
  172. if (!enableRemoteNotification) {
  173. if (!enableLocation) {
  174. [msg appendString:NSLocalizedString(@" and notification permissions", nil)];
  175. } else {
  176. [msg appendString:NSLocalizedString(@" notification permissions", nil)];
  177. }
  178. }
  179. dispatch_async(dispatch_get_main_queue(), ^{
  180. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Warning", nil) message:msg preferredStyle:UIAlertControllerStyleAlert];
  181. UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Ok", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  182. NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
  183. if ([[UIApplication sharedApplication] canOpenURL:url]) {
  184. [[UIApplication sharedApplication] openURL:url];
  185. }
  186. }];
  187. [alertVC addAction:okAction];
  188. [self presentViewController:alertVC animated:YES completion:nil];
  189. });
  190. }
  191. }];
  192. }
  193. #pragma mark - Private
  194. - (void)_checkOrder:(NSString *)orderId {
  195. if (orderId) {
  196. for (RAHomeSectionModel *section in self.sectionArray) {
  197. RAHomeOrderModel *model = [section modelForOrder:orderId];
  198. dispatch_async(dispatch_get_main_queue(), ^{
  199. if (model && model.backendFlag) {
  200. if (section.backendFlagCount > 0) {
  201. section.backendFlagCount = section.backendFlagCount - 1;
  202. }
  203. model.backendFlag = NO;
  204. self.messageCount = self.messageCount - 1;
  205. }
  206. });
  207. }
  208. }
  209. }
  210. #pragma mark - Action
  211. - (void)uploadListItemClick:(UIBarButtonItem *)sender {
  212. ApexDriverUploadListVC *vc = [ApexDriverUploadListVC viewControllerFromStoryboard];
  213. [self.navigationController pushViewController:vc animated:YES];
  214. }
  215. - (void)logoutItemClick:(UIBarButtonItem *)sender {
  216. // show progress
  217. RAProgressHUD *hud = [RAProgressHUD showHUDOnView:self.view];
  218. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  219. [RADataProvider logout];
  220. dispatch_async(dispatch_get_main_queue(), ^{
  221. // dismiss progress
  222. [hud dismiss];
  223. [RASingleton.sharedInstance logout];
  224. [[NSNotificationCenter defaultCenter] postNotificationName:RANotificationLogout object:nil];
  225. });
  226. });
  227. }
  228. - (void)refreshControlValueChanged:(UIRefreshControl *)refresh {
  229. self.currentIndexPath = nil;
  230. [self loadData];
  231. }
  232. #pragma mark - Setter
  233. - (void)setHeaderView:(RAHomeHeaderView *)headerView {
  234. _headerView = headerView;
  235. }
  236. - (void)setMessageCount:(NSUInteger)messageCount {
  237. _messageCount = messageCount;
  238. dispatch_async(dispatch_get_main_queue(), ^{
  239. self.headerView.existNewMessage = messageCount > 0;
  240. });
  241. }
  242. #pragma mark - Getter
  243. - (NSMutableArray *)sectionArray {
  244. if (!_sectionArray) {
  245. _sectionArray = [NSMutableArray array];
  246. }
  247. return _sectionArray;
  248. }
  249. - (RAHomeSectionModel *)modelForSection:(NSInteger)section {
  250. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  251. return sectionModel;
  252. }
  253. - (NSUInteger)orderSectionCount {
  254. return self.sectionArray.count;
  255. }
  256. - (NSUInteger)orderCountForSection:(NSInteger)section {
  257. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  258. return [sectionModel ordersCount];
  259. }
  260. - (RAHomeOrderModel *)orderModelForIndexPath:(NSIndexPath *)indexPath {
  261. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:indexPath.section];
  262. return [sectionModel orderModelForIndex:indexPath.row];
  263. }
  264. - (NSString *)titleForSection:(NSInteger)section {
  265. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  266. return sectionModel.title;
  267. }
  268. - (BOOL)hasMoreOrderForSection:(NSInteger)section {
  269. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  270. return [sectionModel hasMoreOrder];
  271. }
  272. - (NSInteger)backendCountForSection:(NSInteger)section {
  273. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  274. return sectionModel.backendFlagCount;
  275. }
  276. #pragma mark - Set/Update
  277. - (void)setBackendFlagCount:(NSInteger)count forSection:(NSInteger)section {
  278. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  279. sectionModel.backendFlagCount = count;
  280. }
  281. - (void)decreaseBackendFlagCountForSection:(NSInteger)section {
  282. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  283. NSInteger count = sectionModel.backendFlagCount;
  284. sectionModel.backendFlagCount = --count;
  285. }
  286. - (void)setHeaderDelegate:(id<RAHomeSectionModelDelegate>)delegate forSection:(NSInteger)section {
  287. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  288. sectionModel.delegate = delegate;
  289. }
  290. #pragma mark - Data
  291. - (void)loadData {
  292. if (self.loading) {
  293. return;
  294. }
  295. self.loading = YES;
  296. [self.homeOrderTableView hideEmpty];
  297. // show progress
  298. RAProgressHUD *hud = [RAProgressHUD showHUDOnView:self.view];
  299. __weak typeof(self) weakSelf = self;
  300. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  301. NSDictionary *json = [RADataProvider requestOrderList];
  302. dispatch_async(dispatch_get_main_queue(), ^{
  303. // dismiss progress
  304. [hud dismiss];
  305. if (weakSelf.refreshControl.isRefreshing) {
  306. [weakSelf.refreshControl endRefreshing];
  307. }
  308. if (weakSelf) {
  309. __strong typeof(weakSelf) strongSelf = weakSelf;
  310. // header
  311. BOOL driverAvailable = [[json objectForKey:@"driver_available"] boolValue];
  312. strongSelf.headerView.availabel = driverAvailable;
  313. NSInteger newCount = [[json objectForKey:@"new_count"] integerValue];
  314. NSInteger processingCount = [[json objectForKey:@"processing_count"] integerValue];
  315. NSInteger finishCount = [[json objectForKey:@"finish_count"] integerValue];
  316. NSInteger messageCount = [[json objectForKey:@"message_count"] integerValue];
  317. strongSelf.headerView.NewOrderCount = newCount;
  318. strongSelf.headerView.ProcessingOrderCount = processingCount;
  319. strongSelf.headerView.FinishOrderCount = finishCount;
  320. strongSelf.messageCount = messageCount;
  321. int result = [[json objectForKey:@"result"] intValue];
  322. if (result == RESULT_TRUE) {
  323. BOOL requiredLocation = [[json objectForKey:@"requiredLocation"] boolValue];
  324. [RASingleton sharedInstance].requiredLocation = requiredLocation;
  325. NSArray *sectionArray = [json objectForKey:@"sections"];
  326. NSMutableArray *tmpSectionArr = [NSMutableArray array];
  327. strongSelf.currentIndexPath = nil;
  328. for (int i = 0; i < sectionArray.count; i++) {
  329. NSDictionary *section = [sectionArray objectAtIndex:i];
  330. RAHomeSectionModel *sectionModel = [RAHomeSectionModel new];
  331. sectionModel.section = i;
  332. [sectionModel setValuesForKeysWithDictionary:section];
  333. [tmpSectionArr addObject:sectionModel];
  334. if (strongSelf.currentOrderID.length > 0) {
  335. NSInteger idx = [sectionModel orderModelIndexForID:self.currentOrderID];
  336. if (idx > -1) {
  337. strongSelf.currentIndexPath = [NSIndexPath indexPathForRow:idx inSection:i];
  338. }
  339. }
  340. }
  341. strongSelf.sectionArray = tmpSectionArr;
  342. [strongSelf.homeOrderTableView reloadData];
  343. if (strongSelf.currentIndexPath) {
  344. // [strongSelf.homeOrderTableView scrollToRowAtIndexPath:self.currentIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
  345. [strongSelf.homeOrderTableView selectRowAtIndexPath:strongSelf.currentIndexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
  346. } else {
  347. }
  348. } else {
  349. [strongSelf.sectionArray removeAllObjects];
  350. strongSelf.homeOrderTableView.contentOffset = CGPointZero;
  351. [strongSelf.homeOrderTableView reloadData];
  352. // process error
  353. NSString *msg = [json objectForKey:@"err_msg"];
  354. // [strongSelf showAlert:msg];
  355. [strongSelf showAlertTilte:NSLocalizedString(@"Warning", nil) message:msg];
  356. }
  357. }
  358. weakSelf.loading = NO;
  359. if (weakSelf.orderSectionCount == 0) {
  360. [weakSelf.homeOrderTableView showEmpty];
  361. } else {
  362. [weakSelf.homeOrderTableView hideEmpty];
  363. }
  364. });
  365. });
  366. }
  367. - (void)updateDriverAvailable:(BOOL)available {
  368. // show progress
  369. RAProgressHUD *hud = [RAProgressHUD showHUDOnView:self.view];
  370. __weak typeof(self) weakSelf = self;
  371. dispatch_async(dispatch_get_global_queue(0, 0), ^{
  372. NSDictionary *json = [RADataProvider updateDriverAvailable:available];
  373. dispatch_async(dispatch_get_main_queue(), ^{
  374. [hud dismiss];
  375. int result = [[json objectForKey:@"result"] intValue];
  376. if (result == RESULT_TRUE) {
  377. weakSelf.headerView.availabel = available;
  378. } else {
  379. NSString *msg = [json objectForKey:@"err_msg"];
  380. [weakSelf showAlertTilte:NSLocalizedString(@"Warning", nil) message:msg];
  381. }
  382. });
  383. });
  384. }
  385. #pragma mark - Controller Action
  386. - (void)pushDetailViewControllerForModel:(RAHomeOrderModel *)model {
  387. [self pushDetailViewControllerForOrderID:model.orderID type:model.status type2:model.order_type2 statusNo:model.status_no];
  388. }
  389. - (void)pushDetailViewControllerForOrderID:(NSString *)orderID type:(NSInteger)type type2:(NSString *)type2 statusNo:(NSString *)statusNo {
  390. if (!orderID) {
  391. return;
  392. }
  393. RAOrderDetailViewController *detailVC = [RAOrderDetailViewController viewControllerFromStoryboard];
  394. detailVC.orderID = orderID;
  395. detailVC.orderType = type;
  396. detailVC.orderType2 = type2;
  397. detailVC.status_no = statusNo;
  398. [self.navigationController pushViewController:detailVC animated:YES];
  399. }
  400. - (void)showMoreControllerWithTitle:(NSString *)title Type:(RAOrderStatus)type {
  401. RAHomeMoreViewController *homeMoreVC = [RAHomeMoreViewController viewControllerFromStoryboard];
  402. homeMoreVC.title = title;
  403. homeMoreVC.type = type;
  404. __weak typeof(self) weakSelf = self;
  405. homeMoreVC.backendFlagOrderClickBlk = ^{
  406. weakSelf.reloadFlag = YES;
  407. };
  408. [self.navigationController pushViewController:homeMoreVC animated:YES];
  409. }
  410. - (void)showMoreOrderForSection:(NSInteger)section {
  411. RAHomeSectionModel *sectionModel = [self.sectionArray objectAtIndex:section];
  412. [self showMoreControllerWithTitle:sectionModel.title Type:sectionModel.type];
  413. }
  414. #pragma mark - Nofitication Selector
  415. - (void)receiveNewOrderNotification:(NSNotification *)notification {
  416. [self loadData];
  417. }
  418. - (void)receiveReloadNotification:(NSNotification *)notification {
  419. [self loadData];
  420. }
  421. - (void)receiveCheckDetailNofitication:(NSNotification *)notification {
  422. NSDictionary *userInfo = [notification userInfo];
  423. if (userInfo) {
  424. NSString *orderId = [userInfo objectForKey:@"order_id"];
  425. if (orderId) {
  426. [self _checkOrder:orderId];
  427. }
  428. }
  429. }
  430. #pragma mark - Header Delegate
  431. - (void)signoutClick:(UIButton *)sender {
  432. [self logoutItemClick:nil];
  433. }
  434. - (void)settingClick:(UIButton *)sender {
  435. dispatch_async(dispatch_get_main_queue(), ^{
  436. RASettingViewController *settingVC = [RASettingViewController viewControllerFromStoryboard];
  437. [self.navigationController pushViewController:settingVC animated:YES];
  438. });
  439. }
  440. - (void)availableClick:(UIButton *)sender {
  441. NSString *msg = [NSString localizedStringWithFormat:NSLocalizedString(@"are you sure to change status to %@", nil),self.headerView.availabel ? NSLocalizedString(@"Unavailable", nil) : NSLocalizedString(@"Available", nil)];
  442. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Warning", nil) message:msg preferredStyle:UIAlertControllerStyleAlert];
  443. UIAlertAction *yesAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"YES", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  444. [self updateDriverAvailable:!self.headerView.availabel];
  445. }];
  446. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  447. }];
  448. [alertVC addAction:cancelAction];
  449. [alertVC addAction:yesAction];
  450. [self presentViewController:alertVC animated:YES completion:nil];
  451. }
  452. - (void)messageClick:(UIButton *)sender {
  453. RAMessageViewController *messageVC = [RAMessageViewController viewControllerFromStoryboard];
  454. [self.navigationController pushViewController:messageVC animated:YES];
  455. }
  456. - (void)newOrderClick:(id)sender {
  457. [self showMoreControllerWithTitle:NSLocalizedString(@"New Order", nil) Type:RAOrderStatusNew];
  458. }
  459. - (void)processingOrderClick:(id)sender {
  460. [self showMoreControllerWithTitle:NSLocalizedString(@"Processing Order", nil) Type:RAOrderStatusProcessing];
  461. }
  462. - (void)finishedOrderClick:(id)sender {
  463. [self showMoreControllerWithTitle:NSLocalizedString(@"Finished Order", nil) Type:RAOrderStatusFinish];
  464. }
  465. @end