ConfirmPasswdPopupView.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. //
  2. // ConfirmPasswdPopupView.m
  3. // OneCable
  4. //
  5. // Created by Jason Lee on 01/14/15.
  6. // Copyright (c) 2016 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 "ValidateUtil.h"
  14. #import "ConfirmPasswdPopupView.h"
  15. #import "PwdPopupView.h"
  16. @interface ConfirmPasswdPopupView () <CustomTextFieldDelegate>
  17. {
  18. }
  19. @end
  20. @implementation ConfirmPasswdPopupView
  21. - (id)initFromNib {
  22. for (UIView *view in [CommonUtil nibViews:@"ConfirmPasswdPopupView"]) {
  23. if ([view isKindOfClass:[ConfirmPasswdPopupView class]]) {
  24. self = (ConfirmPasswdPopupView *)view;
  25. //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
  26. self.frame = [UIScreen mainScreen].bounds;
  27. _txtPasswd.keyboardType = UIKeyboardTypeDefault;
  28. _txtPasswd.returnKeyType = UIReturnKeyDone;
  29. //Localization
  30. [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  31. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  32. }
  33. }
  34. return self;
  35. }
  36. - (void)didMoveToSuperview {
  37. if (!self.superview) {
  38. return;
  39. }
  40. _txtPasswd.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  41. }
  42. #pragma mark - Main Logic
  43. - (void)requestCheckUserPasswd {
  44. //parameters
  45. NSDictionary *parameter = @{@"password": _txtPasswd.text};
  46. NSString *path = [NSString stringWithFormat:API_GET_CHECK_PWD, [JDFacade facade].loginUser.memberId];
  47. [[RequestHandler handler] sendAsyncGetRequestAPIPath:path parameters:parameter modelClass:[JDJSONModel class] completion:^(id responseObject) {
  48. [self loadPopup];
  49. } failure:^(id errorObject) {
  50. JDErrorModel *error = (JDErrorModel *)errorObject;
  51. [[JDFacade facade] alert:error.errorMessage];
  52. }];
  53. }
  54. - (void)loadPopup {
  55. PwdPopupView *popup = [[PwdPopupView alloc] initFromNib];
  56. [popup show];
  57. [super btnConfirmTouched:nil];
  58. }
  59. #pragma mark - UI Events
  60. - (IBAction)btnConfirmTouched:(id)sender {
  61. //validate
  62. if (![ValidateUtil validateTextfiled:_txtPasswd type:ValidateTypeNull title:@"비밀번호"]) {
  63. return;
  64. }
  65. [self requestCheckUserPasswd];
  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