ModifySecureKeyPopupView.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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.imgTitleBar setImage:[UIImage imageNamed:@"img_popup_bg_head"]inset:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  39. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  40. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  41. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  42. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  43. [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  44. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  45. }
  46. }
  47. return self;
  48. }
  49. - (void)didMoveToSuperview {
  50. _txtSecureCode.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  51. _txtSecureCodeConfirm.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  52. }
  53. #pragma mark - Main Logic
  54. #pragma mark - UI Events
  55. - (void)btnConfirmTouched:(id)sender {
  56. //1.validate
  57. if (![ValidateUtil validateTextfiled:_txtSecureCode type:ValidateTypeNull title:NSLocalizedString(@"보안키", @"보안키")]) {
  58. return;
  59. }
  60. if (![ValidateUtil validateTextfiled:_txtSecureCodeConfirm type:ValidateTypeNull title:NSLocalizedString(@"보안키 확인", @"보안키 확인")]) {
  61. return;
  62. }
  63. if (![_txtSecureCode.text isEqualToString:_txtSecureCodeConfirm.text]) {
  64. [[JDFacade facade] alert:NSLocalizedString(@"보안키와 보안키확인이 다릅니다\n다시 입력해주세요", @"보안키와 보안키확인이 다릅니다\n다시 입력해주세요")];
  65. return;
  66. }
  67. [super btnConfirmTouched:sender];
  68. }
  69. #pragma mark - CustomTextField
  70. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  71. if ([textField isEqual:_txtSecureCodeConfirm]) {
  72. [self btnConfirmTouched:nil];
  73. }
  74. return YES;
  75. }
  76. @end