FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

调整搜索热词细节 · codingYWJ/Coding-iOS@699c6fd · GitHub

Commit 699c6fd

Browse files
committed
调整搜索热词细节
1 parent 4e5ab60 commit 699c6fd

4 files changed

Lines changed: 43 additions & 3 deletions

File tree

‎Coding_iOS/Controllers/Search/CSSearchDisplayVC.m‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#import <QuartzCore/QuartzCore.h>
1212
#import "TopicHotkeyView.h"
13+
#import "Coding_NetAPIManager.h"
1314

1415
@interface CSSearchDisplayVC ()
1516

@@ -100,9 +101,20 @@ - (void)initSubViewsInContentView {
100101
// itemView.frame = CGRectMake(12.0f, 50.0f, 100.0, 100.0f);
101102
// [_contentView addSubview:itemView];
102103

103-
TopicHotkeyView *test = [[TopicHotkeyView alloc] initWithHotkeys:@[@"我最爱的编程语言", @"coding", @"PHP", @"gopher china", @"悬赏80,000", @"Coding客户端里私信做个轮询好不好"]
104-
withFrame:CGRectMake(0.0f, 40.0f, 160.0f, 25.0f)];
105-
[_contentView addSubview:test];
104+
__weak typeof(_contentView) __contentView = _contentView;
105+
106+
[[Coding_NetAPIManager sharedManager] request_TopicHotkeyWithBlock:^(id data, NSError *error) {
107+
if(data) {
108+
NSArray *array = data;
109+
NSMutableArray *hotkeyArray = [[NSMutableArray alloc] initWithCapacity:6];
110+
for (int i = 0; i < (array.count >= 6 ? 6 : array.count); i++) {
111+
[hotkeyArray addObject:[(NSDictionary *)array[i] objectForKey:@"name"]];
112+
}
113+
114+
TopicHotkeyView *test = [[TopicHotkeyView alloc] initWithHotkeys:hotkeyArray withFrame:CGRectMake(0.0f, 40.0f, 160.0f, 25.0f)];
115+
[__contentView addSubview:test];
116+
}
117+
}];
106118
}
107119

108120
- (void)didClickedMoreHotkey:(id)sender {

‎Coding_iOS/Util/Manager/Coding_NetAPIManager.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,7 @@ typedef NS_ENUM(NSUInteger, VerifyType){
210210
- (void)request_Users_WithSearchString:(NSString *)searchStr andBlock:(void (^)(id data, NSError *error))block;
211211
- (void)request_MDHtmlStr_WithMDStr:(NSString *)mdStr inProject:(Project *)project andBlock:(void (^)(id data, NSError *error))block;
212212
- (void)request_VerifyTypeWithBlock:(void (^)(VerifyType type, NSError *error))block;
213+
214+
//Topic HotKey
215+
- (void)request_TopicHotkeyWithBlock:(void (^)(id data, NSError *error))block;
213216
@end

‎Coding_iOS/Util/Manager/Coding_NetAPIManager.m‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,4 +1946,24 @@ - (void)request_VerifyTypeWithBlock:(void (^)(VerifyType type, NSError *error))b
19461946
}
19471947
}];
19481948
}
1949+
1950+
#pragma mark -
1951+
#pragma mark Topic HotKey
1952+
1953+
- (void)request_TopicHotkeyWithBlock:(void (^)(id data, NSError *error))block {
1954+
1955+
NSString *path = @"/api/tweet_topic/hot?page=1&pageSize=20";
1956+
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:path withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
1957+
1958+
if(data) {
1959+
1960+
id resultData = [data valueForKey:@"data"];
1961+
block(resultData, nil);
1962+
}else {
1963+
1964+
block(nil, error);
1965+
}
1966+
}];
1967+
}
1968+
19491969
@end

‎Coding_iOS/Views/Search/TopicHotkeyView.m‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ - (id)initWithHotkeys:(NSArray *)hotkeys withFrame:(CGRect)frame {
7878
}
7979
}
8080

81+
if(i == hotkeys.count - 1) {
82+
83+
currentHeight += currentSize.height + 15.0f;
84+
}
85+
8186
[self addSubview:lblHotKey];
8287
currentSize = CGSizeZero;
8388
lblHotKey = nil;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL