QRCodeInputPopupView.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  35. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  36. }
  37. }
  38. return self;
  39. }
  40. - (void)didMoveToSuperview {
  41. self.txtActivationCode.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  42. self.txtPasswd.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  43. }
  44. #pragma mark - Main Logic
  45. #pragma mark - UI Events
  46. - (void)btnConfirmTouched:(id)sender {
  47. #if TARGET_IPHONE_SIMULATOR
  48. if (_qrcodeType == QRCodeTypeHomeHub) {
  49. if ([_txtActivationCode.text isEmptyString]) {
  50. // _txtActivationCode.text = @"NTels-d73df166b7a8151b";
  51. _txtActivationCode.text = @"NTels-cd39b0d2526513ec";
  52. }
  53. if ([_txtPasswd.text isEmptyString]) {
  54. _txtPasswd.text = @"091377";
  55. }
  56. }
  57. #endif
  58. //1.validate
  59. if (![ValidateUtil validateTextfiled:_txtActivationCode type:ValidateTypeNull title:@"코드"]) {
  60. return;
  61. }
  62. if (![ValidateUtil validateTextfiled:_txtPasswd type:ValidateTypeNull title:@"PW"]) {
  63. return;
  64. }
  65. QRCodeViewController *vc = (QRCodeViewController *)[JDFacade facade].currentViewController;
  66. if (![vc isKindOfClass:[QRCodeViewController class]]) {
  67. vc = [[JDFacade facade] viewControllerOnPresentedViewController:[JDFacade facade].currentViewController viewControllerClass:[QRCodeViewController class]];
  68. }
  69. if (vc) {
  70. [vc requestQRAuthrize:_txtActivationCode.text password:_txtPasswd.text];
  71. }
  72. // [super btnConfirmTouched:sender];
  73. }
  74. #pragma mark - CustomTextField
  75. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  76. if ([textField isEqual:_txtPasswd]) {
  77. [self btnConfirmTouched:nil];
  78. }
  79. return YES;
  80. }
  81. @end