Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add loading to open topic detail;

Change Topic list selected style.
  • Loading branch information...
commit 11fc16f8d808a7aa0dae9c32b466a772434a1f5a 1 parent 5e45df2
Jason Lee authored December 12, 2012
45  ruby-china-for-ios/Controllers/Components/RCTopicTableViewCell.m
@@ -14,14 +14,17 @@
14 14
 #import <SSToolkit/SSBadgeView.h>
15 15
 
16 16
 #define kTitleTextColor [UIColor colorWithRed:0.3255 green:0.3294 blue:0.3373 alpha:1.0000]
  17
+#define kTitleTextHighlightColor [UIColor colorWithRed:0.1 green:0.1 blue:0.1 alpha:1.0000]
17 18
 #define kTitleFontSize 14
  19
+
18 20
 #define kSubTextColor [UIColor colorWithRed:0.8078 green:0.8118 blue:0.8196 alpha:1.0000]
  21
+#define kSubTextHighlightColor [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0000]
19 22
 #define kSubTextFontSize 12
20 23
 
21 24
 #define kBadgeColor [UIColor colorWithRed:0.1098 green:0.4980 blue:0.8588 alpha:1.0000]
22 25
 #define kBadgeWidth 40
23 26
 
24  
-#define kBackgrounImage [UIImage imageNamed:@"tableview_cell_bg.png"]
  27
+#define kBackgroundHighlightColor [UIColor colorWithRed:0.9686 green:0.9490 blue:0.9882 alpha:1.0000]
25 28
 #define kBorderTopImage [UIImage imageNamed:@"tableview_cell_border_top.png"]
26 29
 #define kBorderBottomImage [UIImage imageNamed:@"tableview_cell_border_bottom.png"]
27 30
 
@@ -37,8 +40,7 @@ - (id) initWithTopic: (RCTopic *) aTopic forDetail:(BOOL)isForDetail {
37 40
     topic = aTopic;
38 41
     
39 42
     if (self) {
40  
-        
41  
-//        self.backgroundColor = [UIColor whiteColor];
  43
+        self.selectionStyle = UITableViewCellSelectionStyleGray;
42 44
         
43 45
         avatarImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 32, 32)];
44 46
         [avatarImageView setImageWithURL:[NSURL URLWithString:topic.user.avatarUrl] placeholderImage:[RCUser defaultAvatarImage]];
@@ -57,6 +59,7 @@ - (id) initWithTopic: (RCTopic *) aTopic forDetail:(BOOL)isForDetail {
57 59
         [titleLabel setText:topic.title];
58 60
         [titleLabel setFont:[UIFont systemFontOfSize:kTitleFontSize]];
59 61
         [titleLabel setTextColor:kTitleTextColor];
  62
+        [titleLabel setHighlightedTextColor:kTitleTextHighlightColor];
60 63
         [self.contentView addSubview:titleLabel];
61 64
         
62 65
         
@@ -68,39 +71,29 @@ - (id) initWithTopic: (RCTopic *) aTopic forDetail:(BOOL)isForDetail {
68 71
         infoLabel.backgroundColor = [UIColor clearColor];
69 72
         [infoLabel setFont:[UIFont systemFontOfSize:kSubTextFontSize]];
70 73
         [infoLabel setTextColor:kSubTextColor];
  74
+        [infoLabel setHighlightedTextColor:kSubTextHighlightColor];
71 75
         [self addSubview:infoLabel];
72 76
         
73  
-               
74  
-        if (isForDetail) {
75  
-            bodyLabel = [[UILabel alloc] initWithFrame:CGRectMake(titleLabel.frame.origin.x, infoLabel.frame.origin.y + 20, titleWidth, 14)];
76  
-            [bodyLabel setText:topic.bodyHtml];
77  
-            bodyLabel.backgroundColor = [UIColor clearColor];
78  
-            bodyLabel.font = [UIFont systemFontOfSize:13];
79  
-            bodyLabel.numberOfLines = 10;
80  
-            [bodyLabel setLineBreakMode:NSLineBreakByWordWrapping];
81  
-            bodyLabel.textAlignment = NSTextAlignmentLeft;
82  
-            [self addSubview:bodyLabel];
83  
-        }
84  
-        else {
85  
-            badgeView = [[SSBadgeView alloc] initWithFrame:CGRectMake(self.frame.size.width - kBadgeWidth - 10, 10, kBadgeWidth, 16)];
86  
-            badgeView.textLabel.text = [NSString stringWithFormat:@"%d",topic.repliesCount.intValue];
87  
-            badgeView.backgroundColor = [UIColor clearColor];
88  
-            badgeView.textLabel.font = [UIFont boldSystemFontOfSize:12.0f];
89  
-            badgeView.cornerRadius = 8;
90  
-            badgeView.badgeColor = kBadgeColor;
91  
-            badgeView.badgeAlignment = SSBadgeViewAlignmentRight;
92  
-            [self addSubview:badgeView];
93  
-        }
  77
+        badgeView = [[SSBadgeView alloc] initWithFrame:CGRectMake(self.frame.size.width - kBadgeWidth - 10, 10, kBadgeWidth, 16)];
  78
+        badgeView.textLabel.text = [NSString stringWithFormat:@"%d",topic.repliesCount.intValue];
  79
+        badgeView.backgroundColor = [UIColor clearColor];
  80
+        badgeView.textLabel.font = [UIFont boldSystemFontOfSize:12.0f];
  81
+        badgeView.cornerRadius = 8;
  82
+        badgeView.badgeColor = kBadgeColor;
  83
+        badgeView.highlightedBadgeColor = kBadgeColor;
  84
+        badgeView.textLabel.highlightedTextColor = [UIColor whiteColor];
  85
+        badgeView.badgeAlignment = SSBadgeViewAlignmentRight;
  86
+        [self addSubview:badgeView];
94 87
         
95 88
     }
96 89
     return self;
97 90
 }
