AgreementViewController.m 7.1 KB

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