CNLiveMineHeaderView.swift
9.72 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
//
// CNLiveMineHeaderView.swift
// metaCode
//
// Created by open on 2023/6/7.
//
import Foundation
import HXPHPicker
import Kingfisher
class MineHeaderView : UIView {
lazy var iconView : UIImageView = {
let iconView = UIImageView.init()
iconView.image = UIImage(named: "mine_header_icon_defult_ava")
iconView.backgroundColor = .clear
iconView.layer.cornerRadius = 30
iconView.layer.masksToBounds = true
iconView.contentMode = .scaleToFill
iconView.isUserInteractionEnabled = true
let tap = UITapGestureRecognizer.init(target: self, action: #selector(pushMineInfoAction))
iconView.addGestureRecognizer(tap)
return iconView
}()
lazy var nameLabel: UILabel = {
let nameLabel = UILabel.init()
nameLabel.textColor = .white
nameLabel.font = Font_16
return nameLabel
}()
lazy var tipBtn: UIButton = {
let tipBtn = UIButton(type: .custom)
tipBtn.backgroundColor = .clear
tipBtn.setImage(UIImage(named: "mine_header_icon_notice"), for: .normal)
tipBtn.imageView?.contentMode = .scaleToFill
tipBtn.addTarget(self, action: #selector(tipBtnAction), for: .touchUpInside)
return tipBtn
}()
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = .clear
addSubview(iconView)
iconView.snp.makeConstraints { make in
make.centerY.equalToSuperview().offset(10)
make.left.equalToSuperview().offset(20)
make.size.equalTo(60)
}
addSubview(nameLabel)
nameLabel.snp.makeConstraints { make in
make.centerY.equalToSuperview().offset(10)
make.left.equalTo(iconView.snp.right).offset(15)
}
addSubview(tipBtn)
tipBtn.snp.makeConstraints { make in
make.centerY.equalToSuperview().offset(10)
make.right.equalToSuperview().offset(-15)
make.size.equalTo(30)
}
updateHeaderView()
}
public func updateHeaderView() {
iconView.kf.indicatorType = .activity
iconView.kf.setImage(with: URL(string: UserInfoManager.shared.userInfo.bigFaceUrl), placeholder: UIImage(named: "mine_header_icon_defult_ava"))
nameLabel.text = UserInfoManager.shared.userInfo.nickName
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc func tipBtnAction() {
currentViewController()?.navigationController?.pushViewController(CNLiveMineAddInfoViewController.init(show_type: .message), animated: true)
}
@objc func pushMineInfoAction() {
currentViewController()?.navigationController?.pushViewController(CNLiveTypeFeedBackViewController.init(show_type: .info), animated: true)
}
}
class MineAboutHeaderView: UIView {
lazy var iconView: UIImageView = {
let iconView = UIImageView.init()
iconView.image = UIImage(named: "mine_sub_about_app_logo")
iconView.contentMode = .scaleToFill
iconView.backgroundColor = .clear
return iconView
}()
lazy var nameLabel: UILabel = {
let nameLabel = UILabel.init()
nameLabel.text = "\(kAppDisplayName)"
nameLabel.textColor = HexColor("#333333")
nameLabel.font = BoldFont_18_Fit
nameLabel.textAlignment = .center
return nameLabel
}()
lazy var verLabel: UILabel = {
let verLabel = UILabel.init()
verLabel.text = "YUANMA\(kAppVersion)"
verLabel.textColor = HexColor("#333333")
verLabel.font = Font_16_Fit
verLabel.textAlignment = .center
return verLabel
}()
override init(frame: CGRect) {
super.init(frame: frame)
addSubview(iconView)
addSubview(nameLabel)
addSubview(verLabel)
iconView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalToSuperview().offset(60)
make.size.equalTo(80)
}
nameLabel.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(iconView.snp.bottom).offset(8)
}
verLabel.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(nameLabel.snp.bottom).offset(8)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
typealias ClickResultBlock = (_ index: String) ->Void
class MinePhotoUploadView: UIView, PhotoPickerControllerDelegate {
lazy var imageView01: UIImageView = {
let imageView = UIImageView.init()
imageView.backgroundColor = .white
imageView.image = UIImage(named: "mine_sub_quest_addd_image")
imageView.contentMode = .scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.tag = 1000
imageView.layer.cornerRadius = 7
imageView.layer.masksToBounds = true
imageView.clipsToBounds = true
let tapGes = UITapGestureRecognizer.init(target: self, action: #selector(touchImageAction))
imageView.addGestureRecognizer(tapGes)
return imageView
}()
lazy var imageView02: UIImageView = {
let imageView = UIImageView.init()
imageView.backgroundColor = .white
imageView.image = UIImage(named: "mine_sub_quest_addd_image")
imageView.contentMode = .scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.tag = 1001
imageView.isHidden = true
imageView.clipsToBounds = true
imageView.layer.cornerRadius = 7
imageView.layer.masksToBounds = true
let tapGes = UITapGestureRecognizer.init(target: self, action: #selector(touchImageAction))
imageView.addGestureRecognizer(tapGes)
return imageView
}()
lazy var imageView03: UIImageView = {
let imageView = UIImageView.init()
imageView.backgroundColor = .white
imageView.image = UIImage(named: "mine_sub_quest_addd_image")
imageView.contentMode = .scaleAspectFill
imageView.isUserInteractionEnabled = true
imageView.tag = 1002
imageView.isHidden = true
imageView.clipsToBounds = true
imageView.layer.cornerRadius = 7
imageView.layer.masksToBounds = true
let tapGes = UITapGestureRecognizer.init(target: self, action: #selector(touchImageAction))
imageView.addGestureRecognizer(tapGes)
return imageView
}()
lazy var temp_imageView : UIImageView = {
return UIImageView.init()
}()
lazy var selectedImages: NSMutableArray = {
let tempArrray = NSMutableArray.init()
tempArrray.addObjects(from: ["","",""])
return tempArrray
}()
var _resutBlock : ClickResultBlock?
init(frame: CGRect, resutBlock: @escaping ClickResultBlock) {
super.init(frame: frame)
backgroundColor = .white
_resutBlock = resutBlock
addSubview(imageView01)
imageView01.snp.makeConstraints { make in
make.size.height.equalTo((KSreenWidth - 40)/3)
make.top.equalToSuperview()
make.left.equalToSuperview().offset(10)
}
addSubview(imageView02)
imageView02.snp.makeConstraints { make in
make.top.equalToSuperview()
make.size.height.equalTo((KSreenWidth - 40)/3)
make.size.width.equalTo(imageView02)
make.left.equalTo(imageView01.snp.right).offset(10)
}
addSubview(imageView03)
imageView03.snp.makeConstraints { make in
make.size.height.equalTo((KSreenWidth - 40)/3)
make.size.width.equalTo(imageView02)
make.top.equalToSuperview()
make.right.equalToSuperview().offset(-10)
make.left.equalTo(imageView02.snp.right).offset(10)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
@objc private func touchImageAction(ges: UITapGestureRecognizer) {
temp_imageView = ges.view as! UIImageView
if selectedImages.object(at: temp_imageView.tag - 1000) is String {
let config = PhotoTools.getWXPickerConfig()
config.selectMode = .single
config.selectOptions = .photo
config.maximumSelectedPhotoCount = 3
let pickerController = PhotoPickerController(picker: config)
pickerController.pickerDelegate = self
pickerController.isOriginal = false
currentViewController()!.present(pickerController, animated: true, completion: nil)
}
}
}
extension MinePhotoUploadView {
func pickerController(_ pickerController: PhotoPickerController,
didFinishSelection result: PickerResult) {
result.getImage { [self] (image, photoAsset, index) in
if let image = image {
temp_imageView.image = image
if temp_imageView == imageView01 {
imageView02.isHidden = false
selectedImages.replaceObject(at: 0, with: image)
_resutBlock!("1")
}
if temp_imageView == imageView02 {
imageView03.isHidden = false
selectedImages.replaceObject(at: 1, with: image)
_resutBlock!("2")
}
if temp_imageView == imageView03 {
selectedImages.replaceObject(at: 2, with: image)
_resutBlock!("3")
}
}else {
print("failed")
}
} completionHandler: { (images) in
}
}
}