Procházet zdrojové kódy

Recant mobile

修复自动完成显示问题,新增MDHTMLLabel 用于显示富文本。
Ray Zhang před 8 roky
rodič
revize
5b08cd9293

+ 6 - 0
RedAnt Mobile/RedAnt Mobile.xcodeproj/project.pbxproj

@@ -58,6 +58,7 @@
 		7102C1461FCD51FF0062A67A /* RAImage.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7102C1431FCD486F0062A67A /* RAImage.storyboard */; };
 		714590FE1FE36D99007FD0A4 /* CommonEditorAutoCompleteView.m in Sources */ = {isa = PBXBuildFile; fileRef = 714590FB1FE36D98007FD0A4 /* CommonEditorAutoCompleteView.m */; };
 		714590FF1FE36D99007FD0A4 /* CommonEditorAutoCompleteView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 714590FC1FE36D99007FD0A4 /* CommonEditorAutoCompleteView.xib */; };
+		714591081FEB8E68007FD0A4 /* MDHTMLLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 714591071FEB8E67007FD0A4 /* MDHTMLLabel.m */; };
 		7167802D1FCC087E00FE2784 /* BasicModeViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7167802B1FCC087E00FE2784 /* BasicModeViewController.m */; };
 		7167802F1FCC095000FE2784 /* Mode.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7167802E1FCC095000FE2784 /* Mode.storyboard */; };
 		716780321FCC095D00FE2784 /* TakePhotoPreviewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 716780311FCC095D00FE2784 /* TakePhotoPreviewController.m */; };
@@ -252,6 +253,8 @@
 		714590FB1FE36D98007FD0A4 /* CommonEditorAutoCompleteView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CommonEditorAutoCompleteView.m; path = ../../common/customUI/commoneditor/CommonEditorAutoCompleteView.m; sourceTree = "<group>"; };
 		714590FC1FE36D99007FD0A4 /* CommonEditorAutoCompleteView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = CommonEditorAutoCompleteView.xib; path = ../../common/customUI/commoneditor/CommonEditorAutoCompleteView.xib; sourceTree = "<group>"; };
 		714590FD1FE36D99007FD0A4 /* CommonEditorAutoCompleteView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommonEditorAutoCompleteView.h; path = ../../common/customUI/commoneditor/CommonEditorAutoCompleteView.h; sourceTree = "<group>"; };
+		714591061FEB8E67007FD0A4 /* MDHTMLLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MDHTMLLabel.h; path = "../../RedAnt ERP Mobile/common/customUI/MDHTMLLabel.h"; sourceTree = "<group>"; };
+		714591071FEB8E67007FD0A4 /* MDHTMLLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MDHTMLLabel.m; path = "../../RedAnt ERP Mobile/common/customUI/MDHTMLLabel.m"; sourceTree = "<group>"; };
 		7167802B1FCC087E00FE2784 /* BasicModeViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BasicModeViewController.m; path = "../../RA Image/RA Image/BasicModeViewController.m"; sourceTree = "<group>"; };
 		7167802C1FCC087E00FE2784 /* BasicModeViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BasicModeViewController.h; path = "../../RA Image/RA Image/BasicModeViewController.h"; sourceTree = "<group>"; };
 		7167802E1FCC095000FE2784 /* Mode.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Mode.storyboard; path = "../../RA Image/RA Image/Mode.storyboard"; sourceTree = "<group>"; };
@@ -1139,6 +1142,8 @@
 				71F3AA4C1F6124A2001036C8 /* TouchImageView.m */,
 				71F3AA481F612415001036C8 /* RTLabel.h */,
 				71F3AA491F612415001036C8 /* RTLabel.m */,
+				714591061FEB8E67007FD0A4 /* MDHTMLLabel.h */,
+				714591071FEB8E67007FD0A4 /* MDHTMLLabel.m */,
 			);
 			name = customUI;
 			sourceTree = "<group>";
@@ -1361,6 +1366,7 @@
 				71F3A9CD1F5FA11F001036C8 /* LoginViewController.m in Sources */,
 				71E9F6C81F8C5CCB0052C78E /* NetworkUtils.m in Sources */,
 				7167805C1FCC0D0900FE2784 /* RAUploadManager.m in Sources */,
+				714591081FEB8E68007FD0A4 /* MDHTMLLabel.m in Sources */,
 				71F3A9D01F5FA277001036C8 /* BasicViewController.m in Sources */,
 				7167802D1FCC087E00FE2784 /* BasicModeViewController.m in Sources */,
 				7197D4121FBBE1490063EFBB /* ModelDetailViewController.m in Sources */,

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

@@ -11,4 +11,5 @@
 @interface FullyShowViewController : UIViewController
 @property (weak, nonatomic) IBOutlet UITextView *textView;
 @property (strong, nonatomic)  NSString *text;
+@property (strong, nonatomic)  NSString *htmlText;
 @end

+ 11 - 1
RedAnt Mobile/RedAnt Mobile/FullyShowViewController.m

@@ -16,7 +16,17 @@
 
 - (void)viewDidLoad {
     [super viewDidLoad];
-    self.textView.text = self.text;
+    
+    
+    NSAttributedString *attributedString = [[NSAttributedString alloc]
+                                            initWithData: [self.htmlText dataUsingEncoding:NSUnicodeStringEncoding]
+                                            options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }
+                                            documentAttributes: nil
+                                            error: nil
+                                            ];
+    
+//    self.textView.text = self.text;
+    self.textView.attributedText = attributedString;
     // Do any additional setup after loading the view.
 }
 

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

@@ -8,6 +8,7 @@
 
 #import <UIKit/UIKit.h>
 //#import "TouchLabel.h"
