>
+ })
+ }
+}
+
+extension NavigationController: UIGestureRecognizerDelegate {
+ public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
+ if gestureRecognizer == interactivePopGestureRecognizer {
+ return viewControllers.count > 1
+ }
+ return true
+ }
+}
@@ -72,7 +72,7 @@ open class PageViewController: UIViewController {
|
||
| 72 | 72 |
constructViewHierarchy() |
| 73 | 73 |
activateConstraints() |
| 74 | 74 |
setMenuGestureRecognizer() |
| 75 |
- setupNavigationBarInteractivePopDelegate() |
|
| 75 |
+ |
|
| 76 | 76 |
} |
| 77 | 77 |
|
| 78 | 78 |
open override func viewDidLayoutSubviews() {
|
@@ -90,8 +90,8 @@ open class PageViewController: UIViewController {
|
||
| 90 | 90 |
} |
| 91 | 91 |
|
| 92 | 92 |
private func constructViewHierarchy() {
|
| 93 |
+ navigationItem.titleView = menuView |
|
| 93 | 94 |
view.addSubview(scrollView) |
| 94 |
- navigationController?.navigationBar.addSubview(menuView) |
|
| 95 | 95 |
menuView.addSubview(sliderView) |
| 96 | 96 |
} |
| 97 | 97 |
} |
@@ -150,15 +150,12 @@ fileprivate extension PageViewController {
|
||
| 150 | 150 |
|
| 151 | 151 |
let left: NSLayoutConstraint |
| 152 | 152 |
if let lastLabel = last {
|
| 153 |
- left = label.leftAnchor |
|
| 154 |
- .constraint(equalTo: lastLabel.rightAnchor, constant: option.spacing) |
|
| 153 |
+ left = label.leftAnchor.constraint(equalTo: lastLabel.rightAnchor, constant: option.spacing) |
|
| 155 | 154 |
} else {
|
| 156 |
- left = label.leadingAnchor |
|
| 157 |
- .constraint(equalTo: menuView.leadingAnchor) |
|
| 155 |
+ left = label.leadingAnchor.constraint(equalTo: menuView.leadingAnchor) |
|
| 158 | 156 |
} |
| 159 | 157 |
|
| 160 |
- let centerY = label.centerYAnchor |
|
| 161 |
- .constraint(equalTo: menuView.centerYAnchor) |
|
| 158 |
+ let centerY = label.centerYAnchor.constraint(equalTo: menuView.centerYAnchor) |
|
| 162 | 159 |
|
| 163 | 160 |
if i == 0 {
|
| 164 | 161 |
label.textColor = option.selectedColor |
@@ -178,17 +175,16 @@ fileprivate extension PageViewController {
|
||
| 178 | 175 |
|
| 179 | 176 |
func setSliderViewDetail() {
|
| 180 | 177 |
guard let label = menuView.viewWithTag(baseTag) else { return }
|
| 181 |
- sliderConstraint = sliderView.centerXAnchor |
|
| 182 |
- .constraint(equalTo: label.centerXAnchor) |
|
| 178 |
+ sliderConstraint = sliderView.centerXAnchor.constraint(equalTo: label.centerXAnchor) |
|
| 183 | 179 |
|
| 184 |
- NSLayoutConstraint.activate([sliderConstraint!]) |
|
| 180 |
+ NSLayoutConstraint.activate([sliderConstraint!, |
|
| 181 |
+ sliderView.topAnchor.constraint(equalTo: label.bottomAnchor, constant: 6)]) |
|
| 185 | 182 |
} |
| 186 | 183 |
} |
| 187 | 184 |
|
| 188 | 185 |
/// layout |
| 189 | 186 |
fileprivate extension PageViewController {
|
| 190 | 187 |
func activateConstraints() {
|
| 191 |
- activateConstraintsMenuView() |
|
| 192 | 188 |
activateConstraintsSliderView() |
| 193 | 189 |
activateConstraintsScrollView() |
| 194 | 190 |
} |
@@ -206,18 +202,6 @@ fileprivate extension PageViewController {
|
||
| 206 | 202 |
NSLayoutConstraint.activate([width, height, top, leading, bottom, trailing]) |
| 207 | 203 |
} |
| 208 | 204 |
|
| 209 |
- func activateConstraintsMenuView() {
|
|
| 210 |
- guard let barContentView = navigationController?.navigationBar else { return }
|
|
| 211 |
- |
|
| 212 |
- menuView.translatesAutoresizingMaskIntoConstraints = false |
|
| 213 |
- |
|
| 214 |
- NSLayoutConstraint.activate([ |
|
| 215 |
- menuView.topAnchor.constraint(equalTo: barContentView.topAnchor), |
|
| 216 |
- menuView.bottomAnchor.constraint(equalTo: barContentView.bottomAnchor), |
|
| 217 |
- menuView.centerXAnchor.constraint(equalTo: barContentView.centerXAnchor) |
|
| 218 |
- ]) |
|
| 219 |
- } |
|
| 220 |
- |
|
| 221 | 205 |
func activateConstraintsSliderView() {
|
| 222 | 206 |
|
| 223 | 207 |
sliderView.translatesAutoresizingMaskIntoConstraints = false |
@@ -366,9 +350,3 @@ fileprivate extension PageViewController {
|
||
| 366 | 350 |
} |
| 367 | 351 |
} |
| 368 | 352 |
} |
| 369 |
- |
|
| 370 |
-extension PageViewController: NavigationBarInteractiveViewController {
|
|
| 371 |
- public var navigationView: UIView {
|
|
| 372 |
- return menuView |
|
| 373 |
- } |
|
| 374 |
-} |
@@ -86,5 +86,4 @@ extension GroupNameModificationViewController {
|
||
| 86 | 86 |
} |
| 87 | 87 |
} |
| 88 | 88 |
|
| 89 |
- |
|
| 90 | 89 |
extension GroupNameModificationViewController: NavigationBackViewController {}
|
@@ -59,6 +59,7 @@ final class GroupViewController: UIViewController {
|
||
| 59 | 59 |
bundle: Bundle(identifier: "com.Paiai-iOS")), |
| 60 | 60 |
forCellWithReuseIdentifier: "photoCell") |
| 61 | 61 |
setup() |
| 62 |
+ setNavigationBar() |
|
| 62 | 63 |
binding() |
| 63 | 64 |
} |
| 64 | 65 |
|
@@ -149,7 +150,7 @@ fileprivate extension GroupViewController {
|
||
| 149 | 150 |
} |
| 150 | 151 |
} |
| 151 | 152 |
|
| 152 |
-extension GroupViewController: NavigationBarInteractiveViewController {
|
|
| 153 |
+extension GroupViewController {
|
|
| 153 | 154 |
var navigationView: UIView {
|
| 154 | 155 |
return navigationBarView |
| 155 | 156 |
} |
@@ -157,14 +158,13 @@ extension GroupViewController: NavigationBarInteractiveViewController {
|
||
| 157 | 158 |
func setNavigationBar() {
|
| 158 | 159 |
guard navigationViewNotReady else { return }
|
| 159 | 160 |
setRightBarButtonItems() |
| 160 |
- construvtNaivgationViewHierarchy() |
|
| 161 |
+ constructNaivgationViewHierarchy() |
|
| 161 | 162 |
activateConstraintsNavigation() |
| 162 |
- |
|
| 163 | 163 |
navigationViewNotReady = false |
| 164 | 164 |
} |
| 165 | 165 |
|
| 166 |
- private func construvtNaivgationViewHierarchy() {
|
|
| 167 |
- navigationController?.navigationBar.addSubview(navigationBarView) |
|
| 166 |
+ private func constructNaivgationViewHierarchy() {
|
|
| 167 |
+ navigationItem.titleView = navigationBarView |
|
| 168 | 168 |
navigationBarView.addSubview(navigationBarViewImage) |
| 169 | 169 |
navigationBarView.addSubview(navigationBarViewTitle) |
| 170 | 170 |
} |
@@ -172,7 +172,7 @@ extension GroupViewController: NavigationBarInteractiveViewController {
|
||
| 172 | 172 |
private func setRightBarButtonItems() {
|
| 173 | 173 |
let item = UIBarButtonItem(images: [UIImage(named: "navigation-QR"), |
| 174 | 174 |
UIImage(named: "navigation-right")], |
| 175 |
- targets: [self, viewModel], |
|
| 175 |
+ targets: [self, viewModel!], |
|
| 176 | 176 |
actions: [#selector(GroupViewController.presentGroupQR), |
| 177 | 177 |
#selector(GroupViewModel.navigateToGroupDetail)]) |
| 178 | 178 |
|
@@ -194,23 +194,10 @@ extension GroupViewController: NavigationBarInteractiveViewController {
|
||
| 194 | 194 |
fileprivate extension GroupViewController {
|
| 195 | 195 |
|
| 196 | 196 |
func activateConstraintsNavigation() {
|
| 197 |
- activateConstraintsNavigationBarView() |
|
| 198 | 197 |
activateConstraintsNavigationBarViewImage() |
| 199 | 198 |
activateConstraintsNavigationBarViewTitle() |
| 200 | 199 |
} |
| 201 | 200 |
|
| 202 |
- func activateConstraintsNavigationBarView() {
|
|
| 203 |
- guard let barContentView = navigationController?.navigationBar else { return }
|
|
| 204 |
- |
|
| 205 |
- navigationBarView.translatesAutoresizingMaskIntoConstraints = false |
|
| 206 |
- |
|
| 207 |
- NSLayoutConstraint.activate([ |
|
| 208 |
- navigationBarView.topAnchor.constraint(equalTo: barContentView.topAnchor), |
|
| 209 |
- navigationBarView.bottomAnchor.constraint(equalTo: barContentView.bottomAnchor), |
|
| 210 |
- navigationBarView.centerXAnchor.constraint(equalTo: barContentView.centerXAnchor) |
|
| 211 |
- ]) |
|
| 212 |
- } |
|
| 213 |
- |
|
| 214 | 201 |
func activateConstraintsNavigationBarViewTitle() {
|
| 215 | 202 |
navigationBarViewTitle.translatesAutoresizingMaskIntoConstraints = false |
| 216 | 203 |
NSLayoutConstraint.activate([ |
@@ -24,7 +24,8 @@ final class ScanQRViewController: UIViewController {
|
||
| 24 | 24 |
override func viewDidLoad() {
|
| 25 | 25 |
super.viewDidLoad() |
| 26 | 26 |
scanView.delegate = self |
| 27 |
- viewModel.join(code: "http://pai.ai/g/SpA5be3") |
|
| 27 |
+// viewModel.join(code: "http://pai.ai/g/SpA5be3") |
|
| 28 |
+ setNavigationBar() |
|
| 28 | 29 |
} |
| 29 | 30 |
|
| 30 | 31 |
func setNavigationBar() {
|
@@ -34,7 +35,7 @@ final class ScanQRViewController: UIViewController {
|
||
| 34 | 35 |
|
| 35 | 36 |
override func viewWillAppear(_ animated: Bool) {
|
| 36 | 37 |
super.viewWillAppear(animated) |
| 37 |
- setNavigationBar() |
|
| 38 |
+ |
|
| 38 | 39 |
} |
| 39 | 40 |
|
| 40 | 41 |
override func viewWillDisappear(_ animated: Bool) {
|
@@ -48,7 +48,7 @@ final class MessageListViewController: UIViewController {
|
||
| 48 | 48 |
setup() |
| 49 | 49 |
binding() |
| 50 | 50 |
setNavigationBar() |
| 51 |
- self.viewModel.reload() |
|
| 51 |
+ self.viewModel.reload() |
|
| 52 | 52 |
} |
| 53 | 53 |
|
| 54 | 54 |
private func setNavigationBar() {
|
@@ -174,19 +174,6 @@ fileprivate extension MessageListViewController {
|
||
| 174 | 174 |
self.tableView.endRefreshing(at: .bottom) |
| 175 | 175 |
} |
| 176 | 176 |
}).disposed(by: disposeBag) |
| 177 |
- |
|
| 178 |
- viewModel.hasMoreData |
|
| 179 |
- .asDriver(onErrorJustReturn: true) |
|
| 180 |
- .drive(onNext: {[weak self] flag in
|
|
| 181 |
- guard let `self` = self else { return }
|
|
| 182 |
- if flag {
|
|
| 183 |
- if self.tableView.bottomPullToRefresh == nil {
|
|
| 184 |
- self.setupLoadingControl() |
|
| 185 |
- } |
|
| 186 |
- } else {
|
|
| 187 |
-// self.tableViewt |
|
| 188 |
- } |
|
| 189 |
- }).disposed(by: disposeBag) |
|
| 190 | 177 |
} |
| 191 | 178 |
} |
| 192 | 179 |
|
@@ -128,19 +128,6 @@ fileprivate extension MineGroupViewController {
|
||
| 128 | 128 |
self.tableView.endRefreshing(at: .bottom) |
| 129 | 129 |
} |
| 130 | 130 |
}).disposed(by: disposeBag) |
| 131 |
- |
|
| 132 |
- viewModel.hasMoreData |
|
| 133 |
- .asDriver(onErrorJustReturn: true) |
|
| 134 |
- .drive(onNext: {[weak self] flag in
|
|
| 135 |
- guard let `self` = self else { return }
|
|
| 136 |
- if flag {
|
|
| 137 |
- if self.tableView.bottomPullToRefresh == nil {
|
|
| 138 |
- self.setupLoadingControl() |
|
| 139 |
- } |
|
| 140 |
- } else {
|
|
| 141 |
- // self.tableViewt |
|
| 142 |
- } |
|
| 143 |
- }).disposed(by: disposeBag) |
|
| 144 | 131 |
} |
| 145 | 132 |
} |
| 146 | 133 |
|
@@ -111,19 +111,6 @@ fileprivate extension MineOrderViewController {
|
||
| 111 | 111 |
self.tableView.endRefreshing(at: .bottom) |
| 112 | 112 |
} |
| 113 | 113 |
}).disposed(by: disposeBag) |
| 114 |
- |
|
| 115 |
- viewModel.hasMoreData |
|
| 116 |
- .asDriver(onErrorJustReturn: true) |
|
| 117 |
- .drive(onNext: {[weak self] flag in
|
|
| 118 |
- guard let `self` = self else { return }
|
|
| 119 |
- if flag {
|
|
| 120 |
- if self.tableView.bottomPullToRefresh == nil {
|
|
| 121 |
- self.setupLoadingControl() |
|
| 122 |
- } |
|
| 123 |
- } else {
|
|
| 124 |
- // self.tableViewt |
|
| 125 |
- } |
|
| 126 |
- }).disposed(by: disposeBag) |
|
| 127 | 114 |
} |
| 128 | 115 |
} |
| 129 | 116 |
|