AdminAuthPopupView.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. //
  2. // AdminAuthPopupView.m
  3. // kneet2
  4. //
  5. // Created by Jason Lee on 1/13/16.
  6. // Copyright (c) 2016 ntels. All rights reserved.
  7. //
  8. @import AVFoundation;
  9. #import "JDObject.h"
  10. #import "RequestHandler.h"
  11. #import "JDJSONModel.h"
  12. #import "CustomLabel.h"
  13. #import "CustomTextField.h"
  14. #import "ValidateUtil.h"
  15. #import "AdminAuthPopupView.h"
  16. #define ksSetTopAdminPasswd @"198877"
  17. @interface AdminAuthPopupView () <CustomTextFieldDelegate> {
  18. }
  19. @end
  20. @implementation AdminAuthPopupView
  21. - (id)initFromNib {
  22. for (UIView *view in [CommonUtil nibViews:@"AdminAuthPopupView"]) {
  23. if ([view isKindOfClass:[AdminAuthPopupView class]]) {
  24. self = (AdminAuthPopupView *)view;
  25. //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
  26. self.frame = [UIScreen mainScreen].bounds;
  27. self.lblTitle.text = @"관리자 비밀번호";
  28. _txtPwd.secureTextEntry = YES;
  29. _txtPwd.keyboardType = UIKeyboardTypeDefault;
  30. _txtPwd.returnKeyType = UIReturnKeyDone;
  31. //Localization
  32. [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  33. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  34. }
  35. }
  36. return self;
  37. }
  38. - (void)didMoveToSuperview {
  39. _txtPwd.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  40. }
  41. - (void)btnConfirmTouched:(id)sender {
  42. if (![ValidateUtil validateTextfiled:_txtPwd type:ValidateTypeNull title:NSLocalizedString(@"비밀번호", @"비밀번호")]) {
  43. return;
  44. }
  45. if (![_txtPwd.text isEqualToString:ksSetTopAdminPasswd]) {
  46. [[JDFacade facade] toast:@"비밀번호가 틀렸습니다"];
  47. return;
  48. }
  49. AVAuthorizationStatus avAuthrizationStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
  50. if (avAuthrizationStatus != AVAuthorizationStatusAuthorized) {//카메라 권한이 없을 경우,
  51. NSString *message = MSG_CAMERA_DISABLE;
  52. CustomAlertView *alert = [[CustomAlertView alloc] initWithTitle:@"알림" message:message delegate:nil OKButtonTitle:@"설정" cancelButtonTitle:@"취소"];
  53. [alert showWithCompletion:^(CustomAlertView *alertView, NSInteger buttonIndex) {
  54. if (buttonIndex == 0) {//OK - 이전화면으로
  55. NSURL *settingsURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
  56. [[UIApplication sharedApplication] openURL:settingsURL];
  57. return;
  58. }
  59. }];
  60. }
  61. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"QRCodeViewController" storyboardName:@"HomeHub"];
  62. vc.providesPresentationContextTransitionStyle = YES;
  63. vc.definesPresentationContext = YES;
  64. [vc setModalPresentationStyle:UIModalPresentationOverCurrentContext];
  65. [super btnConfirmTouched:sender];
  66. [[JDFacade facade].currentViewController presentViewController:vc animated:YES completion:nil];
  67. }
  68. #pragma mark - CustomTextField
  69. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  70. if ([textField isEqual:_txtPwd]) {
  71. [self btnConfirmTouched:nil];
  72. }
  73. return YES;
  74. }
  75. @end