Commit 6666520c cgx

导航栏白天夜间模式

1 个父辈 3588475b
......@@ -27,9 +27,9 @@
self.navigationItem.leftBarButtonItem = leftItem;
}
#pragma mark - 导航栏日间模式
#pragma mark - 导航栏日间、黑夜模式
- (NaviStyle)navigationBarStyle {
return NaviStyleLight;
return [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? NaviStyleLight : NaviStyleDark;
}
- (HomeTableView *)homeTV {
......
......@@ -16,6 +16,8 @@
@property (nonatomic, copy) NSURL *link;
@property (nonatomic, assign) BOOL isDetail;
@property (nonatomic, strong) WKWebView *webView;
// 黑夜模式遮罩(到时候提取出来,全局通用)
@property (nonatomic, strong) UIView *darkMaskView;
@end
@implementation PrivacyViewController
......@@ -40,6 +42,12 @@
} else {
[self showPrivacyView];
}
self.darkMaskView.hidden = ![self.dk_manager.themeVersion isEqualToString:DKThemeVersionNight];
}
- (void)dealloc {
[self.maskView removeFromSuperview];
}
- (void)viewWillAppear:(BOOL)animated {
......@@ -78,4 +86,15 @@
return _webView;
}
- (UIView *)darkMaskView {
if (!_darkMaskView) {
_darkMaskView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
_darkMaskView.backgroundColor = ColorFromHex(0x6B7485);
_darkMaskView.alpha = .5;
_darkMaskView.userInteractionEnabled = NO;
[self.view addSubview:_darkMaskView];
}
return _darkMaskView;
}
@end
......@@ -11,7 +11,7 @@
<!--我的-->
<scene sceneID="XXm-nW-BLl">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="z46-F3-9B2" sceneMemberID="viewController">
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="z46-F3-9B2" customClass="BaseNaviController" sceneMemberID="viewController">
<tabBarItem key="tabBarItem" title="我的" image="profile" selectedImage="profile_selected" id="q0K-3e-nOn"/>
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="kJv-b2-G2C">
......
......@@ -6,9 +6,10 @@
//
#import "ProfileController.h"
#import "SystemSetController.h"
@interface ProfileController ()
@property (nonatomic, strong) NSArray *tmpDatas;
@end
@implementation ProfileController
......@@ -16,35 +17,43 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"我的";
self.tableView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
self.tmpDatas = @[@"注册登录信息", @"意见反馈", @"系统设置", @"邀请好友", @"关于我们", @"前往小程序", @"关注公众号", @"添加客服微信", @"失眠的认知行为疗法"];
}
#pragma mark - 导航栏日间、黑夜模式
- (NaviStyle)navigationBarStyle {
return NaviStyleDefault;
}
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 1;
return self.tmpDatas.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"profileCell" forIndexPath:indexPath];
cell.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
cell.textLabel.text = self.tmpDatas[indexPath.row];
cell.textLabel.dk_textColorPicker = DKColorPickerWithKey(TEXT);
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// 模拟切换黑夜模式
if ([self.dk_manager.themeVersion isEqualToString:DKThemeVersionNight]) {
self.dk_manager.themeVersion = DKThemeVersionNormal;
} else {
self.dk_manager.themeVersion = DKThemeVersionNight;
}
}
/*
#pragma mark - Navigation
[tableView deselectRowAtIndexPath:indexPath animated:YES];
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
switch (indexPath.row) {
case 2: // 系统设置入口
{
SystemSetController *sysVC = [SystemSetController new];
[self.navigationController pushViewController:sysVC animated:YES];
}
break;
default:
break;
}
}
*/
@end
//
// TmpViewController.h
// SystemSetController.h
// DreamSleep
//
// Created by peter on 2022/3/30.
// Created by peter on 2022/4/14.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface TmpViewController : UIViewController
/// 系统设置
@interface SystemSetController : UIViewController
@end
......
//
// SystemSetController.m
// DreamSleep
//
// Created by peter on 2022/4/14.
//
#import "SystemSetController.h"
#import "PrivacyViewController.h"
@interface SystemSetController ()
@end
@implementation SystemSetController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"系统设置";
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(20, 100, 100, 40)];
[btn setTitle:@"用户协议" forState:UIControlStateNormal];
[btn setTitleColor:DSRed forState:UIControlStateNormal];
[btn addTarget:self action:@selector(privicyAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
- (void)privicyAction {
[self.navigationController pushViewController:[[PrivacyViewController alloc] initWithTitle:@"用户协议" link:[NSURL URLWithString:UserServiceAgreement] isDetail:YES] animated:YES];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
// 模拟切换黑夜模式
if ([self.dk_manager.themeVersion isEqualToString:DKThemeVersionNight]) {
self.dk_manager.themeVersion = DKThemeVersionNormal;
} else {
self.dk_manager.themeVersion = DKThemeVersionNight;
}
}
#pragma mark - 导航栏日间、黑夜模式
- (NaviStyle)navigationBarStyle {
return NaviStyleDefault;
}
@end
//
// TmpViewController.m
// DreamSleep
//
// Created by peter on 2022/3/30.
//
#import "TmpViewController.h"
@interface TmpViewController ()
@end
@implementation TmpViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
DSLog(@"11111");
}
@end
//
// ViewController.h
// DreamSleep
//
// Created by peter on 2022/3/29.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@end
//
// ViewController.m
// DreamSleep
//
// Created by peter on 2022/3/29.
//
#import "ViewController.h"
#import <DKNightVersion/DKNightVersion.h>
#import "TmpViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(BG);
DSKeyWindow.backgroundColor = DSRed;
}
- (IBAction)changeAction:(id)sender {
if ([self.dk_manager.themeVersion isEqualToString:DKThemeVersionNight]) {
[self.dk_manager dawnComing];
} else if ([self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal]) {
self.dk_manager.themeVersion = @"RED";
} else {
[self.dk_manager nightFalling];
}
}
- (IBAction)jumpAction:(id)sender {
TmpViewController *vc = [TmpViewController new];
vc.view.dk_backgroundColorPicker = DKColorPickerWithKey(BG);
[self presentViewController:vc animated:YES completion:nil];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
DSLog(@"2222");
}
@end
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!