Bladeren bron

1.修改iOS Apex Drivers Detail Map导航。

Pen Li 7 jaren geleden
bovenliggende
commit
5628eed5c0

+ 23 - 0
Redant Drivers/Apex And Drivers/Assets.xcassets/driver_logo.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "driver_logo.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "driver_logo@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "driver_logo@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
Redant Drivers/Apex And Drivers/Assets.xcassets/driver_logo.imageset/driver_logo.png


BIN
Redant Drivers/Apex And Drivers/Assets.xcassets/driver_logo.imageset/driver_logo@2x.png


BIN
Redant Drivers/Apex And Drivers/Assets.xcassets/driver_logo.imageset/driver_logo@3x.png


+ 32 - 13
Redant Drivers/Apex And Drivers/Detail/Cell/RADetailMapCell.m

@@ -13,8 +13,10 @@
 @interface RADetailMapCell ()
 
 @property (strong, nonatomic) IBOutlet UILabel *titleLabel;
-@property (strong, nonatomic) IBOutlet MKMapView *mapView;
+//@property (strong, nonatomic) IBOutlet MKMapView *mapView;
 @property (strong, nonatomic) IBOutlet UILabel *valueLabel;
+@property (strong, nonatomic) IBOutlet UIButton *navigationBtn;
+
 
 @end
 
@@ -48,19 +50,36 @@
     NSString *latStr = _model.lat;
     if (lonStr && lonStr.length > 0 && latStr && latStr.length > 0) {
         
-        double longitude = [lonStr doubleValue];
-        double latitude = [latStr doubleValue];
-        
-        CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(latitude, longitude);
-        
-        MKCoordinateSpan span = MKCoordinateSpanMake(180, 360);
-        // 创建一个区域结构体变量
-        MKCoordinateRegion region = MKCoordinateRegionMake(c2d, span);
-        
-        // 将大头针数据模型添加到MKMapView上管理
-        [self.mapView setRegion:region animated:YES];
-        
+//        double longitude = [lonStr doubleValue];
+//        double latitude = [latStr doubleValue];
+//
+//        CLLocationCoordinate2D c2d = CLLocationCoordinate2DMake(latitude, longitude);
+//
+//        MKCoordinateSpan span = MKCoordinateSpanMake(180, 360);
+//        // 创建一个区域结构体变量
+//        MKCoordinateRegion region = MKCoordinateRegionMake(c2d, span);
+//
+//        // 将大头针数据模型添加到MKMapView上管理
+//        [self.mapView setRegion:region animated:YES];
+        self.navigationBtn.hidden = NO;
+    } else {
+        self.navigationBtn.hidden = YES;
     }
 }
 
+- (IBAction)navigationBtnClick:(UIButton *)sender {
+    
+//    MKMapItem *currentLocation = [MKMapItem mapItemForCurrentLocation];
+    
+    CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([self.model.lat doubleValue], [self.model.lon doubleValue]);
+    
+    MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:coordinate
+                                                                                       addressDictionary:nil]];
+    toLocation.name = self.model.title;
+    [MKMapItem openMapsWithItems:@[toLocation] launchOptions:@{
+                                                               MKLaunchOptionsMapCenterKey : [NSValue valueWithMKCoordinate:coordinate]
+                                                               }];
+    
+}
+
 @end

+ 19 - 9
Redant Drivers/Apex And Drivers/Detail/Detail.storyboard

@@ -239,28 +239,32 @@ OAKLAND,CA</string>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
                                                 </label>
-                                                <mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" mapType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="HTh-Id-rGS">
-                                                    <rect key="frame" x="310" y="33" width="60" height="60"/>
+                                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ev3-or-KB1">
+                                                    <rect key="frame" x="300" y="27" width="70" height="70"/>
                                                     <constraints>
-                                                        <constraint firstAttribute="height" constant="60" id="Ife-Uc-FoA"/>
-                                                        <constraint firstAttribute="width" constant="60" id="hte-fM-6X0"/>
+                                                        <constraint firstAttribute="height" constant="70" id="7wS-i9-I5v"/>
+                                                        <constraint firstAttribute="width" constant="70" id="SOy-eZ-AVi"/>
                                                     </constraints>
-                                                </mapView>
+                                                    <state key="normal" image="action_setting"/>
+                                                    <connections>
+                                                        <action selector="navigationBtnClick:" destination="sLQ-ry-Yxv" eventType="touchUpInside" id="bBe-wQ-Bh4"/>
+                                                    </connections>
+                                                </button>
                                             </subviews>
                                             <constraints>
