Explorar el Código

Redant Mobile 修改结果界面数据结构
结果界面右上按钮改为菜单按钮

Ray Zhang hace 8 años
padre
commit
8c3806eacb

+ 1 - 0
RedAnt Mobile/RedAnt Mobile/ResultViewController.h

@@ -14,6 +14,7 @@
 @property (strong, nonatomic) NSMutableDictionary* content_layout;
 @property (strong, nonatomic) NSMutableDictionary* content_action;
 @property (strong, nonatomic) NSMutableDictionary* content_data;
+@property (strong, nonatomic) NSMutableArray* content_menu;
 @property (strong, nonatomic) UILabel *label;
 @property (strong, nonatomic) NSString *download_query;
 

+ 34 - 4
RedAnt Mobile/RedAnt Mobile/ResultViewController.m

@@ -429,10 +429,39 @@ static const int delta = 25;
 }
 
 - (void)setupNavigationBar {
-    UIBarButtonItem *downloadItem = [[UIBarButtonItem alloc] initWithTitle:@"Download" style:UIBarButtonItemStylePlain target:self action:@selector(downloadItemClick:)];
-    self.navigationItem.rightBarButtonItem = downloadItem;
+    UIBarButtonItem *menuItem = [[UIBarButtonItem alloc] initWithTitle:@"Menu" style:UIBarButtonItemStylePlain target:self action:@selector(MenuClick:)];
+    self.navigationItem.rightBarButtonItem = menuItem;
+}
+- (void)MenuClick:(UIBarButtonItem *)sender {
+    
+    UIAlertController *alertControl = [UIAlertController alertControllerWithTitle:@"Menu" message:nil preferredStyle:UIAlertControllerStyleAlert];
+    //block代码块取代了delegate
+    
+    
+    for(int i=0;i<self.content_menu.count;i++)
+    {
+        NSMutableDictionary* json = self.content_menu[i];
+        NSString* title =json[@"title"];
+        NSString* actiontype = json[@"action"];
+        NSMutableDictionary* add_params = json[@"params"];
+        UIAlertAction *actioni = [UIAlertAction actionWithTitle:title style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+            // DebugLog(@"Cancel");
+            if([actiontype isEqualToString:@"download"])
+            {
+            }
+            else if([actiontype isEqualToString:@"save"])
+            {
+            }
+        }];
+        [alertControl addAction:actioni];
+    }
+    
+  
+    
+    
+    
+    [self presentViewController:alertControl animated:YES completion:nil];
 }
-
 - (void)downloadItemClick:(UIBarButtonItem *)sender {
     
     
@@ -501,7 +530,8 @@ static const int delta = 25;
                     __strong typeof(weakSelf) strongSelf = weakSelf;
                     if (result == RESULT_TRUE) {
                         strongSelf.content_layout = [contentDic objectForKey:@"layout"];
-                        strongSelf.content_action = [contentDic objectForKey:@"action"];
+                        strongSelf.content_action = [contentDic objectForKey:@"row_action"];
+                        strongSelf.content_menu = [[contentDic objectForKey:@"menu"] mutableCopy];
                         strongSelf.content_data = [contentDic objectForKey:@"data"];
                         [strongSelf updateTableFrame];
                         [strongSelf.tableview reloadData];

+ 71 - 52
RedAnt Mobile/RedAnt Mobile/predef_query.json

@@ -1,12 +1,31 @@
 {
     "result": 2,
-    "action":{
-        "title":"demo title",
-        "module":"quick_look",
-        "url":"http://1.1.1.1",
-        "params":{
-            "order#":0
-            
+    "menu": [
+             {
+             "title": "Export 1",
+             "action": "download",
+             "params": {
+             "download#": 1
+             }
+             },
+             {
+             "title": "Export 2",
+             "action": "download",
+             "params": {
+             "download#": 2
+             }
+             },
+             {
+             "title": "Save",
+             "action": "save"
+             }
+             ],
+    "row_action": {
+        "title": "demo title",
+        "module": "quick_look",
+        "url": "http://1.1.1.1",
+        "params": {
+            "order#": 0
         }
     },
     "data": {
@@ -82,54 +101,54 @@
                    "WOOD table with 4 chairs"
                    ],
         "item_10": [
-                   "3",
-                   "7033566",
-                   "$ 13.45",
-                   "57",
-                   "bed"
+                    "3",
+                    "7033566",
+                    "$ 13.45",
+                    "57",
+                    "bed"
                     ],
         "item_11": [
-                   "1",
-                   "8533-UPK",
-                   "$ 123.45",
-                   "43",
-                   "metal table with 4 chairs"
-                   ],
+                    "1",
+                    "8533-UPK",
+                    "$ 123.45",
+                    "43",
+                    "metal table with 4 chairs"
+                    ],
         "item_12": [
-                   "2",
-                   "315318",
-                   "$ 99.49",
-                   "13",
-                   "WOOD table with 4 chairs"
-                   ],
+                    "2",
+                    "315318",
+                    "$ 99.49",
+                    "13",
+                    "WOOD table with 4 chairs"
+                    ],
         "item_13": [
-                   "3",
-                   "7033566",
-                   "$ 13.45",
-                   "57",
-                   "bed"
+                    "3",
+                    "7033566",
+                    "$ 13.45",
+                    "57",
+                    "bed"
                     ],
         "item_14": [
-                   "1",
-                   "8533-UPK",
-                   "$ 123.45",
-                   "43",
-                   "metal table with 4 chairs"
-                   ],
+                    "1",
+                    "8533-UPK",
+                    "$ 123.45",
+                    "43",
+                    "metal table with 4 chairs"
+                    ],
         "item_15": [
-                   "2",
-                   "315318",
-                   "$ 99.49",
-                   "13",
-                   "WOOD table with 4 chairs"
-                   ],
+                    "2",
+                    "315318",
+                    "$ 99.49",
+                    "13",
+                    "WOOD table with 4 chairs"
+                    ],
         "item_16": [
-                   "3",
-                   "7033566",
-                   "$ 13.45",
-                   "57",
-                   "bed"
-                   ]
+                    "3",
+                    "7033566",
+                    "$ 13.45",
+                    "57",
+                    "bed"
+                    ]
     },
     "layout": {
         "header": {
@@ -191,35 +210,35 @@
             "color_1": "0x666666",
             "val": [
                     {
-                    "type":"image",
+                    "type": "image",
                     "h_align": "center",
                     "v_center": "center",
                     "bg_color": "0x123456",
                     "f_color": "0x654321"
                     },
                     {
-                    "type":"text",
+                    "type": "text",
                     "h_align": "center",
                     "v_center": "center",
                     "bg_color": "0x123456",
                     "f_color": "0x654321"
                     },
                     {
-                    "type":"text",
+                    "type": "text",
                     "h_align": "center",
                     "v_center": "center",
                     "bg_color": "0x123456",
                     "f_color": "0x654321"
                     },
                     {
-                    "type":"text",
+                    "type": "text",
                     "h_align": "center",
                     "v_center": "center",
                     "bg_color": "0x123456",
                     "f_color": "0x654321"
                     },
                     {
-                    "type":"text",
+                    "type": "text",
                     "h_align": "center",
                     "v_center": "center",
                     "bg_color": "0x123456",