DeleteAccountPopupView.m 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. //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. }
  38. //계정 삭제
  39. - (void)requestDeleteAccount {
  40. NSString *path = [NSString stringWithFormat:API_DELETE_ACCOUNT, [JDFacade facade].loginUser.memberId];
  41. [[RequestHandler handler] sendAsyncRequestAPIPath:path method:ksHTTPRequestDELETE parameters:nil modelClass:[JDJSONModel class] showLoadingView:@(YES) completion:^(id responseObject) {
  42. //자동 로그인 설정 - 취소
  43. [[JDFacade facade] storeObjectToUserDefaults:@(NO) forKey:USER_DEF_AUTO_LOGIN];
  44. [[JDFacade facade] removeObjectAtKeychain:USER_DEF_AUTOTOKEN];
  45. [JDFacade facade].loginUser = nil;
  46. [JDFacade facade].loginHomeGroup = 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