-                                                <constraint firstItem="HTh-Id-rGS" firstAttribute="centerY" secondItem="PFm-sQ-c4b" secondAttribute="centerY" id="HWn-WY-xhN"/>
+                                                <constraint firstItem="ev3-or-KB1" firstAttribute="centerY" secondItem="PFm-sQ-c4b" secondAttribute="centerY" id="Hpl-vQ-mvZ"/>
                                                 <constraint firstItem="xB6-BK-ueh" firstAttribute="top" secondItem="3xH-7S-3HD" secondAttribute="top" constant="5" id="KSy-vK-d3g"/>
                                                 <constraint firstItem="PFm-sQ-c4b" firstAttribute="top" secondItem="xB6-BK-ueh" secondAttribute="bottom" constant="5" id="RvK-I5-aUn"/>
-                                                <constraint firstAttribute="trailing" secondItem="HTh-Id-rGS" secondAttribute="trailing" constant="5" id="bSW-oA-jc8"/>
+                                                <constraint firstItem="ev3-or-KB1" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="PFm-sQ-c4b" secondAttribute="trailing" constant="5" id="TYF-kk-BvU"/>
+                                                <constraint firstAttribute="trailing" secondItem="ev3-or-KB1" secondAttribute="trailing" constant="5" id="b23-nc-OSg"/>
                                                 <constraint firstItem="xB6-BK-ueh" firstAttribute="leading" secondItem="3xH-7S-3HD" secondAttribute="leading" constant="5" id="eGw-aX-50a"/>
                                                 <constraint firstItem="PFm-sQ-c4b" firstAttribute="leading" secondItem="3xH-7S-3HD" secondAttribute="leading" constant="5" id="eSs-EX-al6"/>
                                                 <constraint firstAttribute="bottom" secondItem="PFm-sQ-c4b" secondAttribute="bottom" constant="5" id="fmQ-Bh-2j8"/>
-                                                <constraint firstItem="HTh-Id-rGS" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="PFm-sQ-c4b" secondAttribute="trailing" constant="5" id="he7-zp-sOU"/>
                                                 <constraint firstAttribute="trailing" secondItem="xB6-BK-ueh" secondAttribute="trailing" constant="5" id="uYg-df-E7T"/>
                                             </constraints>
                                         </tableViewCellContentView>
                                         <connections>
-                                            <outlet property="mapView" destination="HTh-Id-rGS" id="tqR-iW-DG4"/>
+                                            <outlet property="navigationBtn" destination="ev3-or-KB1" id="IjI-gL-BJn"/>
                                             <outlet property="titleLabel" destination="xB6-BK-ueh" id="qka-5z-4Nn"/>
                                             <outlet property="valueLabel" destination="PFm-sQ-c4b" id="oNG-uG-bHW"/>
                                         </connections>
@@ -310,6 +314,9 @@ OAKLAND,CA</string>
                                             <subviews>
                                                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ErT-qT-9u6">
                                                     <rect key="frame" x="5" y="5" width="365" height="21"/>
+                                                    <constraints>
+                                                        <constraint firstAttribute="height" constant="21" id="E3n-pS-av8"/>
+                                                    </constraints>
                                                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
                                                     <nil key="textColor"/>
                                                     <nil key="highlightedColor"/>
@@ -419,4 +426,7 @@ OAKLAND,CA</string>
             <point key="canvasLocation" x="548" y="9"/>
         </scene>
     </scenes>
+    <resources>
+        <image name="action_setting" width="40" height="40"/>
+    </resources>
 </document>

+ 1 - 0
Redant Drivers/Apex And Drivers/Detail/Model/RADetailLocationModel.h

@@ -12,5 +12,6 @@
 
 @property (nonatomic,copy) NSString *title;
 @property (nonatomic,copy) NSString *location;
+@property (nonatomic,copy) NSString *street;
 
 @end

+ 8 - 0
Redant Drivers/Apex And Drivers/Detail/Model/RADetailLocationModel.m

@@ -20,6 +20,14 @@ static const CGFloat SpaceHeight = 38.0f;
     dispatch_async(dispatch_get_global_queue(0, 0), ^{
         [self caculateValueHeight];
     });