98 91
 
99 92
 - (void) drawRect:(CGRect)rect {
  93
+    [super drawRect:rect];
100 94
     [kBorderTopImage drawInRect:CGRectMake(0, 0, self.frame.size.width, 1)];
101  
-    [kBackgrounImage drawInRect:CGRectMake(0, 1, self.frame.size.width, self.frame.size.height - 2)];
  95
+    //    [kBackgrounImage drawInRect:CGRectMake(0, 1, self.frame.size.width, self.frame.size.height - 2)];
102 96
     [kBorderBottomImage drawInRect:CGRectMake(0, self.frame.size.height - 1, self.frame.size.width, 1)];
103  
-    [super drawRect:rect];
104 97
 }
105 98
 
106 99
 
2  ruby-china-for-ios/Controllers/RCTopicViewController.h
@@ -9,10 +9,12 @@
9 9
 #import "RCViewController.h"
10 10
 
11 11
 @class RCTopic;
  12
+@class MBProgressHUD;
12 13
 
13 14
 @interface RCTopicViewController : RCViewController <UIWebViewDelegate>  {
14 15
     RCTopic *topic;
15 16
     IBOutlet UIWebView *webView;
  17
+    MBProgressHUD *hud;
16 18
 }
17 19
 
18 20
 + (RCTopicViewController *) sharedInstance;
19  ruby-china-for-ios/Controllers/RCTopicViewController.m
@@ -35,13 +35,13 @@ - (void)setTopic:(RCTopic *) aTopic {
35 35
 }
36 36
 
37 37
 - (void) loadRemoteInfo:(RCTopic *) aTopic {
38  
-//    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
39  
-//    hud.mode = MBProgressHUDModeIndeterminate;
40  
-//    hud.labelText = @"载入中";
  38
+    [hud show:YES];
  39
+    [self setupBlankWebView];
41 40
     [RCTopic remoteObjectWithID:aTopic.remoteID async:^(id object, NSError *error) {
42 41
         topic = object;
  42
+        sleep(2);
43 43
         [self setupWebView];
44  
-//        [hud hide:YES];
  44
+        [hud hide:YES];
45 45
     }];
46 46
     
47 47
     
@@ -50,6 +50,10 @@ - (void) loadRemoteInfo:(RCTopic *) aTopic {
50 50
 - (void)viewDidLoad {
51 51
     [super viewDidLoad];
52 52
     
  53
+    hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  54
+    hud.mode = MBProgressHUDModeIndeterminate;
  55
+    hud.labelText = @"载入中";
  56
+    
53 57
     UINavigationBar *navBar = self.navigationController.navigationBar;
54 58
     
55 59
     [navBar.backItem.backBarButtonItem setImage:[UIImage imageNamed:@"nav_back_icon"]];
@@ -58,6 +62,13 @@ - (void)viewDidLoad {
58 62
     webView.backgroundColor = [UIColor clearColor];
59 63
 }
60 64
 
  65
+- (void) setupBlankWebView {
  66
+    NSString *html = @"";
  67
+    NSString *path = [[NSBundle mainBundle] bundlePath];
  68
+    NSURL *baseURL = [NSURL fileURLWithPath:path];
  69
+    [webView loadHTMLString:html baseURL:baseURL];
  70
+}
  71
+
61 72
 - (void) setupWebView {
62 73
     NSString *html = [self readTemplate:@"topic_detail"];
63 74
     NSString *repliesTemplate = [self readTemplate:@"_replies"];

0 notes on commit 11fc16f

Please sign in to comment.
Something went wrong with that request. Please try again.