QRCodeInputPopupView.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // QRCodeInputPopupView.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 5/18/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 "QRCodeInputPopupView.h"
  15. #import "ValidateUtil.h"
  16. @interface QRCodeInputPopupView () <CustomTextFieldDelegate> {
  17. }
  18. @end
  19. @implementation QRCodeInputPopupView
  20. - (id)initFromNib {
  21. for (UIView *view in [CommonUtil nibViews:@"QRCodeInputPopupView"]) {
  22. if ([view isKindOfClass:[QRCodeInputPopupView class]]) {
  23. self = (QRCodeInputPopupView *)view;
  24. //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
  25. self.frame = [UIScreen mainScreen].bounds;
  26. NSLog(@"%s\n %@", __PRETTY_FUNCTION__, self.popUpView);
  27. self.lblTitle.text = NSLocalizedString(@"활성화 코드 직접 입력",nil);
  28. _txtActivationCode.keyboardType = UIKeyboardTypeDefault;
  29. _txtActivationCode.returnKeyType = UIReturnKeyDone;
  30. _txtPasswd.delegate = self;
  31. _txtPasswd.secureTextEntry = YES;
  32. _txtPasswd.keyboardType = UIKeyboardTypeDefault;
  33. _txtPasswd.returnKeyType = UIReturnKeyDone;
  34. _txtActivationCode.placeholder = NSLocalizedString(@"활성화코드", @"활성화코드");
  35. _txtPasswd.placeholder = NSLocalizedString(@"비밀번호", @"비밀번호");
  36. [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  37. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  38. }
  39. }
  40. return self;
  41. }
  42. - (void)didMoveToSuperview {
  43. self.txtActivationCode.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  44. self.txtPasswd.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  45. }
  46. #pragma mark - Main Logic
  47. #pragma mark - UI Events
  48. - (void)btnConfirmTouched:(id)sender {
  49. #if TARGET_IPHONE_SIMULATOR
  50. if (_qrcodeType == QRCodeTypeHomeHub) {
  51. // _txtActivationCode.text = @"COMMAX_00-FF-B0-F5-5F-07";
  52. // _txtActivationCode.text = @"COMMAX_12345678901234567890";
  53. if ([_txtActivationCode.text isEmptyString]) {
  54. _txtActivationCode.text = @"KNEET200010001";
  55. }
  56. }
  57. #endif
  58. //1.validate
  59. if (![ValidateUtil validateTextfiled:_txtActivationCode type:ValidateTypeNull title:NSLocalizedString(@"활성화코드", @"활성화코드")]) {
  60. return;
  61. }
  62. if (![ValidateUtil validateTextfiled:_txtPasswd type:ValidateTypeNull title:NSLocalizedString(@"비밀번호", @"비밀번호")]) {
  63. return;
  64. }
  65. [super btnConfirmTouched:sender];
  66. }
  67. #pragma mark - CustomTextField
  68. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  69. if ([textField isEqual:_txtPasswd]) {
  70. [self btnConfirmTouched:nil];
  71. }
  72. return YES;
  73. }
  74. @end