Commit fa0d79042ba477b64ae35b840e693f95feffb751
1 parent
c5b45f2062
Exists in
master
and in
1 other branch
Add search group screen and API search group
Showing 17 changed files with 565 additions and 9 deletions Side-by-side Diff
- LifeLog/LifeLog.xcodeproj/project.pbxproj
- LifeLog/LifeLog/Entities.h
- LifeLog/LifeLog/GroupObject.h
- LifeLog/LifeLog/GroupObject.m
- LifeLog/LifeLog/Localizable.strings
- LifeLog/LifeLog/SNSViewController.h
- LifeLog/LifeLog/SNSViewController.m
- LifeLog/LifeLog/SNSViewController.xib
- LifeLog/LifeLog/SearchGroupTableViewCell.h
- LifeLog/LifeLog/SearchGroupTableViewCell.m
- LifeLog/LifeLog/SearchGroupTableViewCell.xib
- LifeLog/LifeLog/SearchGroupViewController.h
- LifeLog/LifeLog/SearchGroupViewController.m
- LifeLog/LifeLog/SearchGroupViewController.xib
- LifeLog/LifeLog/ServerAPI.h
- LifeLog/LifeLog/ServerAPI.m
- LifeLog/LifeLog/TweetObject.m
LifeLog/LifeLog.xcodeproj/project.pbxproj
| ... | ... | @@ -44,6 +44,11 @@ |
| 44 | 44 | 9CBDA0FA1F2ECE2C0055DED1 /* BaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CBDA0F91F2ECE2C0055DED1 /* BaseViewController.m */; }; |
| 45 | 45 | 9CBDA0FF1F2F03810055DED1 /* RegisterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CBDA0FD1F2F03810055DED1 /* RegisterViewController.m */; }; |
| 46 | 46 | 9CBDA1001F2F03810055DED1 /* RegisterViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9CBDA0FE1F2F03810055DED1 /* RegisterViewController.xib */; }; |
| 47 | + E933E66B1F3E04A6002926F5 /* SearchGroupViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E933E6691F3E04A6002926F5 /* SearchGroupViewController.m */; }; | |
| 48 | + E933E66C1F3E04A6002926F5 /* SearchGroupViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E933E66A1F3E04A6002926F5 /* SearchGroupViewController.xib */; }; | |
| 49 | + E933E6701F3E09B6002926F5 /* SearchGroupTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E933E66E1F3E09B6002926F5 /* SearchGroupTableViewCell.m */; }; | |
| 50 | + E933E6711F3E09B6002926F5 /* SearchGroupTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E933E66F1F3E09B6002926F5 /* SearchGroupTableViewCell.xib */; }; | |
| 51 | + E933E6741F3E0E4E002926F5 /* GroupObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E933E6731F3E0E4E002926F5 /* GroupObject.m */; }; | |
| 47 | 52 | E9373E471F3596940059355A /* AutoTransLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = E9373E461F3596940059355A /* AutoTransLabel.m */; }; |
| 48 | 53 | E9373E4A1F35AA180059355A /* HistoryObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E9373E491F35AA180059355A /* HistoryObject.m */; }; |
| 49 | 54 | E9373E4D1F361A230059355A /* HistoryGraphObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E9373E4C1F361A230059355A /* HistoryGraphObject.m */; }; |
| ... | ... | @@ -148,6 +153,14 @@ |
| 148 | 153 | 9CBDA0FC1F2F03810055DED1 /* RegisterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterViewController.h; sourceTree = "<group>"; }; |
| 149 | 154 | 9CBDA0FD1F2F03810055DED1 /* RegisterViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RegisterViewController.m; sourceTree = "<group>"; }; |
| 150 | 155 | 9CBDA0FE1F2F03810055DED1 /* RegisterViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RegisterViewController.xib; sourceTree = "<group>"; }; |
| 156 | + E933E6681F3E04A6002926F5 /* SearchGroupViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchGroupViewController.h; sourceTree = "<group>"; }; | |
| 157 | + E933E6691F3E04A6002926F5 /* SearchGroupViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchGroupViewController.m; sourceTree = "<group>"; }; | |
| 158 | + E933E66A1F3E04A6002926F5 /* SearchGroupViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SearchGroupViewController.xib; sourceTree = "<group>"; }; | |
| 159 | + E933E66D1F3E09B6002926F5 /* SearchGroupTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SearchGroupTableViewCell.h; sourceTree = "<group>"; }; | |
| 160 | + E933E66E1F3E09B6002926F5 /* SearchGroupTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SearchGroupTableViewCell.m; sourceTree = "<group>"; }; | |
| 161 | + E933E66F1F3E09B6002926F5 /* SearchGroupTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SearchGroupTableViewCell.xib; sourceTree = "<group>"; }; | |
| 162 | + E933E6721F3E0E4E002926F5 /* GroupObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GroupObject.h; sourceTree = "<group>"; }; | |
| 163 | + E933E6731F3E0E4E002926F5 /* GroupObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GroupObject.m; sourceTree = "<group>"; }; | |
| 151 | 164 | E9373E451F3596940059355A /* AutoTransLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoTransLabel.h; sourceTree = "<group>"; }; |
| 152 | 165 | E9373E461F3596940059355A /* AutoTransLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AutoTransLabel.m; sourceTree = "<group>"; }; |
| 153 | 166 | E9373E481F35AA180059355A /* HistoryObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HistoryObject.h; sourceTree = "<group>"; }; |
| ... | ... | @@ -246,6 +259,8 @@ |
| 246 | 259 | E9373E4C1F361A230059355A /* HistoryGraphObject.m */, |
| 247 | 260 | E9D9091F1F3D559D004CF99F /* TweetObject.h */, |
| 248 | 261 | E9D909201F3D559D004CF99F /* TweetObject.m */, |
| 262 | + E933E6721F3E0E4E002926F5 /* GroupObject.h */, | |
| 263 | + E933E6731F3E0E4E002926F5 /* GroupObject.m */, | |
| 249 | 264 | ); |
| 250 | 265 | name = Model; |
| 251 | 266 | sourceTree = "<group>"; |
| ... | ... | @@ -395,6 +410,7 @@ |
| 395 | 410 | 6E84E3AC1F27A954001EB88E /* SNS */ = { |
| 396 | 411 | isa = PBXGroup; |
| 397 | 412 | children = ( |
| 413 | + E933E6671F3E0479002926F5 /* SeachGroup */, | |
| 398 | 414 | 6E84E3BC1F27A9B1001EB88E /* SNSViewController.h */, |
| 399 | 415 | 6E84E3BD1F27A9B1001EB88E /* SNSViewController.m */, |
| 400 | 416 | 6E84E3BE1F27A9B1001EB88E /* SNSViewController.xib */, |
| ... | ... | @@ -497,6 +513,19 @@ |
| 497 | 513 | name = Pods; |
| 498 | 514 | sourceTree = "<group>"; |
| 499 | 515 | }; |
| 516 | + E933E6671F3E0479002926F5 /* SeachGroup */ = { | |
| 517 | + isa = PBXGroup; | |
| 518 | + children = ( | |
| 519 | + E933E6681F3E04A6002926F5 /* SearchGroupViewController.h */, | |
| 520 | + E933E6691F3E04A6002926F5 /* SearchGroupViewController.m */, | |
| 521 | + E933E66A1F3E04A6002926F5 /* SearchGroupViewController.xib */, | |
| 522 | + E933E66D1F3E09B6002926F5 /* SearchGroupTableViewCell.h */, | |
| 523 | + E933E66E1F3E09B6002926F5 /* SearchGroupTableViewCell.m */, | |
| 524 | + E933E66F1F3E09B6002926F5 /* SearchGroupTableViewCell.xib */, | |
| 525 | + ); | |
| 526 | + name = SeachGroup; | |
| 527 | + sourceTree = "<group>"; | |
| 528 | + }; | |
| 500 | 529 | E9373E441F35966D0059355A /* AutoTranslateView */ = { |
| 501 | 530 | isa = PBXGroup; |
| 502 | 531 | children = ( |
| ... | ... | @@ -647,6 +676,7 @@ |
| 647 | 676 | 9CA8AEEB1F31BB4600C5FC74 /* ConfirmForgetPassViewController.xib in Resources */, |
| 648 | 677 | 6E84E3C01F27A9B1001EB88E /* SNSViewController.xib in Resources */, |
| 649 | 678 | E9682E2F1F39675A00FE05A2 /* RankingTableViewCell.xib in Resources */, |
| 679 | + E933E6711F3E09B6002926F5 /* SearchGroupTableViewCell.xib in Resources */, | |
| 650 | 680 | 6E8DA0F81F2BAC3500CCE941 /* TodayViewController.xib in Resources */, |
| 651 | 681 | 6E84E3841F27A701001EB88E /* LaunchScreen.storyboard in Resources */, |
| 652 | 682 | 6E84E3811F27A701001EB88E /* Assets.xcassets in Resources */, |
| ... | ... | @@ -654,6 +684,7 @@ |
| 654 | 684 | 6EF1630A1F29069300DA306C /* Localizable.strings in Resources */, |
| 655 | 685 | 6E84E3B11F27A975001EB88E /* HomeViewController.xib in Resources */, |
| 656 | 686 | 6E84E3B61F27A98B001EB88E /* HistoryViewController.xib in Resources */, |
| 687 | + E933E66C1F3E04A6002926F5 /* SearchGroupViewController.xib in Resources */, | |
| 657 | 688 | E96855121F3C5D9A00317CEF /* SNSRecentTopicTableViewCell.xib in Resources */, |
| 658 | 689 | E99E13B21F33720600C78787 /* LabelCollectionViewCell.xib in Resources */, |
| 659 | 690 | E9F73DCD1F338A0F004A3A6F /* HistoryListTableViewCell.xib in Resources */, |
| ... | ... | @@ -733,6 +764,7 @@ |
| 733 | 764 | 6E7F93431F35872B00EFBC71 /* TPKeyboardAvoidingScrollView.m in Sources */, |
| 734 | 765 | 6E7F93421F35872B00EFBC71 /* TPKeyboardAvoidingCollectionView.m in Sources */, |
| 735 | 766 | E968550A1F3C444900317CEF /* AutoTransButton.m in Sources */, |
| 767 | + E933E6741F3E0E4E002926F5 /* GroupObject.m in Sources */, | |
| 736 | 768 | 9CBDA0FA1F2ECE2C0055DED1 /* BaseViewController.m in Sources */, |
| 737 | 769 | 6E8DA0F71F2BAC3400CCE941 /* TodayViewController.m in Sources */, |
| 738 | 770 | 6E7F93451F35872B00EFBC71 /* UIScrollView+TPKeyboardAvoidingAdditions.m in Sources */, |
| 739 | 771 | |
| ... | ... | @@ -759,8 +791,10 @@ |
| 759 | 791 | 6E18CED31F2E39DB0029891F /* LoginViewController.m in Sources */, |
| 760 | 792 | E9D909241F3D6E8C004CF99F /* BaseTableViewController.m in Sources */, |
| 761 | 793 | 6E84E3761F27A701001EB88E /* main.m in Sources */, |
| 794 | + E933E6701F3E09B6002926F5 /* SearchGroupTableViewCell.m in Sources */, | |
| 762 | 795 | 6E84E3B51F27A98B001EB88E /* HistoryViewController.m in Sources */, |
| 763 | 796 | E9373E4D1F361A230059355A /* HistoryGraphObject.m in Sources */, |
| 797 | + E933E66B1F3E04A6002926F5 /* SearchGroupViewController.m in Sources */, | |
| 764 | 798 | 6E84E3BF1F27A9B1001EB88E /* SNSViewController.m in Sources */, |
| 765 | 799 | ); |
| 766 | 800 | runOnlyForDeploymentPostprocessing = 0; |
LifeLog/LifeLog/Entities.h
LifeLog/LifeLog/GroupObject.h
| 1 | +// | |
| 2 | +// GroupObject.h | |
| 3 | +// LifeLog | |
| 4 | +// | |
| 5 | +// Created by nvtu on 8/11/17. | |
| 6 | +// Copyright ยฉ 2017 PhongNV. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <Foundation/Foundation.h> | |
| 10 | + | |
| 11 | +@interface GroupObject : NSObject | |
| 12 | + | |
| 13 | +@property (nonatomic) int groupID; | |
| 14 | +@property (nonatomic) int numSearch; | |
| 15 | + | |
| 16 | +@property (nonatomic) BOOL walkMode; | |
| 17 | +@property (nonatomic) BOOL runMode; | |
| 18 | +@property (nonatomic) BOOL bikeMode; | |
| 19 | +@property (nonatomic) BOOL stepMode; | |
| 20 | +@property (nonatomic) BOOL gymMode; | |
| 21 | +@property (nonatomic) BOOL beginMode; | |
| 22 | + | |
| 23 | +@property (nonatomic, strong) NSString * name; | |
| 24 | +@property (nonatomic, strong) NSString * avatar; | |
| 25 | +@property (nonatomic, strong) NSDate * createDate; | |
| 26 | + | |
| 27 | +-(id) initWithData : (NSDictionary *) dict; | |
| 28 | + | |
| 29 | +@end |
LifeLog/LifeLog/GroupObject.m
| 1 | +// | |
| 2 | +// GroupObject.m | |
| 3 | +// LifeLog | |
| 4 | +// | |
| 5 | +// Created by nvtu on 8/11/17. | |
| 6 | +// Copyright ยฉ 2017 PhongNV. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "GroupObject.h" | |
| 10 | +#import "Utilities.h" | |
| 11 | + | |
| 12 | +@implementation GroupObject | |
| 13 | + | |
| 14 | +-(id) initWithData : (NSDictionary *) dict { | |
| 15 | + if([dict objectForKey:@"group_id"] != nil) { | |
| 16 | + self.groupID = [dict[@"group_id"] intValue]; | |
| 17 | + } | |
| 18 | + if([dict objectForKey:@"group_name"] != nil) { | |
| 19 | + self.name = dict[@"group_name"]; | |
| 20 | + } | |
| 21 | + if([dict objectForKey:@"group_avatar"] != nil) { | |
| 22 | + self.avatar = dict[@"group_avatar"]; | |
| 23 | + } | |
| 24 | + if([dict objectForKey:@"walk_mode_active"] != nil && ![[dict objectForKey:@"walk_mode_active"] isKindOfClass:[NSNull class]]) { | |
| 25 | + self.walkMode = [dict[@"walk_mode_active"] boolValue]; | |
| 26 | + } | |
| 27 | + if([dict objectForKey:@"run_mode_active"] != nil && ![[dict objectForKey:@"run_mode_active"] isKindOfClass:[NSNull class]]) { | |
| 28 | + self.runMode = [dict[@"run_mode_active"] boolValue]; | |
| 29 | + } | |
| 30 | + if([dict objectForKey:@"run_mode_active"] != nil && ![[dict objectForKey:@"run_mode_active"] isKindOfClass:[NSNull class]]) { | |
| 31 | + self.bikeMode = [dict[@"bike_mode_active"] boolValue]; | |
| 32 | + } | |
| 33 | + if([dict objectForKey:@"step_mode_active"] != nil && ![[dict objectForKey:@"step_mode_active"] isKindOfClass:[NSNull class]]) { | |
| 34 | + self.stepMode = [dict[@"step_mode_active"] boolValue]; | |
| 35 | + } | |
| 36 | + if([dict objectForKey:@"gym_mode_active"] != nil && ![[dict objectForKey:@"gym_mode_active"] isKindOfClass:[NSNull class]]) { | |
| 37 | + self.gymMode = [dict[@"gym_mode_active"] boolValue]; | |
| 38 | + } | |
| 39 | + if([dict objectForKey:@"beginer_mode_active"] != nil && ![[dict objectForKey:@"beginer_mode_active"] isKindOfClass:[NSNull class]]) { | |
| 40 | + self.beginMode = [dict[@"beginer_mode_active"] boolValue]; | |
| 41 | + } | |
| 42 | + if([dict objectForKey:@"created_at"] != nil) { | |
| 43 | + NSString *dateString = dict[@"created_at"]; | |
| 44 | + self.createDate = [Utilities dateFromString:dateString withFormat:@"yyyy-MM-dd hh:mm:ss"]; | |
| 45 | + } | |
| 46 | + else { | |
| 47 | + self.createDate = [NSDate date]; | |
| 48 | + } | |
| 49 | + if([dict objectForKey:@"num_search"] != nil) { | |
| 50 | + self.numSearch = [dict[@"num_search"] intValue]; | |
| 51 | + } | |
| 52 | + return self; | |
| 53 | +} | |
| 54 | + | |
| 55 | +@end |
LifeLog/LifeLog/Localizable.strings
No preview for this file type
LifeLog/LifeLog/SNSViewController.h
LifeLog/LifeLog/SNSViewController.m
| ... | ... | @@ -7,11 +7,15 @@ |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | 9 | #import "SNSViewController.h" |
| 10 | -#import "SNSRecentTopicTableViewCell.h" | |
| 10 | + | |
| 11 | +#import <SDWebImage/UIImageView+WebCache.h> | |
| 12 | + | |
| 11 | 13 | #import "ServerAPI.h" |
| 12 | 14 | #import "Utilities.h" |
| 13 | -#import <SDWebImage/UIImageView+WebCache.h> | |
| 14 | 15 | |
| 16 | +#import "SNSRecentTopicTableViewCell.h" | |
| 17 | +#import "SearchGroupViewController.h" | |
| 18 | + | |
| 15 | 19 | @interface SNSViewController () |
| 16 | 20 | |
| 17 | 21 | @end |
| ... | ... | @@ -34,6 +38,11 @@ |
| 34 | 38 | // Dispose of any resources that can be recreated. |
| 35 | 39 | } |
| 36 | 40 | |
| 41 | +#pragma mark IBAction | |
| 42 | +- (IBAction)clickRecommendGroup:(id)sender { | |
| 43 | + SearchGroupViewController * search = [[SearchGroupViewController alloc] init]; | |
| 44 | + [self.navigationController pushViewController:search animated:true]; | |
| 45 | +} | |
| 37 | 46 | |
| 38 | 47 | #pragma mark UITableView Delegate |
| 39 | 48 | - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
LifeLog/LifeLog/SNSViewController.xib
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> | |
| 2 | +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12118" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> | |
| 3 | 3 | <device id="retina4_7" orientation="portrait"> |
| 4 | 4 | <adaptation id="fullscreen"/> |
| 5 | 5 | </device> |
| 6 | 6 | <dependencies> |
| 7 | - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/> | |
| 7 | + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/> | |
| 8 | 8 | <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> |
| 9 | 9 | </dependencies> |
| 10 | 10 | <objects> |
| ... | ... | @@ -80,6 +80,9 @@ |
| 80 | 80 | </userDefinedRuntimeAttribute> |
| 81 | 81 | <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.sns.bt.commendgroup"/> |
| 82 | 82 | </userDefinedRuntimeAttributes> |
| 83 | + <connections> | |
| 84 | + <action selector="clickRecommendGroup:" destination="-1" eventType="touchUpInside" id="DEw-ej-loH"/> | |
| 85 | + </connections> | |
| 83 | 86 | </button> |
| 84 | 87 | <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uB3-Sm-i6e" customClass="AutoTransButton"> |
| 85 | 88 | <rect key="frame" x="20" y="126" width="335" height="40"/> |
LifeLog/LifeLog/SearchGroupTableViewCell.h
| 1 | +// | |
| 2 | +// SearchGroupTableViewCell.h | |
| 3 | +// LifeLog | |
| 4 | +// | |
| 5 | +// Created by nvtu on 8/11/17. | |
| 6 | +// Copyright ยฉ 2017 PhongNV. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | + | |
| 11 | +@interface SearchGroupTableViewCell : UITableViewCell | |
| 12 | + | |
| 13 | +@property (weak, nonatomic) IBOutlet UIImageView *imgAvatar; | |
| 14 | +@property (weak, nonatomic) IBOutlet UILabel *lblName; | |
| 15 | + | |
| 16 | +@end |
LifeLog/LifeLog/SearchGroupTableViewCell.m
| 1 | +// | |
| 2 | +// SearchGroupTableViewCell.m | |
| 3 | +// LifeLog | |
| 4 | +// | |
| 5 | +// Created by nvtu on 8/11/17. | |
| 6 | +// Copyright ยฉ 2017 PhongNV. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "SearchGroupTableViewCell.h" | |
| 10 | + | |
| 11 | +@implementation SearchGroupTableViewCell | |
| 12 | + | |
| 13 | +- (void)awakeFromNib { | |
| 14 | + [super awakeFromNib]; | |
| 15 | + // Initialization code | |
| 16 | +} | |
| 17 | + | |
| 18 | +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { | |
| 19 | + [super setSelected:selected animated:animated]; | |
| 20 | + | |
| 21 | + // Configure the view for the selected state | |
| 22 | +} | |
| 23 | + | |
| 24 | +@end |
LifeLog/LifeLog/SearchGroupTableViewCell.xib
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12118" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> | |
| 3 | + <device id="retina4_7" orientation="portrait"> | |
| 4 | + <adaptation id="fullscreen"/> | |
| 5 | + </device> | |
| 6 | + <dependencies> | |
| 7 | + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/> | |
| 8 | + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | |
| 9 | + </dependencies> | |
| 10 | + <objects> | |
| 11 | + <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> | |
| 12 | + <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | |
| 13 | + <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="SearchGroupCell" id="KGk-i7-Jjw" customClass="SearchGroupTableViewCell"> | |
| 14 | + <rect key="frame" x="0.0" y="0.0" width="320" height="70"/> | |
| 15 | + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> | |
| 16 | + <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> | |
| 17 | + <rect key="frame" x="0.0" y="0.0" width="320" height="69.5"/> | |
| 18 | + <autoresizingMask key="autoresizingMask"/> | |
| 19 | + <subviews> | |
| 20 | + <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar_default" translatesAutoresizingMaskIntoConstraints="NO" id="V29-aB-z6m"> | |
| 21 | + <rect key="frame" x="10" y="10" width="50" height="50"/> | |
| 22 | + <constraints> | |
| 23 | + <constraint firstAttribute="width" constant="50" id="NCc-vl-jbV"/> | |
| 24 | + <constraint firstAttribute="height" constant="50" id="nPg-m6-RJC"/> | |
| 25 | + </constraints> | |
| 26 | + </imageView> | |
| 27 | + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PqD-FA-DIk"> | |
| 28 | + <rect key="frame" x="68" y="20" width="212" height="20"/> | |
| 29 | + <constraints> | |
| 30 | + <constraint firstAttribute="height" constant="20" id="fDB-VO-fgq"/> | |
| 31 | + </constraints> | |
| 32 | + <fontDescription key="fontDescription" type="system" pointSize="14"/> | |
| 33 | + <nil key="textColor"/> | |
| 34 | + <nil key="highlightedColor"/> | |
| 35 | + </label> | |
| 36 | + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SNy-dc-xb8"> | |
| 37 | + <rect key="frame" x="0.0" y="68.5" width="320" height="1"/> | |
| 38 | + <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> | |
| 39 | + <constraints> | |
| 40 | + <constraint firstAttribute="height" constant="1" id="EuB-6b-DDV"/> | |
| 41 | + </constraints> | |
| 42 | + </view> | |
| 43 | + </subviews> | |
| 44 | + <color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/> | |
| 45 | + <constraints> | |
| 46 | + <constraint firstItem="V29-aB-z6m" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="10" id="6NK-Up-vWU"/> | |
| 47 | + <constraint firstAttribute="bottom" secondItem="SNy-dc-xb8" secondAttribute="bottom" id="CKE-YJ-Sv6"/> | |
| 48 | + <constraint firstItem="SNy-dc-xb8" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="Jvh-LM-ymJ"/> | |
| 49 | + <constraint firstItem="PqD-FA-DIk" firstAttribute="leading" secondItem="V29-aB-z6m" secondAttribute="trailing" constant="8" id="O4W-xn-z9e"/> | |
| 50 | + <constraint firstItem="PqD-FA-DIk" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="20" id="biO-wT-ELG"/> | |
| 51 | + <constraint firstItem="V29-aB-z6m" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="poP-mK-1Dh"/> | |
| 52 | + <constraint firstAttribute="trailing" secondItem="SNy-dc-xb8" secondAttribute="trailing" id="tRm-Jq-VNR"/> | |
| 53 | + <constraint firstAttribute="trailing" secondItem="PqD-FA-DIk" secondAttribute="trailing" constant="40" id="wZt-Nt-oWk"/> | |
| 54 | + </constraints> | |
| 55 | + </tableViewCellContentView> | |
| 56 | + <connections> | |
| 57 | + <outlet property="imgAvatar" destination="V29-aB-z6m" id="ye6-9r-VIf"/> | |
| 58 | + <outlet property="lblName" destination="PqD-FA-DIk" id="OLi-eS-E1G"/> | |
| 59 | + </connections> | |
| 60 | + </tableViewCell> | |
| 61 | + </objects> | |
| 62 | + <resources> | |
| 63 | + <image name="avatar_default" width="80" height="80"/> | |
| 64 | + </resources> | |
| 65 | +</document> |
LifeLog/LifeLog/SearchGroupViewController.h
| 1 | +// | |
| 2 | +// SearchGroupViewController.h | |
| 3 | +// LifeLog | |
| 4 | +// | |
| 5 | +// Created by nvtu on 8/11/17. | |
| 6 | +// Copyright ยฉ 2017 PhongNV. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <UIKit/UIKit.h> | |
| 10 | +#import "BaseTableViewController.h" | |
| 11 | + | |
| 12 | +@interface SearchGroupViewController : BaseTableViewController<UITextFieldDelegate> | |
| 13 | + | |
| 14 | +@property (weak, nonatomic) IBOutlet UITextField *textFieldSearch; | |
| 15 | + | |
| 16 | +- (IBAction)clickBack:(id)sender; | |
| 17 | +- (IBAction)clickSearch:(id)sender; | |
| 18 | +- (IBAction)clickCreateGroup:(id)sender; | |
| 19 | + | |
| 20 | +@end |
LifeLog/LifeLog/SearchGroupViewController.m
| 1 | +// | |
| 2 | +// SearchGroupViewController.m | |
| 3 | +// LifeLog | |
| 4 | +// | |
| 5 | +// Created by nvtu on 8/11/17. | |
| 6 | +// Copyright ยฉ 2017 PhongNV. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "SearchGroupViewController.h" | |
| 10 | + | |
| 11 | +#import <SDWebImage/UIImageView+WebCache.h> | |
| 12 | + | |
| 13 | +#import "ServerAPI.h" | |
| 14 | +#import "Utilities.h" | |
| 15 | + | |
| 16 | +#import "SearchGroupTableViewCell.h" | |
| 17 | + | |
| 18 | +@interface SearchGroupViewController () | |
| 19 | + | |
| 20 | +@end | |
| 21 | + | |
| 22 | +@implementation SearchGroupViewController | |
| 23 | + | |
| 24 | +- (void)viewDidLoad { | |
| 25 | + [super viewDidLoad]; | |
| 26 | + [self callRequestToUpdateData]; | |
| 27 | + | |
| 28 | + //register nib for table view | |
| 29 | + [self.tableBase registerNib:[UINib nibWithNibName:@"SearchGroupTableViewCell" bundle:nil] forCellReuseIdentifier:@"SearchGroupCell"]; | |
| 30 | +} | |
| 31 | + | |
| 32 | +- (void)didReceiveMemoryWarning { | |
| 33 | + [super didReceiveMemoryWarning]; | |
| 34 | + // Dispose of any resources that can be recreated. | |
| 35 | +} | |
| 36 | + | |
| 37 | +#pragma mark IBAction | |
| 38 | + | |
| 39 | +- (IBAction)clickBack:(id)sender { | |
| 40 | + [self.navigationController popViewControllerAnimated:true]; | |
| 41 | +} | |
| 42 | + | |
| 43 | +- (IBAction)clickSearch:(id)sender { | |
| 44 | + [self resetData]; | |
| 45 | +} | |
| 46 | + | |
| 47 | +- (IBAction)clickCreateGroup:(id)sender { | |
| 48 | + | |
| 49 | +} | |
| 50 | + | |
| 51 | +#pragma mark UITableView Delegate | |
| 52 | +- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | |
| 53 | + SearchGroupTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"SearchGroupCell"]; | |
| 54 | + GroupObject *object = [_curDataList objectAtIndex:indexPath.row]; | |
| 55 | + if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { | |
| 56 | + [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; | |
| 57 | + } | |
| 58 | + cell.lblName.text = object.name; | |
| 59 | + return cell; | |
| 60 | +} | |
| 61 | + | |
| 62 | +-(void) scrollViewDidScroll:(UIScrollView *)scrollView { | |
| 63 | + [self.view endEditing:true]; | |
| 64 | +} | |
| 65 | + | |
| 66 | +#pragma mark UITextField Delegate | |
| 67 | +-(BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { | |
| 68 | + [self resetData]; | |
| 69 | + return true; | |
| 70 | +} | |
| 71 | + | |
| 72 | +#pragma mark Private Function | |
| 73 | +-(void) callRequestToUpdateData { | |
| 74 | + [super callRequestToUpdateData]; | |
| 75 | + | |
| 76 | + NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; | |
| 77 | + MBProgressHUD *hudView = nil; | |
| 78 | + if(_curPage == 1 && !self.refreshControl.isRefreshing) { | |
| 79 | + hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; | |
| 80 | + } | |
| 81 | + [[ServerAPI server] searchGroup:token withKey:self.textFieldSearch.text andPage:_curPage CompletionHandler:^(NSArray *array, NSError *error) { | |
| 82 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 83 | + if(hudView != nil) { | |
| 84 | + [hudView hideAnimated:true]; | |
| 85 | + } | |
| 86 | + }); | |
| 87 | + SearchGroupViewController __weak *weakSelf = self; | |
| 88 | + [weakSelf updateTableData:array error:error]; | |
| 89 | + }]; | |
| 90 | +} | |
| 91 | +@end |
LifeLog/LifeLog/SearchGroupViewController.xib
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12118" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> | |
| 3 | + <device id="retina4_7" orientation="portrait"> | |
| 4 | + <adaptation id="fullscreen"/> | |
| 5 | + </device> | |
| 6 | + <dependencies> | |
| 7 | + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/> | |
| 8 | + <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | |
| 9 | + </dependencies> | |
| 10 | + <objects> | |
| 11 | + <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="SearchGroupViewController"> | |
| 12 | + <connections> | |
| 13 | + <outlet property="tableBase" destination="yF3-ZN-ebL" id="WYE-g2-1iW"/> | |
| 14 | + <outlet property="textFieldSearch" destination="ZV5-M6-gge" id="my5-ga-rV2"/> | |
| 15 | + <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> | |
| 16 | + </connections> | |
| 17 | + </placeholder> | |
| 18 | + <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> | |
| 19 | + <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT"> | |
| 20 | + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | |
| 21 | + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | |
| 22 | + <subviews> | |
| 23 | + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YHv-ES-wQ0" userLabel="ViewHeader"> | |
| 24 | + <rect key="frame" x="0.0" y="0.0" width="375" height="46"/> | |
| 25 | + <subviews> | |
| 26 | + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SNS" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qQF-tf-31d" customClass="AutoTransLabel"> | |
| 27 | + <rect key="frame" x="0.0" y="0.0" width="375" height="46"/> | |
| 28 | + <fontDescription key="fontDescription" type="system" pointSize="17"/> | |
| 29 | + <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | |
| 30 | + <nil key="highlightedColor"/> | |
| 31 | + <userDefinedRuntimeAttributes> | |
| 32 | + <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.sns.title"/> | |
| 33 | + </userDefinedRuntimeAttributes> | |
| 34 | + </label> | |
| 35 | + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pK9-Nf-LNR"> | |
| 36 | + <rect key="frame" x="0.0" y="5" width="70" height="36"/> | |
| 37 | + <constraints> | |
| 38 | + <constraint firstAttribute="width" constant="70" id="Kdt-q3-40K"/> | |
| 39 | + </constraints> | |
| 40 | + <state key="normal" image="today_back_button"/> | |
| 41 | + <connections> | |
| 42 | + <action selector="clickBack:" destination="-1" eventType="touchUpInside" id="Z3f-Fd-CEc"/> | |
| 43 | + </connections> | |
| 44 | + </button> | |
| 45 | + <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="PkV-G3-Fru"> | |
| 46 | + <rect key="frame" x="330" y="0.0" width="45" height="46"/> | |
| 47 | + <constraints> | |
| 48 | + <constraint firstAttribute="width" constant="45" id="7W6-Cl-TRS"/> | |
| 49 | + </constraints> | |
| 50 | + <state key="normal" image="icon_menu"/> | |
| 51 | + </button> | |
| 52 | + </subviews> | |
| 53 | + <color key="backgroundColor" red="0.098039215690000001" green="0.098039215690000001" blue="0.098039215690000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> | |
| 54 | + <constraints> | |
| 55 | + <constraint firstItem="pK9-Nf-LNR" firstAttribute="leading" secondItem="YHv-ES-wQ0" secondAttribute="leading" id="84D-o2-cdT"/> | |
| 56 | + <constraint firstAttribute="trailing" secondItem="qQF-tf-31d" secondAttribute="trailing" id="BMv-VR-p7j"/> | |
| 57 | + <constraint firstAttribute="trailing" secondItem="PkV-G3-Fru" secondAttribute="trailing" id="CiO-zw-1XR"/> | |
| 58 | + <constraint firstAttribute="height" constant="46" id="KDJ-I2-eMi"/> | |
| 59 | + <constraint firstItem="qQF-tf-31d" firstAttribute="leading" secondItem="YHv-ES-wQ0" secondAttribute="leading" id="heq-vX-GHv"/> | |
| 60 | + <constraint firstAttribute="bottom" secondItem="qQF-tf-31d" secondAttribute="bottom" id="iJg-Q2-eLi"/> | |
| 61 | + <constraint firstItem="qQF-tf-31d" firstAttribute="top" secondItem="YHv-ES-wQ0" secondAttribute="top" id="l3t-CY-3zr"/> | |
| 62 | + <constraint firstAttribute="bottom" secondItem="pK9-Nf-LNR" secondAttribute="bottom" constant="5" id="lJY-v6-1cM"/> | |
| 63 | + <constraint firstItem="pK9-Nf-LNR" firstAttribute="top" secondItem="YHv-ES-wQ0" secondAttribute="top" constant="5" id="ppE-r0-ai7"/> | |
| 64 | + <constraint firstItem="PkV-G3-Fru" firstAttribute="top" secondItem="YHv-ES-wQ0" secondAttribute="top" id="ptk-1B-s3f"/> | |
| 65 | + <constraint firstAttribute="bottom" secondItem="PkV-G3-Fru" secondAttribute="bottom" id="yNR-37-Qmd"/> | |
| 66 | + </constraints> | |
| 67 | + </view> | |
| 68 | + <textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="ZV5-M6-gge"> | |
| 69 | + <rect key="frame" x="16" y="86" width="209" height="30"/> | |
| 70 | + <nil key="textColor"/> | |
| 71 | + <fontDescription key="fontDescription" type="system" pointSize="14"/> | |
| 72 | + <textInputTraits key="textInputTraits"/> | |
| 73 | + <connections> | |
| 74 | + <outlet property="delegate" destination="-1" id="Wzs-Wc-gd1"/> | |
| 75 | + </connections> | |
| 76 | + </textField> | |
| 77 | + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="V72-De-hhR" customClass="AutoTransButton"> | |
| 78 | + <rect key="frame" x="250" y="86" width="110" height="30"/> | |
| 79 | + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | |
| 80 | + <constraints> | |
| 81 | + <constraint firstAttribute="height" constant="30" id="plQ-aS-bwK"/> | |
| 82 | + <constraint firstAttribute="width" constant="110" id="w47-Tg-vYC"/> | |
| 83 | + </constraints> | |
| 84 | + <fontDescription key="fontDescription" type="system" pointSize="13"/> | |
| 85 | + <state key="normal" title="ๆค็ดข"> | |
| 86 | + <color key="titleColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> | |
| 87 | + </state> | |
| 88 | + <userDefinedRuntimeAttributes> | |
| 89 | + <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius"> | |
| 90 | + <integer key="value" value="5"/> | |
| 91 | + </userDefinedRuntimeAttribute> | |
| 92 | + <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.searchGr.bt.search"/> | |
| 93 | + </userDefinedRuntimeAttributes> | |
| 94 | + <connections> | |
| 95 | + <action selector="clickSearch:" destination="-1" eventType="touchUpInside" id="WPo-6j-0K1"/> | |
| 96 | + </connections> | |
| 97 | + </button> | |
| 98 | + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Rb5-To-ffT" customClass="AutoTransButton"> | |
| 99 | + <rect key="frame" x="250" y="131" width="110" height="30"/> | |
| 100 | + <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | |
| 101 | + <constraints> | |
| 102 | + <constraint firstAttribute="height" constant="30" id="Cwt-yy-rcp"/> | |
| 103 | + </constraints> | |
| 104 | + <fontDescription key="fontDescription" type="system" pointSize="13"/> | |
| 105 | + <state key="normal" title="ใฐใซใผใไฝๆ"> | |
| 106 | + <color key="titleColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> | |
| 107 | + </state> | |
| 108 | + <userDefinedRuntimeAttributes> | |
| 109 | + <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius"> | |
| 110 | + <integer key="value" value="5"/> | |
| 111 | + </userDefinedRuntimeAttribute> | |
| 112 | + <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.searchGr.bt.createGr"/> | |
| 113 | + </userDefinedRuntimeAttributes> | |
| 114 | + <connections> | |
| 115 | + <action selector="clickCreateGroup:" destination="-1" eventType="touchUpOutside" id="iYI-HB-mhb"/> | |
| 116 | + </connections> | |
| 117 | + </button> | |
| 118 | + <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="70" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="yF3-ZN-ebL"> | |
| 119 | + <rect key="frame" x="0.0" y="176" width="375" height="441"/> | |
| 120 | + <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> | |
| 121 | + <connections> | |
| 122 | + <outlet property="dataSource" destination="-1" id="tKB-Uq-esC"/> | |
| 123 | + <outlet property="delegate" destination="-1" id="88z-Bd-dz0"/> | |
| 124 | + </connections> | |
| 125 | + </tableView> | |
| 126 | + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="ใชในในใกใฐใซใผใ" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YIq-l4-77c" customClass="AutoTransLabel"> | |
| 127 | + <rect key="frame" x="16" y="54" width="343" height="21"/> | |
| 128 | + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> | |
| 129 | + <fontDescription key="fontDescription" type="system" pointSize="17"/> | |
| 130 | + <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> | |
| 131 | + <nil key="highlightedColor"/> | |
| 132 | + <userDefinedRuntimeAttributes> | |
| 133 | + <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.searchGr.lbl.title"/> | |
| 134 | + </userDefinedRuntimeAttributes> | |
| 135 | + </label> | |
| 136 | + </subviews> | |
| 137 | + <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> | |
| 138 | + <constraints> | |
| 139 | + <constraint firstItem="yF3-ZN-ebL" firstAttribute="top" secondItem="Rb5-To-ffT" secondAttribute="bottom" constant="15" id="2wi-jL-dso"/> | |
| 140 | + <constraint firstAttribute="trailing" secondItem="V72-De-hhR" secondAttribute="trailing" constant="15" id="342-Ur-sPT"/> | |
| 141 | + <constraint firstItem="YHv-ES-wQ0" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="3ft-ch-v8f"/> | |
| 142 | + <constraint firstItem="Rb5-To-ffT" firstAttribute="top" secondItem="V72-De-hhR" secondAttribute="bottom" constant="15" id="Hic-jl-Ndk"/> | |
| 143 | + <constraint firstAttribute="bottom" secondItem="yF3-ZN-ebL" secondAttribute="bottom" constant="50" id="Nad-2Y-mrb"/> | |
| 144 | + <constraint firstItem="V72-De-hhR" firstAttribute="leading" secondItem="ZV5-M6-gge" secondAttribute="trailing" constant="25" id="Pv6-Li-O07"/> | |
| 145 | + <constraint firstAttribute="trailing" secondItem="YHv-ES-wQ0" secondAttribute="trailing" id="crv-XZ-T34"/> | |
| 146 | + <constraint firstItem="yF3-ZN-ebL" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="f6n-Zr-w64"/> | |
| 147 | + <constraint firstItem="Rb5-To-ffT" firstAttribute="trailing" secondItem="V72-De-hhR" secondAttribute="trailing" id="fHS-Kk-Ew0"/> | |
| 148 | + <constraint firstItem="YHv-ES-wQ0" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="fdM-w1-hOo"/> | |
| 149 | + <constraint firstItem="V72-De-hhR" firstAttribute="top" secondItem="YHv-ES-wQ0" secondAttribute="bottom" constant="40" id="hlc-vb-EVo"/> | |
| 150 | + <constraint firstItem="Rb5-To-ffT" firstAttribute="width" secondItem="V72-De-hhR" secondAttribute="width" id="jtP-uw-vkF"/> | |
| 151 | + <constraint firstItem="ZV5-M6-gge" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="16" id="kxD-e8-dYm"/> | |
| 152 | + <constraint firstAttribute="trailing" secondItem="yF3-ZN-ebL" secondAttribute="trailing" id="rZv-uL-RZ3"/> | |
| 153 | + <constraint firstItem="V72-De-hhR" firstAttribute="top" secondItem="ZV5-M6-gge" secondAttribute="top" id="voZ-Kp-Zm3"/> | |
| 154 | + </constraints> | |
| 155 | + <point key="canvasLocation" x="24.5" y="52.5"/> | |
| 156 | + </view> | |
| 157 | + </objects> | |
| 158 | + <resources> | |
| 159 | + <image name="icon_menu" width="30" height="30"/> | |
| 160 | + <image name="today_back_button" width="73" height="37"/> | |
| 161 | + </resources> | |
| 162 | +</document> |
LifeLog/LifeLog/ServerAPI.h
| ... | ... | @@ -29,5 +29,6 @@ |
| 29 | 29 | |
| 30 | 30 | #pragma mark - SNS Screen Function |
| 31 | 31 | - (void) requestRecentlyTweetsList:(NSString *)token withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion; |
| 32 | +- (void) searchGroup:(NSString *)token withKey:(NSString *)key andPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion; | |
| 32 | 33 | @end |
LifeLog/LifeLog/ServerAPI.m
| ... | ... | @@ -37,6 +37,8 @@ |
| 37 | 37 | @implementation ServerAPI |
| 38 | 38 | static ServerAPI *_server = nil; |
| 39 | 39 | |
| 40 | +NSURLSessionDataTask * searchTask; | |
| 41 | + | |
| 40 | 42 | @synthesize timeOutInterval = _timeOutInterval; |
| 41 | 43 | |
| 42 | 44 | + (instancetype)server |
| ... | ... | @@ -438,6 +440,52 @@ |
| 438 | 440 | }]; |
| 439 | 441 | } |
| 440 | 442 | |
| 443 | +- (void) searchGroup:(NSString *)token withKey:(NSString *)key andPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion { | |
| 444 | + NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/search"]; | |
| 445 | + NSLog(@"searchGroup link %@ page %d", url, page); | |
| 446 | + if(searchTask != nil) { | |
| 447 | + [searchTask cancel]; | |
| 448 | + } | |
| 449 | + | |
| 450 | + searchTask = [self _request:url method:@"POST" token:token paras:@{@"keyword":key, @"page": [NSNumber numberWithInt:page]} completion:^(NSData *data, NSError *error) { | |
| 451 | + searchTask = nil; | |
| 452 | + if (completion == NULL) { | |
| 453 | + return ; | |
| 454 | + } | |
| 455 | + | |
| 456 | + if (error == nil) | |
| 457 | + { | |
| 458 | + NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; | |
| 459 | + NSLog(@"%@", dataResult); | |
| 460 | + int status = [dataResult[@"status"] intValue]; | |
| 461 | + if (status == 1) { // status = 1 success | |
| 462 | + if(dataResult[@"result"] != nil) { | |
| 463 | + NSArray * array = dataResult[@"result"]; | |
| 464 | + NSMutableArray * arrayTweets = [[NSMutableArray alloc] init]; | |
| 465 | + for(NSDictionary * dict in array) { | |
| 466 | + GroupObject * object = [[GroupObject alloc] initWithData:dict]; | |
| 467 | + [arrayTweets addObject:object]; | |
| 468 | + } | |
| 469 | + completion(arrayTweets, nil); | |
| 470 | + } | |
| 471 | + else { | |
| 472 | + NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; | |
| 473 | + completion(nil, errorObject); | |
| 474 | + } | |
| 475 | + } | |
| 476 | + else { | |
| 477 | + NSString *message = dataResult[@"message"]; | |
| 478 | + NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; | |
| 479 | + completion(nil, errorObject); | |
| 480 | + } | |
| 481 | + } | |
| 482 | + else | |
| 483 | + { | |
| 484 | + completion(nil, error); | |
| 485 | + } | |
| 486 | + }]; | |
| 487 | +} | |
| 488 | + | |
| 441 | 489 | #pragma mark - Private Function |
| 442 | 490 | - (NSData *) _encodeDictionary: (NSDictionary *) dictionary |
| 443 | 491 | { |
| ... | ... | @@ -453,7 +501,7 @@ |
| 453 | 501 | return [encodedDictionary dataUsingEncoding: NSUTF8StringEncoding]; |
| 454 | 502 | } |
| 455 | 503 | |
| 456 | -- (void) _request:(NSString *)address method:(NSString *)method token:(NSString *) token paras:(NSDictionary *)paras completion:(void (^)(NSData *data, NSError *error))completion | |
| 504 | +- (NSURLSessionDataTask *) _request:(NSString *)address method:(NSString *)method token:(NSString *) token paras:(NSDictionary *)paras completion:(void (^)(NSData *data, NSError *error))completion | |
| 457 | 505 | { |
| 458 | 506 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:address]]; |
| 459 | 507 | request.HTTPMethod = method; |
| 460 | 508 | |
| ... | ... | @@ -488,8 +536,8 @@ |
| 488 | 536 | completion(nil, error); |
| 489 | 537 | } |
| 490 | 538 | }]; |
| 491 | - | |
| 492 | 539 | [task resume]; |
| 540 | + return task; | |
| 493 | 541 | } |
| 494 | 542 | |
| 495 | 543 | @end |
LifeLog/LifeLog/TweetObject.m
| ... | ... | @@ -51,9 +51,6 @@ |
| 51 | 51 | self.avatarLink = dict[@"profile_image"]; |
| 52 | 52 | } |
| 53 | 53 | if([dict objectForKey:@"created_at"] != nil) { |
| 54 | - self.createDate = dict[@"created_at"]; | |
| 55 | - } | |
| 56 | - if([dict objectForKey:@"created_at"] != nil) { | |
| 57 | 54 | NSString *dateString = dict[@"created_at"]; |
| 58 | 55 | self.createDate = [Utilities dateFromString:dateString withFormat:@"yyyy-MM-dd hh:mm:ss"]; |
| 59 | 56 | } |