RANavigationController.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // RANavigationController.m
  3. // Apex And Drivers
  4. //
  5. // Created by Jack on 2018/8/31.
  6. // Copyright © 2018年 USAI. All rights reserved.
  7. //
  8. #import "RANavigationController.h"
  9. #import "RAOrderDetailViewController.h"
  10. @interface RANavigationController ()
  11. @end
  12. @implementation RANavigationController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. // Do any additional setup after loading the view.
  16. [self _configAppearance];
  17. [self registNotification];
  18. }
  19. - (void)dealloc {
  20. [[NSNotificationCenter defaultCenter] removeObserver:self];
  21. }
  22. - (void)didReceiveMemoryWarning {
  23. [super didReceiveMemoryWarning];
  24. // Dispose of any resources that can be recreated.
  25. }
  26. - (UIStatusBarStyle)preferredStatusBarStyle {
  27. return UIStatusBarStyleLightContent;
  28. }
  29. - (void)_configAppearance {
  30. [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:ApexDriverWhiteColor}]; // Title Color
  31. [self.navigationBar setTintColor:ApexDriverWhiteColor]; // BarItem颜色
  32. self.navigationBar.barTintColor = ApexDriverOrangeColor; // 背景色
  33. self.navigationBar.translucent = NO;
  34. self.navigationBar.shadowImage = [UIImage new]; // 去除Bar黑色分割线
  35. }
  36. - (void)registNotification {
  37. // [RASingleton.sharedInstance writeLog:[NSString stringWithFormat:@"%s",__func__]];
  38. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveHandleOrderNotification:) name:RANotificationHandleOrder object:nil];
  39. }
  40. - (void)receiveHandleOrderNotification:(NSNotification *)notification {
  41. NSDictionary *userInfo = notification.userInfo;
  42. NSDictionary *aps = [userInfo objectForKey:@"aps"];
  43. NSString *orderID = [aps objectForKey:@"order-id"];
  44. NSInteger orderType = [[aps objectForKey:@"order-type"] integerValue];
  45. NSString *orderType2 = [aps objectForKey:@"order-type2"];
  46. NSString *statusNo = [aps objectForKey:@"status-no"];
  47. if (!orderType2) {
  48. orderType2 = @"";
  49. }
  50. // [RASingleton.sharedInstance writeLog:[NSString stringWithFormat:@"%s",__func__]];
  51. if (orderID) {
  52. NSString *msg = [aps objectForKey:@"message"];
  53. if (msg.length == 0) {
  54. msg = [NSString stringWithFormat:@"%@ status changed,view detail?",orderID];
  55. }
  56. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
  57. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  58. }];
  59. __weak typeof(self) weakSelf = self;
  60. UIAlertAction *detailAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  61. [weakSelf pushDetailViewControllerForOrderID:orderID type:orderType type2:orderType2 statusNo:statusNo];
  62. }];
  63. [alertVC addAction:cancelAction];
  64. [alertVC addAction:detailAction];
  65. [self presentViewController:alertVC animated:YES completion:nil];
  66. }
  67. }
  68. - (void)pushDetailViewControllerForOrderID:(NSString *)orderID type:(NSInteger)type type2:(NSString *)type2 statusNo:(NSString *)statusNo {
  69. if (!orderID) {
  70. return;
  71. }
  72. RAOrderDetailViewController *detailVC = [RAOrderDetailViewController viewControllerFromStoryboard];
  73. detailVC.orderID = orderID;
  74. detailVC.orderType = type;
  75. detailVC.orderType2 = type2;
  76. [self pushViewController:detailVC animated:YES];
  77. }
  78. @end