+#import "MDHTMLLabel.h"
 @interface ResultViewController : UIViewController<UIPopoverPresentationControllerDelegate>
 @property (weak, nonatomic) IBOutlet UITableView *tableview;
 @property (weak, nonatomic) IBOutlet UIScrollView *scrollview;
@@ -15,7 +16,7 @@
 @property (strong, nonatomic) NSMutableArray* content_action;
 @property (strong, nonatomic) NSMutableDictionary* content_data;
 @property (strong, nonatomic) NSMutableArray* content_menu;
-@property (strong, nonatomic) UILabel *label;
+@property (strong, nonatomic) MDHTMLLabel *label;
 @property (strong, nonatomic) NSString *download_query;
 
 - (void)setQueryParams:(NSDictionary *)params;

+ 47 - 6
RedAnt Mobile/RedAnt Mobile/ResultViewController.m

@@ -18,6 +18,8 @@
 #import <QuickLook/QuickLook.h>
 #import "config.h"
 #import "RAConvertor.h"
+//#import "RTLabel.h"
+
 
 static const int delta = 25;
 
@@ -69,7 +71,7 @@ static const int delta = 25;
     
 //    singleFingerTwo.delegate = self;
     
-    self.label = [UILabel new];
+    self.label = [MDHTMLLabel new];
 //    NSString* Path = [[NSBundle mainBundle] pathForResource:@"layout.json" ofType:nil];
 //
 //    NSData *data = [NSData dataWithContentsOfFile:Path];
@@ -342,8 +344,8 @@ static const int delta = 25;
 {
     
     NSLog(@"label touched");
-    UILabel* label = (UILabel*)[gestureRecognizer view];
-    self.label.text = label.text;
+    MDHTMLLabel* label = (MDHTMLLabel*)[gestureRecognizer view];
+    self.label.htmlText = label.htmlText;
     [self.label sizeToFit];
     if(self.label.frame.size.width>label.frame.size.width||self.label.frame.size.height>label.frame.size.height)
     {
@@ -352,7 +354,10 @@ static const int delta = 25;
         
         
         FullyShowViewController *fullVC = [ self.storyboard instantiateViewControllerWithIdentifier:@"fullyShowViewController"];
-        fullVC.text = label.text;
+        
+        
+
+        fullVC.htmlText = label.htmlText;
         
         fullVC.preferredContentSize = CGSizeMake(200, 240);
         
@@ -485,6 +490,9 @@ static const int delta = 25;
 -(NSTextAlignment) get_TextHAlign:(NSString*)textHAlign
 {
     
+    
+    
+    
     if([textHAlign.lowercaseString isEqualToString:@"center"])
         return NSTextAlignmentCenter;
     else     if([textHAlign.lowercaseString isEqualToString:@"left"])
@@ -494,6 +502,21 @@ static const int delta = 25;
     
     return NSTextAlignmentLeft;
 }
+//-(RTTextAlignment) get_RTTextHAlign:(NSString*)textHAlign
+//{
+//    
+//    
+//
+//    
+//    if([textHAlign.lowercaseString isEqualToString:@"center"])
+//        return RTTextAlignmentCenter;
+//    else     if([textHAlign.lowercaseString isEqualToString:@"left"])
+//        return RTTextAlignmentLeft;
+//    else      if([textHAlign.lowercaseString isEqualToString:@"right"])
+//        return RTTextAlignmentRight;
+//    
+//    return RTTextAlignmentLeft;
+//}
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
     
@@ -559,11 +582,29 @@ static const int delta = 25;
 
             
             
+            
             int width = [arr_col[i][@"width"] intValue];;
-            UILabel *vallabel = [[UILabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
+            MDHTMLLabel *vallabel = [[MDHTMLLabel alloc] initWithFrame:CGRectMake(x, y, width, height)];
             vallabel.textColor=UIColorFromRGB(fcolor);//UIColor.blackColor;
             vallabel.backgroundColor = [UIColor clearColor];
-            vallabel.text=item[i];
+            
+            NSString* text=@"";
+            if(i>item.count-1)
+                text=@"row data missing";
+            else
+                text=item[i];
+            
+            
+//            RTTextLineBreakModeWordWrapping = kCTLineBreakByWordWrapping,
+//            RTTextLineBreakModeCharWrapping = kCTLineBreakByCharWrapping,
+//            RTTextLineBreakModeClip = kCTLineBreakByClipping,
+
+//            NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:text];
+            
+        
+//            vallabel.attributedText = attrStr;
+            
+            vallabel.htmlText = text;
             vallabel.textAlignment= [self get_TextHAlign:arr_col[i][@"h_align"] ];
             
             vallabel.layer.borderWidth=0.5;

+ 1 - 1
RedAnt Mobile/RedAnt Mobile/config.h

@@ -31,7 +31,7 @@
 #define PDF_DEBUG false
 
 
-//#define FAKE_DATA
+#define FAKE_DATA
 
 #define PROJ_RAMOBILE
 

+ 3 - 3
RedAnt Mobile/RedAnt Mobile/predef_query.json

@@ -31,8 +31,8 @@
     "data": {
         "count": 17,
         "item_0": [
-                   "1",
-                   "8533-UPK",
+                   "<b></b>",
+                   "<b>def</b>",
                    "$ 123.45",
                    "43",
                    "metal table with 4 chairs"
@@ -56,7 +56,7 @@
                    "8533-UVR",
                    "$ 1123.45",
                    "143",
-                   "Desk & chair UILongPressGestureRecognizer *longPress"
+                   "<b>Desk</b> & chair UILongPressGestureRecognizer *longPress"
                    ],
         "item_4": [
                    "1",