SleepReadyController.m
5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//
// SleepReadyController.m
// DreamSleep
//
// Created by peter on 2022/7/11.
//
#import "SleepReadyController.h"
#import "ReadyListController.h"
#import "SRTipsView.h"
#import "SRMusicView.h"
#import "NoisePlayerManager.h"
#import "WhiteNoiseRequestModel.h"
@interface SleepReadyController () <ReadyListControllerDelegate>
@property (nonatomic, strong) UIImageView *headIV;
@property (nonatomic, strong) UIButton *tipsBtn;
@property (nonatomic, strong) UIButton *setBtn;
@property (nonatomic, strong) SRTipsView *sRTipsView;
@property (nonatomic, strong) UIButton *startBtn;
@property (nonatomic, strong) UIButton *musicBtn;
@property (nonatomic, strong) SRMusicView *musicView;
@end
@implementation SleepReadyController
- (void)viewDidLoad {
[super viewDidLoad];
self.naviTitle = @"睡前准备";
self.naviBarAlpha = 1.0;
self.dsNaviBar.dk_backgroundColorPicker = DKColorPickerWithColors(DSClearColor, DSClearColor, DSWhite);
[self.dsNaviBar addSubview:self.backBtn];
self.titleLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
[self.backBtn dk_setImage:DKImagePickerWithNames(@"cus_back_icon", @"sys_back_icon", @"sys_back_icon") forState:UIControlStateNormal];
[self.dsNaviBar addSubview:self.tipsBtn];
[self.dsNaviBar addSubview:self.setBtn];
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self.view insertSubview:self.headIV atIndex:0];
[self.view addSubview:self.startBtn];
[self.view addSubview:self.musicBtn];
[self.tipsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.titleLab);
}];
[self.setBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.tipsBtn);
make.left.equalTo(self.tipsBtn.mas_right).offset(24);
make.right.equalTo(self.view).offset(-15);
}];
[self.headIV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self.view);
}];
[self.startBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(155, 40));
make.centerX.equalTo(self.view);
make.bottom.equalTo(self.view).offset(-94-Bottom_SafeArea_Height);
}];
[self.musicBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.startBtn);
make.right.equalTo(self.view).offset(-15);
}];
// 暂停白噪音
[[NSNotificationCenter defaultCenter] postNotificationName:NeedPauseAllNoise object:nil];
[self queryRelaxWhiteNoiseType];
}
- (void)queryRelaxWhiteNoiseType {
// 获取白噪音类型请求
[WhiteNoiseRequestModel queryRelaxWhiteNoiseTypeWithCompletion:^(WhiteNoiseRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
DSLog(@"获取白噪音类型请求成功...");
[self.musicView refreshNoiseTypeData:requestModel.noiseTypeArr];
}
}];
}
- (void)backAction {
// 暂停白噪音
[[NSNotificationCenter defaultCenter] postNotificationName:NeedPauseAllNoise object:nil];
[super backAction];
}
#pragma mark - ReadyListControllerDelegate
#pragma mark - lazy
- (UIImageView *)headIV {
if (!_headIV) {
_headIV = [UIImageView new];
_headIV.dk_imagePicker = DKImagePickerWithNames(@"bg_anshui_start", @"dk_bg_anshui_start", @"bg_anshui_start");
}
return _headIV;
}
- (UIButton *)tipsBtn {
if (!_tipsBtn) {
WS(weakSelf);
_tipsBtn = [UIButton new];
[_tipsBtn dk_setImage:DKImagePickerWithNames(@"ic_zhunbei_zhushi", @"dk_ic_zhunbei_zhushi", @"ic_zhunbei_zhushi") forState:UIControlStateNormal];
[_tipsBtn addTouchUpInsideHandler:^(NSInteger tag) {
[weakSelf.sRTipsView showTipsAlertView];
}];
}
return _tipsBtn;
}
- (UIButton *)setBtn {
if (!_setBtn) {
WS(weakSelf);
_setBtn = [UIButton new];
[_setBtn dk_setImage:DKImagePickerWithNames(@"ic_zhunbei_set", @"dk_ic_zhunbei_set", @"ic_zhunbei_set") forState:UIControlStateNormal];
[_setBtn addTouchUpInsideHandler:^(NSInteger tag) {
ReadyListController *setListVC = [[ReadyListController alloc] initWithDelegate:weakSelf];
[weakSelf.navigationController pushViewController:setListVC animated:YES];
}];
}
return _setBtn;
}
- (SRTipsView *)sRTipsView {
if (!_sRTipsView) {
_sRTipsView = [SRTipsView new];
}
return _sRTipsView;
}
- (UIButton *)startBtn {
if (!_startBtn) {
_startBtn = [UIButton btnWithTitle:@"开始仪式" font:BoldFont(16.0)];
[_startBtn cornerRadius:20.0];
[_startBtn dk_setBackgroundColorPicker:DKColorPickerWithColors(BrandColor, SubNaviDarkColor, DSWhite)];
[_startBtn dk_setTitleColorPicker:DKColorPickerWithColors(DSWhite, DkTitleColor, DSWhite) forState:UIControlStateNormal];
[_startBtn addTouchUpInsideHandler:^(NSInteger tag) {
}];
}
return _startBtn;
}
- (UIButton *)musicBtn {
if (!_musicBtn) {
WS(weakSelf);
_musicBtn = [UIButton new];
[_musicBtn setImage:[UIImage imageNamed:@"ic_zhunbei_baizaoyin"] forState:UIControlStateNormal];
[_musicBtn addTouchUpInsideHandler:^(NSInteger tag) {
[weakSelf.musicView showMusicView];
}];
}
return _musicBtn;
}
- (SRMusicView *)musicView {
if (!_musicView) {
_musicView = [[SRMusicView alloc] initWithFrame:CGRectZero];
}
return _musicView;
}
@end