Sfoglia il codice sorgente

1.修改iOS Apex Mobile Home布局将加载指示器拆分为Recent和KPI。

Pen Li 8 anni fa
parent
commit
4cd584587e

+ 37 - 12
Apex Mobile/Apex Mobile/HomeViewController.m

@@ -26,10 +26,18 @@ typedef enum {
 @interface HomeViewController () <UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,KPIDelegate>
 
 @property (strong, nonatomic) IBOutlet UISegmentedControl *segmentControl;
+
+@property (nonatomic,strong) IBOutlet UIView *ShipContainer;
+@property (nonatomic,strong) IBOutlet UIActivityIndicatorView *ShipLoading;
+@property (nonatomic,strong) IBOutlet UIButton *ShipNoDataBtn;
 @property (strong, nonatomic) IBOutlet UITableView *shipTableView;
 @property (strong, nonatomic) IBOutlet UISearchBar *shipSearchBar;
 @property (nonatomic,strong) NSMutableArray *shipArray;
 @property (nonatomic,strong) UIRefreshControl *refreshControl;
+
+@property (nonatomic,strong) IBOutlet UIView *KPIContainer;
+@property (nonatomic,strong) IBOutlet UIActivityIndicatorView *KPILoading;
+@property (nonatomic,strong) IBOutlet UIButton *KPINoDataBtn;
 @property (nonatomic,strong) IBOutlet UITableView *KPITableView;
 @property (nonatomic,strong) UIRefreshControl *KPIRefresh;
 
@@ -207,11 +215,11 @@ typedef enum {
 //    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
     
     // 避免重复刷新
-    if (self.refreshControl.isRefreshing) {
+    if (self.ShipLoading.isAnimating) {
         return;
     }
     
-    [self.refreshControl beginRefreshing];
+    [self.ShipLoading startAnimating];
     
     __weak typeof(self) weakSelf = self;
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
@@ -227,6 +235,7 @@ typedef enum {
                 [self.refreshControl endRefreshing];
             }
             
+            [self.ShipLoading stopAnimating];
             
             int result = [[json objectForKey:@"result"] intValue];
             if (result == RESULT_TRUE) {
@@ -239,7 +248,11 @@ typedef enum {
                 NSString *msg = [json objectForKey:@"err_msg"];
                 [RAUtils message_alert:msg title:@"Warning" controller:weakSelf];
             }
-            [self.shipTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
+
+            self.ShipNoDataBtn.hidden = self.shipArray.count > 0;
+            if (self.shipArray.count) {
+                [self.shipTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:NO];
+            }
         });
         
     });
@@ -247,11 +260,11 @@ typedef enum {
 
 - (void)loadKPIData {
     
-    if (self.KPIRefresh.isRefreshing) {
+    if (self.KPILoading.isAnimating) {
         return;
     }
     
-    [self.KPIRefresh beginRefreshing];
+    [self.KPILoading startAnimating];
     
     __weak typeof(self) weakSelf = self;
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
@@ -264,6 +277,8 @@ typedef enum {
                 [self.KPIRefresh endRefreshing];
             }
             
+            [self.KPILoading stopAnimating];
+            
             int result = [[json objectForKey:@"result"] intValue];
             if (result == RESULT_TRUE) {
                 
@@ -271,7 +286,7 @@ typedef enum {
                 
                 [self.KPIArray removeAllObjects];
                 NSArray *kpiArr = [json objectForKey:@"KPI"];
-                
+
                 [self.KPIArray addObject:[[kpiArr firstObject] mutableCopy]];
                 [self.KPIArray addObjectsFromArray:kpiArr];
                 [self.KPIArray addObject:[[kpiArr lastObject] mutableCopy]];
@@ -283,8 +298,8 @@ typedef enum {
                 NSString *msg = [json objectForKey:@"err_msg"];
                 [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];
+            self.KPINoDataBtn.hidden = self.KPIArray.count > 0;
+
         });
         
     });
@@ -314,8 +329,8 @@ typedef enum {
     
     if (sender.selectedSegmentIndex == 1) {
         self.mode = HomeModeKPI;
-        self.shipTableView.hidden = YES;
-        self.KPITableView.hidden = NO;
+        self.ShipContainer.hidden = YES;
+        self.KPIContainer.hidden = NO;
         
         if (self.KPIArray.count == 0) {
             [self loadKPIData];
@@ -327,9 +342,12 @@ typedef enum {
         
     } else {
         self.mode = HomeModeRecent;
-        self.KPITableView.hidden = YES;
-        self.shipTableView.hidden = NO;
+        self.KPIContainer.hidden = YES;
+        self.ShipContainer.hidden = NO;
         self.parentViewController.title = nil;
+        if (self.shipArray.count == 0) {
+            [self loadData];
+        }
     }
     
     
@@ -359,6 +377,13 @@ typedef enum {
     [RAUtils alert_view:msg title:@"Personal Mode"];
 }
 
+- (IBAction)ShipNoDataBtnClick:(UIButton *)sender {
+    [self loadData];
+}
+
+- (IBAction)KPINoDataBtnClick:(UIButton *)sender {
+    [self loadKPIData];
+}
 
 #pragma mark - TableView DataSource && Delegate
 

+ 118 - 22
Apex Mobile/Apex Mobile/Main.storyboard

@@ -286,23 +286,113 @@
                         <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="5aj-tl-FN7">
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="CoA-Tq-6Qs">
                                 <rect key="frame" x="0.0" y="94" width="375" height="524"/>
+                                <subviews>
+                                    <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="5aj-tl-FN7">
+                                        <rect key="frame" x="0.0" y="0.0" width="375" height="524"/>
+                                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                        <connections>
+                                            <outlet property="dataSource" destination="ucJ-C2-JJ8" id="sHI-R9-c02"/>
+                                            <outlet property="delegate" destination="ucJ-C2-JJ8" id="Svl-Ln-geD"/>
+                                        </connections>
+                                    </tableView>
+                                    <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="FSX-U7-TKb">
+                                        <rect key="frame" x="132" y="242" width="110" height="40"/>
+                                        <constraints>
+                                            <constraint firstAttribute="width" constant="110" id="nD7-1h-tBS"/>
+                                            <constraint firstAttribute="height" constant="40" id="nba-D9-tvl"/>
+                                        </constraints>
+                                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                        <state key="normal" title="No KPI Data">
+                                            <color key="titleColor" white="0.33333333329999998" alpha="1" colorSpace="calibratedWhite"/>
+                                        </state>
+                                        <userDefinedRuntimeAttributes>
+                                            <userDefinedRuntimeAttribute type="number" keyPath="layer.borderWidth">
+                                                <integer key="value" value="1"/>
+                                            </userDefinedRuntimeAttribute>
+                                            <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
+                                                <integer key="value" value="5"/>
+                                            </userDefinedRuntimeAttribute>
+                                        </userDefinedRuntimeAttributes>
+                                        <connections>
+                                            <action selector="KPINoDataBtnClick:" destination="ucJ-C2-JJ8" eventType="touchUpInside" id="g6P-pQ-3OK"/>
+                                        </connections>
+                                    </button>
+                                    <activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="JzT-Iw-sPl">
+                                        <rect key="frame" x="167.5" y="242.5" width="40" height="40"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="40" id="5z1-10-GGb"/>
+                                            <constraint firstAttribute="width" constant="40" id="hj6-cC-Pvu"/>
+                                        </constraints>
+                                    </activityIndicatorView>
+                                </subviews>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                                <connections>
-                                    <outlet property="dataSource" destination="ucJ-C2-JJ8" id="sHI-R9-c02"/>
-                                    <outlet property="delegate" destination="ucJ-C2-JJ8" id="Svl-Ln-geD"/>
-                                </connections>
-                            </tableView>
-                            <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="iIl-j9-7oa">
+                                <constraints>
+                                    <constraint firstItem="5aj-tl-FN7" firstAttribute="height" secondItem="CoA-Tq-6Qs" secondAttribute="height" id="HEw-J4-NXZ"/>
+                                    <constraint firstItem="FSX-U7-TKb" firstAttribute="centerX" secondItem="CoA-Tq-6Qs" secondAttribute="centerX" id="Ivp-NP-4LM"/>
+                                    <constraint firstItem="JzT-Iw-sPl" firstAttribute="centerY" secondItem="CoA-Tq-6Qs" secondAttribute="centerY" id="NV7-Rj-WKh"/>
+                                    <constraint firstItem="5aj-tl-FN7" firstAttribute="width" secondItem="CoA-Tq-6Qs" secondAttribute="width" id="Wxf-7b-0tw"/>
+                                    <constraint firstItem="5aj-tl-FN7" firstAttribute="centerX" secondItem="CoA-Tq-6Qs" secondAttribute="centerX" id="flB-Z7-Fan"/>
+                                    <constraint firstItem="5aj-tl-FN7" firstAttribute="centerY" secondItem="CoA-Tq-6Qs" secondAttribute="centerY" id="k4v-rG-3mT"/>
+                                    <constraint firstItem="FSX-U7-TKb" firstAttribute="centerY" secondItem="CoA-Tq-6Qs" secondAttribute="centerY" id="lt8-rq-pnr"/>
+                                    <constraint firstItem="JzT-Iw-sPl" firstAttribute="centerX" secondItem="CoA-Tq-6Qs" secondAttribute="centerX" id="tOv-MM-GXg"/>
+                                </constraints>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="TYb-wc-Nwg">
                                 <rect key="frame" x="0.0" y="94" width="375" height="524"/>
-                                <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
-                                <inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
-                                <connections>
-                                    <outlet property="dataSource" destination="ucJ-C2-JJ8" id="87k-f6-Pjn"/>
-                                    <outlet property="delegate" destination="ucJ-C2-JJ8" id="qcO-e8-lls"/>
-                                </connections>
-                            </tableView>
+                                <subviews>
+                                    <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="iIl-j9-7oa">
+                                        <rect key="frame" x="0.0" y="0.0" width="375" height="524"/>
+                                        <color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
+                                        <inset key="separatorInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
+                                        <connections>
+                                            <outlet property="dataSource" destination="ucJ-C2-JJ8" id="87k-f6-Pjn"/>
+                                            <outlet property="delegate" destination="ucJ-C2-JJ8" id="qcO-e8-lls"/>
+                                        </connections>
+                                    </tableView>
+                                    <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0Al-V9-YKc">
+                                        <rect key="frame" x="117" y="242" width="140" height="40"/>
+                                        <constraints>
+                                            <constraint firstAttribute="width" constant="140" id="9UW-08-GTi"/>
+                                            <constraint firstAttribute="height" constant="40" id="tfG-C9-CfW"/>
+                                        </constraints>
+                                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                        <state key="normal" title="No Recent Data">
+                                            <color key="titleColor" white="0.33333333329999998" alpha="1" colorSpace="calibratedWhite"/>
+                                        </state>
+                                        <userDefinedRuntimeAttributes>
+                                            <userDefinedRuntimeAttribute type="number" keyPath="layer.borderWidth">
+                                                <integer key="value" value="1"/>
+                                            </userDefinedRuntimeAttribute>
+                                            <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
+                                                <integer key="value" value="5"/>
+                                            </userDefinedRuntimeAttribute>
+                                        </userDefinedRuntimeAttributes>
+                                        <connections>
+                                            <action selector="ShipNoDataBtnClick:" destination="ucJ-C2-JJ8" eventType="touchUpInside" id="QKx-BX-Hck"/>
+                                        </connections>
+                                    </button>
+                                    <activityIndicatorView hidden="YES" opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="whiteLarge" translatesAutoresizingMaskIntoConstraints="NO" id="IFp-NK-v1o">
+                                        <rect key="frame" x="167.5" y="242.5" width="40" height="40"/>
+                                        <constraints>
+                                            <constraint firstAttribute="height" constant="40" id="36I-ae-Ncc"/>
+                                            <constraint firstAttribute="width" constant="40" id="L8H-4i-m7R"/>
+                                        </constraints>
+                                    </activityIndicatorView>
+                                </subviews>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                <constraints>
+                                    <constraint firstItem="iIl-j9-7oa" firstAttribute="width" secondItem="TYb-wc-Nwg" secondAttribute="width" id="3bU-Ll-nT0"/>
+                                    <constraint firstItem="0Al-V9-YKc" firstAttribute="centerX" secondItem="TYb-wc-Nwg" secondAttribute="centerX" id="8a8-fw-f0B"/>
+                                    <constraint firstItem="iIl-j9-7oa" firstAttribute="centerX" secondItem="TYb-wc-Nwg" secondAttribute="centerX" id="Jd3-gv-peg"/>
+                                    <constraint firstItem="IFp-NK-v1o" firstAttribute="centerY" secondItem="TYb-wc-Nwg" secondAttribute="centerY" id="Q19-iJ-g2O"/>
+                                    <constraint firstItem="0Al-V9-YKc" firstAttribute="centerY" secondItem="TYb-wc-Nwg" secondAttribute="centerY" id="fYu-3V-T4O"/>
+                                    <constraint firstItem="IFp-NK-v1o" firstAttribute="centerX" secondItem="TYb-wc-Nwg" secondAttribute="centerX" id="lcn-AL-YXN"/>
+                                    <constraint firstItem="iIl-j9-7oa" firstAttribute="centerY" secondItem="TYb-wc-Nwg" secondAttribute="centerY" id="u2T-Xe-eO1"/>
+                                    <constraint firstItem="iIl-j9-7oa" firstAttribute="height" secondItem="TYb-wc-Nwg" secondAttribute="height" id="whL-aN-51R"/>
+                                </constraints>
+                            </view>
                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3xo-DP-qWN">
                                 <rect key="frame" x="0.0" y="64" width="375" height="30"/>
                                 <subviews>
@@ -328,24 +418,30 @@
                         </subviews>
                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <constraints>
-                            <constraint firstItem="6yV-PD-KCp" firstAttribute="top" secondItem="5aj-tl-FN7" secondAttribute="bottom" id="05a-xR-fo2"/>
-                            <constraint firstItem="5aj-tl-FN7" firstAttribute="top" secondItem="3xo-DP-qWN" secondAttribute="bottom" id="3Af-tB-X67"/>
+                            <constraint firstItem="TYb-wc-Nwg" firstAttribute="top" secondItem="3xo-DP-qWN" secondAttribute="bottom" id="7Q1-xA-m6A"/>
                             <constraint firstItem="3xo-DP-qWN" firstAttribute="top" secondItem="70L-ql-L3f" secondAttribute="bottom" id="7dN-EO-3Yh"/>
-                            <constraint firstItem="iIl-j9-7oa" firstAttribute="trailing" secondItem="ifC-vl-u6I" secondAttribute="trailing" id="9jR-8W-zYM"/>
+                            <constraint firstAttribute="trailing" secondItem="TYb-wc-Nwg" secondAttribute="trailing" id="F3N-vc-FCU"/>
+                            <constraint firstAttribute="trailing" secondItem="CoA-Tq-6Qs" secondAttribute="trailing" id="FSs-a2-2km"/>
+                            <constraint firstItem="6yV-PD-KCp" firstAttribute="top" secondItem="TYb-wc-Nwg" secondAttribute="bottom" id="GRL-Lc-GfQ"/>
                             <constraint firstAttribute="trailing" secondItem="3xo-DP-qWN" secondAttribute="trailing" id="Gvc-tU-QdZ"/>
-                            <constraint firstItem="iIl-j9-7oa" firstAttribute="top" secondItem="3xo-DP-qWN" secondAttribute="bottom" id="JZI-44-qDk"/>
-                            <constraint firstAttribute="trailing" secondItem="5aj-tl-FN7" secondAttribute="trailing" id="Ple-1P-42o"/>
-                            <constraint firstItem="5aj-tl-FN7" firstAttribute="leading" secondItem="ifC-vl-u6I" secondAttribute="leading" id="eLf-n9-JxT"/>
-                            <constraint firstItem="iIl-j9-7oa" firstAttribute="leading" secondItem="ifC-vl-u6I" secondAttribute="leading" id="lPc-7m-bBJ"/>
+                            <constraint firstItem="6yV-PD-KCp" firstAttribute="top" secondItem="CoA-Tq-6Qs" secondAttribute="bottom" id="Oci-pa-FUE"/>
+                            <constraint firstItem="TYb-wc-Nwg" firstAttribute="leading" secondItem="ifC-vl-u6I" secondAttribute="leading" id="UFA-oo-scR"/>
+                            <constraint firstItem="CoA-Tq-6Qs" firstAttribute="leading" secondItem="ifC-vl-u6I" secondAttribute="leading" id="UHT-mf-Uts"/>
+                            <constraint firstItem="CoA-Tq-6Qs" firstAttribute="top" secondItem="3xo-DP-qWN" secondAttribute="bottom" id="gVC-BJ-pMJ"/>
                             <constraint firstItem="3xo-DP-qWN" firstAttribute="leading" secondItem="ifC-vl-u6I" secondAttribute="leading" id="mui-fH-ZHN"/>
-                            <constraint firstItem="iIl-j9-7oa" firstAttribute="bottom" secondItem="6yV-PD-KCp" secondAttribute="top" id="nZz-HM-ESm"/>
                         </constraints>
                     </view>
                     <tabBarItem key="tabBarItem" title="Home" image="tab_home" id="OC9-MV-8nf"/>
                     <navigationItem key="navigationItem" id="giR-co-TyJ"/>
                     <simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
                     <connections>
+                        <outlet property="KPIContainer" destination="CoA-Tq-6Qs" id="vVk-8b-fBX"/>
+                        <outlet property="KPILoading" destination="JzT-Iw-sPl" id="7FG-GF-kXY"/>
+                        <outlet property="KPINoDataBtn" destination="FSX-U7-TKb" id="X2J-Vu-SzK"/>
                         <outlet property="KPITableView" destination="5aj-tl-FN7" id="aND-mx-T5V"/>
+                        <outlet property="ShipContainer" destination="TYb-wc-Nwg" id="zGZ-eO-IiP"/>
+                        <outlet property="ShipLoading" destination="IFp-NK-v1o" id="2qd-dX-YqA"/>
+                        <outlet property="ShipNoDataBtn" destination="0Al-V9-YKc" id="1ZI-ki-vjV"/>
                         <outlet property="segmentControl" destination="6ie-Rf-Nau" id="q6N-98-j6F"/>
                         <outlet property="shipTableView" destination="iIl-j9-7oa" id="vsk-WU-ScI"/>
                     </connections>