// // YMPrivacyViewController.m // YUMI // // Created by zu on 2021/12/28. // #import "XPPrivacyViewController.h" #import #import "XPMineSettingTableViewCell.h" #import "XPMineSettingItemModel.h" #import "XPWebViewController.h" #import "XPPermissionsViewController.h" #import "YUMIHtmlUrl.h" #import "NSArray+Safe.h" @interface XPPrivacyViewController () @property (nonatomic, strong) UITableView * tableView; @property (nonatomic, strong) NSArray * datasource; @end @implementation XPPrivacyViewController - (void)viewDidLoad { [super viewDidLoad]; self.title = YMLocalizedString(@"XPPrivacyViewController0"); [self.view addSubview:self.tableView]; [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.mas_equalTo(self.view); make.top.mas_equalTo(0); }]; } - (void)pushWebViewWIthUrl:(NSString *)url { XPWebViewController * webVC = [[XPWebViewController alloc] init]; webVC.url = url; [self.navigationController pushViewController:webVC animated:YES]; } #pragma mark - UITableViewDelegate And UITableViewDataSource - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 45; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.datasource.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { XPMineSettingTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPMineSettingTableViewCell class])]; if (cell == nil) { cell = [[XPMineSettingTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPMineSettingTableViewCell class])]; } cell.itemModel = [self.datasource safeObjectAtIndex1:indexPath.row]; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; switch (indexPath.row) { case 0: { XPPermissionsViewController * pvc = [[XPPermissionsViewController alloc] init]; [self.navigationController pushViewController:pvc animated:YES]; } break; case 1: [self pushWebViewWIthUrl:URLWithType(kPrivacyURL)]; break; case 2: [self pushWebViewWIthUrl:URLWithType(kPrivacySDKURL)]; break; case 3: [self pushWebViewWIthUrl:URLWithType(kPrivacyPersonalURL)]; break; case 4: [self pushWebViewWIthUrl:URLWithType(kPrivacyDeviceURL)]; break; case 5: [self pushWebViewWIthUrl:URLWithType(kUserRechargeAgrURL)]; break; case 6: [self pushWebViewWIthUrl:URLWithType(kUserRegiServiceAgrURL)]; break; case 7: [self pushWebViewWIthUrl:URLWithType(kLiveServiceAgrURL)]; break; case 8: [self pushWebViewWIthUrl:URLWithType(kCommunitySpecURL)]; break; case 9: [self pushWebViewWIthUrl:URLWithType(kAccountlogoutAgrURL)]; break; default: break; } } - (UITableView *)tableView { if (!_tableView) { _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.showsVerticalScrollIndicator = NO; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; _tableView.backgroundColor = [UIColor clearColor]; [_tableView registerClass:[XPMineSettingTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPMineSettingTableViewCell class])]; } return _tableView; } - (NSArray *)datasource { if (!_datasource) { XPMineSettingItemModel * sysPermission = [[XPMineSettingItemModel alloc] init]; sysPermission.title = YMLocalizedString(@"XPPrivacyViewController1"); sysPermission.subTitle = @""; XPMineSettingItemModel * privacy = [[XPMineSettingItemModel alloc] init]; privacy.title = YMLocalizedString(@"XPPrivacyViewController2"); privacy.subTitle = @""; XPMineSettingItemModel * sdk = [[XPMineSettingItemModel alloc] init]; sdk.title = YMLocalizedString(@"XPPrivacyViewController3"); sdk.subTitle = @""; XPMineSettingItemModel * personalInfo = [[XPMineSettingItemModel alloc] init]; personalInfo.title = YMLocalizedString(@"XPPrivacyViewController4"); personalInfo.subTitle = @""; XPMineSettingItemModel * permissionList = [[XPMineSettingItemModel alloc] init]; permissionList.title = YMLocalizedString(@"XPPrivacyViewController5"); permissionList.subTitle = @""; XPMineSettingItemModel * userChargeProtocol = [[XPMineSettingItemModel alloc] init]; userChargeProtocol.title = YMLocalizedString(@"XPPrivacyViewController6"); userChargeProtocol.subTitle = @""; XPMineSettingItemModel *userRegistProtocol = [[XPMineSettingItemModel alloc] init]; userRegistProtocol.title = YMLocalizedString(@"XPPrivacyViewController7"); userRegistProtocol.subTitle = @""; XPMineSettingItemModel * liveServiceProtocol = [[XPMineSettingItemModel alloc] init]; liveServiceProtocol.title = YMLocalizedString(@"XPPrivacyViewController8"); liveServiceProtocol.subTitle = @""; XPMineSettingItemModel * communitySpec = [[XPMineSettingItemModel alloc] init]; communitySpec.title = YMLocalizedString(@"XPPrivacyViewController9"); communitySpec.subTitle = @""; XPMineSettingItemModel * accountLogout = [[XPMineSettingItemModel alloc] init]; accountLogout.title = YMLocalizedString(@"XPPrivacyViewController10"); accountLogout.subTitle = @""; _datasource = @[sysPermission, privacy, sdk, personalInfo, permissionList, userChargeProtocol, userRegistProtocol, liveServiceProtocol, communitySpec,accountLogout]; } return _datasource; } @end