Просмотр исходного кода

1.修改iOS Apex Mobile Home和History,增加Transport Stage。
2.修改iOS Apex Mobile Save Document,增加Email保存。

Pen Li 8 лет назад
Родитель
Сommit
a1bee2b0ce

+ 19 - 2
Apex Mobile/Apex Mobile/AMResultViewController.m

@@ -20,6 +20,9 @@
 
 @property (nonatomic,assign) BOOL dirty;
 @property (nonatomic,strong) UIDocumentInteractionController *documentController;
+@property (nonatomic,copy) NSString *email;
+@property (nonatomic,copy) NSString *email_subject;
+@property (nonatomic,copy) NSString *email_content;
 
 @end
 
@@ -237,8 +240,9 @@
 
     
     NSString* URL =action[@"url"];
-//    URL = @"http://192.168.0.130/lantern-installer.apk";
-//    params = nil;
+    self.email = params[@"email"];
+    self.email_subject = params[@"email_subject"];
+    self.email_content = params[@"email_content"];
     
     NSString *module_name = [self.params objectForKey:@"module_name"];
     __weak typeof(self) weakSelf = self;
@@ -543,9 +547,21 @@
 
 - (void)saveDocument {
     
+    NSMutableDictionary *emailInfo = [NSMutableDictionary dictionaryWithCapacity:3];
+    if (self.email) {
+        [emailInfo setValue:self.email forKey:@"reciptions"];
+    }
+    if (self.email_subject) {
+        [emailInfo setValue:self.email_subject forKey:@"subject"];
+    }
+    if (self.email_content) {
+        [emailInfo setValue:self.email_content forKey:@"content"];
+    }
+    
     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
     NSString *path = [paths objectAtIndex:0];
     NSString *filePath = [path stringByAppendingPathComponent:[self.documentPath lastPathComponent]];
+    NSString *emailPath = [path stringByAppendingPathComponent:[NSString stringWithFormat:@".%@",[[self.documentPath stringByDeletingPathExtension] lastPathComponent]]];
     
     NSError *err;
     
@@ -553,6 +569,7 @@
         [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil];
     }
     [[NSFileManager defaultManager] moveItemAtPath:self.documentPath toPath:filePath error:&err];
+    [emailInfo writeToFile:emailPath atomically:NO];
     
     UIAlertController *alertVC;
     UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

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

@@ -212,8 +212,9 @@
     NSString *detail = [item objectForKey:@"detail"];
     NSString *date = [item objectForKey:@"date"];
     NSString *port = [item objectForKey:@"port"];
+    NSInteger stage = [[item objectForKey:@"transport_stage"] integerValue];
     
-    [[[[[[cell setTitle:title] setDescription:desc] setDetail:detail] setPort:port] setTime:date] setIcon:icon];
+    [[[[[[[cell setTitle:title] setDescription:desc] setDetail:detail] setPort:port] setTime:date] setIcon:icon] setTransportStage:stage];
     
     return cell;
 }

+ 57 - 8
Apex Mobile/Apex Mobile/LocalDocumentsViewController.m

@@ -7,12 +7,14 @@
 //
 
 #import "LocalDocumentsViewController.h"
-#import <QuickLook/QuickLook.h>
+#import "MyQLPreviewController.h"
 
-@interface LocalDocumentsViewController () <QLPreviewControllerDelegate,QLPreviewControllerDataSource>
+@interface LocalDocumentsViewController () <QLPreviewControllerDelegate,QLPreviewControllerDataSource,UIDocumentInteractionControllerDelegate>
 
-@property (nonatomic,strong) QLPreviewController *quickLook;
+@property (nonatomic,strong) MyQLPreviewController *quickLook;
 @property (nonatomic,copy) NSString *selectedDocumentPath;
+@property (nonatomic,strong) UIDocumentInteractionController *documentController;
+
 
 @end
 
@@ -126,11 +128,11 @@
     NSString *filename;
     while (filename = [direnum nextObject])
     {
-        if ([[filename pathExtension] isEqualToString:@"pdf"])
-        {
+//        if ([[filename pathExtension] isEqualToString:@"pdf"])
+//        {
             NSString *filePath = [path stringByAppendingPathComponent:filename];
             [manager removeItemAtPath:filePath error:nil];
-        }
+//        }
     }
     [self.toolsinfo removeAllObjects];
     [self.tableview reloadData];
@@ -247,6 +249,9 @@
             [tableView reloadData];
         }
         
+        NSString *emailPath = [self emailPathForFile:filePath];
+        [[NSFileManager defaultManager] removeItemAtPath:emailPath error:nil];
+        
     }];
     
     return @[delete];
@@ -331,14 +336,58 @@
     return self.view;
 }
 
