AgreementViewController.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. //
  2. // AgreementViewController.m
  3. // kneet2
  4. //
  5. // Created by Jason Lee on 10/15/15.
  6. // Copyright © 2015 ntels. All rights reserved.
  7. //
  8. #import "AgreementViewController.h"
  9. #import "CustomLabel.h"
  10. #import "CustomCheckBox.h"
  11. #import "CustomTableView.h"
  12. #import "WebBrowseViewController.h"
  13. #import "SignUpTypeSelectViewController.h"
  14. /**
  15. 현재 Term,Service,All,Guide Cell을 사용 중이나 Guide Cell 에서 lblGuide는 Hidden 처리 중
  16. **/
  17. @implementation AgreementTermTableViewCell
  18. - (void)didMoveToSuperview {
  19. // [_lblTitle setUnderLine:_lblTitle.text];
  20. }
  21. @end
  22. @implementation AgreementServiceTableViewCell
  23. - (void)didMoveToSuperview {
  24. // [_lblTitle setUnderLine:_lblTitle.text];
  25. }
  26. @end
  27. @implementation AgreementLocationTableViewCell
  28. - (void)didMoveToSuperview{
  29. }
  30. @end
  31. @implementation AgreementAllTableViewCell
  32. - (void)didMoveToSuperview {
  33. }
  34. @end
  35. @implementation AgreementGuideTableViewCell
  36. - (void)didMoveToSuperview {
  37. // [_lblGuide setUnderLine:_lblGuide.text];
  38. }
  39. @end
  40. @interface AgreementViewController () <CustomCheckBoxDelegate> {
  41. NSArray *_tableZombieValues;
  42. CustomCheckBox *_chkTerm, *_chkService, *_chkAll,*_chkLocation;
  43. BOOL _isNotFirstLoading;
  44. }
  45. @end
  46. #pragma mark - Class Definition
  47. @implementation AgreementViewController
  48. - (void)viewDidLoad {
  49. [super viewDidLoad];
  50. [self initUI];
  51. [self prepareViewDidLoad];
  52. }
  53. // UI 설정
  54. - (void)initUI {
  55. [self.navigationController.navigationBar setHidden:YES];
  56. _btnNext.enabled = NO;
  57. [_lblStep setColor:kUITextColor03 text:[NSString stringWithFormat:@"%@", @"/ 5"]];
  58. NSLog(@"signType : %@",[JDFacade facade].signType);
  59. // _tableZombieValues = @[@"t0", @"t1", @"t2", @"t3",@"t4"];
  60. _tableZombieValues = @[@"t0", @"t1", @"t3",@"t4"];
  61. [self initTableViewAsDefaultStyle:_tableView];
  62. }
  63. - (void)prepareViewDidLoad {
  64. }
  65. - (void)viewDidAppear:(BOOL)animated {
  66. [super viewDidAppear:animated];
  67. }
  68. #pragma mark - Main Logic
  69. #pragma mark - UITableView DataSource & Delegate
  70. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  71. return 1;
  72. }
  73. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  74. return 4;
  75. // return 5;
  76. }
  77. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  78. CGFloat height = 114;
  79. if (indexPath.row == 3) {
  80. height = 120;
  81. }
  82. // if (indexPath.row == 2) {
  83. // height = 80;
  84. // } else if (indexPath.row == 3) {
  85. // height = 120;
  86. // }
  87. return height;
  88. }
  89. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  90. UITableViewCell *cell = nil;
  91. NSString *tzombie = _tableZombieValues[indexPath.row];
  92. // 서비스 이용약관 Cell
  93. if (indexPath.row == 0) {
  94. AgreementTermTableViewCell *tcell = (AgreementTermTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"TermCellIdentifier"];
  95. // CheckBox Check여부 확인
  96. if (!_chkTerm) {
  97. _chkTerm = tcell.chkAgree;
  98. }
  99. tcell.chkAgree.delegate = self;
  100. tcell.chkAgree.value = tzombie;
  101. tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
  102. cell = tcell;
  103. // 개인정보 취급방침 Cell
  104. } else if (indexPath.row == 1) {
  105. AgreementServiceTableViewCell *tcell = (AgreementServiceTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"ServiceCellIdentifier"];
  106. if (!_chkService) {
  107. _chkService = tcell.chkAgree;
  108. }
  109. tcell.chkAgree.delegate = self;
  110. tcell.chkAgree.value = tzombie;
  111. tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
  112. cell = tcell;
  113. }
  114. // 위치기반 서비스 이용안내 Cell
  115. // else if (indexPath.row == 2) {
  116. // AgreementLocationTableViewCell *tcell = (AgreementLocationTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"locationCellIdentifier"];
  117. //
  118. // if (!_chkLocation) {
  119. // _chkLocation = tcell.chkAgree;
  120. // }
  121. //
  122. // tcell.chkAgree.delegate = self;
  123. // tcell.chkAgree.value = tzombie;
  124. // tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
  125. //
  126. // cell = tcell;
  127. // }
  128. // 전체 동의 Cell
  129. else if (indexPath.row == 2){
  130. AgreementAllTableViewCell *tcell = (AgreementAllTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"AllCellIdentifier"];
  131. if (!_chkAll) {
  132. _chkAll = tcell.chkAgree;
  133. }
  134. tcell.chkAgree.delegate = self;
  135. tcell.chkAgree.value = tzombie;
  136. tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
  137. cell = tcell;
  138. // Guide Cell
  139. }else if (indexPath.row == 3) {
  140. AgreementGuideTableViewCell *tcell = (AgreementGuideTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"GuideCellIdentifier"];
  141. cell = tcell;
  142. }
  143. return cell;
  144. }
  145. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  146. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  147. if (indexPath.row == 2 || indexPath.row == 3) {
  148. return;
  149. }
  150. // 서비스 이용약관 내용보기
  151. NSString *URLString = nil;
  152. if (indexPath.row == 0) {
  153. URLString = [NSString stringWithFormat:@"%@%@", kWebLinkServer, URL_PATH_TERMS];
  154. // 개인정보 취급방침 내용보기
  155. } else if (indexPath.row == 1) {
  156. URLString = [NSString stringWithFormat:@"%@%@", kWebLinkServer, URL_PATH_POLICY];
  157. }
  158. NSLog(@"URL String : %@", URLString);
  159. [[JDFacade facade] loadURLExternalBrowser:URLString];
  160. }
  161. // CheckBox Check여부에 따라 다음버튼 Enable여부 설정
  162. #pragma mark - CustomCheckBox Delegate {
  163. - (void)didCheckBoxClicked:(id)sender {
  164. if ([sender isEqual:_chkAll]) {
  165. // _chkTerm.checked = _chkService.checked = _chkLocation.checked =_chkAll.checked;
  166. _chkTerm.checked = _chkService.checked =_chkAll.checked;
  167. _btnNext.enabled = _chkAll.checked;
  168. } else {
  169. _chkAll.checked = _chkTerm.checked && _chkService.checked;
  170. _btnNext.enabled = _chkTerm.checked && _chkService.checked;
  171. }
  172. }
  173. // 휴대폰 번호 인증 메뉴로 이동
  174. #pragma mark - UI Events
  175. - (IBAction)btnNextTouched:(id)sender {
  176. // if (!_chkAll.checked) {
  177. // [[JDFacade facade] toast:@"모든 약관에 동의해주세요"];
  178. // return;
  179. // }
  180. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"CertificationViewController" storyboardName:@"SignUp"];
  181. [self.navigationController pushViewController:vc animated:YES];
  182. }
  183. // 메뉴 닫기
  184. - (IBAction)btnCancelTouched:(id)sender {
  185. [self dismissViewControllerAnimated:YES completion:nil];
  186. }
  187. #pragma mark - MemoryWarning
  188. - (void)viewDidDisappear:(BOOL)animated {
  189. [super viewDidDisappear:animated];
  190. for (NSString *zombie in _tableZombieValues) {
  191. [[JDFacade facade] setCheckBoxStatus:@NO object:zombie];
  192. }
  193. _tableZombieValues = nil;
  194. }
  195. - (void)didReceiveMemoryWarning
  196. {
  197. [super didReceiveMemoryWarning];
  198. // Dispose of any resources that can be recreated.
  199. }
  200. @end