HomeMemberViewController.m 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  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:setColor(@"#888FA8") 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. NSInteger normalmemberCount = _memberList ? [[_memberList filteredArrayUsingPredicateFormat:@"memberTypeCode == %@", @"01"] filteredArrayUsingPredicateFormat:@"gradeCode", KNEET_MEMBER_SIMPLE].count : 0;
  176. if([[JDFacade facade].loginUser.gradeCode isEqualToString:KNEET_MEMBER_MASTER]) {
  177. for (int i = 0; i < 4; i++) {
  178. MoreBtnModel *btnModel;
  179. switch (i) {
  180. case 0:{
  181. btnModel = [[MoreBtnModel alloc] initWithTyep:MasterTransfer isEnable:YES];
  182. if (![[JDFacade facade].loginUser isHomehubOnline] || normalmemberCount == 0) {
  183. [btnModel setEnable:NO];
  184. }
  185. }
  186. break;
  187. case 1:
  188. btnModel = [[MoreBtnModel alloc] initWithTyep:AddMember isEnable:YES];
  189. break;
  190. case 2:
  191. btnModel = [[MoreBtnModel alloc] initWithTyep:Del isEnable:YES];
  192. break;
  193. case 3:
  194. btnModel = [[MoreBtnModel alloc] initWithTyep:Refresh isEnable:YES];
  195. break;
  196. default:
  197. break;
  198. }
  199. [_arrMoreBtn addObject:btnModel];
  200. }
  201. }
  202. else {
  203. MoreBtnModel *btnModel = [[MoreBtnModel alloc] initWithTyep:Refresh isEnable:YES];
  204. [_arrMoreBtn addObject:btnModel];
  205. }
  206. }
  207. - (void)returnMoreId:(id)moreButtonId{
  208. NSLog(@"moreButtonId : %@",moreButtonId);
  209. }
  210. - (IBAction)btnCloseEditModeTouched:(id)sender {
  211. }
  212. - (void)addNewMember {
  213. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"HomeMemberAddViewController" storyboardName:@"HomeMember"];
  214. [self presentViewController:vc animated:YES completion:nil];
  215. }
  216. - (void)toggleEditMode {
  217. _isDeleteMode = !_isDeleteMode;
  218. if (!_isDeleteMode) {
  219. for (HomeMemberModel *member in _memberList) {
  220. [[JDFacade facade] setCheckBoxStatus:@(NO) object:member];
  221. }
  222. [self updateTitle];
  223. } else {
  224. _lblTitle.text = @"멤버 삭제";
  225. _imgvHubAlert.hidden = YES;
  226. }
  227. [_collectionView reloadData];
  228. _constraintEditModeRight.constant = _isDeleteMode ? 0 : -_editModeView.width;
  229. [UIView animateWithDuration:kfAnimationDur animations:^{
  230. [self.view layoutIfNeeded];
  231. }];
  232. }
  233. - (void)leaveHomegroup {
  234. if (!_masterNickname) {
  235. NSString *path = [NSString stringWithFormat:API_GET_HOMEGROUP_MEMBERS, [[JDFacade facade].loginUser custId], [[JDFacade facade].loginUser ctrtGrpId]];
  236. [[RequestHandler handler] sendAsyncGetRequestAPIPath:path parameters:nil modelClass:[HomeMemberListModel class] completion:^(id responseObject) {
  237. if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
  238. return;
  239. }
  240. NSLog(@"Member List : %@", responseObject);
  241. HomeMemberListModel *fetchedMemberList = (HomeMemberListModel *)responseObject;
  242. NSArray<HomeMemberModel> *homegrpMemberList = fetchedMemberList.ctrtGrpMemberList;
  243. if (homegrpMemberList && homegrpMemberList.count) {
  244. HomeMemberModel *master = [homegrpMemberList objectKey:@"gradeCode" eqaulToString:KNEET_MEMBER_MASTER];
  245. _masterNickname = master && master.nickname ? master.nickname : ksEmptyString;
  246. [self leaveHomegroup];
  247. }
  248. } failure:^(id errorObject) {
  249. JDErrorModel *error = (JDErrorModel *)errorObject;
  250. [[JDFacade facade] alert:error.errorMessage];
  251. }];
  252. return;
  253. }
  254. NSString *message = [NSString stringWithFormat:@"[%@]님의 홈그룹에서 탈퇴하시겠습니까?", _masterNickname];
  255. [[JDFacade facade] confirmTitle:@"멤버 탈퇴" message:message completion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  256. if (buttonIndex == 0) {//OK
  257. [self requestLeaveHomegroup];
  258. }
  259. }];
  260. }
  261. #pragma mark - Main Logic
  262. - (void)requestHomeMemberList {
  263. if (![JDFacade facade].loginUser.hasHomeHub) {
  264. return;
  265. }
  266. NSString *path = [NSString stringWithFormat:API_GET_HOMEGROUP_MEMBERS, [[JDFacade facade].loginUser custId], [[JDFacade facade].loginUser ctrtGrpId]];
  267. [[RequestHandler handler] sendAsyncGetRequestAPIPath:path parameters:nil modelClass:[HomeMemberListModel class] completion:^(id responseObject) {
  268. if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
  269. return;
  270. }
  271. NSLog(@"Member List : %@", responseObject);
  272. HomeMemberListModel *fetchedMemberList = (HomeMemberListModel *)responseObject;
  273. NSArray<HomeMemberModel> *homegrpMemberList = fetchedMemberList.ctrtGrpMemberList;
  274. if (homegrpMemberList && homegrpMemberList.count) {
  275. _memberList = homegrpMemberList;
  276. } else {//조회 내역이 없을 경우,
  277. }
  278. [self setContents];
  279. [_collectionView reloadData];
  280. //refresh controller
  281. if (self.refreshController && self.refreshController.refreshState == JYRefreshStateLoading) {
  282. [self.refreshController stopRefreshWithAnimated:YES completion:nil];
  283. }
  284. } failure:^(id errorObject) {
  285. JDErrorModel *error = (JDErrorModel *)errorObject;
  286. [[JDFacade facade] alert:error.errorMessage];
  287. }];
  288. }
  289. - (void)setContents {
  290. HomeMemberModel *master = [_memberList objectKey:@"gradeCode" eqaulToString:KNEET_MEMBER_MASTER];
  291. _masterNickname = master && master.nickname ? master.nickname : ksEmptyString;
  292. [self updateTitle];
  293. }
  294. - (void)requestDeleteMembers:(NSString *)memberIds invitations:(NSString *)invitations {
  295. //parameters
  296. NSDictionary *parameter = @{@"member_ids" : ![memberIds isEmptyString] ? memberIds : ksEmptyString,
  297. @"invitation_hist_ids": ![invitations isEmptyString] ? invitations : ksEmptyString};
  298. NSString *path = [NSString stringWithFormat:API_DELETE_HOMEGROUP_MEMBERS];
  299. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:parameter modelClass:[JDJSONModel class] showLoadingView:YES completion:^(id responseObject) {
  300. [self toggleEditMode];
  301. [self requestHomeMemberList];
  302. [[JDFacade facade] toast:NSLocalizedString(@"멤버를 삭제했습니다", @"멤버를 삭제했습니다")];
  303. } failure:^(id errorObject) {
  304. JDErrorModel *error = (JDErrorModel *)errorObject;
  305. [[JDFacade facade] alert:error.errorMessage];
  306. }];
  307. }
  308. - (void)requestLeaveHomegroup {
  309. //api path
  310. NSString *path = [NSString stringWithFormat:API_DELETE_HOMEGROUP_MEMBER, [JDFacade facade].loginUser.memberId];
  311. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:nil modelClass:[JDJSONModel class] showLoadingView:YES completion:^(id responseObject) {
  312. [[JDFacade facade] alertTitle:@"멤버 탈퇴" message:@"탈퇴를 완료했습니다" completionHander:^{
  313. [[JDFacade facade] gotoWishMenu:KNMenuIdDashboard];
  314. }];
  315. } failure:^(id errorObject) {
  316. JDErrorModel *error = (JDErrorModel *)errorObject;
  317. [[JDFacade facade] alert:error.errorMessage];
  318. }];
  319. }
  320. #pragma mark - UICollectionView Delegate
  321. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  322. NSInteger auth = [JDFacade facade].loginUser.level == 90 && !_isDeleteMode; //마스터 권한일 경우,
  323. NSInteger count = _memberList.count % _deviceFlag == 0 ? _memberList.count : _memberList.count + auth; //홀수일 경우, 멤버 초대 버튼을 추가해줌.
  324. return count;
  325. }
  326. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  327. UICollectionViewCell *rcell = nil;
  328. if (indexPath.row < _memberList.count) {
  329. HomeMemberCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCellIdentifier" forIndexPath:indexPath];
  330. HomeMemberModel *member = _memberList[indexPath.row];
  331. cell.indexPath = indexPath;
  332. [cell.btnProfile sd_setBackgroundImageWithURL:[NSURL URLWithString:member.imageFileName] forState:UIControlStateNormal placeholderImage:nil options:SDWebImageRefreshCached];
  333. cell.lblNickname.text = member.nickname;
  334. cell.lblMemID.text = member.memberId;
  335. if ([member.memberTypeCode isEqualToString:KNEET_MEMBER_TYPE_HOME]) {
  336. cell.lblNickname.text = [NSString stringWithFormat:@"%@", cell.lblNickname.text];
  337. UIColor *pcolor = [member.gradeCode isEqualToString:KNEET_MEMBER_MASTER] ? kUITextBlackColor06 : kUITextBlackColor06;
  338. [cell.lblNickname setColor:pcolor text:@"●"];
  339. cell.lblStatus.text = member.gradeCode;
  340. //cell.lblStatus.text = member.gradeCodeName;
  341. [cell.lblStatus setColor:kUITextGreenColor05 text:cell.lblStatus.text];
  342. } else {
  343. if ([member.invitation isEqualToString:@"01"]) {//초대 대기중
  344. cell.lblStatus.text = @"초대 대기 중";
  345. } else if ([member.invitation isEqualToString:@"21"]) {//초대 유효기간 종료
  346. cell.lblStatus.text = @"초대 무효";
  347. } else if ([member.invitation isEqualToString:@"22"]) {//답변 오류 제한 초과
  348. cell.lblStatus.text = @"답변 오류 제한 초과";
  349. } else if ([member.invitation isEqualToString:@"23"]) {//초대 거절
  350. cell.lblStatus.text = @"초대 거절";
  351. }
  352. [cell.lblStatus setColor:kUITextColor03 text:cell.lblStatus.text];
  353. }
  354. cell.chkSelect.hidden = !(_isDeleteMode && [member.gradeCode isEqualToString:KNEET_MEMBER_SIMPLE] && _memberList.count > 1);
  355. cell.chkSelect.value = member;
  356. cell.chkSelect.checked = [cell.chkSelect getCheckStatusFromValue];
  357. rcell = cell;
  358. } else {
  359. HomeMemberAddCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AddCollectionCellIdentifier" forIndexPath:indexPath];
  360. [cell.btnAdd.label setUnderLine:cell.btnAdd.label.text];
  361. if (![cell.btnAdd actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  362. [cell.btnAdd addTarget:self action:@selector(addNewMember) forControlEvents:UIControlEventTouchUpInside];
  363. }
  364. rcell = cell;
  365. }
  366. return rcell;
  367. }
  368. //- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
  369. // viewForSupplementaryElementOfKind:(NSString *)kind
  370. // atIndexPath:(NSIndexPath *)indexPath
  371. //{
  372. //
  373. // HomeMemberCollectionFooterView *footerView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter
  374. // withReuseIdentifier:@"FooterIdentifier" forIndexPath:indexPath];
  375. // [footerView.btnAdd.label setUnderLine:footerView.btnAdd.label.text];
  376. // if (![footerView.btnAdd actionsForTarget:self forControlEvent:UIControlEventTouchUpInside]) {
  377. // [footerView.btnAdd addTarget:self action:@selector(addNewMember) forControlEvents:UIControlEventTouchUpInside];
  378. // }
  379. // return footerView;
  380. //}
  381. //- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
  382. // if (_memberList.count % _deviceFlag != 0 || [JDFacade facade].loginUser.level < 90 || _isDeleteMode) {//마스터 권한이 아니거나, 짝수가 아닐 경우
  383. // return CGSizeZero;
  384. // }
  385. // return CGSizeMake(ViewWidth(_collectionView), 168.0f);
  386. //}
  387. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
  388. NSLog(@"Phone View Size : %f", IPHONE_WIDTH);
  389. NSLog(@"Collection View Size : %f", ViewWidth(_collectionView));
  390. NSLog(@"Cell Width Size : %f", (ViewWidth(_collectionView)-kiCellInset) / kiCellItem);
  391. NSLog(@"Cell Height Size : %f", ((ViewWidth(_collectionView)-kiCellInset)+kiCellRatio) / kiCellItem);
  392. return CGSizeMake((ViewWidth(_collectionView)-kiCellInset) / kiCellItem, ((ViewWidth(_collectionView)-kiCellInset)+kiCellRatio) / kiCellItem);
  393. // return CGSizeMake((ViewWidth(_collectionView)-(_deviceFlag*kiCellInsetSize)) / _deviceFlag, 168.0f);
  394. }
  395. // Cell 사이 최소 간격
  396. - (CGFloat) collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
  397. return kiCellInset;
  398. }
  399. // Line 별 최소 간격
  400. -(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
  401. {
  402. return kiCellInset;
  403. }
  404. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  405. [collectionView deselectItemAtIndexPath:indexPath animated:YES];
  406. if (indexPath.row < _memberList.count) {
  407. HomeMemberCollectionCell *cell = (HomeMemberCollectionCell *)[collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCellIdentifier" forIndexPath:indexPath];
  408. HomeMemberModel *member = _memberList[indexPath.row];
  409. cell.chkSelect.value = member;
  410. [cell.chkSelect checkBoxClicked];
  411. }
  412. }
  413. #pragma mark - UI Events
  414. - (IBAction)btnDeleteOnEditModeTouched:(id)sender {
  415. if (!_isDeleteMode)
  416. return;
  417. NSMutableString *memberIds = [[NSMutableString alloc] init];
  418. NSMutableString *invitationHistIds = [[NSMutableString alloc] init];
  419. for (HomeMemberModel *member in _memberList) {
  420. if ([[[JDFacade facade] getCheckBoxStatus:member] boolValue]) {
  421. if ([member.memberTypeCode isEqualToString:KNEET_MEMBER_TYPE_HOME]) {//홈멤버일 경우,
  422. NSString *prefix = [memberIds isEmptyString] ? ksEmptyString : @",";
  423. [memberIds appendFormat:@"%@%@", prefix, member.memberId];
  424. } else if ([member.memberTypeCode isEqualToString:KNEET_MEMBER_TYPE_INV]) {//초대중일 경우,
  425. NSString *prefix = [invitationHistIds isEmptyString] ? ksEmptyString : @",";
  426. [invitationHistIds appendFormat:@"%@%@", prefix, member.invitationHistId];
  427. }
  428. }
  429. }
  430. if ([memberIds isEmptyString] && [invitationHistIds isEmptyString]) {
  431. [[JDFacade facade] alert:NSLocalizedString(@"선택된 멤버가 없습니다", @"선택된 멤버가 없습니다")];
  432. return;
  433. }
  434. CustomAlertView *alert = [[CustomAlertView alloc] initWithTitle:@"알림" message:@"멤버를 삭제하시겠습니까?\n\n삭제된 멤버는 홈의 모든 기능을\n이용할 수 없게되며,\n참여 대기중인 사람은 초대가\n취소됩니다." delegate:nil OKButtonTitle:@"멤버삭제" cancelButtonTitle:@"취소"];
  435. [alert showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  436. if (buttonIndex == 0) {//OK
  437. [self requestDeleteMembers:memberIds invitations:invitationHistIds];
  438. }
  439. }];
  440. }
  441. - (IBAction)btnCloseOnEditModeTouched:(id)sender {
  442. [self toggleEditMode];
  443. }
  444. //- (IBAction)btnCoverIconTouched:(id)sender {
  445. //
  446. // if (_selectedCoverIcon) {
  447. // [_selectedCoverIcon faceOffImage];
  448. // }
  449. //
  450. // CustomButton *btn = (CustomButton *)sender;
  451. // _selectedCoverIcon = btn;
  452. // [_selectedCoverIcon faceOffImage];
  453. //}
  454. #pragma mark - MoreButtonDelegate
  455. -(void)moreBtnAction:(id)sender
  456. {
  457. NSInteger tag = [(UIButton *)sender tag];
  458. NSLog(@"MoreBtn Action : %li", (long)tag);
  459. switch (tag) {
  460. case MasterTransfer:
  461. {
  462. }
  463. break;
  464. default:
  465. break;
  466. }
  467. }
  468. #pragma mark - MemoryWarning
  469. - (void)didReceiveMemoryWarning
  470. {
  471. [super didReceiveMemoryWarning];
  472. // Dispose of any resources that can be recreated.
  473. }
  474. @end