+    
+    NSArray *tmpArr = [location componentsSeparatedByString:@"TEL:"];
+    NSString *tmpStr = [tmpArr objectAtIndex:0];
+    tmpArr = [tmpStr componentsSeparatedByString:@"\r\n"];
+    NSMutableArray *tmpMArr = [tmpArr mutableCopy];
+    [tmpMArr removeObjectAtIndex:0];
+    tmpStr = [tmpMArr componentsJoinedByString:@" "];
+    self.street = tmpStr;
 }
 
 - (CGFloat)height {

+ 9 - 5
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController+TableViewDataSource.m

@@ -116,6 +116,10 @@
 
 - (void)locationCell:(RADetailLocationCell *)cell didClickNavigation:(RADetailLocationModel *)model {
     
+    if (model.street == nil) {
+        return;
+    }
+    
     // @"东大街芷泉段6号"
     
     UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
@@ -124,7 +128,7 @@
 
         UIAlertAction *googleMapAction = [UIAlertAction actionWithTitle:@"Google Map" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
 
-            NSString *urlString = [[NSString stringWithFormat:@"comgooglemaps://?q=%@&directionsmode=driving",model.location]
+            NSString *urlString = [[NSString stringWithFormat:@"comgooglemaps://?q=%@&directionsmode=driving",model.street]
                                    stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
 
             [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString] options:@{} completionHandler:^(BOOL success) {
@@ -145,12 +149,12 @@
         
         MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:kCLLocationCoordinate2DInvalid
                                                                                            addressDictionary:@{
-                                                                                                               (__bridge id)kABPersonAddressStreetKey : model.location
+                                                                                                               (__bridge id)kABPersonAddressStreetKey : model.street
                                                                                                                }]];
         [MKMapItem openMapsWithItems:@[currentLocation, toLocation] launchOptions:@{
-                                                                                    MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving,
-                                                                                    MKLaunchOptionsShowsTrafficKey: @(YES)
-                                                                                    }];
+                                                                    MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving,
+                                                                    MKLaunchOptionsShowsTrafficKey: @(YES)
+                                                                    }];
         
     }];
     [alertVC addAction:appleMapAction];

+ 2 - 2
Redant Drivers/Apex And Drivers/Login/Login.storyboard

@@ -81,7 +81,7 @@
                                     <constraint firstItem="vy2-V9-9ML" firstAttribute="centerY" secondItem="Qz0-oF-i3d" secondAttribute="centerY" id="qjq-Ld-Wsm"/>
                                 </constraints>
                             </view>
-                            <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo" translatesAutoresizingMaskIntoConstraints="NO" id="uPR-4Z-qVR">
+                            <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="driver_logo" translatesAutoresizingMaskIntoConstraints="NO" id="uPR-4Z-qVR">
                                 <rect key="frame" x="49.5" y="49" width="276" height="120"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="120" id="4oM-B6-IP5"/>
@@ -234,7 +234,7 @@
         </scene>
     </scenes>
     <resources>
-        <image name="logo" width="276" height="120"/>
+        <image name="driver_logo" width="276" height="120"/>
         <image name="unchecked_32" width="16" height="16"/>
     </resources>
 </document>

+ 2 - 0
Redant Drivers/Apex And Drivers/RADataProvider.h

@@ -44,4 +44,6 @@
 
 + (NSDictionary *)requestChange:(NSString *)old password:(NSString *)pass;
 
++ (NSDictionary *)requestMessage:(NSInteger)offset limit:(NSInteger)limit;
+
 @end

+ 23 - 1
Redant Drivers/Apex And Drivers/RADataProvider.m

@@ -353,7 +353,29 @@
 
 + (NSDictionary *)requestChange:(NSString *)old password:(NSString *)pass {
     
-    return nil;
+    NSMutableDictionary *params = [NSMutableDictionary dictionary];
+    if (old) {
+        [params setObject:old forKey:@"oldPassword"];
+    }
+    if (pass) {
+        [params setObject:pass forKey:@"newPassword"];
+    }
+    
+    NSData* json=[self get_json:URL_CHANGE_PASSWORD parameters:params  file:nil];
+    
+    return [self handleJsonData:json];
+}
+
++ (NSDictionary *)requestMessage:(NSInteger)offset limit:(NSInteger)limit {
+    
+    NSMutableDictionary *params = [NSMutableDictionary dictionary];
+    
+    [params setObject:@(offset) forKey:@"offset"];
+    [params setObject:@(limit) forKey:@"limit"];
+    
+    NSData* json=[self get_json:URL_MESSAGE_LIST parameters:params  file:nil];
+    
+    return [self handleJsonData:json];
 }
 
 #pragma mark - Utils

+ 2 - 0
Redant Drivers/Apex And Drivers/config.h

@@ -29,6 +29,8 @@
 #define URL_REPORT_TOKEN        APPENDING_STR(@"/j/mobile/uploadToken.mo/")
 #define URL_RETRIVE_PASSWORD    APPENDING_STR(@"/j/mobile/resetPassword.mo/")
 #define URL_DRIVER_AVAILABLE    APPENDING_STR(@"/j/mobile/updateDriverAvailable.mo/")
+#define URL_CHANGE_PASSWORD     APPENDING_STR(@"/j/mobile/updateDriverAvailable.mo/")
+#define URL_MESSAGE_LIST        APPENDING_STR(@"/j/mobile/moreDriverMessages.mo/")
 
 //#define URL_HOME                @"http://192.168.0.130:8080/MyWeb/Test"
 //#define URL_LOGIN               @"http://192.168.0.130:8080/MyWeb/Test"