设置-个人信息和权限管理

This commit is contained in:
zu
2021-12-28 01:03:57 +08:00
committed by fengshuo
parent 9154bb74b5
commit a9ffaba490
20 changed files with 555 additions and 6 deletions

View File

@@ -196,4 +196,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: a3a94c2fefbbf41722d4664a7a8c01ae0311c8e1
COCOAPODS: 1.10.1
COCOAPODS: 1.11.0

View File

@@ -112,6 +112,8 @@
9B7D804D27537950003DAC0C /* MessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D804C27537950003DAC0C /* MessageCell.m */; };
9B7D80502753AA9D003DAC0C /* UITableView+NIMScrollToBottom.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D804E2753AA9D003DAC0C /* UITableView+NIMScrollToBottom.m */; };
9B7D80562753C595003DAC0C /* SendMessageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 9B7D80552753C595003DAC0C /* SendMessageView.m */; };
9BAA5FED277A1BBE007453F3 /* XPPrivacyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BAA5FEC277A1BBE007453F3 /* XPPrivacyViewController.m */; };
9BAA5FF0277A23F4007453F3 /* XPPermissionsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9BAA5FEF277A23F4007453F3 /* XPPermissionsViewController.m */; };
E80487652717DDD9008595F2 /* XPRoomMenuItem.m in Sources */ = {isa = PBXBuildFile; fileRef = E80487642717DDD9008595F2 /* XPRoomMenuItem.m */; };
E811FFF72742367B00918544 /* XPGiftEmptyCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E811FFF62742367B00918544 /* XPGiftEmptyCollectionViewCell.m */; };
E8133916273E532D00708B66 /* XPGiftItemCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8133915273E532D00708B66 /* XPGiftItemCollectionViewCell.m */; };
@@ -574,6 +576,10 @@
9B7D804F2753AA9D003DAC0C /* UITableView+NIMScrollToBottom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITableView+NIMScrollToBottom.h"; sourceTree = "<group>"; };
9B7D80542753C595003DAC0C /* SendMessageView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SendMessageView.h; sourceTree = "<group>"; };
9B7D80552753C595003DAC0C /* SendMessageView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SendMessageView.m; sourceTree = "<group>"; };
9BAA5FEB277A1BBE007453F3 /* XPPrivacyViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPPrivacyViewController.h; sourceTree = "<group>"; };
9BAA5FEC277A1BBE007453F3 /* XPPrivacyViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPPrivacyViewController.m; sourceTree = "<group>"; };
9BAA5FEE277A23F4007453F3 /* XPPermissionsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPPermissionsViewController.h; sourceTree = "<group>"; };
9BAA5FEF277A23F4007453F3 /* XPPermissionsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPPermissionsViewController.m; sourceTree = "<group>"; };
9BB865B4272076140029CDE0 /* RtcImplDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RtcImplDelegate.h; sourceTree = "<group>"; };
B66633E061B1B34177CD011C /* Pods-xplan-ios.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-xplan-ios.release.xcconfig"; path = "Target Support Files/Pods-xplan-ios/Pods-xplan-ios.release.xcconfig"; sourceTree = "<group>"; };
CACF623970097D653132D69A /* Pods_xplan_ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_xplan_ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -2880,6 +2886,10 @@
E8B846C826FDD79700A777FE /* Recharge */,
E88B5CBE26FB404800DA9178 /* MineInfo */,
E88B5CA926FB15B900DA9178 /* Teenager */,
9BAA5FEB277A1BBE007453F3 /* XPPrivacyViewController.h */,
9BAA5FEC277A1BBE007453F3 /* XPPrivacyViewController.m */,
9BAA5FEE277A23F4007453F3 /* XPPermissionsViewController.h */,
9BAA5FEF277A23F4007453F3 /* XPPermissionsViewController.m */,
);
path = View;
sourceTree = "<group>";
@@ -3403,6 +3413,7 @@
186A536B26FC6F2E00D67B2C /* XPShareItemCell.m in Sources */,
E8B846C526FDB41A00A777FE /* XPMineUserInfolbumPresenter.m in Sources */,
E83DB47D2746372300D8CBD1 /* XPRoomGiftBannerView.m in Sources */,
9BAA5FED277A1BBE007453F3 /* XPPrivacyViewController.m in Sources */,
E872309326E8D31500B90D4F /* LoginVerifCodeView.m in Sources */,
186A534626FC6ED900D67B2C /* TTPopup.m in Sources */,
E81C278C26EAFAF60031E639 /* Base64.m in Sources */,
@@ -3467,6 +3478,7 @@
E8A03DF927634A590098D9EA /* CandyTreeResultModel.m in Sources */,
E872308D26E89DAA00B90D4F /* LoginInputView.m in Sources */,
E8788948273A55D000BF1D57 /* XPGiftBarView.m in Sources */,
9BAA5FF0277A23F4007453F3 /* XPPermissionsViewController.m in Sources */,
189DD58F26DF97E700AB55B1 /* LoginPresenter.m in Sources */,
E89DA67227008D59008483C1 /* WalletInfoModel.m in Sources */,
189DD55026DE37F900AB55B1 /* MvpViewController.m in Sources */,

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "album@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "album@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "camera@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "camera@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 881 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "voice@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "voice@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -13,6 +13,9 @@ NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, URLType) {
kPrivacyURL,///隐私政策
kPrivacySDKURL,// 隐私政策-SDK
kPrivacyPersonalURL,// 隐私政策-个人信息
kPrivacyDeviceURL,// 隐私政策-设备权限
kUserProtocalURL, ///用户协议
kUserInviteFriendURL, ///邀请好友
kFAQURL,///帮助

View File

@@ -12,9 +12,12 @@
NSString * const URLWithType(URLType type) {
NSString * prefix = @"yinyou";
NSDictionary * dic = @{
@(kPrivacyURL) : @"modules/rule/privacy-wap.html",
@(kUserProtocalURL) : @"modules/rule/protocol.html",
@(kUserInviteFriendURL) : @"modules/game/index.html",
@(kPrivacyURL) : @"modules/rule/privacy-wap.html",//
@(kPrivacySDKURL) : @"modules/rule/sdk.html",//-SDK
@(kPrivacyPersonalURL) : @"modules/rule/personal-info.html",//-
@(kPrivacyDeviceURL) : @"modules/rule/permissions.html",//-
@(kUserProtocalURL) : @"modules/rule/protocol.html",///
@(kUserInviteFriendURL) : @"modules/game/index.html",///
@(kFAQURL) : @"modules/rule/guide.html ",//
@(kIdentityURL) : @"modules/identity/new.html",//
@(kGameBindAccountURL) : @"modules/game/bindAccount.html",///

View File

@@ -13,6 +13,7 @@ typedef NS_ENUM(NSInteger, XPMineSettingItemType){
XPMineSettingItemType_Phone, ///手机号
XPMineSettingItemType_Pay_Password,///支付密码
XPMineSettingItemType_Notification_Remind, ///通知提醒
XPMineSettingItemType_Permission,///关于我们
XPMineSettingItemType_Helper,///帮助
XPMineSettingItemType_Feedback,//我要反馈
XPMineSettingItemType_Clear_Memory,///清楚缓存

View File

@@ -54,6 +54,11 @@
notificaItem.title = @"通知提醒设置";
notificaItem.subTitle = @"设置";
notificaItem.type = XPMineSettingItemType_Notification_Remind;
XPMineSettingItemModel * privacyItem = [[XPMineSettingItemModel alloc] init];
privacyItem.title = @"个人信息与权限";
privacyItem.subTitle = @"";
privacyItem.type = XPMineSettingItemType_Permission;
XPMineSettingItemModel * helperItem = [[XPMineSettingItemModel alloc] init];
helperItem.title = @"帮助";
@@ -77,9 +82,10 @@
NSArray * oneSection = @[phoneItem];
NSArray * twoSection = @[payItem, notificaItem];
NSArray * threeSection = @[helperItem, feedbackItem, clearMemoryItem, aboutusItem];
NSArray * threeSection = @[privacyItem];
NSArray * fourthSection = @[helperItem, feedbackItem, clearMemoryItem, aboutusItem];
self.datasouce = @[oneSection, twoSection, threeSection];
self.datasouce = @[oneSection, twoSection, threeSection, fourthSection];
}
[[self getView] getMineSettingDatasourceSuccess:self.datasouce];

View File

@@ -31,6 +31,7 @@
#import "XPMineNotificaViewController.h"
#import "XPMinePayPwdViewController.h"
#import "XPMineModifPayPwdViewController.h"
#import "XPPrivacyViewController.h"
///VC
#import "XPWebViewController.h"
#import "XPLoginVerifBindPhoneViewController.h"
@@ -121,6 +122,12 @@
[self.navigationController pushViewController:notiVC animated:YES];
}
break;
case XPMineSettingItemType_Permission:
{
XPPrivacyViewController * pvc = [[XPPrivacyViewController alloc] init];
[self.navigationController pushViewController:pvc animated:YES];
}
break;
case XPMineSettingItemType_Helper:
{
[self pushWebViewWIthUrl:URLWithType(kFAQURL)];

View File

@@ -0,0 +1,16 @@
//
// XPPermissionsViewController.h
// xplan-ios
//
// Created by zu on 2021/12/28.
//
#import "BaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPPermissionsViewController : BaseViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,292 @@
//
// XPPermissionsViewController.m
// xplan-ios
//
// Created by zu on 2021/12/28.
//
#import "XPPermissionsViewController.h"
#import <Masonry/Masonry.h>
#import <Photos/Photos.h>
#import <AVFoundation/AVFoundation.h>
#import "XPMacro.h"
#import "ThemeColor.h"
@interface XPPermissionCell : UITableViewCell
@property (nonatomic, strong) UIImageView * icon;
@property (nonatomic, strong) UILabel * name;
@property (nonatomic, strong) UILabel * tip;
@end
@implementation XPPermissionCell
- (instancetype)init {
if (self == [super init]) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = UIColor.clearColor;
[self.contentView addSubview:self.icon];
[self.contentView addSubview:self.name];
[self.contentView addSubview:self.tip];
self.contentView.backgroundColor = ThemeColor.appCellBackgroundColor;
self.contentView.layer.masksToBounds = YES;
self.contentView.layer.cornerRadius = 8;
[self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.contentView);
make.left.mas_equalTo(self.contentView).offset(15);
}];
[self.name mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.icon.mas_right).offset(8);
make.top.mas_equalTo(self.contentView).offset(16);
}];
[self.tip mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.icon.mas_right).offset(8);
make.bottom.mas_equalTo(self.contentView).offset(-16);
}];
}
return self;
}
- (UIImageView *)icon {
if (!_icon) {
_icon = [[UIImageView alloc] init];
}
return _icon;
}
- (UILabel *)name {
if (!_name) {
_name = [[UILabel alloc] init];
_name.textColor = ThemeColor.mainTextColor;
_name.font = [UIFont systemFontOfSize:14];
}
return _name;
}
- (UILabel *)tip {
if (!_tip) {
_tip = [[UILabel alloc] init];
_tip.textColor = ThemeColor.secondTextColor;
_tip.font = [UIFont systemFontOfSize:13];
}
return _tip;
}
@end
@interface XPPermissionsViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic,strong) UITableView * tableView;
@property (nonatomic, strong) NSMutableArray<NSString *> * permissionIcons;
@property (nonatomic, strong) NSMutableArray<NSString *> * permissionNames;
@property (nonatomic, strong) NSMutableArray<NSString *> * permissionTips;
@property (nonatomic, strong) UIView * empty;
@property (nonatomic, strong) UIImageView * emptyImage;
@property (nonatomic, strong) UILabel * emptyTip;
@property (nonatomic, strong) UIView * footer;
@property (nonatomic, strong) UILabel * footerTip;
@property (nonatomic, strong) UIButton * gotoSetting;
@end
@implementation XPPermissionsViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"系统权限管理";
[self.empty addSubview:self.emptyImage];
[self.empty addSubview:self.emptyTip];
[self.view addSubview:self.tableView];
[self.footer addSubview:self.footerTip];
[self.footer addSubview:self.gotoSetting];
[self.view addSubview:self.footer];
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.right.bottom.mas_equalTo(self.view).insets(UIEdgeInsetsMake(16, 16, 16, 16));
}];
[self.emptyImage mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.empty);
make.top.mas_equalTo(self.empty).offset(200);
make.size.mas_equalTo(CGSizeMake(100, 100));
}];
[self.emptyTip mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.empty);
make.top.mas_equalTo(self.emptyImage.mas_bottom).offset(16);
}];
[self.footer mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.view).offset(-kSafeAreaBottomHeight);
make.height.mas_equalTo(100);
}];
[self.footerTip mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.footer);
make.top.mas_equalTo(self.footer).offset(24);
}];
[self.gotoSetting mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.footer);
make.top.mas_equalTo(self.footerTip.mas_bottom).offset(40);
}];
}
- (void)viewWillAppear:(BOOL)animated {
PHAuthorizationStatus phStatus = [PHPhotoLibrary authorizationStatus];
if (phStatus == PHAuthorizationStatusAuthorized) {
[self.permissionNames addObject:@"照片"];
[self.permissionTips addObject:@"读取相册或者存储图片到相册"];
[self.permissionIcons addObject:@"mine_setting_permission_album"];
}
AVAuthorizationStatus microPhoneStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
if (microPhoneStatus == AVAuthorizationStatusAuthorized) {
[self.permissionNames addObject:@"麦克风"];
[self.permissionTips addObject:@"录制音频"];
[self.permissionIcons addObject:@"mine_setting_permission_voice"];
}
AVAuthorizationStatus cameraStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if (cameraStatus == AVAuthorizationStatusAuthorized) {
[self.permissionNames addObject:@"相机"];
[self.permissionTips addObject:@"拍摄照片或录制视频"];
[self.permissionIcons addObject:@"mine_setting_permission_camera"];
}
}
- (void)gotoSettingClick:(UIButton *)sender {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
}
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
tableView.backgroundView = self.permissionNames.count == 0 ? self.empty : nil;
return self.permissionNames.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (section == 0) {
return 0.001f;
}
return 16.f;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 70.f;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor clearColor];
return view;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger section = indexPath.section;
XPPermissionCell * cell = [[XPPermissionCell alloc] init];
cell.icon.image = [UIImage imageNamed:[self.permissionIcons objectAtIndex:section]];
cell.name.text = [self.permissionNames objectAtIndex:section];
cell.tip.text = [self.permissionTips objectAtIndex:section];
return cell;
}
- (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:[XPPermissionCell class] forCellReuseIdentifier:NSStringFromClass([XPPermissionCell class])];
}
return _tableView;
}
- (NSMutableArray<NSString *> *)permissionIcons {
if (!_permissionIcons) {
_permissionIcons = [[NSMutableArray alloc] init];
}
return _permissionIcons;
}
- (NSMutableArray<NSString *> *)permissionNames {
if (!_permissionNames) {
_permissionNames = [[NSMutableArray alloc] init];
}
return _permissionNames;
}
- (NSMutableArray<NSString *> *)permissionTips {
if (!_permissionTips) {
_permissionTips = [[NSMutableArray alloc] init];
}
return _permissionTips;
}
- (UIView *)empty {
if (!_empty) {
_empty = [[UIView alloc] init];
}
return _empty;
}
- (UIImageView *)emptyImage {
if (!_emptyImage) {
_emptyImage = [[UIImageView alloc] init];
_emptyImage.contentMode = UIViewContentModeScaleAspectFit;
_emptyImage.image = [UIImage imageNamed:@"common_empty"];
}
return _emptyImage;
}
- (UILabel *)emptyTip {
if (!_emptyTip) {
_emptyTip = [[UILabel alloc] init];
_emptyTip.textColor = ThemeColor.secondTextColor;
_emptyTip.font = [UIFont systemFontOfSize:12];
_emptyTip.text = @"未有已授权的系统权限";
}
return _emptyTip;
}
- (UIView *)footer {
if (!_footer) {
_footer = [[UIView alloc] init];
}
return _footer;
}
- (UILabel *)footerTip {
if (!_footerTip) {
_footerTip = [[UILabel alloc] init];
_footerTip.textColor = ThemeColor.mainTextColor;
_footerTip.font = [UIFont systemFontOfSize:12];
_footerTip.text = @"—— 仅展示能查询到的已授权系统权限 ——";
}
return _footerTip;
}
- (UIButton *)gotoSetting {
if (!_gotoSetting) {
_gotoSetting = [UIButton buttonWithType:UIButtonTypeCustom];
[_gotoSetting setTitle:@"前往系统设置>" forState:UIControlStateNormal];
[_gotoSetting setTitleColor:ThemeColor.appMainColor forState:UIControlStateNormal];
_gotoSetting.titleLabel.font = [UIFont systemFontOfSize:14];
_gotoSetting.titleLabel.adjustsFontSizeToFitWidth = YES;
[_gotoSetting addTarget:self action:@selector(gotoSettingClick:) forControlEvents:UIControlEventTouchUpInside];
}
return _gotoSetting;
}
@end

View File

@@ -0,0 +1,16 @@
//
// XPPrivacyViewController.h
// xplan-ios
//
// Created by zu on 2021/12/28.
//
#import "BaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPPrivacyViewController : BaseViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,127 @@
//
// XPPrivacyViewController.m
// xplan-ios
//
// Created by zu on 2021/12/28.
//
#import "XPPrivacyViewController.h"
#import <Masonry/Masonry.h>
#import "XPMineSettingTableViewCell.h"
#import "XPMineSettingItemModel.h"
#import "XPWebViewController.h"
#import "XPPermissionsViewController.h"
#import "XPHtmlUrl.h"
@interface XPPrivacyViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView * tableView;
@property (nonatomic, strong) NSArray<XPMineSettingItemModel *> * datasource;
@end
@implementation XPPrivacyViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"个人信息与权限";
[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 objectAtIndex: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;
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<XPMineSettingItemModel *> *)datasource {
if (!_datasource) {
XPMineSettingItemModel * sysPermission = [[XPMineSettingItemModel alloc] init];
sysPermission.title = @"系统权限管理";
sysPermission.subTitle = @"";
XPMineSettingItemModel * privacy = [[XPMineSettingItemModel alloc] init];
privacy.title = @"隐私保护指引";
privacy.subTitle = @"";
XPMineSettingItemModel * sdk = [[XPMineSettingItemModel alloc] init];
sdk.title = @"第三方 SDK 目录";
sdk.subTitle = @"";
XPMineSettingItemModel * personalInfo = [[XPMineSettingItemModel alloc] init];
personalInfo.title = @"个人信息收集清单";
personalInfo.subTitle = @"";
XPMineSettingItemModel * permissionList = [[XPMineSettingItemModel alloc] init];
permissionList.title = @"设备权限清单";
permissionList.subTitle = @"";
_datasource = @[sysPermission, privacy, sdk, personalInfo, permissionList];
}
return _datasource;
}
@end