| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- //
- // AgreementViewController.m
- // kneet2
- //
- // Created by Jason Lee on 10/15/15.
- // Copyright © 2015 ntels. All rights reserved.
- //
- #import "AgreementViewController.h"
- #import "CustomLabel.h"
- #import "CustomCheckBox.h"
- #import "CustomTableView.h"
- #import "WebBrowseViewController.h"
- @implementation AgreementTermTableViewCell
- - (void)didMoveToSuperview {
- // [_lblTitle setUnderLine:_lblTitle.text];
- }
- @end
- @implementation AgreementServiceTableViewCell
- - (void)didMoveToSuperview {
- // [_lblTitle setUnderLine:_lblTitle.text];
- }
- @end
- @implementation AgreementLocationTableViewCell
- - (void)didMoveToSuperview{
-
- }
- @end
- @implementation AgreementAllTableViewCell
- - (void)didMoveToSuperview {
- }
- @end
- @implementation AgreementGuideTableViewCell
- - (void)didMoveToSuperview {
- // [_lblGuide setUnderLine:_lblGuide.text];
- }
- @end
- @interface AgreementViewController () <CustomCheckBoxDelegate> {
- NSArray *_tableZombieValues;
- CustomCheckBox *_chkTerm, *_chkService, *_chkAll,*_chkLocation;
- BOOL _isNotFirstLoading;
- }
- @end
- #pragma mark - Class Definition
- @implementation AgreementViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- [self initUI];
- [self prepareViewDidLoad];
- }
- - (void)initUI {
- [self.btnCancle setBackgroundImage:[UIImage imageNamed:@"Common_button_left_bg"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
-
- [self.btnNext setBackgroundImage:[UIImage imageNamed:@"Common_button_right_bg"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
-
- _tableZombieValues = @[@"t0", @"t1", @"t2", @"t3",@"t4"];
-
- [self initTableViewAsDefaultStyle:_tableView];
- }
- - (void)prepareViewDidLoad {
-
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
-
- }
- #pragma mark - Main Logic
- #pragma mark - UITableView DataSource & Delegate
- - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return 1;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return 5;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- CGFloat height = 67;
-
- // if (indexPath.row == 2) {
- // height = 80;
- // } else if (indexPath.row == 3) {
- // height = 120;
- // }
-
- return height;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- UITableViewCell *cell = nil;
- NSString *tzombie = _tableZombieValues[indexPath.row];
-
- if (indexPath.row == 0) {
- AgreementTermTableViewCell *tcell = (AgreementTermTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"TermCellIdentifier"];
-
- if (!_chkTerm) {
- _chkTerm = tcell.chkAgree;
- }
-
- tcell.chkAgree.delegate = self;
- tcell.chkAgree.value = tzombie;
- tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
-
- cell = tcell;
- } else if (indexPath.row == 1) {
- AgreementServiceTableViewCell *tcell = (AgreementServiceTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"ServiceCellIdentifier"];
-
- if (!_chkService) {
- _chkService = tcell.chkAgree;
- }
-
- tcell.chkAgree.delegate = self;
- tcell.chkAgree.value = tzombie;
- tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
-
- cell = tcell;
-
- }else if (indexPath.row == 2) {
- AgreementLocationTableViewCell *tcell = (AgreementLocationTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"locationCellIdentifier"];
-
- if (!_chkLocation) {
- _chkLocation = tcell.chkAgree;
- }
-
- tcell.chkAgree.delegate = self;
- tcell.chkAgree.value = tzombie;
- tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
- cell = tcell;
-
-
- }else if (indexPath.row == 3){
- AgreementAllTableViewCell *tcell = (AgreementAllTableViewCell * )[tableView dequeueReusableCellWithIdentifier:@"AllCellIdentifier"];
-
- if (!_chkAll) {
- _chkAll = tcell.chkAgree;
- }
-
- tcell.chkAgree.delegate = self;
- tcell.chkAgree.value = tzombie;
- tcell.chkAgree.checked = [tcell.chkAgree getCheckStatusFromValue];
-
- cell = tcell;
-
- }else if (indexPath.row == 4) {//Guide
- AgreementGuideTableViewCell *tcell = (AgreementGuideTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"GuideCellIdentifier"];
- cell = tcell;
- }
-
- return cell;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [super tableView:tableView didSelectRowAtIndexPath:indexPath];
-
- if (indexPath.row == 2 || indexPath.row == 3) {
- return;
- }
-
- NSString *URLString = nil;
- if (indexPath.row == 0) {
- URLString = [NSString stringWithFormat:@"%@%@", kAPIServer, URL_PATH_TERMS];
-
- } else if (indexPath.row == 1) {
- URLString = [NSString stringWithFormat:@"%@%@", kAPIServer, URL_PATH_POLICY];
- }
-
- [[JDFacade facade] loadURLExternalBrowser:URLString];
- }
- #pragma mark - CustomCheckBox Delegate {
- - (void)didCheckBoxClicked:(id)sender {
-
- if ([sender isEqual:_chkAll]) {
- _chkTerm.checked = _chkService.checked = _chkLocation.checked =_chkAll.checked;
- } else {
- if (_chkTerm.checked && _chkService.checked && _chkLocation.checked) {
- _chkAll.checked = YES;
- } else {
- _chkAll.checked = NO;
- }
- }
- }
- #pragma mark - UI Events
- - (IBAction)btnNextTouched:(id)sender {
-
- if (!_chkAll.checked) {
- [[JDFacade facade] toast:@"모든 약관에 동의해주세요"];
- return;
- }
-
- UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"CertificationViewController" storyboardName:@"SignUp"];
-
- vc.providesPresentationContextTransitionStyle = YES;
- vc.definesPresentationContext = YES;
-
- [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
-
- [self presentViewController:vc animated:YES completion:nil];
- }
- - (IBAction)btnCancelTouched:(id)sender {
- [self dismissViewControllerAnimated:YES completion:nil];
- }
- #pragma mark - MemoryWarning
- - (void)viewDidDisappear:(BOOL)animated {
- [super viewDidDisappear:animated];
-
- for (NSString *zombie in _tableZombieValues) {
- [[JDFacade facade] setCheckBoxStatus:@NO object:zombie];
- }
-
- _tableZombieValues = nil;
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|