DeleteAccountPopupView.m 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. [_lblWarning setUnderLine:_lblWarning.text];
  25. //Localization
  26. _lblDesc1.text = NSLocalizedString(@"계정을 삭제한 즉시\n모든 장치와 규칙이 사라집니다", @"계정을 삭제한 즉시\n모든 장치와 규칙이 사라집니다");
  27. _lblDesc2.text = NSLocalizedString(@"삭제 후에는 복구할 수 없으며\n새로운 계정을 만들고\n장치를 등록해야 합니다", @"삭제 후에는 복구할 수 없으며\n새로운 계정을 만들고\n장치를 등록해야 합니다");
  28. _lblDesc3.text = NSLocalizedString(@"신중하게 결정해주세요", @"신중하게 결정해주세요");
  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. }
  43. //계정 삭제
  44. - (void)requestDeleteAccount {
  45. NSString *path = [NSString stringWithFormat:API_DELETE_ACCOUNT, [JDFacade facade].loginUser.memberId];
  46. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:nil modelClass:[JDJSONModel class] showLoadingView:YES completion:^(id responseObject) {
  47. //자동 로그인 설정 - 취소
  48. [[JDFacade facade] storeObjectToUserDefaults:@(NO) forKey:USDEF_APP_AUTO_LOGIN];
  49. [[JDFacade facade] removeObjectAtKeychain:USDEF_SESSION_AUTOTOKEN];
  50. [JDFacade facade].loginUser = nil;
  51. UIViewController *vc = [CommonUtil instantiateViewControllerWithIdentifier:@"GoodbyeViewController" storyboardName:@"Settings"];
  52. [[JDFacade facade] presentViewControllerByPush:vc];
  53. [super btnConfirmTouched:nil];
  54. } failure:^(id errorObject) {
  55. JDErrorModel *error = (JDErrorModel *)errorObject;
  56. [[JDFacade facade] alert:error.errorMessage];
  57. }];
  58. }
  59. - (void)btnConfirmTouched:(id)sender {
  60. [self requestDeleteAccount];
  61. }
  62. @end