FeedbackDetailController.m
9.0 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
//
// FeedbackDetailController.m
// DreamSleep
//
// Created by peter on 2022/4/26.
//
#import "FeedbackDetailController.h"
#import "FeedbackRequestModel.h"
@interface FeedbackDetailController ()
@property (nonatomic, strong) UIScrollView *detailSV;
@property (nonatomic, strong) UIView *feedView;
@property (nonatomic, strong) UILabel *contentLab;
@property (nonatomic, strong) UIView *imgContainerView;
@property (nonatomic, strong) UILabel *createdTimeLab;
@property (nonatomic, strong) UIView *replyView;
@property (nonatomic, strong) UILabel *replyTitleLab;
@property (nonatomic, strong) UILabel *replierContentLab;
@property (nonatomic, strong) UILabel *replierNameLab;
@property (nonatomic, strong) UILabel *replierTimeLab;
@end
@implementation FeedbackDetailController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = @"详情信息";
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[FeedbackRequestModel queryAdviceDetailWithAdviceID:self.advice_id completion:^(FeedbackRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
[self buildUI:requestModel.feedDetailModel];
}
}];
}
- (void)buildUI:(MyFeedDetailModel *)detailModel {
[self.view addSubview:self.detailSV];
[self.detailSV mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
[self.detailSV addSubview:self.feedView];
[self.feedView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.detailSV.mas_top).offset(15);
make.left.equalTo(self.view).offset(15);
make.right.equalTo(self.view).offset(-15);
}];
[self.feedView addSubview:self.contentLab];
self.contentLab.text = detailModel.content;
[self.contentLab sizeToFit];
[self.contentLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.feedView).offset(8);
make.top.equalTo(self.feedView).offset(8);
make.right.equalTo(self.feedView).offset(-8);
}];
BOOL hasImg = NO;
if (detailModel.content_img && detailModel.content_img.length > 0) {
hasImg = YES;
[self.feedView addSubview:self.imgContainerView];
[self.imgContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.feedView).offset(8);
make.top.equalTo(self.contentLab.mas_bottom).offset(20);
make.right.equalTo(self.feedView).offset(-8);
make.height.equalTo(@105);
}];
// 截取图片字符串链接
NSArray *imgUrls = [detailModel.content_img componentsSeparatedByString:@","];
for (int i = 0; i < imgUrls.count; i++) {
UIImageView *showIV = [[UIImageView alloc] initWithFrame:CGRectMake(i*(105 + 8), 0, 105, 105)];
showIV.dk_alphaPicker = DKAlphaPickerWithAlphas(1.0, .5, .5);
[showIV yy_setImageWithURL:[NSURL URLWithString:imgUrls[i]] placeholder:[UIImage imageNamed:@"basicPlaceholder"]];
[showIV cornerRadius:12.0];
[self.imgContainerView addSubview:showIV];
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGRAction:)];
[showIV addGestureRecognizer:tapGR];
showIV.userInteractionEnabled = YES;
}
}
[self.feedView addSubview:self.createdTimeLab];
self.createdTimeLab.text = detailModel.created_at;
[self.createdTimeLab sizeToFit];
[self.createdTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.feedView).offset(-8);
make.bottom.equalTo(self.feedView).offset(-8);
make.top.equalTo(hasImg ? self.imgContainerView.mas_bottom : self.contentLab.mas_bottom).offset(39);
}];
UIView *lastView = self.feedView;
// 判断是否有回复信息
if (detailModel.replier_content && detailModel.replier_content.length > 0) {
[self.detailSV addSubview:self.replyView];
lastView = self.replyView;
[self.replyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.view).offset(15);
make.right.equalTo(self.view).offset(-15);
make.top.equalTo(self.feedView.mas_bottom).offset(15);
}];
[self.replyView addSubview:self.replyTitleLab];
[self.replyTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.replyView).offset(8);
make.top.equalTo(self.replyView).offset(15);
}];
[self.replyView addSubview:self.replierContentLab];
self.replierContentLab.text = detailModel.replier_content;
[self.replierContentLab sizeToFit];
[self.replierContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.replyTitleLab.mas_bottom).offset(12);
make.left.equalTo(self.replyView).offset(8);
make.right.equalTo(self.replyView).offset(-8);
}];
[self.replyView addSubview:self.replierNameLab];
self.replierNameLab.text = [NSString stringWithFormat:@"回复人:%@", detailModel.replier_name];
[self.replyTitleLab sizeToFit];
[self.replierNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.replierContentLab.mas_bottom).offset(46);
make.right.equalTo(self.replyView).offset(-8);
}];
[self.replyView addSubview:self.replierTimeLab];
self.replierTimeLab.text = [NSString stringWithFormat:@"回复时间:%@", detailModel.replier_time];
[self.replierTimeLab sizeToFit];
[self.replierTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.replierNameLab.mas_bottom).offset(8);
make.right.equalTo(self.replyView).offset(-8);
make.bottom.equalTo(self.replyView).offset(-15);
}];
}
[lastView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.detailSV.mas_bottom).offset(-15);
}];
}
- (void)tapGRAction:(UITapGestureRecognizer *)gr {
UIImageView *showIV = (UIImageView *)gr.view;
showIV.image;
DSLog(@"=========");
}
#pragma mark - 品牌模式
- (NaviStyle)navigationBarStyle {
return NaviStyleDefault;
}
#pragma mark - lazy
- (UIScrollView *)detailSV {
if (!_detailSV) {
_detailSV = [UIScrollView new];
_detailSV.showsVerticalScrollIndicator = NO;
_detailSV.contentSize = CGSizeMake(kScreenWidth, 1000);
}
return _detailSV;
}
- (UIView *)feedView {
if (!_feedView) {
_feedView = [UIView new];
[_feedView cornerRadius:12.0];
_feedView.dk_backgroundColorPicker = DKColorPickerWithKey(CornerViewBG);
}
return _feedView;
}
- (UILabel *)contentLab {
if (!_contentLab) {
_contentLab = [UILabel labWithFont:SysFont(14)];
_contentLab.numberOfLines = 0;
_contentLab.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, DarkTextColor, DSWhite);
}
return _contentLab;
}
- (UILabel *)createdTimeLab {
if (!_createdTimeLab) {
_createdTimeLab = [UILabel labWithFont:SysFont(12)];
_createdTimeLab.textAlignment = NSTextAlignmentRight;
_createdTimeLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHex(0x5C6274), DSWhite);
}
return _createdTimeLab;
}
- (UIView *)imgContainerView {
if (!_imgContainerView) {
_imgContainerView = [UIView new];
}
return _imgContainerView;
}
- (UIView *)replyView {
if (!_replyView) {
_replyView = [UIView new];
[_replyView cornerRadius:12.0];
_replyView.dk_backgroundColorPicker = DKColorPickerWithKey(CornerViewBG);
}
return _replyView;
}
- (UILabel *)replyTitleLab {
if (!_replyTitleLab) {
_replyTitleLab = [UILabel labWithText:@"回复内容" textColor:ColorFromHex(0xF04B77) font:BoldFont(16.0)];
[_replyTitleLab sizeToFit];
}
return _replyTitleLab;
}
- (UILabel *)replierContentLab {
if (!_replierContentLab) {
_replierContentLab = [UILabel labWithFont:SysFont(14)];
_replierContentLab.numberOfLines = 0;
_replierContentLab.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, DarkTextColor, DSWhite);
}
return _replierContentLab;
}
- (UILabel *)replierNameLab {
if (!_replierNameLab) {
_replierNameLab = [UILabel labWithFont:SysFont(12)];
_replierNameLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHex(0x5C6274), DSWhite);
_replierNameLab.textAlignment = NSTextAlignmentRight;
}
return _replierNameLab;
}
- (UILabel *)replierTimeLab {
if (!_replierTimeLab) {
_replierTimeLab = [UILabel labWithFont:SysFont(12)];
_replierTimeLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHex(0x5C6274), DSWhite);
_replierTimeLab.textAlignment = NSTextAlignmentRight;
}
return _replierTimeLab;
}
@end