AgreementViewController.m 6.8 KB

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