CCManageAccount.m 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. //
  2. // CCManageAccount.m
  3. // Nextcloud iOS
  4. //
  5. // Created by Marino Faggiana on 12/03/15.
  6. // Copyright (c) 2017 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. #import <JDStatusBarNotification/JDStatusBarNotification.h>
  24. #import "CCManageAccount.h"
  25. #import "AppDelegate.h"
  26. #import "CCLogin.h"
  27. #import "NCAutoUpload.h"
  28. #import "NCBridgeSwift.h"
  29. #define actionSheetCancellaAccount 1
  30. @interface CCManageAccount () <CCLoginDelegate, CCLoginDelegateWeb>
  31. {
  32. AppDelegate *appDelegate;
  33. tableAccount *_tableAccount;
  34. }
  35. @end
  36. @implementation CCManageAccount
  37. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  38. {
  39. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  40. if (self) {
  41. appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  42. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeTheming) name:@"changeTheming" object:nil];
  43. }
  44. return self;
  45. }
  46. - (void)initializeForm
  47. {
  48. XLFormDescriptor *form = [XLFormDescriptor formDescriptorWithTitle:NSLocalizedString(@"_credentials_", nil)];
  49. XLFormSectionDescriptor *section;
  50. XLFormRowDescriptor *row;
  51. NSArray *listAccount = [[NCManageDatabase sharedInstance] getAccounts];
  52. // Section : CLOUD ACCOUNT -------------------------------------------
  53. section = [XLFormSectionDescriptor formSectionWithTitle:@"cloud account"];
  54. [form addFormSection:section];
  55. form.rowNavigationOptions = XLFormRowNavigationOptionNone;
  56. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"pickerAccount" rowType:XLFormRowDescriptorTypePicker];
  57. row.height = 100;
  58. if (listAccount.count > 0) {
  59. row.selectorOptions = listAccount;
  60. row.value = appDelegate.activeAccount;
  61. } else {
  62. row.selectorOptions = [[NSArray alloc] initWithObjects:@"", nil];
  63. }
  64. [section addFormRow:row];
  65. // Section : USER INFORMATION -------------------------------------------
  66. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_personal_information_", nil)];
  67. [form addFormSection:section];
  68. // Full Name
  69. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"userfullname" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_full_name_", nil)];
  70. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  71. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  72. [section addFormRow:row];
  73. // Address
  74. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"useraddress" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_address_", nil)];
  75. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  76. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  77. [section addFormRow:row];
  78. // City
  79. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"usercity" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_city_", nil)];
  80. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  81. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  82. [section addFormRow:row];
  83. // Zip
  84. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"userzip" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_zip_", nil)];
  85. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  86. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  87. [section addFormRow:row];
  88. // Phone
  89. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"userphone" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_phone_", nil)];
  90. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  91. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  92. [section addFormRow:row];
  93. // Email
  94. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"useremail" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_email_", nil)];
  95. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  96. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  97. [section addFormRow:row];
  98. // Web
  99. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"userweb" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_web_", nil)];
  100. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  101. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  102. [section addFormRow:row];
  103. // Twitter
  104. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"usertwitter" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_twitter_", nil)];
  105. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  106. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  107. [section addFormRow:row];
  108. // Business Type
  109. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"userbusinesstype" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_businesstype_", nil)];
  110. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  111. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  112. [section addFormRow:row];
  113. // Business Size
  114. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"userbusinesssize" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_businesssize_", nil)];
  115. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  116. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  117. [section addFormRow:row];
  118. // Role
  119. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"userrole" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_role_", nil)];
  120. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  121. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  122. [section addFormRow:row];
  123. // Company
  124. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"usercompany" rowType:XLFormRowDescriptorTypeInfo title:NSLocalizedString(@"_user_company_", nil)];
  125. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  126. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"detailTextLabel.font"];
  127. [section addFormRow:row];
  128. // Section : MANAGE ACCOUNT -------------------------------------------
  129. if ([NCBrandOptions sharedInstance].disable_manage_account == NO) {
  130. section = [XLFormSectionDescriptor formSectionWithTitle:NSLocalizedString(@"_manage_account_", nil)];
  131. [form addFormSection:section];
  132. // Modify Account
  133. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"changePassword" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_change_password_", nil)];
  134. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  135. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"rename"] multiplier:2 color:[NCBrandColor sharedInstance].icon] forKey:@"imageView.image"];
  136. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  137. [row.cellConfig setObject:[UIColor blackColor] forKey:@"textLabel.textColor"];
  138. row.action.formSelector = @selector(changePassword:);
  139. if (listAccount.count == 0) row.disabled = @YES;
  140. [section addFormRow:row];
  141. // Brand
  142. if ([NCBrandOptions sharedInstance].disable_multiaccount == NO) {
  143. // New Account nextcloud
  144. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"addAccount" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_add_account_", nil)];
  145. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  146. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"add"] multiplier:2 color:[NCBrandColor sharedInstance].icon] forKey:@"imageView.image"];
  147. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  148. [row.cellConfig setObject:[UIColor blackColor] forKey:@"textLabel.textColor"];
  149. row.action.formSelector = @selector(addAccount:);
  150. [section addFormRow:row];
  151. }
  152. // delete Account
  153. row = [XLFormRowDescriptor formRowDescriptorWithTag:@"delAccount" rowType:XLFormRowDescriptorTypeButton title:NSLocalizedString(@"_delete_account_", nil)];
  154. [row.cellConfig setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
  155. [row.cellConfig setObject:[UIFont systemFontOfSize:15.0]forKey:@"textLabel.font"];
  156. [row.cellConfig setObject:[CCGraphics changeThemingColorImage:[UIImage imageNamed:@"trash"] width:50 height:50 color:[UIColor redColor]] forKey:@"imageView.image"];
  157. [row.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
  158. row.action.formSelector = @selector(answerDelAccount:);
  159. if (listAccount.count == 0) row.disabled = @YES;
  160. [section addFormRow:row];
  161. }
  162. self.form = form;
  163. }
  164. // Apparirà
  165. - (void)viewWillAppear:(BOOL)animated
  166. {
  167. [super viewWillAppear:animated];
  168. self.tableView.backgroundColor = [NCBrandColor sharedInstance].backgroundView;
  169. self.tableView.showsVerticalScrollIndicator = NO;
  170. // Color
  171. [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
  172. [appDelegate aspectTabBar:self.tabBarController.tabBar hidden:NO];
  173. [self initializeForm];
  174. [self UpdateForm];
  175. }
  176. - (void)changeTheming
  177. {
  178. [appDelegate changeTheming:self];
  179. }
  180. #pragma --------------------------------------------------------------------------------------------
  181. #pragma mark === Delegate ===
  182. #pragma --------------------------------------------------------------------------------------------
  183. -(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
  184. {
  185. [super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
  186. if ([rowDescriptor.tag isEqualToString:@"pickerAccount"] && oldValue && newValue) {
  187. if (![newValue isEqualToString:oldValue] && ![newValue isEqualToString:@""] && ![newValue isEqualToString:appDelegate.activeAccount])
  188. [self ChangeDefaultAccount:newValue];
  189. if ([newValue isEqualToString:@""]) {
  190. NSArray *listAccount = [[NCManageDatabase sharedInstance] getAccounts];
  191. if ([listAccount count] > 0)
  192. [self ChangeDefaultAccount:listAccount[0]];
  193. }
  194. }
  195. }
  196. #pragma --------------------------------------------------------------------------------------------
  197. #pragma mark === Delegate Login ===
  198. #pragma --------------------------------------------------------------------------------------------
  199. - (void)loginSuccess:(NSInteger)loginType
  200. {
  201. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
  202. }
  203. #pragma --------------------------------------------------------------------------------------------
  204. #pragma mark === Add Account ===
  205. #pragma --------------------------------------------------------------------------------------------
  206. - (void)addAccount:(XLFormRowDescriptor *)sender
  207. {
  208. [self deselectFormRow:sender];
  209. [appDelegate openLoginView:self delegate:self loginType:k_login_Add selector:k_intro_login];
  210. }
  211. #pragma --------------------------------------------------------------------------------------------
  212. #pragma mark === Modify Account ===
  213. #pragma --------------------------------------------------------------------------------------------
  214. - (void)changePassword:(XLFormRowDescriptor *)sender
  215. {
  216. [self deselectFormRow:sender];
  217. [appDelegate openLoginView:self delegate:self loginType:k_login_Modify_Password selector:k_intro_login];
  218. }
  219. #pragma --------------------------------------------------------------------------------------------
  220. #pragma mark === Delete Account ===
  221. #pragma --------------------------------------------------------------------------------------------
  222. - (void)deleteAccount:(NSString *)account
  223. {
  224. tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
  225. if (tableAccount) {
  226. [appDelegate unsubscribingNextcloudServerPushNotification:tableAccount.account url:tableAccount.url withSubscribing:false];
  227. }
  228. [[NCManageDatabase sharedInstance] clearTable:[tableAccount class] account:account];
  229. [[NCManageDatabase sharedInstance] clearTable:[tableActivity class] account:account];
  230. [[NCManageDatabase sharedInstance] clearTable:[tableActivitySubjectRich class] account:account];
  231. [[NCManageDatabase sharedInstance] clearTable:[tableCapabilities class] account:account];
  232. [[NCManageDatabase sharedInstance] clearTable:[tableDirectory class] account:account];
  233. [[NCManageDatabase sharedInstance] clearTable:[tableE2eEncryption class] account:account];
  234. [[NCManageDatabase sharedInstance] clearTable:[tableExternalSites class] account:account];
  235. [[NCManageDatabase sharedInstance] clearTable:[tableLocalFile class] account:account];
  236. [[NCManageDatabase sharedInstance] clearTable:[tableMetadata class] account:account];
  237. [[NCManageDatabase sharedInstance] clearTable:[tableMedia class] account:account];
  238. [[NCManageDatabase sharedInstance] clearTable:[tablePhotoLibrary class] account:account];
  239. [[NCManageDatabase sharedInstance] clearTable:[tableShare class] account:account];
  240. // Clear active user
  241. [appDelegate settingActiveAccount:nil activeUrl:nil activeUser:nil activeUserID:nil activePassword:nil];
  242. }
  243. - (void)answerDelAccount:(XLFormRowDescriptor *)sender
  244. {
  245. [self deselectFormRow:sender];
  246. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_want_delete_",nil) message:nil preferredStyle:UIAlertControllerStyleActionSheet];
  247. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_delete_", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  248. XLFormPickerCell *pickerAccount = (XLFormPickerCell *)[[self.form formRowWithTag:@"pickerAccount"] cellForFormController:self];
  249. NSString *accountNow = pickerAccount.rowDescriptor.value;
  250. [self deleteAccount:accountNow];
  251. NSArray *listAccount = [[NCManageDatabase sharedInstance] getAccounts];
  252. if ([listAccount count] > 0)
  253. [self ChangeDefaultAccount:listAccount[0]];
  254. else {
  255. [appDelegate openLoginView:self delegate:self loginType:k_login_Add_Forced selector:k_intro_login];
  256. }
  257. }]];
  258. [alertController addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  259. [alertController dismissViewControllerAnimated:YES completion:nil];
  260. }]];
  261. alertController.popoverPresentationController.sourceView = self.view;
  262. NSIndexPath *indexPath = [self.form indexPathOfFormRow:sender];
  263. alertController.popoverPresentationController.sourceRect = [self.tableView rectForRowAtIndexPath:indexPath];
  264. [self presentViewController:alertController animated:YES completion:nil];
  265. }
  266. #pragma --------------------------------------------------------------------------------------------
  267. #pragma mark === Change Default Account ===
  268. #pragma --------------------------------------------------------------------------------------------
  269. - (void)ChangeDefaultAccount:(NSString *)account
  270. {
  271. tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:account];
  272. if (tableAccount) {
  273. [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
  274. // Init home
  275. [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
  276. [self UpdateForm];
  277. }
  278. }
  279. #pragma --------------------------------------------------------------------------------------------
  280. #pragma mark === Update Form ===
  281. #pragma --------------------------------------------------------------------------------------------
  282. - (void)UpdateForm
  283. {
  284. NSArray *listAccount = [[NCManageDatabase sharedInstance] getAccounts];
  285. if (listAccount.count == 0) {
  286. [appDelegate openLoginView:self delegate:self loginType:k_login_Add_Forced selector:k_intro_login];
  287. return;
  288. }
  289. XLFormPickerCell *pickerAccount = (XLFormPickerCell *)[[self.form formRowWithTag:@"pickerAccount"] cellForFormController:self];
  290. pickerAccount.rowDescriptor.selectorOptions = listAccount;
  291. pickerAccount.rowDescriptor.value = appDelegate.activeAccount;
  292. NSString *fileNamePath = [NSString stringWithFormat:@"%@/%@-%@.png", [CCUtility getDirectoryUserData], [CCUtility getStringUser:appDelegate.activeUser activeUrl:appDelegate.activeUrl], appDelegate.activeUser];
  293. UIImage *avatar = [UIImage imageWithContentsOfFile:fileNamePath];
  294. if (avatar) {
  295. avatar = [CCGraphics scaleImage:avatar toSize:CGSizeMake(40, 40) isAspectRation:YES];
  296. CCAvatar *avatarImageView = [[CCAvatar alloc] initWithImage:avatar borderColor:[UIColor lightGrayColor] borderWidth:0.5];
  297. CGSize imageSize = avatarImageView.bounds.size;
  298. UIGraphicsBeginImageContextWithOptions(imageSize, NO, 0);
  299. CGContextRef context = UIGraphicsGetCurrentContext();
  300. [avatarImageView.layer renderInContext:context];
  301. avatar = UIGraphicsGetImageFromCurrentImageContext();
  302. UIGraphicsEndImageContext();
  303. } else {
  304. avatar = [UIImage imageNamed:@"avatarBN"];
  305. }
  306. [pickerAccount.rowDescriptor.cellConfig setObject:avatar forKey:@"imageView.image"];
  307. // --
  308. _tableAccount = [[NCManageDatabase sharedInstance] getAccountActive];
  309. XLFormRowDescriptor *rowUserFullName = [self.form formRowWithTag:@"userfullname"];
  310. XLFormRowDescriptor *rowUserAddress = [self.form formRowWithTag:@"useraddress"];
  311. XLFormRowDescriptor *rowUserCity = [self.form formRowWithTag:@"usercity"];
  312. XLFormRowDescriptor *rowUserZip = [self.form formRowWithTag:@"userzip"];
  313. XLFormRowDescriptor *rowUserPhone = [self.form formRowWithTag:@"userphone"];
  314. XLFormRowDescriptor *rowUserEmail = [self.form formRowWithTag:@"useremail"];
  315. XLFormRowDescriptor *rowUserWeb = [self.form formRowWithTag:@"userweb"];
  316. XLFormRowDescriptor *rowUserTwitter = [self.form formRowWithTag:@"usertwitter"];
  317. XLFormRowDescriptor *rowUserBusinessType = [self.form formRowWithTag:@"userbusinesstype"];
  318. XLFormRowDescriptor *rowUserBusinessSize = [self.form formRowWithTag:@"userbusinesssize"];
  319. XLFormRowDescriptor *rowUserRole = [self.form formRowWithTag:@"userrole"];
  320. XLFormRowDescriptor *rowUserCompany = [self.form formRowWithTag:@"usercompany"];
  321. rowUserFullName.value = _tableAccount.displayName;
  322. if ([_tableAccount.displayName isEqualToString:@""] || _tableAccount.displayName == nil) rowUserFullName.hidden = @YES;
  323. else rowUserFullName.hidden = @NO;
  324. rowUserAddress.value = _tableAccount.address;
  325. if ([_tableAccount.address isEqualToString:@""] || _tableAccount.address == nil) rowUserAddress.hidden = @YES;
  326. else rowUserAddress.hidden = @NO;
  327. rowUserCity.value = _tableAccount.city;
  328. if ([_tableAccount.city isEqualToString:@""] || _tableAccount.city == nil) rowUserCity.hidden = @YES;
  329. else rowUserCity.hidden = @NO;
  330. rowUserZip.value = _tableAccount.zip;
  331. if ([_tableAccount.zip isEqualToString:@""] || _tableAccount.zip == nil) rowUserZip.hidden = @YES;
  332. else rowUserZip.hidden = @NO;
  333. rowUserPhone.value = _tableAccount.phone;
  334. if ([_tableAccount.phone isEqualToString:@""] || _tableAccount.phone == nil) rowUserPhone.hidden = @YES;
  335. else rowUserPhone.hidden = @NO;
  336. rowUserEmail.value = _tableAccount.email;
  337. if ([_tableAccount.email isEqualToString:@""] || _tableAccount.email == nil) rowUserEmail.hidden = @YES;
  338. else rowUserEmail.hidden = @NO;
  339. rowUserWeb.value = _tableAccount.webpage;
  340. if ([_tableAccount.webpage isEqualToString:@""] || _tableAccount.webpage == nil) rowUserWeb.hidden = @YES;
  341. else rowUserWeb.hidden = @NO;
  342. rowUserTwitter.value = _tableAccount.twitter;
  343. if ([_tableAccount.twitter isEqualToString:@""] || _tableAccount.twitter == nil) rowUserTwitter.hidden = @YES;
  344. else rowUserTwitter.hidden = @NO;
  345. rowUserBusinessType.value = _tableAccount.businessType;
  346. if ([_tableAccount.businessType isEqualToString:@""] || _tableAccount.businessType == nil) rowUserBusinessType.hidden = @YES;
  347. else rowUserBusinessType.hidden = @NO;
  348. rowUserBusinessSize.value = @(_tableAccount.businessSize).stringValue;
  349. if (_tableAccount.businessSize > 0) rowUserBusinessSize.hidden = @YES;
  350. else rowUserBusinessSize.hidden = @NO;
  351. rowUserRole.value = _tableAccount.role;
  352. if ([_tableAccount.role isEqualToString:@""] || _tableAccount.role == nil) rowUserRole.hidden = @YES;
  353. else rowUserRole.hidden = @NO;
  354. rowUserCompany.value = _tableAccount.company;
  355. if ([_tableAccount.company isEqualToString:@""] || _tableAccount.company == nil) rowUserCompany.hidden = @YES;
  356. else rowUserCompany.hidden = @NO;
  357. [self.tableView reloadData];
  358. [self performSelector:@selector(reloadData) withObject:nil afterDelay:1];
  359. }
  360. - (void)reloadData
  361. {
  362. [self.tableView reloadData];
  363. }
  364. @end