HomeMemberViewController.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. //
  2. // HomeMemberViewController.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 6/15/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "RequestHandler.h"
  9. #import "LoginModel.h"
  10. #import "CustomButton.h"
  11. #import "CustomLabel.h"
  12. #import "CustomLabelButton.h"
  13. #import "CustomImageView.h"
  14. #import "CustomCheckBox.h"
  15. #import "CustomAlertView.h"
  16. #import "UIImageView+WebCache.h"
  17. #import "UIButton+WebCache.h"
  18. #import "HomeMemberViewController.h"
  19. #import "JYPullToRefreshController.h"
  20. #import "MoreBtnModel.h"
  21. #define kfMemberTableViewCellHeight 100.0f
  22. #define kiCellInset 10
  23. #define kiCellItem 2
  24. #define kiCellRatio 46
  25. @interface HomeMemberCollectionCell () {
  26. }
  27. @property (weak, nonatomic) NSIndexPath *indexPath;
  28. @end
  29. @implementation HomeMemberCollectionCell
  30. - (void)awakeFromNib {
  31. _chkSelect.hidden = YES;
  32. }
  33. @end
  34. @implementation HomeMemberAddCollectionCell
  35. @end
  36. @interface HomeMemberViewController () <UICollectionViewDelegate, UICollectionViewDataSource> {
  37. NSArray<HomeMemberModel> *_memberList;
  38. BOOL _isNotFirstLoading, _isDeleteMode;
  39. NSInteger _deviceFlag;
  40. NSString *_masterNickname;
  41. NSMutableArray<MoreBtnModel *> *_arrMoreBtn;
  42. }
  43. @property (strong, nonatomic) JYPullToRefreshController *refreshController;
  44. @end
  45. #pragma mark - Class Definition
  46. @implementation HomeMemberViewController
  47. - (void)viewDidLoad {
  48. [super viewDidLoad];
  49. [self initProperties];
  50. [self initUI];
  51. }
  52. - (void)viewWillAppear:(BOOL)animated {
  53. [super viewWillAppear:animated];
  54. [self prepareViewDidLoad];
  55. }
  56. - (void)initProperties {
  57. _deviceFlag = IS_IPHONE_6P ? 2 : 2;
  58. }
  59. - (void)initUI {
  60. //set tableview option
  61. _collectionView.delegate = self;
  62. _collectionView.dataSource = self;
  63. _collectionView.backgroundColor = [UIColor clearColor];
  64. _collectionView.alwaysBounceVertical = YES;
  65. [_btnClose setHidden:YES];
  66. [_btnOption setHidden:NO];
  67. [self setThingsPopoverOptions];
  68. [self initRefreshController];
  69. [self setMoreBtnArray];
  70. }
  71. - (void)initRefreshController {
  72. //set refresh controls
  73. __weak typeof(self) weakSelf = self;
  74. self.refreshController = [[JYPullToRefreshController alloc] initWithScrollView:self.collectionView];
  75. self.refreshController.pullToRefreshHandleAction = ^{
  76. [weakSelf requestHomeMemberList];
  77. };
  78. }
  79. - (void)setThingsPopoverOptions {
  80. //set Popover Contents
  81. __weak typeof(self) weakSelf = self;
  82. _popooverOptionArray = [[NSMutableArray alloc] init];
  83. [_popooverOptionArray addObject:@{@"menuName" : NSLocalizedString(@"새로 고침",nil),
  84. @"iconName": @"img_bg_morepopup_icon_refresh",
  85. @"target": weakSelf,
  86. @"selector": [NSValue valueWithPointer:@selector(requestHomeMemberList)]}];
  87. if ([JDFacade facade].loginUser.level == 90) {
  88. [_popooverOptionArray addObject:@{@"menuName" : NSLocalizedString(@"멤버 삭제", @"멤버 삭제"),
  89. @"iconName": @"img_bg_morepopup_icon_del",
  90. @"target": weakSelf,
  91. @"selector": [NSValue valueWithPointer:@selector(toggleEditMode)]}];
  92. } else {
  93. [_popooverOptionArray addObject:@{@"menuName" : NSLocalizedString(@"멤버 탈퇴", @"멤버 탈퇴"),
  94. @"iconName": @"img_bg_morepopup_icon_del",
  95. @"target": weakSelf,
  96. @"selector": [NSValue valueWithPointer:@selector(leaveHomegroup)]}];
  97. }
  98. }
  99. - (void)prepareViewDidLoad {
  100. [self updateTitle];
  101. [self performSelector:@selector(requestHomeMemberList) withObject:nil afterDelay:0.0f];
  102. }
  103. - (void)updateTitle {
  104. NSInteger memberCount = _memberList ? [_memberList filteredArrayUsingPredicateFormat:@"memberTypeCode == %@", @"01"].count : 0;
  105. NSInteger invitationCount = _memberList ? [_memberList filteredArrayUsingPredicateFormat:@"memberTypeCode == %@", @"02"].count : 0;
  106. _lblTitle.text = [NSString stringWithFormat:@"참여 %zd / 초대 %zd", memberCount, invitationCount];
  107. if (![JDFacade facade].loginUser.hasHomeHub) {//홈허브 아이디가 없는 경우,
  108. [_mainView bringSubviewToFront:_addHubContainerView];
  109. _addHubContainerView.hidden = NO;
  110. _collectionView.hidden = YES;
  111. _btnOption.hidden = NO;
  112. _btnClose.hidden = YES;
  113. if (![JDFacade facade].loginUser.homegrpId) {//연결한 적이 없음
  114. _lblConnectHub.text = @"초대를 받아서\n시작해 보세요";
  115. _imgvHubAlert.hidden = YES;
  116. _imgvConnectHub.image = [UIImage imageNamed:@"img_1depth_invitation"];
  117. _lblLeaveAccount.hidden = YES;
  118. _lblSimpleMemberInfo.hidden = YES;
  119. } else {//홈허브가 삭제됨.
  120. _lblTitle.text = @" 홈허브 삭제됨";
  121. _imgvHubAlert.hidden = NO;
  122. _lblConnectHub.text = @"홈허브를 다시 연결하려면\n고객센터에 문의해주세요";
  123. _imgvConnectHub.image = [UIImage imageNamed:@"img_things_homehub_img_hubdelete_cscenter"];
  124. if ([JDFacade facade].loginUser.level < 90) {//일반 유저일 경우,
  125. _imgvConnectHub.image = [UIImage imageNamed:@"img_things_homehub_img_hubdelete_wait"];
  126. _lblLeaveAccount.hidden = NO;
  127. _lblSimpleMemberInfo.hidden = NO;
  128. [_lblLeaveAccount setUnderLine:_lblLeaveAccount.text];
  129. if (!_lblLeaveAccount.touchHandler) {
  130. [_lblLeaveAccount addTouchEventHandler:^(id label) {
  131. [self leaveHomegroup];
  132. }];
  133. }
  134. }
  135. }
  136. } else {
  137. if (![JDFacade facade].loginUser.isHomehubOnline) {
  138. _imgvHubAlert.hidden = NO;
  139. _lblTitle.text = @"홈허브 오프라인";
  140. [_lblTitle setColor:kUITextColor01 text:_lblTitle.text];
  141. } else {
  142. _imgvHubAlert.hidden = YES;
  143. }
  144. [_mainView bringSubviewToFront:_collectionView];
  145. _addHubContainerView.hidden = YES;
  146. _collectionView.hidden = NO;
  147. _btnOption.hidden = NO;
  148. }
  149. if ([_lblTitle.text rangeOfString:@"참여"].location != NSNotFound) {
  150. [_lblTitle setColor:kUITextColor02 text:[NSString stringWithFormat:@"%zd", memberCount]];
  151. [_lblTitle setColor:kUITextColor03 text:[NSString stringWithFormat:@"초대 %zd", invitationCount]];
  152. }
  153. }
  154. - (void)updateHomeHubStatusToMembers {
  155. [self updateTitle];
  156. }
  157. - (IBAction)btnOptionTouched:(id)sender
  158. {
  159. // NSMutableArray *btnArray = [NSMutableArray array];
  160. //img_bg_morepopup_icon_masterchange, img_bg_morepopup_icon_masterchange_press
  161. //img_bg_morepopup_icon_masterchange
  162. //img_bg_morepopup_icon_masterchange
  163. // NSMutableArray *btnArray = [NSMutableArray arrayWithObjects:[NSNumber numberWithInteger:masterChange],[NSNumber numberWithInteger:add],[NSNumber numberWithInteger:del], nil];
  164. //
  165. // [self toggleOptionsWithArray:sender btnArray:btnArray];
  166. [self toggleOptionsWithArray:sender btnArray:_arrMoreBtn];
  167. }
  168. - (void)setMoreBtnArray {
  169. if (_arrMoreBtn == nil) {
  170. _arrMoreBtn = [NSMutableArray array];
  171. }
  172. if (![[JDFacade facade].loginUser hasHomeHub]) {
  173. [_btnOption setHidden:YES];
  174. }
  175. if([[JDFacade facade].loginUser.gradeCode isEqualToString:KNEET_MEMBER_SIMPLE]) {
  176. for (int i = 0; i < 4; i++) {
  177. MoreBtnModel *btnModel;
  178. switch (i) {
  179. case 0:{
  180. btnModel = [[MoreBtnModel alloc] initWithTyep:MasterTransfer isEnable:YES];
  181. if (![[JDFacade facade].loginUser isHomehubOnline]) {
  182. [btnModel setEnable:NO];
  183. }
  184. }
  185. break;
  186. case 1:
  187. btnModel = [[MoreBtnModel alloc] initWithTyep:AddMember isEnable:YES];
  188. break;
  189. case 2:
  190. btnModel = [[MoreBtnModel alloc] initWithTyep:Del isEnable:YES];
  191. break;
  192. case 3:
  193. btnModel = [[MoreBtnModel alloc] initWithTyep:Refresh isEnable:YES];
  194. break;
  195. default:
  196. break;
  197. }
  198. [_arrMoreBtn addObject:btnModel];
  199. }
  200. }
  201. else {
  202. MoreBtnModel *btnModel = [[MoreBtnModel alloc] initWithTyep:Refresh isEnable:YES];
  203. [_arrMoreBtn addObject:btnModel];
  204. }
  205. }
  206. - (void)returnMoreId:(id)moreButtonId{
  207. NSLog(@"moreButtonId : %@",moreButtonId);
  208. }
  209. - (IBAction)btnCloseEditModeTouched:(id)sender {
  210. }
  211. - (void)addNewMember {
  212. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeMemberAddViewController" storyboardName:@"HomeMember"];
  213. [self presentViewController:vc animated:YES completion:nil];
  214. }
  215. - (void)toggleEditMode {
  216. _isDeleteMode = !_isDeleteMode;
  217. if (!_isDeleteMode) {
  218. for (HomeMemberModel *member in _memberList) {
  219. [[JDFacade facade] setCheckBoxStatus:@(NO) object:member];
  220. }
  221. [self updateTitle];
  222. } else {
  223. _lblTitle.text = @"멤버 삭제";
  224. _imgvHubAlert.hidden = YES;
  225. }
  226. [_collectionView reloadData];
  227. _constraintEditModeRight.constant = _isDeleteMode ? 0 : -_editModeView.width;
  228. [UIView animateWithDuration:kfAnimationDur animations:^{
  229. [self.view layoutIfNeeded];
  230. }];
  231. }
  232. - (void)leaveHomegroup {
  233. if (!_masterNickname) {
  234. NSString *path = [NSString stringWithFormat:API_GET_HOMEGROUP_MEMBERS, [[JDFacade facade].loginUser custId], [[JDFacade facade].loginUser ctrtGrpId]];
  235. [[RequestHandler handler] sendAsyncGetRequestAPIPath:path parameters:nil modelClass:[HomeMemberListModel class] completion:^(id responseObject) {
  236. if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
  237. return;
  238. }
  239. NSLog(@"Member List : %@", responseObject);
  240. HomeMemberListModel *fetchedMemberList = (HomeMemberListModel *)responseObject;
  241. NSArray<HomeMemberModel> *homegrpMemberList = fetchedMemberList.ctrtGrpMemberList;
  242. if (homegrpMemberList && homegrpMemberList.count) {
  243. HomeMemberModel *master = [homegrpMemberList objectKey:@"gradeCode" eqaulToString:KNEET_MEMBER_MASTER];
  244. _masterNickname = master && master.nickname ? master.nickname : ksEmptyString;
  245. [self leaveHomegroup];
  246. }
  247. } failure:^(id errorObject) {
  248. JDErrorModel *error = (JDErrorModel *)errorObject;
  249. [[JDFacade facade] alert:error.errorMessage];
  250. }];
  251. return;
  252. }
  253. NSString *message = [NSString stringWithFormat:@"[%@]님의 홈그룹에서 탈퇴하시겠습니까?", _masterNickname];
  254. [[JDFacade facade] confirmTitle:@"멤버 탈퇴" message:message completion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  255. if (buttonIndex == 0) {//OK
  256. [self requestLeaveHomegroup];
  257. }
  258. }];
  259. }
  260. #pragma mark - Main Logic
  261. - (void)requestHomeMemberList {
  262. if (![JDFacade facade].loginUser.hasHomeHub) {
  263. return;
  264. }
  265. NSString *path = [NSString stringWithFormat:API_GET_HOMEGROUP_MEMBERS, [[JDFacade facade].loginUser custId], [[JDFacade facade].loginUser ctrtGrpId]];
  266. [[RequestHandler handler] sendAsyncGetRequestAPIPath:path parameters:nil modelClass:[HomeMemberListModel class] completion:^(id responseObject) {
  267. if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
  268. return;
  269. }
  270. NSLog(@"Member List : %@", responseObject);
  271. HomeMemberListModel *fetchedMemberList = (HomeMemberListModel *)responseObject;
  272. NSArray<HomeMemberModel> *homegrpMemberList = fetchedMemberList.ctrtGrpMemberList;
  273. if (homegrpMemberList && homegrpMemberList.count) {
  274. _memberList = homegrpMemberList;
  275. } else {//조회 내역이 없을 경우,
  276. }
  277. [self setContents];
  278. [_collectionView reloadData];
  279. //refresh controller
  280. if (self.refreshController && self.refreshController.refreshState == JYRefreshStateLoading) {
  281. [self.refreshController stopRefreshWithAnimated:YES completion:nil];
  282. }
  283. } failure:^(id errorObject) {
  284. JDErrorModel *error = (JDErrorModel *)errorObject;
  285. [[JDFacade facade] alert:error.errorMessage];
  286. }];
  287. }
  288. - (void)setContents {
  289. HomeMemberModel *master = [_memberList objectKey:@"gradeCode" eqaulToString:KNEET_MEMBER_MASTER];
  290. _masterNickname = master && master.nickname ? master.nickname : ksEmptyString;
  291. [self updateTitle];
  292. }
  293. - (void)requestDeleteMembers:(NSString *)memberIds invitations:(NSString *)invitations {
  294. //parameters
  295. NSDictionary *parameter = @{@"member_ids" : ![memberIds isEmptyString] ? memberIds : ksEmptyString,
  296. @"invitation_hist_ids": ![invitations isEmptyString] ? invitations : ksEmptyString};
  297. NSString *path = [NSString stringWithFormat:API_DELETE_HOMEGROUP_MEMBERS];
  298. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:parameter modelClass:[JDJSONModel class] showLoadingView:YES completion:^(id responseObject) {
  299. [self toggleEditMode];
  300. [self requestHomeMemberList];
  301. [[JDFacade facade] toast:NSLocalizedString(@"멤버를 삭제했습니다", @"멤버를 삭제했습니다")];
  302. } failure:^(id errorObject) {
  303. JDErrorModel *error = (JDErrorModel *)errorObject;
  304. [[JDFacade facade] alert:error.errorMessage];
  305. }];
  306. }
  307. - (void)requestLeaveHomegroup {
  308. //api path
  309. NSString *path = [NSString stringWithFormat:API_DELETE_HOMEGROUP_MEMBER, [JDFacade facade].loginUser.memberId];
  310. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:nil modelClass:[JDJSONModel class] showLoadingView:YES completion:^(id responseObject) {
  311. [[JDFacade facade] alertTitle:@"멤버 탈퇴" message:@"탈퇴를 완료했습니다" completionHander:^{
  312. [[JDFacade facade] gotoWishMenu:KNMenuIdDashboard];
  313. }];
  314. } failure:^(id errorObject) {
  315. JDErrorModel *error = (JDErrorModel *)errorObject;
  316. [[JDFacade facade] alert:error.errorMessage];
  317. }];
  318. }
  319. #pragma mark - UICollectionView Delegate
  320. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  321. NSInteger auth = [JDFacade facade].loginUser.level == 90 && !_isDeleteMode; //마스터 권한일 경우,
  322. NSInteger count = _memberList.count % _deviceFlag == 0 ? _memberList.count : _memberList.count + auth; //홀수일 경우, 멤버 초대 버튼을 추가해줌.
  323. return count;
  324. }
  325. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  326. UICollectionViewCell *rcell = nil;
  327. if (indexPath.row < _memberList.count) {
  328. HomeMemberCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCellIdentifier" forIndexPath:indexPath];
  329. HomeMemberModel *member = _memberList[indexPath.row];
  330. cell.indexPath = indexPath;
  331. [cell.btnProfile sd_setBackgroundImageWithURL:[NSURL URLWithString:member.imageFileName] forState:UIControlStateNormal placeholderImage:nil options:SDWebImageRefreshCached];
  332. cell.lblNickname.text = member.nickname;
  333. cell.lblMemID.text = member.memberId;
  334. if ([member.memberTypeCode isEqualToString:KNEET_MEMBER_TYPE_HOME]) {
  335. cell.lblNickname.text = [NSString stringWithFormat:@"%@", cell.lblNickname.text];
  336. UIColor *pcolor = [member.gradeCode isEqualToString:KNEET_MEMBER_MASTER] ? kUITextBlackColor06 : kUITextBlackColor06;
  337. [cell.lblNickname setColor:pcolor text:@"●"];
  338. cell.lblStatus.text = member.gradeCode;
  339. //cell.lblStatus.text = member.gradeCodeName;
  340. [cell.lblStatus setColor:kUITextGreenColor05 text:cell.lblStatus.text];
  341. } else {
  342. if ([member.invitation isEqualToString:@"01"]) {//초대 대기중
  343. cell.lblStatus.text = @"초대 대기 중";
  344. } else if ([member.invitation isEqualToString:@"21"]) {//초대 유효기간 종료
  345. cell.lblStatus.text = @"초대 무효";
  346. } else if ([member.invitation isEqualToString:@"22"]) {//답변 오류 제한 초과
  347. cell.lblStatus.text = @"답변 오류 제한 초과";
  348. } else if ([member.invitation isEqualToString:@"23"]) {//초대 거절
  349. cell.lblStatus.text = @"초대 거절";
  350. }
  351. [cell.lblStatus setColor:kUITextColor03 text:cell.lblStatus.text];
  352. }
  353. cell.chkSelect.hidden = !(_isDeleteMode && [member.gradeCode isEqualToString:KNEET_MEMBER_SIMPLE] && _memberList.count > 1);
  354. cell.chkSelect.value = member;
  355. cell.chkSelect.checked = [cell.chkSelect getCheckStatusFromValue];
  356. rcell = cell;
  357. } else {
  358. HomeMemberAddCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AddCollectionCellIdentifier" forIndexPath:indexPath];
  359. [cell.btnAdd.label setUnderLine:cell.btnAdd.label.text];
  360. if (![cell.btnAdd actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  361. [cell.btnAdd addTarget:self action:@selector(addNewMember) forControlEvents:UIControlEventTouchUpInside];
  362. }
  363. rcell = cell;
  364. }
  365. return rcell;
  366. }
  367. //- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
  368. // viewForSupplementaryElementOfKind:(NSString *)kind
  369. // atIndexPath:(NSIndexPath *)indexPath
  370. //{
  371. //
  372. // HomeMemberCollectionFooterView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter
  373. // withReuseIdentifier:@"FooterIdentifier" forIndexPath:indexPath];
  374. // [footerView.btnAdd.label setUnderLine:footerView.btnAdd.label.text];
  375. // if (![footerView.btnAdd actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  376. // [footerView.btnAdd addTarget:self action:@selector(addNewMember) forControlEvents:UIControlEventTouchUpInside];
  377. // }
  378. // return footerView;
  379. //}
  380. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
  381. if (_memberList.count % _deviceFlag != 0 || [JDFacade facade].loginUser.level < 90 || _isDeleteMode) {//마스터 권한이 아니거나, 짝수가 아닐 경우
  382. return CGSizeZero;
  383. }
  384. return CGSizeMake(ViewWidth(_collectionView), 168.0f);
  385. }
  386. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  387. NSLog(@"Phone View Size : %f", IPHONE_WIDTH);
  388. NSLog(@"Collection View Size : %f", ViewWidth(_collectionView));
  389. NSLog(@"Cell Width Size : %f", (ViewWidth(_collectionView)-kiCellInset) / kiCellItem);
  390. NSLog(@"Cell Height Size : %f", ((ViewWidth(_collectionView)-kiCellInset)+kiCellRatio) / kiCellItem);
  391. return CGSizeMake((ViewWidth(_collectionView)-kiCellInset) / kiCellItem, ((ViewWidth(_collectionView)-kiCellInset)+kiCellRatio) / kiCellItem);
  392. // return CGSizeMake((ViewWidth(_collectionView)-(_deviceFlag*kiCellInsetSize)) / _deviceFlag, 168.0f);
  393. }
  394. // Cell 사이 최소 간격
  395. - (CGFloat) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  396. return kiCellInset;
  397. }
  398. // Line 별 최소 간격
  399. -(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
  400. {
  401. return kiCellInset;
  402. }
  403. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  404. [collectionView deselectItemAtIndexPath:indexPath animated:YES];
  405. if (indexPath.row < _memberList.count) {
  406. HomeMemberCollectionCell *cell = (HomeMemberCollectionCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCellIdentifier" forIndexPath:indexPath];
  407. HomeMemberModel *member = _memberList[indexPath.row];
  408. cell.chkSelect.value = member;
  409. [cell.chkSelect checkBoxClicked];
  410. }
  411. }
  412. #pragma mark - UI Events
  413. - (IBAction)btnDeleteOnEditModeTouched:(id)sender {
  414. if (!_isDeleteMode)
  415. return;
  416. NSMutableString *memberIds = [[NSMutableString alloc] init];
  417. NSMutableString *invitationHistIds = [[NSMutableString alloc] init];
  418. for (HomeMemberModel *member in _memberList) {
  419. if ([[[JDFacade facade] getCheckBoxStatus:member] boolValue]) {
  420. if ([member.memberTypeCode isEqualToString:KNEET_MEMBER_TYPE_HOME]) {//홈멤버일 경우,
  421. NSString *prefix = [memberIds isEmptyString] ? ksEmptyString : @",";
  422. [memberIds appendFormat:@"%@%@", prefix, member.memberId];
  423. } else if ([member.memberTypeCode isEqualToString:KNEET_MEMBER_TYPE_INV]) {//초대중일 경우,
  424. NSString *prefix = [invitationHistIds isEmptyString] ? ksEmptyString : @",";
  425. [invitationHistIds appendFormat:@"%@%@", prefix, member.invitationHistId];
  426. }
  427. }
  428. }
  429. if ([memberIds isEmptyString] && [invitationHistIds isEmptyString]) {
  430. [[JDFacade facade] alert:NSLocalizedString(@"선택된 멤버가 없습니다", @"선택된 멤버가 없습니다")];
  431. return;
  432. }
  433. CustomAlertView *alert = [[CustomAlertView alloc] initWithTitle:@"알림" message:@"멤버를 삭제하시겠습니까?\n\n삭제된 멤버는 홈의 모든 기능을\n이용할 수 없게되며,\n참여 대기중인 사람은 초대가\n취소됩니다." delegate:nil OKButtonTitle:@"멤버삭제" cancelButtonTitle:@"취소"];
  434. [alert showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  435. if (buttonIndex == 0) {//OK
  436. [self requestDeleteMembers:memberIds invitations:invitationHistIds];
  437. }
  438. }];
  439. }
  440. - (IBAction)btnCloseOnEditModeTouched:(id)sender {
  441. [self toggleEditMode];
  442. }
  443. //- (IBAction)btnCoverIconTouched:(id)sender {
  444. //
  445. // if (_selectedCoverIcon) {
  446. // [_selectedCoverIcon faceOffImage];
  447. // }
  448. //
  449. // CustomButton *btn = (CustomButton *)sender;
  450. // _selectedCoverIcon = btn;
  451. // [_selectedCoverIcon faceOffImage];
  452. //}
  453. #pragma mark - MoreButtonDelegate
  454. -(void)moreBtnAction:(id)sender
  455. {
  456. NSInteger tag = [(UIButton *)sender tag];
  457. NSLog(@"MoreBtn Action : %li", (long)tag);
  458. switch (tag) {
  459. case MasterTransfer:
  460. {
  461. }
  462. break;
  463. default:
  464. break;
  465. }
  466. }
  467. #pragma mark - MemoryWarning
  468. - (void)didReceiveMemoryWarning
  469. {
  470. [super didReceiveMemoryWarning];
  471. // Dispose of any resources that can be recreated.
  472. }
  473. @end