DeleteAccountPopupView.m 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // DeleteAccountPopupView.m
  3. // kneet
  4. //
  5. // Created by Jason Lee on 5/12/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 "DeleteAccountPopupView.h"
  13. @interface DeleteAccountPopupView () {
  14. }
  15. @end
  16. @implementation DeleteAccountPopupView
  17. - (id)initFromNib {
  18. for (UIView *view in [CommonUtil nibViews:@"DeleteAccountPopupView"]) {
  19. if ([view isKindOfClass:[DeleteAccountPopupView class]]) {
  20. self = (DeleteAccountPopupView *)view;
  21. //XIB의 경우, 현재 화면 사이즈로 맞춰줘야 함.
  22. self.frame = [UIScreen mainScreen].bounds;
  23. self.lblTitle.text = NSLocalizedString(@"계정 삭제",nil);
  24. //Localization
  25. [self.imgTitleBar setImage:[UIImage imageNamed:@"img_popup_bg_head"]inset:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  26. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  27. [self.btnConfirm setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_right_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  28. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left"] forState:UIControlStateNormal capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  29. [self.btnCancel setBackgroundImage:[UIImage imageNamed:@"img_popup_btn_left_press"] forState:UIControlStateHighlighted capInsets:UIEdgeInsetsMake(kfTopInset,kfRightInset,kfBottomInset,kfLeftInset)];
  30. //Localization
  31. [self.btnConfirm setTitle:NSLocalizedString(@"예", @"예") forState:UIControlStateNormal];
  32. [self.btnCancel setTitle:NSLocalizedString(@"아니오", @"아니오") forState:UIControlStateNormal];
  33. }
  34. }
  35. return self;
  36. }
  37. - (void)didMoveToSuperview {
  38. }
  39. //계정 삭제
  40. - (void)requestDeleteAccount {
  41. NSString *path = [NSString stringWithFormat:API_DELETE_ACCOUNT, [JDFacade facade].loginUser.memberId];
  42. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:nil modelClass:[JDJSONModel class] showLoadingView:YES completion:^(id responseObject) {
  43. //자동 로그인 설정 - 취소
  44. [[JDFacade facade] storeObjectToUserDefaults:@(NO) forKey:USDEF_APP_AUTO_LOGIN];
  45. [[JDFacade facade] removeObjectAtKeychain:USDEF_SESSION_AUTOTOKEN];
  46. [JDFacade facade].loginUser = nil;
  47. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"GoodbyeViewController" storyboardName:@"Settings"];
  48. [[JDFacade facade] presentViewControllerByPush:vc];
  49. [super btnConfirmTouched:nil];
  50. } failure:^(id errorObject) {
  51. JDErrorModel *error = (JDErrorModel *)errorObject;
  52. [[JDFacade facade] alert:error.errorMessage];
  53. }];
  54. }
  55. - (void)btnConfirmTouched:(id)sender {
  56. [self requestDeleteAccount];
  57. }
  58. @end