HomeMemberViewController.m 23 KB

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