| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- //
- // PwdPopupView.m
- // kneet
- //
- // Created by Jason Lee on 5/12/15.
- // Copyright (c) 2015 ntels. All rights reserved.
- //
- #import "JDObject.h"
- #import "RequestHandler.h"
- #import "JDJSONModel.h"
- #import "CustomLabel.h"
- #import "CustomTextField.h"
- #import "ValidateUtil.h"
- #import "PwdPopupView.h"
- @interface PwdPopupView () <CustomTextFieldDelegate>
- {
- }
- @end
- @implementation PwdPopupView
- - (id)initFromNib {
- for (UIView *view in [CommonUtil nibViews:@"PwdPopupView"]) {
- if ([view isKindOfClass:[PwdPopupView class]]) {
- self = (PwdPopupView *)view;
- //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
- self.frame = [UIScreen mainScreen].bounds;
- self.lblTitle.text = NSLocalizedString(@"비밀번호 변경",nil);
- _txtPwd.secureTextEntry = YES;
- _txtPwd.keyboardType = UIKeyboardTypeDefault;
- _txtPwd.returnKeyType = UIReturnKeyDone;
- _txtPwdConfirm.delegate = self;
- _txtPwdConfirm.secureTextEntry = YES;
- _txtPwdConfirm.keyboardType = UIKeyboardTypeDefault;
- _txtPwdConfirm.returnKeyType = UIReturnKeyDone;
-
- //Localization
- _lblDesc1.text = NSLocalizedString(@"새로운 비밀번호를 입력하세요", @"새로운 비밀번호를 입력하세요");
- _lblDesc2.text = NSLocalizedString(@"영어, 숫자, 특수문자 중 2가지 이상을 사용해서\n8글자 이상으로 만들어 주세요", @"영어, 숫자, 특수문자 중 2가지 이상을 사용해서\n8글자 이상으로 만들어 주세요");
-
- //Localization
- [self.btnConfirm setTitle:NSLocalizedString(@"변경", @"변경") forState:UIControlStateNormal];
- [self.btnCancel setTitle:NSLocalizedString(@"취소", @"취소") forState:UIControlStateNormal];
- }
- }
- return self;
- }
- - (void)didMoveToSuperview {
- _txtPwd.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
- _txtPwdConfirm.customTextFieldSuperview = CustomTextFieldSuperviewIsPopupContentView;
- }
- - (void)requestSetNewPassword {
- //parameters
- NSDictionary *parameter = @{@"new_password": _txtPwd.text,
- @"confirm_password": _txtPwdConfirm.text};
- NSString *path = [NSString stringWithFormat:API_POST_MEMBER_UPDATE, [JDFacade facade].loginUser.memberId, @"password"];
- [[RequestHandler handler] sendAsyncPostRequestAPIPath:path parameters:parameter modelClass:[JDJSONModel class] completion:^(id responseObject) {
- if (!responseObject) {//응답결과가 잘못되었거나 없을 경우,
- return;
- }
- JDJSONModel *result = (JDJSONModel *) responseObject;
- if (result) {//API 성공 ,
- [JDFacade facade].tmpPassword = nil;
- [JDFacade facade].loginUser.tempPasswordYn = @"N";
- [[JDFacade facade] toast:NSLocalizedString(@"비밀번호가 변경되었습니다", @"비밀번호가 변경되었습니다")];
- [super btnConfirmTouched:nil]; //closePopup
- }
- } failure:^(id errorObject) {
- JDErrorModel *error = (JDErrorModel *)errorObject;
- [[JDFacade facade] alert:error.errorMessage];
- }];
- }
- - (void)btnConfirmTouched:(id)sender {
- if (![ValidateUtil validateTextfiled:_txtPwd type:ValidateTypePassword title:NSLocalizedString(@"비밀번호", @"비밀번호")]) {
- return;
- }
- if (![_txtPwd.text isEqualToString:_txtPwdConfirm.text]) {
- [[JDFacade facade] alert:NSLocalizedString(@"비밀번호와 비밀번호 확인이 일치하지 않습니다\n다시 시도해주세요", @"비밀번호와 비밀번호 확인이 일치하지 않습니다\n다시 시도해주세요")];
- return;
- }
- [self requestSetNewPassword];
- }
- #pragma mark - CustomTextField
- - (BOOL)textFieldShouldReturn:(UITextField *)textField {
- if ([textField isEqual:_txtPwdConfirm]) {
- [self btnConfirmTouched:nil];
- }
- return YES;
- }
- @end
|