فهرست منبع

1.修改iOS Apex Drivers Order Detail Action。

Pen Li 7 سال پیش
والد
کامیت
d6375748d0

+ 31 - 2
Redant Drivers/Apex And Drivers/Detail/Action Selection/RADetailActionSelectionViewController+TableDelegate.m

@@ -17,11 +17,40 @@
 
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     
+    RADetailActionSelectionModel *model = [self.actions objectAtIndex:indexPath.row];
+    
+    if (indexPath.row != 0) {
+        
+        RADetailActionSelectionModel *currentModel = [self.actions objectAtIndex:0];
+        
+        NSString *msg = [NSString stringWithFormat:@"the %@ is not done,are you sure to update %@ now?",currentModel.actionTitle,model.actionTitle];
+        
+        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Warning" message:msg preferredStyle:UIAlertControllerStyleAlert];
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+        }];
+        
+        UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
+            [self dismissForAction:model];
+        }];
+        
+        [alertVC addAction:cancelAction];
+        [alertVC addAction:sureAction];
+        
+        [self presentViewController:alertVC animated:YES completion:nil];
+        
+    } else {
+        [self dismissForAction:model];
+    }
+}
+
+- (void)dismissForAction:(RADetailActionSelectionModel *)action {
+    
     [self dismissViewControllerAnimated:NO completion:^{
         
         if (self.delegate && [self.delegate respondsToSelector:@selector(detailSelectAction:)]) {
-            RADetailActionSelectionModel *model = [self.actions objectAtIndex:indexPath.row];
-            [self.delegate detailSelectAction:model];
+            
+            [self.delegate detailSelectAction:action];
         }
     }];
 }

+ 15 - 4
Redant Drivers/Apex And Drivers/Detail/Model/Collection/RADetailActionModel.h

@@ -17,7 +17,8 @@ typedef enum {
     RADetailActionSubTypeEnum = 0,
     RADetailActionSubTypeAccept = 1,
     RADetailActionSubTypeReject = 2,
-    RADetailActionSubTypeOther = 3
+    RADetailActionSubTypeUpdate = 3,
+    RADetailActionSubTypeOther = 4
 } RADetailActionSubType;
 
 @class RADetailActionSelectionModel;
@@ -27,13 +28,23 @@ typedef enum {
 @property (nonatomic,assign) RADetailActionSubType actionSubType;
 @property (nonatomic,copy) NSString *actionTitle;
 
+#pragma mark - actionType == RADetailActionTypeRemote
+
+@property (nonatomic,copy) NSString *url;///<
+@property (nonatomic,strong) NSMutableDictionary *params;///<
+
 #pragma mark - actionType == RADetailActionTypeLocal && actionSubType == RADetailActionSubTypeEnum
 
 @property (nonatomic,strong,readonly) NSArray <RADetailActionSelectionModel *> *enums;///<
 
-#pragma mark - actionType == RADetailActionTypeRemote
+#pragma mark - actionType == RADetailActionTypeLocal && actionSubType == RADetailActionSubTypeUpdate
 
-@property (nonatomic,copy) NSString *url;///<
-@property (nonatomic,strong) NSMutableDictionary *params;///<
+@property (nonatomic,assign) NSInteger actionID;///<
+
+#pragma mark - Alert
+
+@property (nonatomic,assign) BOOL alert;
+@property (nonatomic,copy) NSString *alertTitle;
+@property (nonatomic,copy) NSString *alertMsg;
 
 @end

+ 43 - 0
Redant Drivers/Apex And Drivers/Detail/RAOrderDetailViewController+TableViewDataSource.m

@@ -139,6 +139,29 @@
 #pragma mark - Action Delegate
 
 - (void)actionsCell:(RADetailActionsCell *)cell didClickSubCell:(RADetailActionSubCell *)subCell forModel:(RADetailActionModel *)model {
+    
+    if (model.alert) {
+        
+        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:model.alertTitle message:model.alertMsg preferredStyle:UIAlertControllerStyleAlert];
+        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+        }];
+        UIAlertAction *yesAction = [UIAlertAction actionWithTitle:@"YES" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            [self handleActionForModel:model withSubCell:subCell];
+        }];
+        
+        [alertVC addAction:cancelAction];
+        [alertVC addAction:yesAction];
+        
+        [self presentViewController:alertVC animated:YES completion:nil];
+        
+    } else {
+        [self handleActionForModel:model withSubCell:subCell];
+    }
+}
+
+- (void)handleActionForModel:(RADetailActionModel *)model withSubCell:(RADetailActionSubCell *)subCell {
+    
     switch (model.actionType) {
         case RADetailActionTypeRemote: {
             [self handleRemoteAction:model];
@@ -151,6 +174,10 @@
                     [self handleEnumAction:model forCell:subCell];
                 }
                     break;
+                case RADetailActionSubTypeUpdate: {
+                    [self showUpdateForModel:model];
+                }
+                    break;
                     
                 default:
                     break;
@@ -219,6 +246,22 @@
     });
 }
 
+- (void)showUpdateForModel:(RADetailActionModel *)model {
+    if (model.actionSubType != RADetailActionSubTypeUpdate) {
+        return;
+    }
+    
+    RAOrderEditViewController *vc = [RAOrderEditViewController viewControllerFromStoryboard];
+    
+    vc.title = model.actionTitle;
+    vc.orderID = self.orderID;
+    vc.actionID = model.actionID;
+    vc.actionTitle = model.actionTitle;
+    vc.orderType2 = self.orderType2;
+    [self.navigationController pushViewController:vc animated:YES];
+    
+}
+
 #pragma mark - Popover Delegate
 
 -(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller{