Commit d03ad2c0 cgx

系统设置页面部分UI搭建

1 个父辈 c9ab3f78
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
D0F808FE280421C20097899F /* ThreeMinuteController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F808FD280421C20097899F /* ThreeMinuteController.m */; }; D0F808FE280421C20097899F /* ThreeMinuteController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F808FD280421C20097899F /* ThreeMinuteController.m */; };
D0F8090428042A0B0097899F /* SafeSleepCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F8090328042A0B0097899F /* SafeSleepCell.m */; }; D0F8090428042A0B0097899F /* SafeSleepCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F8090328042A0B0097899F /* SafeSleepCell.m */; };
D0F80907280431100097899F /* UILabel+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F80906280431100097899F /* UILabel+Extras.m */; }; D0F80907280431100097899F /* UILabel+Extras.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F80906280431100097899F /* UILabel+Extras.m */; };
D0F82286280C44D10039F586 /* SetTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0F82285280C44D10039F586 /* SetTableView.m */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
...@@ -216,6 +217,8 @@ ...@@ -216,6 +217,8 @@
D0F8090328042A0B0097899F /* SafeSleepCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SafeSleepCell.m; sourceTree = "<group>"; }; D0F8090328042A0B0097899F /* SafeSleepCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SafeSleepCell.m; sourceTree = "<group>"; };
D0F80905280431100097899F /* UILabel+Extras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UILabel+Extras.h"; sourceTree = "<group>"; }; D0F80905280431100097899F /* UILabel+Extras.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UILabel+Extras.h"; sourceTree = "<group>"; };
D0F80906280431100097899F /* UILabel+Extras.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UILabel+Extras.m"; sourceTree = "<group>"; }; D0F80906280431100097899F /* UILabel+Extras.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UILabel+Extras.m"; sourceTree = "<group>"; };
D0F82284280C44D10039F586 /* SetTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SetTableView.h; sourceTree = "<group>"; };
D0F82285280C44D10039F586 /* SetTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SetTableView.m; sourceTree = "<group>"; };
F02C34A5649294F60932630C /* Pods-DreamSleep.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DreamSleep.release.xcconfig"; path = "Target Support Files/Pods-DreamSleep/Pods-DreamSleep.release.xcconfig"; sourceTree = "<group>"; }; F02C34A5649294F60932630C /* Pods-DreamSleep.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DreamSleep.release.xcconfig"; path = "Target Support Files/Pods-DreamSleep/Pods-DreamSleep.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
...@@ -375,6 +378,8 @@ ...@@ -375,6 +378,8 @@
D0E660042807D02C006562F2 /* UserRequestModel.m */, D0E660042807D02C006562F2 /* UserRequestModel.m */,
D0E6600628080F97006562F2 /* SystemSetController.h */, D0E6600628080F97006562F2 /* SystemSetController.h */,
D0E6600728080F97006562F2 /* SystemSetController.m */, D0E6600728080F97006562F2 /* SystemSetController.m */,
D0F82284280C44D10039F586 /* SetTableView.h */,
D0F82285280C44D10039F586 /* SetTableView.m */,
); );
path = Profile; path = Profile;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -759,6 +764,7 @@ ...@@ -759,6 +764,7 @@
D01814D227FFCBAF00583D4E /* CWFlowLayout.m in Sources */, D01814D227FFCBAF00583D4E /* CWFlowLayout.m in Sources */,
D0878F48280BD18F005F1B7F /* LoginView.m in Sources */, D0878F48280BD18F005F1B7F /* LoginView.m in Sources */,
D0E660052807D02C006562F2 /* UserRequestModel.m in Sources */, D0E660052807D02C006562F2 /* UserRequestModel.m in Sources */,
D0F82286280C44D10039F586 /* SetTableView.m in Sources */,
D0930F1B2801874B006B497A /* UINavigationController+Pop.m in Sources */, D0930F1B2801874B006B497A /* UINavigationController+Pop.m in Sources */,
D0506B1528051ED400229278 /* SafeSleepModel.m in Sources */, D0506B1528051ED400229278 /* SafeSleepModel.m in Sources */,
D01814D527FFCCFA00583D4E /* HomeTableView.m in Sources */, D01814D527FFCCFA00583D4E /* HomeTableView.m in Sources */,
......
...@@ -16,6 +16,8 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -16,6 +16,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (UILabel *)dkLabWithFont:(UIFont *)font; + (UILabel *)dkLabWithFont:(UIFont *)font;
+ (UILabel *)labWithFont:(UIFont *)font;
+ (UILabel *)labWithTextColor:(UIColor *)textColor font:(UIFont *)font; + (UILabel *)labWithTextColor:(UIColor *)textColor font:(UIFont *)font;
+ (UILabel *)labWithText:(NSString *)text textColor:(UIColor *)textColor font:(UIFont *)font; + (UILabel *)labWithText:(NSString *)text textColor:(UIColor *)textColor font:(UIFont *)font;
......
...@@ -25,6 +25,12 @@ ...@@ -25,6 +25,12 @@
return lab; return lab;
} }
+ (UILabel *)labWithFont:(UIFont *)font {
UILabel *lab = [UILabel new];
lab.font = font;
return lab;
}
+ (UILabel *)labWithTextColor:(UIColor *)textColor font:(UIFont *)font { + (UILabel *)labWithTextColor:(UIColor *)textColor font:(UIFont *)font {
UILabel *lab = [UILabel new]; UILabel *lab = [UILabel new];
lab.font = font; lab.font = font;
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
// 设置tabbar选中及未选中的文字颜色 // 设置tabbar选中及未选中的文字颜色
self.tabBar.tintColor = ColorFromHex(0x62C3D5); self.tabBar.tintColor = ColorFromHex(0x62C3D5);
self.tabBar.unselectedItemTintColor = ColorFromHex(0x777777); self.tabBar.unselectedItemTintColor = SubTitleColor;
// 设置tabbaritem图片渲染模式 // 设置tabbaritem图片渲染模式
for (UITabBarItem *item in self.tabBar.items) { for (UITabBarItem *item in self.tabBar.items) {
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/// 隐私政策弹框及详情控制器 /// 隐私政策弹框及详情控制器(H页面,需要改名封装)
@interface PrivacyViewController : UIViewController @interface PrivacyViewController : UIViewController
/// 隐私政策详情控制器初始化 /// 隐私政策详情控制器初始化
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#import "ProfileController.h" #import "ProfileController.h"
#import "SystemSetController.h" #import "SystemSetController.h"
#import "LoginController.h" #import "LoginController.h"
#import "PrivacyViewController.h"
@interface ProfileController () @interface ProfileController ()
@property (nonatomic, strong) NSArray *tmpDatas; @property (nonatomic, strong) NSArray *tmpDatas;
...@@ -63,6 +64,10 @@ ...@@ -63,6 +64,10 @@
[self.navigationController pushViewController:sysVC animated:YES]; [self.navigationController pushViewController:sysVC animated:YES];
} }
break; break;
case 4: // 关于我们
{
[self.navigationController pushViewController:[[PrivacyViewController alloc] initWithTitle:@"关于我们" link:[NSURL URLWithString:PrivacyPolicy] isDetail:YES] animated:YES];
}
default: default:
break; break;
} }
......
//
// SetTableView.h
// DreamSleep
//
// Created by peter on 2022/4/17.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol SetTableViewDelegate <NSObject>
- (void)didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
@end
/// 设置页面
@interface SetTableView : UITableView
@property (nonatomic, weak) id<SetTableViewDelegate> setDelegate;
- (instancetype)initWithDelegate:(id<SetTableViewDelegate>)delegate;
@end
NS_ASSUME_NONNULL_END
//
// SetTableView.m
// DreamSleep
//
// Created by peter on 2022/4/17.
//
#import "SetTableView.h"
/// 设置自定义数据模型
@interface SetModel : NSObject
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *detail;
+ (NSArray *)getAllSetDatas;
@end
@implementation SetModel
+ (NSArray *)getAllSetDatas {
NSArray *titles = @[@"应用版本及升级", @"用户协议", @"隐私政策", @"清除缓存"];
NSString *version = [NSString stringWithFormat:@"当前版本%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]];
NSArray *details = @[version, @"", @"", @"10.0M"];
NSMutableArray *tmpArr = [NSMutableArray array];
for (int i = 0; i < 4; i++) {
SetModel *m = [SetModel new];
m.title = titles[i];
m.detail = details[i];
[tmpArr addObject:m];
}
return [tmpArr copy];
}
@end
/// 设置自定义Cell
@interface SetCell : UITableViewCell
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *detailLab;
@property (nonatomic, strong) UIImageView *rightIcon;
- (void)updateConstraintsWithModel:(SetModel *)model;
@end
@implementation SetCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
self.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, ColorFromHex(0x1F263F), DSWhite);
self.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"moreIcon"]];
self.titleLab = [UILabel dkLabWithFont:BoldFont(15.0)];
[self addSubview:self.titleLab];
self.detailLab = [UILabel labWithFont:SysFont(14.0)];
self.detailLab.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, ColorFromHex(0x8C8F9D), DSWhite);
[self addSubview:self.detailLab];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
self.selectedBackgroundView = [[UIView alloc] initWithFrame:self.frame];
self.selectedBackgroundView.backgroundColor = DSClearColor;
[super setSelected:selected animated:animated];
}
- (void)updateConstraintsWithModel:(SetModel *)model {
self.titleLab.text = model.title;
self.detailLab.text = model.detail;
[self.titleLab sizeToFit];
[self.detailLab sizeToFit];
[self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15);
make.centerY.equalTo(self);
}];
[self.detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.accessoryView.mas_left).offset(-8);
make.centerY.equalTo(self);
}];
}
@end
@interface SetTableView () <UITableViewDelegate>
@property (nonatomic, strong) DSDataSource *setDataSource;
@property (nonatomic, strong) NSArray *dataArr;
@end
@implementation SetTableView
- (instancetype)initWithDelegate:(id<SetTableViewDelegate>)delegate {
if (self = [super initWithFrame:CGRectMake(15, 15, kScreenWidth - 30, 348) style:UITableViewStylePlain]) {
self.dataArr = [SetModel getAllSetDatas];
self.setDelegate = delegate;
[self cornerRadius:10];
self.scrollEnabled = NO;
self.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, ColorFromHex(0x1F263F), DSWhite);
self.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.setDataSource addDataArray:self.dataArr];
}
return self;
}
- (DSDataSource *)setDataSource {
if (!_setDataSource) {
CellConfigureBlock cellBlock = ^(SetCell * cell, SetModel * model, NSIndexPath * indexPath) {
[cell updateConstraintsWithModel:model];
};
NSString * const setCellID = @"SetCellID";
_setDataSource = [[DSDataSource alloc] initWithIdentifier:setCellID datas:@[] isSection:NO configureBlock:cellBlock];
self.dataSource = _setDataSource;
self.delegate = self;
[self registerClass:[SetCell class] forCellReuseIdentifier:setCellID];
}
return _setDataSource;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 50;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) { // 应用版本升级
// 跳转到AppStore
[DSProgressHUD showToast:@"暂无新版本"];
} else if (indexPath.row == 3) { // 清除缓存
[DSProgressHUD showToast:@"清除成功"];
SetModel *m = self.dataArr[indexPath.row];
m.detail = @"0M";
[tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:indexPath.row inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
} else {
if (self.setDelegate && [self.setDelegate respondsToSelector:@selector(didSelectRowAtIndexPath:)]) {
[self.setDelegate didSelectRowAtIndexPath:indexPath];
}
}
}
@end
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
#import "SystemSetController.h" #import "SystemSetController.h"
#import "PrivacyViewController.h" #import "PrivacyViewController.h"
#import "SetTableView.h"
@interface SystemSetController () @interface SystemSetController () <SetTableViewDelegate>
@property (nonatomic, strong) SetTableView *sTabView;
@end @end
@implementation SystemSetController @implementation SystemSetController
...@@ -20,14 +21,9 @@ ...@@ -20,14 +21,9 @@
self.navigationItem.title = @"系统设置"; self.navigationItem.title = @"系统设置";
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(20, 100, 100, 40)]; [self.view addSubview:self.sTabView];
[btn setTitle:@"用户协议" forState:UIControlStateNormal];
[btn debugViewShowBorder];
[btn setTitleColor:DSRed forState:UIControlStateNormal];
[btn addTarget:self action:@selector(privicyAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
UIButton *darkBtn = [[UIButton alloc] initWithFrame:CGRectMake(20, 200, 100, 40)]; UIButton *darkBtn = [[UIButton alloc] initWithFrame:CGRectMake(20, CGRectGetMaxY(self.sTabView.frame), 100, 40)];
[darkBtn setTitle:@"黑夜模式" forState:UIControlStateNormal]; [darkBtn setTitle:@"黑夜模式" forState:UIControlStateNormal];
[darkBtn debugViewShowBorder]; [darkBtn debugViewShowBorder];
[darkBtn setTitleColor:DSRed forState:UIControlStateNormal]; [darkBtn setTitleColor:DSRed forState:UIControlStateNormal];
...@@ -35,10 +31,6 @@ ...@@ -35,10 +31,6 @@
[self.view addSubview:darkBtn]; [self.view addSubview:darkBtn];
} }
- (void)privicyAction {
[self.navigationController pushViewController:[[PrivacyViewController alloc] initWithTitle:@"用户协议" link:[NSURL URLWithString:UserServiceAgreement] isDetail:YES] animated:YES];
}
- (void)darkBtnAction { - (void)darkBtnAction {
// 模拟切换黑夜模式 // 模拟切换黑夜模式
if ([self.dk_manager.themeVersion isEqualToString:DKThemeVersionNight]) { if ([self.dk_manager.themeVersion isEqualToString:DKThemeVersionNight]) {
...@@ -53,4 +45,29 @@ ...@@ -53,4 +45,29 @@
return NaviStyleDefault; return NaviStyleDefault;
} }
#pragma mark - SetTableViewDelegate
- (void)didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.row) {
case 1: // 用户协议
{
[self.navigationController pushViewController:[[PrivacyViewController alloc] initWithTitle:@"用户服务协议" link:[NSURL URLWithString:UserServiceAgreement] isDetail:YES] animated:YES];
}
break;
case 2: // 隐私政策
{
[self.navigationController pushViewController:[[PrivacyViewController alloc] initWithTitle:@"隐私政策" link:[NSURL URLWithString:PrivacyPolicy] isDetail:YES] animated:YES];
}
break;
default:
break;
}
}
- (SetTableView *)sTabView {
if (!_sTabView) {
_sTabView = [[SetTableView alloc] initWithDelegate:self];
}
return _sTabView;
}
@end @end
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "moreIcon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "moreIcon@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "moreIcon@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
...@@ -52,6 +52,8 @@ ...@@ -52,6 +52,8 @@
/** 主title颜色 */ /** 主title颜色 */
#define MainTextColor ColorFromHex(0x333333) #define MainTextColor ColorFromHex(0x333333)
/** 子title颜色 */
#define SubTitleColor ColorFromHex(0x777777)
/** 品牌色 */ /** 品牌色 */
#define BrandColor ColorFromHex(0x62C3D5) #define BrandColor ColorFromHex(0x62C3D5)
/** 背景色深色 */ /** 背景色深色 */
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!