ModifySecureKeyPopupView.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // ModifySecureKeyPopupView.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 6/23/15.
  6. // Copyright (c) 2015 ntels. All rights reserved.
  7. //
  8. #import "JDObject.h"
  9. #import "RequestHandler.h"
  10. #import "JDJSONModel.h"
  11. #import "CustomLabel.h"
  12. #import "CustomTextField.h"
  13. #import "DeviceModel.h"
  14. #import "ModifySecureKeyPopupView.h"
  15. #import "ValidateUtil.h"
  16. @interface ModifySecureKeyPopupView () <CustomTextFieldDelegate> {
  17. }
  18. @end
  19. @implementation ModifySecureKeyPopupView
  20. - (id)initFromNib {
  21. for (UIView *view in [CommonUtil nibViews:@"ModifySecureKeyPopupView"]) {
  22. if ([view isKindOfClass:[ModifySecureKeyPopupView class]]) {
  23. self = (ModifySecureKeyPopupView *)view;
  24. //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
  25. self.frame = [UIScreen mainScreen].bounds;
  26. self.lblTitle.text = NSLocalizedString(@"장치등록 보안키 변경", @"장치등록 보안키 변경");
  27. _txtSecureCode.delegate = self;
  28. _txtSecureCode.secureTextEntry = YES;
  29. _txtSecureCode.keyboardType = UIKeyboardTypeDefault;
  30. _txtSecureCode.returnKeyType = UIReturnKeyDone;
  31. _txtSecureCodeConfirm.delegate = self;
  32. _txtSecureCodeConfirm.secureTextEntry = YES;
  33. _txtSecureCodeConfirm.keyboardType = UIKeyboardTypeDefault;
  34. _txtSecureCodeConfirm.returnKeyType = UIReturnKeyDone;
  35. _txtSecureCode.placeholder = NSLocalizedString(@"보안키 입력", @"보안키 입력");
  36. _txtSecureCodeConfirm.placeholder = NSLocalizedString(@"보안키 재확인", @"보안키 재확인");
  37. _lblDesc.text = NSLocalizedString(@"보안키를 안전하게 설정할수록\n다른 사람이 장치를 함부로\n등록할 수 없게 보호할 수 있습니다", @"보안키를 안전하게 설정할수록\n다른 사람이 장치를 함부로\n등록할 수 없게 보호할 수 있습니다");
  38. [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  39. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  40. }
  41. }
  42. return self;
  43. }
  44. - (void)didMoveToSuperview {
  45. _txtSecureCode.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  46. _txtSecureCodeConfirm.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  47. }
  48. #pragma mark - Main Logic
  49. #pragma mark - UI Events
  50. - (void)btnConfirmTouched:(id)sender {
  51. //1.validate
  52. if (![ValidateUtil validateTextfiled:_txtSecureCode type:ValidateTypeNull title:NSLocalizedString(@"보안키", @"보안키")]) {
  53. return;
  54. }
  55. if (![ValidateUtil validateTextfiled:_txtSecureCodeConfirm type:ValidateTypeNull title:NSLocalizedString(@"보안키 확인", @"보안키 확인")]) {
  56. return;
  57. }
  58. if (![_txtSecureCode.text isEqualToString:_txtSecureCodeConfirm.text]) {
  59. [[JDFacade facade] alert:NSLocalizedString(@"보안키와 보안키확인이 다릅니다\n다시 입력해주세요", @"보안키와 보안키확인이 다릅니다\n다시 입력해주세요")];
  60. return;
  61. }
  62. [super btnConfirmTouched:sender];
  63. }
  64. #pragma mark - CustomTextField
  65. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  66. if ([textField isEqual:_txtSecureCodeConfirm]) {
  67. [self btnConfirmTouched:nil];
  68. }
  69. return YES;
  70. }
  71. @end