Sfoglia il codice sorgente

1.修改iOS Apex Mobile KPI小于8%不显示文字。
2.修改iOS Apex Mobile Person Mode显示和刷新。

Pen Li 8 anni fa
parent
commit
b8abe114a1

+ 1 - 0
Apex Mobile/Apex Mobile/AppDelegate.h

@@ -10,6 +10,7 @@
 #import <GoogleMaps/GoogleMaps.h>
 
 UIKIT_EXTERN NSString * const APLogoutNotification;
+UIKIT_EXTERN NSString * const APPersonModeChangeNotification;
 
 @interface AppDelegate : UIResponder <UIApplicationDelegate>
 

+ 2 - 1
Apex Mobile/Apex Mobile/AppDelegate.m

@@ -14,7 +14,7 @@
 
 
 NSString * const APLogoutNotification = @"LogoutNofitication";
-
+NSString * const APPersonModeChangeNotification = @"PersonModeChangeNotification";
 
 @implementation AppDelegate
 
@@ -202,6 +202,7 @@ void UncaughtExceptionHandler(NSException *exception) {
     self.isLogin = NO;
     self.user = nil;
     self.password=nil;
+    self.personalmode = NO;
 //    self.sessionid=nil;
     [RANetwork Logout];
     NSUserDefaults *defaults =[NSUserDefaults standardUserDefaults];

+ 60 - 31
Apex Mobile/Apex Mobile/HomeViewController.m

@@ -54,6 +54,7 @@
     
     [self.loadIndicator stopAnimating];
     
+    [self registNotification];
     [self configureCollectionView];
     [self configureTableView];
     self.shipSearchBar.delegate =self;
@@ -99,6 +100,10 @@
     if (self.navigationController && !self.navigationController.isNavigationBarHidden) {
         
         UIImage *logo = [[UIImage imageNamed:@"apexlogo-2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        if (appDelegate.personalmode) {
+            logo = [[UIImage imageNamed:@"apexlogo-2p"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
+        }
         UIBarButtonItem *logoItem = [[UIBarButtonItem alloc] initWithImage:logo landscapeImagePhone:logo style:UIBarButtonItemStylePlain target:self action:@selector(switchMode:)];
         logoItem.enabled = true;
         self.tabBarController.navigationItem.leftBarButtonItem = logoItem;
@@ -108,34 +113,6 @@
     }
 }
 
-- (void)switchMode:(id)sender {
-    
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
-    appDelegate.personalmode = ! appDelegate.personalmode;
-    
-    NSString* msg = @"";
-    if(appDelegate.personalmode)
-    {
-        msg=@"Personal Mode On.";
-           self.tabBarController.navigationItem.leftBarButtonItem.image = [[UIImage imageNamed:@"apexlogo-2p"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
-    }
-    else
-    {
-        msg=@"Personal Mode Off.";
-        self.tabBarController.navigationItem.leftBarButtonItem.image = [[UIImage imageNamed:@"apexlogo-2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
-    }
-    
-    
-    [RAUtils alert_view:msg title:@"Personal Mode"];
-    [self reloadContent];
-}
-
-- (void)reloadContent {
-    
-    [self loadData];
-}
-
 - (void)configureTableView {
     
     CGFloat w = CGRectGetWidth(self.shipTableView.bounds);
@@ -161,11 +138,27 @@
     layout.estimatedItemSize = self.KPICollectionView.bounds.size;
 }
 
+- (void)registNotification {
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePersonModeChangeNotification:) name:APPersonModeChangeNotification object:nil];
+}
+
 - (void)logout {
     [self.shipArray removeAllObjects];
     [self.shipTableView reloadData];
 }
 
+- (void)handlePersonModeChangeNotification:(NSNotification *)notification {
+    [self reloadContent];
+}
+
+- (void)postPersonModeChangeNotification {
+    [[NSNotificationCenter defaultCenter] postNotificationName:APPersonModeChangeNotification object:nil];
+}
+
+- (void)dealloc {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
 #pragma mark - Load Data
 
 - (NSMutableArray *)shipArray {
@@ -182,16 +175,28 @@
     return _KPIArray;
 }
 
+- (void)reloadContent {
+    NSLog(@"Home Person Mode Change");
+    
+    [self loadData];
+}
+
 - (void)loadData {
 //    NSString *path = [[NSBundle mainBundle] pathForResource:@"fake_container_list.json" ofType:nil];
 //    NSData *data = [[NSData alloc] initWithContentsOfFile:path];
 //
 //    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
     
-    if (!self.refreshControl.isRefreshing) {
-        [self.loadIndicator startAnimating];
+    // 避免重复刷新
+    if (self.loadIndicator.isAnimating) {
+        return;
     }
     
+//    if (!self.refreshControl.isRefreshing) {
+//
+//    }
+    [self.loadIndicator startAnimating];
+    
     __weak typeof(self) weakSelf = self;
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
        
@@ -232,7 +237,7 @@
                 [RAUtils message_alert:msg title:@"Warning" controller:weakSelf];
             }
             self.emptyBtn.hidden = self.shipArray.count > 0;
-            
+            [self.shipTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
         });
         
     });
@@ -270,6 +275,30 @@
     }
 }
 
+- (void)switchMode:(id)sender {
+    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+    appDelegate.personalmode = ! appDelegate.personalmode;
+    
+    NSString* msg = @"";
+    if(appDelegate.personalmode)
+    {
+        msg=@"Personal Mode On.";
+        self.tabBarController.navigationItem.leftBarButtonItem.image = [[UIImage imageNamed:@"apexlogo-2p"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
+    }
+    else
+    {
+        msg=@"Personal Mode Off.";
+        self.tabBarController.navigationItem.leftBarButtonItem.image = [[UIImage imageNamed:@"apexlogo-2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
+    }
+    
+    
+    [self postPersonModeChangeNotification];
+    [RAUtils alert_view:msg title:@"Personal Mode"];
+}
+
+
 #pragma mark - TableView DataSource && Delegate
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

+ 1 - 1
Apex Mobile/Apex Mobile/KPICell.m

@@ -247,7 +247,7 @@
         return;
     }
 
-    self.selectedInfoLB.text = [NSString stringWithFormat:@"%@ %@ %@%%",selectedType[@"full_title"],selectedType[@"A_val"],selectedType[@"CP_val"]];
+    self.selectedInfoLB.text = [NSString stringWithFormat:@"%@ %@ %.2f%%",selectedType[@"full_title"],selectedType[@"A_val"],[selectedType[@"CP_val"] floatValue]];
     
 }
 

+ 4 - 4
Apex Mobile/Apex Mobile/Main.storyboard

@@ -306,7 +306,7 @@
                                             <autoresizingMask key="autoresizingMask"/>
                                             <subviews>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Shipment:5868" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HR2-MW-QBD">
-                                                    <rect key="frame" x="0.0" y="31" width="113" height="19.5"/>
+                                                    <rect key="frame" x="5" y="31" width="113" height="19.5"/>
                                                     <constraints>
                                                         <constraint firstAttribute="height" constant="19.5" id="hDC-6j-Te0"/>
                                                     </constraints>
@@ -315,7 +315,7 @@
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TEU:16436" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="SiU-f3-vg5">
-                                                    <rect key="frame" x="237" y="31" width="82" height="19.5"/>
+                                                    <rect key="frame" x="242" y="31" width="82" height="19.5"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
@@ -331,7 +331,7 @@
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Container:9035" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5BU-lo-4qt">
-                                                    <rect key="frame" x="118" y="31" width="114" height="19.5"/>
+                                                    <rect key="frame" x="123" y="31" width="114" height="19.5"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
@@ -388,7 +388,7 @@
                                             <constraint firstItem="NEW-gP-kfO" firstAttribute="width" secondItem="5at-hb-Z6F" secondAttribute="width" id="Pt4-h9-f63"/>
                                             <constraint firstItem="TdU-EN-0bl" firstAttribute="leading" secondItem="hOk-Q6-U2Y" secondAttribute="leading" constant="5" id="RCu-sb-u2d"/>
                                             <constraint firstItem="5BU-lo-4qt" firstAttribute="centerY" secondItem="HR2-MW-QBD" secondAttribute="centerY" id="aJp-oe-BEb"/>
-                                            <constraint firstItem="HR2-MW-QBD" firstAttribute="leading" secondItem="hOk-Q6-U2Y" secondAttribute="leading" id="c5e-3z-YkJ"/>
+                                            <constraint firstItem="HR2-MW-QBD" firstAttribute="leading" secondItem="hOk-Q6-U2Y" secondAttribute="leading" constant="5" id="c5e-3z-YkJ"/>
                                             <constraint firstItem="SiU-f3-vg5" firstAttribute="centerY" secondItem="5BU-lo-4qt" secondAttribute="centerY" id="cUe-lI-M8w"/>
                                             <constraint firstItem="5BU-lo-4qt" firstAttribute="height" secondItem="HR2-MW-QBD" secondAttribute="height" id="epV-Od-GWW"/>
                                             <constraint firstItem="Fzk-UY-Jay" firstAttribute="top" secondItem="aTr-Mi-Mg3" secondAttribute="bottom" constant="5" id="jpV-Oc-1y7"/>

+ 56 - 30
Apex Mobile/Apex Mobile/OrderHistoryViewController.m

@@ -48,6 +48,7 @@ static const int history_delta = 7;
     self.emptyBtn.layer.masksToBounds = YES;
     self.emptyBtn.hidden = YES;
     
+    [self registNotification];
     [self.loadIndicator stopAnimating];
     [self configureTableView];
     
@@ -58,33 +59,7 @@ static const int history_delta = 7;
     [super didReceiveMemoryWarning];
     // Dispose of any resources that can be recreated.
 }
-- (void)switchMode:(id)sender {
-    
-    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
-    
-    appDelegate.personalmode = ! appDelegate.personalmode;
-    
-    NSString* msg = @"";
-    if(appDelegate.personalmode)
-    {
-        msg=@"Personal Mode On.";
-        self.tabBarController.navigationItem.leftBarButtonItem.image = [[UIImage imageNamed:@"apexlogo-2p"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
-    }
-    else
-    {
-        msg=@"Personal Mode Off.";
-        self.tabBarController.navigationItem.leftBarButtonItem.image = [[UIImage imageNamed:@"apexlogo-2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
-    }
-    
-    
-    [RAUtils alert_view:msg title:@"Personal Mode"];
-//        [self loadContentWithOption:option Complete:^(int result, int count)
-    [self reloadContent];
-}
-         
-- (void)reloadContent {
-    [self loadData];
-}
+
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     
@@ -111,6 +86,10 @@ static const int history_delta = 7;
     if (self.navigationController && !self.navigationController.isNavigationBarHidden) {
         
         UIImage *logo = [[UIImage imageNamed:@"apexlogo-2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
+        AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
+        if (appDelegate.personalmode) {
+            logo = [[UIImage imageNamed:@"apexlogo-2p"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
+        }
         UIBarButtonItem *logoItem = [[UIBarButtonItem alloc] initWithImage:logo landscapeImagePhone:logo style:UIBarButtonItemStylePlain target:self action:@selector(switchMode:)];
         logoItem.enabled = true;
         self.tabBarController.navigationItem.leftBarButtonItem = logoItem;
@@ -140,6 +119,22 @@ static const int history_delta = 7;
     [self.shipTableView reloadData];
 }
 
+- (void)registNotification {
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePersonModeChangeNotification:) name:APPersonModeChangeNotification object:nil];
+}
+
+- (void)handlePersonModeChangeNotification:(NSNotification *)notification {
+    [self reloadContent];
+}
+
+- (void)postPersonModeChangeNotification {
+    [[NSNotificationCenter defaultCenter] postNotificationName:APPersonModeChangeNotification object:nil];
+}
+
+- (void)dealloc {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
 #pragma mark - Load Data
 
 - (NSMutableArray *)shipArray {
@@ -149,11 +144,18 @@ static const int history_delta = 7;
     return _shipArray;
 }
 
+- (void)reloadContent {
+    NSLog(@"History Person Mode Change");
+    
+    [self loadData];
+}
+
 - (void)loadData {
     
     __weak typeof(self) weakSelf = self;
     [self loadContentWithOption:0 Complete:^(int result, int count) {
         [weakSelf.shipTableView reloadData];
+        [weakSelf.shipTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
     }];
 }
 
@@ -164,6 +166,11 @@ static const int history_delta = 7;
  */
 - (void)loadContentWithOption:(int)option Complete:(void (^)(int result,int count))finish {
     
+    // 避免重复刷新
+    if (self.loadIndicator.isAnimating) {
+        return;
+    }
+    
     NSInteger offset = 0;
     
     if (option == 2) {
@@ -224,9 +231,6 @@ static const int history_delta = 7;
         
     });
     
-   
-    
-    
 }
 
 #pragma mark - Actinon
@@ -236,6 +240,28 @@ static const int history_delta = 7;
     [self loadData];
 }
 
+- (void)switchMode:(id)sender {
+    
+    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
+    
+    appDelegate.personalmode = ! appDelegate.personalmode;
+    
+    NSString* msg = @"";
+    if(appDelegate.personalmode)
+    {
+        msg=@"Personal Mode On.";
+        self.tabBarController.navigationItem.leftBarButtonItem.image = [[UIImage imageNamed:@"apexlogo-2p"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
+    }
+    else
+    {
+        msg=@"Personal Mode Off.";
+        self.tabBarController.navigationItem.leftBarButtonItem.image = [[UIImage imageNamed:@"apexlogo-2"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
+    }
+    
+    [self postPersonModeChangeNotification];
+    [RAUtils alert_view:msg title:@"Personal Mode"];
+}
+
 #pragma mark - TableView DataSource && Delegate
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

+ 1 - 1
Apex Mobile/Apex Mobile/PieChart/XYPieChartView.m

@@ -253,7 +253,7 @@
     
     
     // 当有一项数据的百分比小于你所校验的数值时,会将该项数值百分比移出饼图展示(校验数值从0~100)
-    [self setCheckLessThanPercent:10];
+    [self setCheckLessThanPercent:8.0f];
 }
 
 - (id)initWithFrame:(CGRect)frame withPieChartData:(NSMutableDictionary *)pieChartData