Kaynağa Gözat

1.修改iOS Apex Mobile KPI布局。
2.修改iOS Apex Mobile Home和History数据加载。

Pen Li 8 yıl önce
ebeveyn
işleme
d2ea9a8a36

+ 4 - 0
Apex Mobile/Apex Mobile/HomeViewController.m

@@ -44,6 +44,8 @@
         self.automaticallyAdjustsScrollViewInsets = NO;
     }
     
+    self.segmentControl.tintColor = APGRAYCOLOR;
+    
     self.emptyBtn.layer.borderColor = [UIColor darkGrayColor].CGColor;
     self.emptyBtn.layer.borderWidth = 1.0f;
     self.emptyBtn.layer.cornerRadius = 10.0f;
@@ -105,6 +107,7 @@
         self.tabBarController.navigationItem.rightBarButtonItem = searchItem;
     }
 }
+
 - (void)switchMode:(id)sender {
     
     AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
@@ -130,6 +133,7 @@
 
 - (void)reloadContent {
     
+    [self loadData];
 }
 
 - (void)configureTableView {

+ 52 - 3
Apex Mobile/Apex Mobile/KPICell.m

@@ -82,12 +82,20 @@
     NSDictionary *json = _infoDic;
     NSArray * itemsArr = json[@"arr_val"];
     
+    // 向底部对其
+    NSInteger rowCount = itemsArr.count / colCount;
+    NSInteger mod = itemsArr.count % colCount;
+    if (mod > 0) {
+        rowCount++;
+    }
+    CGFloat ItemAreaH = (h + vInterval) * rowCount;
+    CGFloat offsetY = (CGRectGetHeight(self.itemsContainer.bounds) - ItemAreaH) * 0.5;
     for(int i = 0; i < itemsArr.count; i++) {
         
         NSMutableDictionary* item = [itemsArr objectAtIndex:i];
         NSInteger row = i / colCount;
         NSInteger col = i % colCount;
-        CGRect frame = CGRectMake(hInterval + (w + hInterval) * col, (h + vInterval) * row, w, h);
+        CGRect frame = CGRectMake(hInterval + (w + hInterval) * col, offsetY + (h + vInterval) * row, w, h);
         [self createKPIButtonWithItem:item Frame:frame Index:i];
     }
     
@@ -158,14 +166,55 @@
     self.countLB.text = nil;
     self.percentLB.text = nil;
     
-    CGFloat w = self.bounds.size.width;
-    CGFloat h = self.bounds.size.height;
+    CGFloat w = [UIScreen mainScreen].bounds.size.width;
+    CGFloat h = [UIScreen mainScreen].bounds.size.height;
     if (MAX(w, h) <= 568) {
         self.KPIHeightConstraint.constant = 180;
         [self layoutIfNeeded];
     }
 }
 
+- (void)layoutSubviews {
+    [super layoutSubviews];
+    
+    // 从Storyboard加载后,获取的Frame不正确。
+    NSArray *subViews = self.itemsContainer.subviews;
+    if (subViews.count > 0) {
+        
+        NSInteger colCount = 2;
+        CGFloat vInterval = 5.0f, hInterval = 5.0f;
+        CGFloat w = (CGRectGetWidth(self.bounds) - hInterval * (colCount + 1)) / colCount;
+        CGFloat h = 20.0f;
+        
+        // 居中对其
+        NSInteger rowCount = subViews.count / colCount;
+        NSInteger mod = subViews.count % colCount;
+        if (mod > 0) {
+            rowCount++;
+        }
+        CGFloat ItemAreaH = (h + vInterval) * rowCount;
+        CGFloat offsetY = (CGRectGetHeight(self.itemsContainer.bounds) - ItemAreaH) * 0.5;
+
+        for (int i = 0; i < subViews.count; i++) {
+            UIButton *btn = [(UIButton *)self.itemsContainer viewWithTag:TAG_INDEX + i];
+            NSInteger row = i / colCount;
+            NSInteger col = i % colCount;
+            CGRect frame = CGRectMake(hInterval + (w + hInterval) * col, offsetY + (h + vInterval) * row, w, h);
+            btn.frame = frame;
+        }
+        
+        
+    }
+}
+
+- (void)didMoveToSuperview {
+    [super didMoveToSuperview];
+    
+    // 从storyboard加载后,其Size不正确,必须强制Layout。
+    [self layoutIfNeeded];
+    
+}
+
 #pragma mark - Action
 
 - (IBAction)preItemBtnClick:(UIButton *)sender {

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

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="YOs-rL-bRV">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="YOs-rL-bRV">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
         <deployment version="2304" identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
         <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
         <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
@@ -321,11 +321,11 @@
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Fzk-UY-Jay">
-                                                    <rect key="frame" x="0.0" y="287" width="374" height="240"/>
+                                                    <rect key="frame" x="0.0" y="337" width="374" height="190"/>
                                                     <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                                 </view>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="7 Days" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="a70-xK-8Gt">
-                                                    <rect key="frame" x="220.5" y="57.5" width="49" height="19.5"/>
+                                                    <rect key="frame" x="113.5" y="57.5" width="49" height="19.5"/>
                                                     <constraints>
                                                         <constraint firstAttribute="height" constant="19.5" id="77T-V5-J6j"/>
                                                     </constraints>
@@ -346,27 +346,27 @@
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="3855" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZTm-4z-LAb">
-                                                    <rect key="frame" x="274.5" y="57.5" width="39" height="19.5"/>
+                                                    <rect key="frame" x="167.5" y="57.5" width="39" height="19.5"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="48.5%" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="nqS-Pj-374">
-                                                    <rect key="frame" x="318.5" y="57.5" width="45.5" height="19.5"/>
+                                                    <rect key="frame" x="211.5" y="57.5" width="46" height="19.5"/>
                                                     <fontDescription key="fontDescription" type="system" pointSize="16"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
                                                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="aTr-Mi-Mg3" customClass="XYPieChartView">
-                                                    <rect key="frame" x="87" y="82" width="200" height="200"/>
+                                                    <rect key="frame" x="62" y="82" width="250" height="250"/>
                                                     <color key="backgroundColor" red="0.31186315860000002" green="0.73688559149999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                                     <constraints>
                                                         <constraint firstAttribute="width" secondItem="aTr-Mi-Mg3" secondAttribute="height" multiplier="1:1" id="Huw-mu-fRN"/>
-                                                        <constraint firstAttribute="height" constant="200" id="VQp-Nn-Hkb"/>
+                                                        <constraint firstAttribute="height" constant="250" id="VQp-Nn-Hkb"/>
                                                     </constraints>
                                                 </view>
                                                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5at-hb-Z6F">
-                                                    <rect key="frame" x="5" y="82" width="30" height="200"/>
+                                                    <rect key="frame" x="5" y="82" width="30" height="250"/>
                                                     <constraints>
                                                         <constraint firstAttribute="width" constant="30" id="zSs-uv-rnc"/>
                                                     </constraints>
@@ -376,7 +376,7 @@
                                                     </connections>
                                                 </button>
                                                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="NEW-gP-kfO">
-                                                    <rect key="frame" x="339" y="82" width="30" height="200"/>
+                                                    <rect key="frame" x="339" y="82" width="30" height="250"/>
                                                     <state key="normal" image="nextItem"/>
                                                     <connections>
                                                         <action selector="nextItemBtnClick:" destination="hOk-Q6-U2Y" eventType="touchUpInside" id="jah-g3-sSG"/>
@@ -396,6 +396,7 @@
                                             <constraint firstItem="SiU-f3-vg5" firstAttribute="height" secondItem="5BU-lo-4qt" secondAttribute="height" id="HDa-AP-k8s"/>
                                             <constraint firstItem="NEW-gP-kfO" firstAttribute="bottom" secondItem="aTr-Mi-Mg3" secondAttribute="bottom" id="IF9-dO-PCB"/>
                                             <constraint firstItem="nqS-Pj-374" firstAttribute="top" secondItem="SiU-f3-vg5" secondAttribute="bottom" constant="7" id="K1A-lf-3l3"/>
+                                            <constraint firstItem="ZTm-4z-LAb" firstAttribute="centerX" secondItem="hOk-Q6-U2Y" secondAttribute="centerX" id="M6w-jZ-sEd"/>
                                             <constraint firstItem="aTr-Mi-Mg3" firstAttribute="centerX" secondItem="hOk-Q6-U2Y" secondAttribute="centerX" id="NJD-sL-lZu"/>
                                             <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="SiU-f3-vg5" secondAttribute="trailing" id="Oqq-Mo-cDQ"/>
                                             <constraint firstItem="nqS-Pj-374" firstAttribute="height" secondItem="ZTm-4z-LAb" secondAttribute="height" id="P83-8U-2dM"/>
@@ -407,7 +408,6 @@
                                             <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"/>
-                                            <constraint firstAttribute="trailing" secondItem="nqS-Pj-374" secondAttribute="trailing" constant="10" id="lhw-nz-wbA"/>
                                             <constraint firstItem="5at-hb-Z6F" firstAttribute="bottom" secondItem="aTr-Mi-Mg3" secondAttribute="bottom" id="nie-Ua-1Nc"/>
                                             <constraint firstItem="ZTm-4z-LAb" firstAttribute="height" secondItem="a70-xK-8Gt" secondAttribute="height" id="nl5-T3-U8t"/>
                                             <constraint firstItem="nqS-Pj-374" firstAttribute="centerY" secondItem="ZTm-4z-LAb" secondAttribute="centerY" id="oIx-OR-2oK"/>

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

@@ -83,7 +83,7 @@ static const int history_delta = 7;
 }
          
 - (void)reloadContent {
-           
+    [self loadData];
 }
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];

+ 3 - 3
Apex Mobile/Apex Mobile/fake_home.json

@@ -5,17 +5,17 @@
     {
       "key": "Shipment",
       "val": "1234",
-      "color": "0x440000"
+      "color": "0xC60012"
     },
     {
       "key": "Container",
       "val": "1234",
-      "color": "0x000066"
+      "color": "0xCA7D10"
     },
     {
       "key": "TEU",
       "val": "1234",
-      "color": "0x445500"
+      "color": "0x1EAC5F"
     }
   ],
   "KPI": [