AgreementViewController.m 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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. Step Page Text Color
  16. - 현재 : kUITextColor01
  17. - 전체 : kUITextColor03
  18. 서비스 이용약관 , 개인정보 취급방침 Text Color : kUITextColor01
  19. 내용 보기 Text Color : kUITextColor03
  20. 동의 Text Color : kUITextColor01
  21. 안내 문구 Text Color : kUITextColor01
  22. **/
  23. @implementation AgreementTermTableViewCell
  24. - (void)didMoveToSuperview {
  25. // [_lblTitle setUnderLine:_lblTitle.text];
  26. }
  27. @end
  28. @implementation AgreementServiceTableViewCell
  29. - (void)didMoveToSuperview {
  30. // [_lblTitle setUnderLine:_lblTitle.text];
  31. }
  32. @end
  33. @implementation AgreementLocationTableViewCell
  34. - (void)didMoveToSuperview{
  35. }
  36. @end
  37. @implementation AgreementAllTableViewCell
  38. - (void)didMoveToSuperview {
  39. }
  40. @end
  41. @implementation AgreementGuideTableViewCell
  42. - (void)didMoveToSuperview {
  43. // [_lblGuide setUnderLine:_lblGuide.text];
  44. }
  45. @end
  46. @interface AgreementViewController () <CustomCheckBoxDelegate,signTypeDelegate> {
  47. NSArray *_tableZombieValues;
  48. CustomCheckBox *_chkTerm, *_chkService, *_chkAll,*_chkLocation;
  49. BOOL _isNotFirstLoading;
  50. }
  51. @end
  52. #pragma mark - Class Definition
  53. @implementation AgreementViewController
  54. - (void)viewDidLoad {
  55. [super viewDidLoad];
  56. // Do any additional setup after loading the view.
  57. SignUpTypeSelectViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"SignUpTypeSelectViewController" storyboardName:@"SignUp"];
  58. vc.delegate = self;
  59. [self initUI];
  60. [self prepareViewDidLoad];
  61. }
  62. - (void)initUI {
  63. [self.navigationController.navigationBar setHidden:YES];
  64. [_lblStep setColor:kUITextColor03 text:[NSString stringWithFormat:@"%@", @"/ 5"]];
  65. // _tableZombieValues = @[@"t0", @"t1", @"t2", @"t3",@"t4"];
  66. _tableZombieValues = @[@"t0", @"t1", @"t3",@"t4"];
  67. [self initTableViewAsDefaultStyle:_tableView];
  68. }
  69. - (void)signType:(NSString *)type {
  70. NSLog(@"TYPE : %@",type);
  71. }
  72. - (void)prepareViewDidLoad {
  73. }
  74. - (void)viewDidAppear:(BOOL)animated {
  75. [super viewDidAppear:animated];
  76. }
  77. #pragma mark - Main Logic
  78. #pragma mark - UITableView DataSource & Delegate
  79. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  80. return 1;
  81. }
  82. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  83. return 4;
  84. // return 5;
  85. }
  86. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  87. CGFloat height = 114;
  88. if (indexPath.row == 3) {
  89. height = 120;
  90. }
  91. // if (indexPath.row == 2) {
  92. // height = 80;
  93. // } else if (indexPath.row == 3) {
  94. // height = 120;
  95. // }
  96. return height;
  97. }
  98. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  99. UITableViewCell *cell = nil;
  100. NSString *tzombie = _tableZombieValues[indexPath.row];
  101. if (indexPath.row == 0) {
  102. AgreementTermTableViewCell *tcell = (AgreementTermTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"TermCellIdentifier"];
  103. if (!_chkTerm) {
  104. _chkTerm = tcell.chkAgree;
  105. }
  106. tcell.chkAgree.delegate = self;
  107. tcell.chkAgree.value = tzombie;
  108. tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
  109. cell = tcell;
  110. } else if (indexPath.row == 1) {
  111. AgreementServiceTableViewCell *tcell = (AgreementServiceTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"ServiceCellIdentifier"];
  112. if (!_chkService) {
  113. _chkService = tcell.chkAgree;
  114. }
  115. tcell.chkAgree.delegate = self;
  116. tcell.chkAgree.value = tzombie;
  117. tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
  118. cell = tcell;
  119. }
  120. // else if (indexPath.row == 2) {
  121. // AgreementLocationTableViewCell *tcell = (AgreementLocationTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"locationCellIdentifier"];
  122. //
  123. // if (!_chkLocation) {
  124. // _chkLocation = tcell.chkAgree;
  125. // }
  126. //
  127. // tcell.chkAgree.delegate = self;
  128. // tcell.chkAgree.value = tzombie;
  129. // tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
  130. //
  131. // cell = tcell;
  132. // }
  133. else if (indexPath.row == 2){
  134. AgreementAllTableViewCell *tcell = (AgreementAllTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"AllCellIdentifier"];
  135. if (!_chkAll) {
  136. _chkAll = tcell.chkAgree;
  137. }
  138. tcell.chkAgree.delegate = self;
  139. tcell.chkAgree.value = tzombie;
  140. tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
  141. cell = tcell;
  142. }else if (indexPath.row == 3) {//Guide
  143. AgreementGuideTableViewCell *tcell = (AgreementGuideTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"GuideCellIdentifier"];
  144. cell = tcell;
  145. }
  146. return cell;
  147. }
  148. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  149. [super tableView:tableView didSelectRowAtIndexPath:indexPath];
  150. if (indexPath.row == 2 || indexPath.row == 3) {
  151. return;
  152. }
  153. NSString *URLString = nil;
  154. if (indexPath.row == 0) {
  155. URLString = [NSString stringWithFormat:@"%@%@", kWebLinkServer, URL_PATH_TERMS];
  156. } else if (indexPath.row == 1) {
  157. URLString = [NSString stringWithFormat:@"%@%@", kWebLinkServer, URL_PATH_POLICY];
  158. }
  159. NSLog(@"URL String : %@", URLString);
  160. [[JDFacade facade] loadURLExternalBrowser:URLString];
  161. }
  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. } else {
  168. // if (_chkTerm.checked && _chkService.checked && _chkLocation.checked) {
  169. if (_chkTerm.checked && _chkService.checked) {
  170. _chkAll.checked = YES;
  171. } else {
  172. _chkAll.checked = NO;
  173. }
  174. }
  175. }
  176. #pragma mark - UI Events
  177. - (IBAction)btnNextTouched:(id)sender {
  178. if (!_chkAll.checked) {
  179. [[JDFacade facade] toast:@"모든 약관에 동의해주세요"];
  180. return;
  181. }
  182. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"CertificationViewController" storyboardName:@"SignUp"];
  183. // vc.providesPresentationContextTransitionStyle = YES;
  184. // vc.definesPresentationContext = YES;
  185. //
  186. // [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
  187. //
  188. // [self presentViewController:vc animated:YES completion:nil];
  189. [self.navigationController pushViewController:vc animated:YES];
  190. }
  191. - (IBAction)btnCancelTouched:(id)sender {
  192. [self dismissViewControllerAnimated:YES completion:nil];
  193. }
  194. #pragma mark - MemoryWarning
  195. - (void)viewDidDisappear:(BOOL)animated {
  196. [super viewDidDisappear:animated];
  197. for (NSString *zombie in _tableZombieValues) {
  198. [[JDFacade facade] setCheckBoxStatus:@NO object:zombie];
  199. }
  200. _tableZombieValues = nil;
  201. }
  202. - (void)didReceiveMemoryWarning
  203. {
  204. [super didReceiveMemoryWarning];
  205. // Dispose of any resources that can be recreated.
  206. }
  207. @end