ConfirmPasswdPopupView.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. [self.imgTitleBar setImage:[UIImage imageNamed:@"img_popup_bg_head"]inset:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  30. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  31. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  32. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  33. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  34. //Localization
  35. [self.btnConfirm setTitle:NSLocalizedString(@"확인", @"확인") forState:UIControlStateNormal];
  36. [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
  37. }
  38. }
  39. return self;
  40. }
  41. - (void)didMoveToSuperview {
  42. if (!self.superview) {
  43. return;
  44. }
  45. _txtPasswd.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
  46. }
  47. #pragma mark - Main Logic
  48. - (void)requestCheckUserPasswd {
  49. //parameters
  50. NSDictionary *parameter = @{@"password": _txtPasswd.text};
  51. NSString *path = [NSString stringWithFormat:API_GET_CHECK_PWD, [JDFacade facade].loginUser.memberId];
  52. [[RequestHandler handler] sendAsyncGetRequestAPIPath:path parameters:parameter modelClass:[JDJSONModel class] completion:^(id responseObject) {
  53. [self loadPopup];
  54. } failure:^(id errorObject) {
  55. JDErrorModel *error = (JDErrorModel *)errorObject;
  56. [[JDFacade facade] alert:error.errorMessage];
  57. }];
  58. }
  59. - (void)loadPopup {
  60. PwdPopupView *popup = [[PwdPopupView alloc] initFromNib];
  61. [popup show];
  62. [super btnConfirmTouched:nil];
  63. }
  64. #pragma mark - UI Events
  65. - (IBAction)btnConfirmTouched:(id)sender {
  66. //validate
  67. if (![ValidateUtil validateTextfiled:_txtPasswd type:ValidateTypeNull title:@"비밀번호"]) {
  68. return;
  69. }
  70. [self requestCheckUserPasswd];
  71. }
  72. #pragma mark - CustomTextField
  73. - (BOOL)textFieldShouldReturn:(UITextField *)textField {
  74. if ([textField isEqual:_txtPasswd]) {
  75. [self btnConfirmTouched:nil];
  76. }
  77. return YES;
  78. }
  79. @end