HomeLocationViewController.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // HomeLocationViewController.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 4/23/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "RequestHandler.h"
  10. #import "CustomButton.h"
  11. #import "ValidateUtil.h"
  12. #import "CustomTextField.h"
  13. #import "CustomAlertView.h"
  14. #import "CustomRadioGroup.h"
  15. #import "PopTableView.h"
  16. #import "HomeLocationViewController.h"
  17. @interface HomeLocationViewController () <CLLocationManagerDelegate, MKMapViewDelegate, PopTableViewDelegate, CustomTextFieldDelegate, CustomRadioGroupDelegate> {
  18. }
  19. @end
  20. #pragma mark - Class Definition
  21. @implementation HomeLocationViewController
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. // Do any additional setup after loading the view.
  25. [self initUI];
  26. [self prepareViewDidLoad];
  27. }
  28. - (void)viewWillAppear:(BOOL)animated {
  29. [super viewWillAppear:animated];
  30. self.title = NSLocalizedString(@"홈의 위치를 등록하세요", nil);
  31. }
  32. - (void)initUI {
  33. _txtKeyword.delegate = self;
  34. _txtKeyword.keyboardType = UIKeyboardTypeDefault;
  35. _txtKeyword.returnKeyType = UIReturnKeySearch;
  36. _rdoRadius100.value = @100;
  37. _rdoRadius300.value = @300;
  38. _rdoRadius500.value = @500;
  39. _rdoRadius1000.value = @1000;
  40. _rgroup = [[CustomRadioGroup alloc] initWithRadioButtons:_rdoRadius100, _rdoRadius300, _rdoRadius500, _rdoRadius1000, nil];
  41. _rgroup.delegate = self;
  42. //Localization
  43. _txtKeyword.placeholder = NSLocalizedString(@"주소 검색", @"주소 검색");
  44. [_btnRegister setTitle:NSLocalizedString(@"다음", @"다음") forState:UIControlStateNormal];
  45. }
  46. - (void)viewDidAppear:(BOOL)animated {
  47. [super viewDidAppear:animated];
  48. if (!_isEnableLocatonService) {
  49. [self.navigationController popViewControllerAnimated:YES];
  50. }
  51. }
  52. - (void)prepareViewDidLoad {
  53. }
  54. #pragma mark - Main Logic
  55. #pragma mark - UI Events
  56. - (IBAction)btnCurrentLocationTouched:(id)sender {
  57. }
  58. //구글 지오코딩 요청.
  59. - (void)btnSearchAddrTouched:(id)sender {
  60. #ifdef DEBUG_MODE
  61. if ([_txtKeyword.text isEmptyString]) {
  62. _txtKeyword.text = @"삼성동";
  63. }
  64. #endif
  65. [_txtKeyword resignFirstResponder];
  66. if (![ValidateUtil validateTextfiled:_txtKeyword type:ValidateTypeNull title:NSLocalizedString(@"주소", @"주소")]) {
  67. return;
  68. }
  69. }
  70. - (void)checkNewMobileDevice {
  71. //새로운 단말인 경우,
  72. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"NewMobileViewController" storyboardName:@"SignUp"];
  73. [[JDFacade facade] presentViewControllerByPush:vc pvc:self];
  74. }
  75. - (IBAction)btnRegisterTouched:(id)sender {
  76. JDGeofenceAnnotation *pin = nil;
  77. for (id annotation in _mapView.annotations) {
  78. if (annotation != _mapView.userLocation) {
  79. pin = annotation;
  80. break;
  81. }
  82. }
  83. if (!pin) {//선택된 곳이 있는지 확인
  84. [[JDFacade facade] alert:NSLocalizedString(@"홈 위치를 먼저 설정해 주세요", @"홈 위치를 먼저 설정해 주세요")];
  85. return;
  86. }
  87. // //1. validate
  88. // if (!_pinAnnotation || [_pinAnnotation.title isEmptyString] || (_pinAnnotation.coordinate.latitude == 0 || _pinAnnotation.coordinate.longitude == 0)) {
  89. // [[JDFacade facade] alert:@"홈 위치를 먼저 설정해 주세요"];
  90. // return;
  91. // }
  92. }
  93. - (IBAction)btnRegisterLaterTouched:(id)sender {
  94. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"SignUpCompleteViewController" storyboardName:@"SignUp"];
  95. [[JDFacade facade] presentViewControllerByPush:vc pvc:self];
  96. }
  97. #pragma mark - CustomTextField
  98. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  99. [self btnSearchAddrTouched:nil];
  100. return YES;
  101. }
  102. #pragma mark - MemoryWarning
  103. - (void)didReceiveMemoryWarning
  104. {
  105. [super didReceiveMemoryWarning];
  106. // Dispose of any resources that can be recreated.
  107. }
  108. @end