AgreementViewController.m 7.3 KB

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