+#pragma mark - Share
+
+- (void)shareClick:(id)sender {
+    [self shareDocument];
+}
+
+- (void)shareDocument {
+    
+    NSString *filePath = self.selectedDocumentPath;
+    NSString *emailPath = [self emailPathForFile:filePath];
+    
+    NSURL *fileURL = [NSURL fileURLWithPath:filePath];
+    
+    if (self.documentController == nil) {
+        UIDocumentInteractionController *documentController = [UIDocumentInteractionController interactionControllerWithURL:fileURL];
+        documentController.delegate = self;
+        documentController.UTI = @"com.adobe.pdf";
+        self.documentController = documentController;
+    } else {
+        self.documentController.URL = fileURL;
+    }
+    self.documentController.annotation = @{@"_toRecipients" : @[@"676034647@qq.com"]};
+    self.documentController.name = @"Test";
+    
+    //    [self.documentController presentOpenInMenuFromRect:self.navigationController.topViewController.view.bounds
+    //                                                inView:self.navigationController.topViewController.view
+    //                                              animated:YES];
+    
+    [self.documentController presentOptionsMenuFromRect:self.navigationController.topViewController.view.bounds
+                                                 inView:self.navigationController.topViewController.view
+                                               animated:YES];
+}
+
+- (NSString *)emailPathForFile:(NSString *)file {
+    if (file == nil) {
+        return nil;
+    }
+    NSString *fileName = [file lastPathComponent];
+    NSString *emailPath = [[file stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@".%@",fileName]];
+    return emailPath;
+}
+
 #pragma mark - Quick Look
 
-- (QLPreviewController *)quickLook {
+- (MyQLPreviewController *)quickLook {
     if (!_quickLook)
     {
-        _quickLook = [[QLPreviewController alloc] init];
+        _quickLook = [[MyQLPreviewController alloc] init];
         _quickLook.delegate = self;
         _quickLook.dataSource = self;
+        UIBarButtonItem *shareBtn = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"ic_share_new"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(shareClick:)];
+        _quickLook.navigationItem.rightBarButtonItem = shareBtn;
     }
     else
     {

+ 23 - 0
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_share_new.imageset/Contents.json

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

BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_share_new.imageset/ic_share_new.png


BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_share_new.imageset/ic_share_new@2x.png


BIN
Apex Mobile/Apex Mobile/NewImages.xcassets/ic_share_new.imageset/ic_share_new@3x.png


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

@@ -232,8 +232,9 @@ static const int history_delta = 7;
     NSString *detail = [item objectForKey:@"detail"];
     NSString *date = [item objectForKey:@"date"];
     NSString *port = [item objectForKey:@"port"];
+    NSInteger stage = [[item objectForKey:@"transport_stage"] integerValue];
     
-    [[[[[[cell setTitle:title] setDescription:desc] setDetail:detail] setPort:port] setTime:date] setIcon:icon];
+    [[[[[[[cell setTitle:title] setDescription:desc] setDetail:detail] setPort:port] setTime:date] setIcon:icon] setTransportStage:stage];
     
     return cell;
 }

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

@@ -16,5 +16,6 @@
 - (instancetype)setDescription:(NSString *)desc;
 - (instancetype)setDetail:(NSString *)detail;
 - (instancetype)setIcon:(NSString *)icon;
+- (instancetype)setTransportStage:(NSInteger)stage;
 
 @end

+ 32 - 0
Apex Mobile/Apex Mobile/ShipingStatusCell.m

@@ -17,6 +17,7 @@
 @property (strong, nonatomic) IBOutlet UIImageView *iconView;
 @property (strong, nonatomic) IBOutlet UILabel *descLabel;
 @property (strong, nonatomic) IBOutlet UILabel *detailLabel;
+@property (strong, nonatomic) IBOutlet UIView *transportStageView;
 
 @property (nonatomic,strong) NSOperation *operation;
 @property (nonatomic,strong) NSOperationQueue *queue;
@@ -132,6 +133,37 @@
     return self;
 }
 
+- (instancetype)setTransportStage:(NSInteger)stage {
+    
+    UIColor *stageColor;
+    switch (stage) {
+        case 0: {
+            stageColor = [UIColor colorWithRed:0.2 green:0.14 blue:0.12 alpha:1.0];
+        }
+            break;
+        case 1: {
+            stageColor = [UIColor colorWithRed:0.13 green:0.8 blue:0.8 alpha:1.0];
+        }
+            break;
+        case 2: {
+            stageColor = [UIColor colorWithRed:0.25 green:0.13 blue:0.64 alpha:1.0];
+        }
+            break;
+        case 3: {
+            stageColor = [UIColor colorWithRed:8 / 255.0 green:115 / 255.0 blue:3 / 255.0 alpha:1.0];
+        }
+            break;
+        default: {
+            stageColor = [UIColor colorWithRed:0.2 green:0.14 blue:0.12 alpha:1.0];
+        }
+            break;
+    }
+    
+    self.transportStageView.backgroundColor = stageColor;
+    
+    return self;
+}
+
 - (void)prepareForReuse {
     [super prepareForReuse];
     

+ 2 - 1
Apex Mobile/Apex Mobile/ShippingStatusCell.xib

@@ -49,7 +49,7 @@
                         <nil key="textColor"/>
                         <nil key="highlightedColor"/>
                     </label>
-                    <view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="n0i-nd-KME">
+                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="n0i-nd-KME">
                         <rect key="frame" x="370" y="0.0" width="5" height="110"/>
                         <color key="backgroundColor" red="0.0" green="0.56031829119999998" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                         <constraints>
@@ -101,6 +101,7 @@
                 <outlet property="portLabel" destination="X99-0j-XQm" id="vMo-sm-Ghw"/>
                 <outlet property="timeLabel" destination="A9v-MV-LqP" id="7Br-4s-QfR"/>
                 <outlet property="titleLabel" destination="NSI-Dy-9wQ" id="t3H-5x-9f7"/>
+                <outlet property="transportStageView" destination="n0i-nd-KME" id="uGm-fd-a0a"/>
             </connections>
             <point key="canvasLocation" x="195.5" y="-336"/>
         </tableViewCell>