GRect) {
|
17
|
|
- // Drawing code
|
|
|
12
|
+class GroupQRView: NiblessView {
|
|
|
13
|
+
|
|
|
14
|
+ private var groupName: String
|
|
|
15
|
+ private var groupAvatar: String
|
|
|
16
|
+ private var groupQR: String
|
|
|
17
|
+
|
|
|
18
|
+ lazy var groupAvatarImageView: UIImageView = {
|
|
|
19
|
+ let imageView = UIImageView()
|
|
|
20
|
+
|
|
|
21
|
+ imageView.image = UIImage(named: groupAvatar)
|
|
|
22
|
+
|
|
|
23
|
+ return imageView
|
|
|
24
|
+ }()
|
|
|
25
|
+
|
|
|
26
|
+ lazy var groupNameLabel: UILabel = {
|
|
|
27
|
+ let label = UILabel()
|
|
|
28
|
+
|
|
|
29
|
+ label.text = groupName
|
|
|
30
|
+ label.font = UIFont.systemFont(ofSize: 17)
|
|
|
31
|
+
|
|
|
32
|
+ return label
|
|
|
33
|
+ }()
|
|
|
34
|
+
|
|
|
35
|
+ lazy var qrImageView: UIImageView = {
|
|
|
36
|
+ let imageView = UIImageView()
|
|
|
37
|
+
|
|
|
38
|
+ imageView.image = UIImage(qr: groupQR)
|
|
|
39
|
+
|
|
|
40
|
+ return imageView
|
|
|
41
|
+ }()
|
|
|
42
|
+
|
|
|
43
|
+ lazy var qrLabel: UILabel = {
|
|
|
44
|
+ let label = UILabel()
|
|
|
45
|
+
|
|
|
46
|
+ label.text = "扫描二维码加入群"
|
|
|
47
|
+ label.textColor = UIColor(gray: 153)
|
|
|
48
|
+ label.font = UIFont.systemFont(ofSize: 14)
|
|
|
49
|
+
|
|
|
50
|
+ return label
|
|
|
51
|
+ }()
|
|
|
52
|
+
|
|
|
53
|
+ init(groupName: String, groupAvatar: String, groupQR: String) {
|
|
|
54
|
+ self.groupName = groupName
|
|
|
55
|
+ self.groupAvatar = groupAvatar
|
|
|
56
|
+ self.groupQR = groupQR
|
|
|
57
|
+
|
|
|
58
|
+ super.init(frame: CGRect.zero)
|
|
|
59
|
+ }
|
|
|
60
|
+
|
|
|
61
|
+ override func didMoveToWindow() {
|
|
|
62
|
+ super.didMoveToWindow()
|
|
|
63
|
+ constructViewHierarchy()
|
|
|
64
|
+ activateConstraints()
|
|
|
65
|
+ backgroundColor = UIColor.white
|
|
|
66
|
+ }
|
|
|
67
|
+
|
|
|
68
|
+ private func constructViewHierarchy() {
|
|
|
69
|
+ addSubview(groupAvatarImageView)
|
|
|
70
|
+ addSubview(groupNameLabel)
|
|
|
71
|
+ addSubview(qrImageView)
|
|
|
72
|
+ addSubview(qrLabel)
|
|
18
|
73
|
}
|
|
19
|
|
- */
|
|
|
74
|
+}
|
|
20
|
75
|
|
|
|
76
|
+fileprivate extension GroupQRView {
|
|
|
77
|
+ func activateConstraints() {
|
|
|
78
|
+ activateConstraintsContent()
|
|
|
79
|
+ activateConstraintsQRImageView()
|
|
|
80
|
+ activateConstraintsQRLabel()
|
|
|
81
|
+ activateConstraintsGroupAvatarImageView()
|
|
|
82
|
+ activateConstraintsGroupNameLabel()
|
|
|
83
|
+ }
|
|
|
84
|
+
|
|
|
85
|
+ func activateConstraintsContent() {
|
|
|
86
|
+ guard let superView = superview else { return }
|
|
|
87
|
+
|
|
|
88
|
+ translatesAutoresizingMaskIntoConstraints = false
|
|
|
89
|
+
|
|
|
90
|
+ NSLayoutConstraint.activate([
|
|
|
91
|
+ widthAnchor.constraint(equalToConstant: 300),
|
|
|
92
|
+ centerXAnchor.constraint(equalTo: superView.centerXAnchor),
|
|
|
93
|
+ centerYAnchor.constraint(equalTo: superView.centerYAnchor)
|
|
|
94
|
+ ])
|
|
|
95
|
+ }
|
|
|
96
|
+
|
|
|
97
|
+ func activateConstraintsGroupAvatarImageView() {
|
|
|
98
|
+ groupAvatarImageView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
99
|
+
|
|
|
100
|
+ NSLayoutConstraint.activate([
|
|
|
101
|
+ groupAvatarImageView.widthAnchor.constraint(equalToConstant: 50),
|
|
|
102
|
+ groupAvatarImageView.heightAnchor.constraint(equalToConstant: 50),
|
|
|
103
|
+ groupAvatarImageView.centerXAnchor.constraint(equalTo: centerXAnchor),
|
|
|
104
|
+ groupAvatarImageView.topAnchor.constraint(equalTo: topAnchor, constant: 12),
|
|
|
105
|
+ ])
|
|
|
106
|
+ }
|
|
|
107
|
+
|
|
|
108
|
+ func activateConstraintsGroupNameLabel() {
|
|
|
109
|
+ groupNameLabel.translatesAutoresizingMaskIntoConstraints = false
|
|
|
110
|
+
|
|
|
111
|
+ NSLayoutConstraint.activate([
|
|
|
112
|
+ groupNameLabel.centerXAnchor.constraint(equalTo: centerXAnchor),
|
|
|
113
|
+ groupNameLabel.topAnchor.constraint(equalTo: groupAvatarImageView.bottomAnchor, constant: 6)
|
|
|
114
|
+ ])
|
|
|
115
|
+
|
|
|
116
|
+ }
|
|
|
117
|
+
|
|
|
118
|
+ func activateConstraintsQRImageView() {
|
|
|
119
|
+ qrImageView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
120
|
+
|
|
|
121
|
+ NSLayoutConstraint.activate([
|
|
|
122
|
+ qrImageView.widthAnchor.constraint(equalToConstant: 250),
|
|
|
123
|
+ qrImageView.centerXAnchor.constraint(equalTo: centerXAnchor),
|
|
|
124
|
+ qrImageView.widthAnchor.constraint(equalTo: qrImageView.heightAnchor),
|
|
|
125
|
+ qrImageView.topAnchor.constraint(equalTo: groupNameLabel.bottomAnchor, constant: 12),
|
|
|
126
|
+ ])
|
|
|
127
|
+ }
|
|
|
128
|
+
|
|
|
129
|
+ func activateConstraintsQRLabel() {
|
|
|
130
|
+ qrLabel.translatesAutoresizingMaskIntoConstraints = false
|
|
|
131
|
+
|
|
|
132
|
+ NSLayoutConstraint.activate([
|
|
|
133
|
+ qrLabel.centerXAnchor.constraint(equalTo: centerXAnchor),
|
|
|
134
|
+ qrLabel.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -12),
|
|
|
135
|
+ qrLabel.topAnchor.constraint(equalTo: qrImageView.bottomAnchor, constant: 6),
|
|
|
136
|
+ ])
|
|
|
137
|
+ }
|
|
21
|
138
|
}
|
|
|
|
@@ -37,7 +37,7 @@ final class GroupViewController: UIViewController {
|
|
37
|
37
|
|
|
38
|
38
|
var navigationBarViewImage: UIImageView = {
|
|
39
|
39
|
let image = UIImageView()
|
|
40
|
|
- image.cornerRadius = 20
|
|
|
40
|
+ image.cornerRadius = 18
|
|
41
|
41
|
return image
|
|
42
|
42
|
}()
|
|
43
|
43
|
|
|
|
|
@@ -70,6 +70,7 @@ final class GroupViewController: UIViewController {
|
|
70
|
70
|
[unowned self] in
|
|
71
|
71
|
self.viewModel.reload()
|
|
72
|
72
|
}
|
|
|
73
|
+ collectionView.startRefreshing(at: .top)
|
|
73
|
74
|
}
|
|
74
|
75
|
}
|
|
75
|
76
|
|
|
|
|
@@ -86,7 +87,6 @@ fileprivate extension GroupViewController {
|
|
86
|
87
|
}
|
|
87
|
88
|
|
|
88
|
89
|
func binding() {
|
|
89
|
|
- bindInteraction()
|
|
90
|
90
|
bindViewModelToRefreshing()
|
|
91
|
91
|
bindCollectionViewDelegate()
|
|
92
|
92
|
bindViewModelToCollectionView()
|
|
|
|
@@ -95,10 +95,6 @@ fileprivate extension GroupViewController {
|
|
95
|
95
|
bindViewModelToNavigationBarTitle()
|
|
96
|
96
|
}
|
|
97
|
97
|
|
|
98
|
|
- func bindInteraction() {
|
|
99
|
|
- photographBtn.rx.tap.bind(to: viewModel.photographBtnTapped).disposed(by: disposeBag)
|
|
100
|
|
- }
|
|
101
|
|
-
|
|
102
|
98
|
func bindViewModelToRefreshing() {
|
|
103
|
99
|
viewModel.isLoading
|
|
104
|
100
|
.subscribe(onNext: {[unowned self] flag in
|
|
|
|
@@ -156,15 +152,23 @@ extension GroupViewController: NavigationBarInteractiveViewController {
|
|
156
|
152
|
private func setRightBarButtonItems() {
|
|
157
|
153
|
let item = UIBarButtonItem(images: [UIImage(named: "navigation-QR"),
|
|
158
|
154
|
UIImage(named: "navigation-right")],
|
|
159
|
|
- btnSpace: 6,
|
|
160
|
|
- target: self,
|
|
161
|
|
- actions: [#selector(viewModel!.presentGroupQR),
|
|
162
|
|
- #selector(viewModel!.navigateToGroupDetail)])
|
|
|
155
|
+ targets: [self, viewModel],
|
|
|
156
|
+ actions: [#selector(GroupViewController.presentGroupQR),
|
|
|
157
|
+ #selector(GroupViewModel.navigateToGroupDetail)])
|
|
|
158
|
+
|
|
163
|
159
|
navigationItem.rightBarButtonItem = item
|
|
164
|
160
|
}
|
|
|
161
|
+
|
|
|
162
|
+ @objc func presentGroupQR() {
|
|
|
163
|
+ let alert = AlertViewController(style: .custom(GroupQRView(groupName: groupItem.group_name,
|
|
|
164
|
+ groupAvatar: "Group\(groupItem.group_default_avatar)",
|
|
|
165
|
+ groupQR: "https:pai.ai/g/\(groupItem.group_id)"),
|
|
|
166
|
+ AlertAnimator()) )
|
|
|
167
|
+ presentController(alert)
|
|
|
168
|
+ }
|
|
165
|
169
|
}
|
|
166
|
170
|
|
|
167
|
|
-/// layout
|
|
|
171
|
+/// navigation bar layout
|
|
168
|
172
|
fileprivate extension GroupViewController {
|
|
169
|
173
|
|
|
170
|
174
|
func activateConstraintsNavigation() {
|
|
|
|
@@ -199,14 +203,18 @@ fileprivate extension GroupViewController {
|
|
199
|
203
|
navigationBarViewImage.translatesAutoresizingMaskIntoConstraints = false
|
|
200
|
204
|
|
|
201
|
205
|
NSLayoutConstraint.activate([
|
|
202
|
|
- navigationBarViewImage.widthAnchor.constraint(equalToConstant: 40),
|
|
203
|
|
- navigationBarViewImage.heightAnchor.constraint(equalToConstant: 40),
|
|
|
206
|
+ navigationBarViewImage.widthAnchor.constraint(equalToConstant: 36),
|
|
|
207
|
+ navigationBarViewImage.heightAnchor.constraint(equalToConstant: 36),
|
|
204
|
208
|
navigationBarViewImage.centerYAnchor.constraint(equalTo: navigationBarView.centerYAnchor),
|
|
205
|
209
|
navigationBarViewImage.leadingAnchor.constraint(equalTo: navigationBarView.leadingAnchor),
|
|
206
|
210
|
])
|
|
207
|
211
|
}
|
|
208
|
212
|
}
|
|
209
|
213
|
|
|
|
214
|
+extension GroupViewController {
|
|
|
215
|
+
|
|
|
216
|
+}
|
|
|
217
|
+
|
|
210
|
218
|
extension GroupViewController: UICollectionViewDelegateFlowLayout {
|
|
211
|
219
|
func collectionView(_ collectionView: UICollectionView,
|
|
212
|
220
|
layout collectionViewLayout: UICollectionViewLayout,
|
|
|
|
@@ -231,10 +239,10 @@ extension GroupViewController: UIImagePickerControllerDelegate, UINavigationCont
|
|
231
|
239
|
|
|
232
|
240
|
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
|
|
233
|
241
|
dismiss(animated: true, completion: nil)
|
|
|
242
|
+ guard let image = info[.originalImage] as? UIImage,
|
|
|
243
|
+ let data = image.scaledImage(length: 1280, with: 0.4) else { return }
|
|
234
|
244
|
|
|
235
|
|
- guard let image = info[.originalImage] as? UIImage else { return }
|
|
236
|
|
-
|
|
237
|
|
- viewModel.submit(image: image)
|
|
|
245
|
+ viewModel.submit(data: data)
|
|
238
|
246
|
}
|
|
239
|
247
|
|
|
240
|
248
|
func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
|
|
|
|
@@ -24,7 +24,7 @@ final class ScanQRViewController: UIViewController {
|
|
24
|
24
|
// MARK: view function
|
|
25
|
25
|
override func viewDidLoad() {
|
|
26
|
26
|
super.viewDidLoad()
|
|
27
|
|
- navigationController?.navigationBar.setBackgroundImage(UIImage.imageWithColor(UIColor.black), for: .default)
|
|
|
27
|
+// navigationController?.navigationBar.setBackgroundImage(UIImage.imageWithColor(UIColor.black), for: .default)
|
|
28
|
28
|
scanView.delegate = self
|
|
29
|
29
|
}
|
|
30
|
30
|
|
|
|
|
@@ -60,11 +60,10 @@ extension MineCoordinator: MineViewControllerDelegate {
|
|
60
|
60
|
|
|
61
|
61
|
extension MineCoordinator: MineGroupViewModelDelegate {
|
|
62
|
62
|
func didSelect(_ item: GroupItem) {
|
|
63
|
|
- let vc = makeGroupViewController(item: item)
|
|
64
|
|
- let coordinator = GroupCoordinator(navigationController: navigationController)
|
|
|
63
|
+ let coordinator = GroupCoordinator(makeGroupViewController(item: item),
|
|
|
64
|
+ navigationController: navigationController)
|
|
65
|
65
|
childCoordinator["group"] = coordinator
|
|
66
|
|
-
|
|
67
|
|
- navigationController.pushViewController(vc)
|
|
|
66
|
+ navigationController.pushViewController(coordinator.groupViewController)
|
|
68
|
67
|
}
|
|
69
|
68
|
}
|
|
70
|
69
|
|
|
|
|
@@ -82,7 +82,7 @@ extension MineViewController: UITableViewDataSource {
|
|
82
|
82
|
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
83
|
83
|
let cell = tableView.dequeueReusableCell(withIdentifier: "mineCell", for: indexPath)
|
|
84
|
84
|
cell.textLabel?.text = menuTitle[indexPath.row]
|
|
85
|
|
- cell.textLabel?.textColor = UIColor(r: 51, g: 51, b: 51, a: 1.0)
|
|
|
85
|
+ cell.textLabel?.textColor = UIColor(gray: 51)
|
|
86
|
86
|
cell.imageView?.image = UIImage(named: menuImage[indexPath.row])
|
|
87
|
87
|
|
|
88
|
88
|
return cell
|
|
|
|
@@ -19,7 +19,7 @@ final class ImageCell: UICollectionViewCell, UIScrollViewDelegate {
|
|
19
|
19
|
photoImage.contentMode = .scaleAspectFit
|
|
20
|
20
|
scrollView.contentSize = size
|
|
21
|
21
|
scrollView.addSubview(photoImage)
|
|
22
|
|
- photoImage.image = UIImage.imageWithColor(UIColor.black)
|
|
|
22
|
+// photoImage.image = UIImage.imageWithColor(UIColor.black)
|
|
23
|
23
|
if !url.isEmpty {
|
|
24
|
24
|
// photoImage.setImageWithNullableURL(url, placeholderImage: UIImage(named: "详情页占位图"))
|
|
25
|
25
|
} else {
|