AgreementViewController.m 7.3 KB

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