num lines-num-new">
-        }, completion: { flag in
48
-//            if flag {
49
-                self.setNavigationBar()
50
-//            }
51
-            print("move in \(flag)")
52
-        })
53
-    }
54
-    
55
-    func navigationBarFadeAndMoveOut(percentage: CGFloat) {
56
-        print(self.navigationView.center)
57
-        UIView.animate(withDuration: TimeInterval(0.3 * percentage),
58
-                       animations: {
59
-            self.navigationView.alpha = 0
60
-            self.navigationView.center.x = UIScreen.main.bounds.width
61
-        }, completion: { flag in
62
-//            if flag {
63
-                self.navigationView.removeFromSuperview()
64
-//            }
65
-            print("move out \(flag)")
66
-        })
67
-    }
68
-    
69
-    func navigationBarFadeOutWithPercentage(_ percentage: CGFloat) {
70
-        navigationView.alpha = 1 * (1 - 1.1 * percentage)
71
-        navigationView.center.x = UIScreen.main.bounds.width / 2  * (1 + 1.1 * percentage)
72
-    }
73
-    
74
-    func navigationBarFadeInWithPercentage(_ percentage: CGFloat) {
75
-        navigationView.alpha = 1 * percentage
76
-    }
77
-}

+ 0 - 63
PaiAi/PaiaiUIKit/Reusable/UIKit/NavigationBar/NavigationBarInteractivePopDeletegate.swift

@@ -1,63 +0,0 @@
1
-//
2
-//  NavigationBarInteractivePopDeletegate.swift
3
-//  PaiaiUIKit
4
-//
5
-//  Created by ffib on 2019/1/15.
6
-//  Copyright © 2019 yb. All rights reserved.
7
-//
8
-
9
-import Foundation
10
-
11
-public protocol NavigationBarInteractivePopDeletegate: class {
12
-    func setupNavigationBarInteractivePopDelegate()
13
-}
14
-
15
-public extension NavigationBarInteractivePopDeletegate where Self: UIViewController & NavigationBarInOutAnimator {
16
-    func setupNavigationBarInteractivePopDelegate() {
17
-        guard let nav = navigationController else { return }
18
-        nav.interactivePopGestureRecognizer?.addTarget(self, action: #selector(interactivePopAnimation(gesture:)))
19
-    }
20
-}
21
-
22
-extension UIViewController {
23
-    @objc func interactivePopAnimation(gesture: UIPanGestureRecognizer) {
24
-        guard let `self` =  self as? (NavigationBarInOutAnimator & UIViewController) else { return }
25
-        let point = gesture.translation(in: view)
26
-        let percentage = calculatePercentageOfOffsets(point: point)
27
-        
28
-        /// naivgationController == nil  popped viewController
29
-        /// navigationController?.visibleViewController == self pop to viewController
30
-        
31
-        let percentageAnimation: ((CGFloat) -> Void)
32
-        let fadeInAnimation: ((CGFloat) -> Void)
33
-        let fadeOutAnimation: ((CGFloat) -> Void)
34
-
35
-        if navigationController == nil {
36
-            percentageAnimation = self.navigationBarFadeOutWithPercentage
37
-            fadeInAnimation = self.navigationBarFadeAndMoveIn
38
-            fadeOutAnimation = self.navigationBarFadeAndMoveOut
39
-        } else if navigationController?.visibleViewController == self {
40
-            percentageAnimation = self.navigationBarFadeInWithPercentage
41
-            fadeInAnimation = self.navigationBarFadeIn
42
-            fadeOutAnimation = self.navigationBarFadeOut
43
-        } else {
44
-            return
45
-        }
46
-        
47
-        percentageAnimation(percentage)
48
-        
49
-        guard gesture.state == .ended else { return }
50
-
51
-        if (percentage > 0.5 && navigationController == nil) ||
52
-            (percentage < 0.5 && navigationController?.visibleViewController == self) {
53
-            fadeOutAnimation(1 - percentage)
54
-        } else if (percentage < 0.5 && navigationController == nil) ||
55
-            (percentage > 0.5 && navigationController?.visibleViewController == self) {
56
-            fadeInAnimation(percentage)
57
-        }
58
-    }
59
-    
60
-    private func calculatePercentageOfOffsets(point: CGPoint) -> CGFloat {
61
-        return point.x / view.bounds.width
62
-    }
63
-}

+ 0 - 12
PaiAi/PaiaiUIKit/Reusable/UIKit/NavigationBar/NavigationBarInteractiveViewController.swift

@@ -1,12 +0,0 @@
1
-//
2
-//  NavigationBarInteractiveViewController.swift
3
-//  PaiaiUIKit
4
-//
5
-//  Created by ffib on 2019/1/16.
6
-//  Copyright © 2019 yb. All rights reserved.
7
-//
8
-
9
-import Foundation
10
-
11
-public typealias NavigationBarInteractiveViewController = NavigationBarInteractivePopDeletegate & NavigationBarPushAndPopDelegate & NavigationBarInOutAnimator & NavigationControllerDelegate
12
-

+ 0 - 49
PaiAi/PaiaiUIKit/Reusable/UIKit/NavigationBar/NavigationBarPushAndPopDelegate.swift

@@ -1,49 +0,0 @@
1
-//
2
-//  NavigationBarPushAndPopDelegate.swift
3
-//  PaiaiUIKit
4
-//
5
-//  Created by ffib on 2019/1/16.
6
-//  Copyright © 2019 yb. All rights reserved.
7
-//
8
-
9
-import Foundation
10
-
11
-public protocol NavigationBarPushAndPopDelegate: class {
12
-    func setupNavigationBarPushAndPopDelegate()
13
-    func setNavigationBar()
14
-}
15
-
16
-public extension NavigationBarPushAndPopDelegate where Self: UIViewController & NavigationControllerDelegate {
17
-    func setupNavigationBarPushAndPopDelegate() {
18
-        navigationController?.setDelegate(self)
19
-    }
20
-    
21
-    func setNavigationBar() {}
22
-}
23
-
24
-public extension NavigationControllerDelegate where Self: UIViewController {
25
-    
26
-    func navigationController(_ navigationController: UINavigationController,
27
-                              animationControllerFor operation: UINavigationController.Operation,
28
-                              from fromVC: UIViewController,
29
-                              to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
30
-        
31
-        if operation == .push {
32
-            (toVC as? NavigationBarInOutAnimator)?.navigationBarFadeAndMoveIn(percentage: 1)
33
-            (fromVC as? NavigationBarInOutAnimator)?.navigationBarFadeOut(percentage: 1)
34
-        } else {
35
-            (toVC as? NavigationBarInOutAnimator)?.navigationBarFadeIn(percentage: 1)
36
-            (fromVC as? NavigationBarInOutAnimator)?.navigationBarFadeAndMoveOut(percentage: 1)
37
-        }
38
-        
39
-        return nil
40
-    }
41
-    
42
-    func navigationController(_ navigationController: UINavigationController,
43
-                              didShow viewController: UIViewController, animated: Bool) {
44
-        guard let recognizer = navigationController.interactivePopGestureRecognizer else { return }
45
-        recognizer.isEnabled = true
46
-        guard let vc = viewController as? GestureRecognizerDelegate else { return }
47
-        recognizer.setDelegate(vc)
48
-    }
49
-}

+ 233 - 0
PaiAi/PaiaiUIKit/Reusable/UIKit/NavigationController/NavigationBar.swift

@@ -0,0 +1,233 @@
1
+//
2
+//  NavigationBar.swift
3
+//  PaiaiUIKit
4
+//
5
+//  Created by ffib on 2019/4/23.
6
+//  Copyright © 2019 FFIB. All rights reserved.
7
+//
8
+
9
+import UIKit
10
+
11
+class NavigationBar: UINavigationBar {
12
+    
13
+    private var currBgImage: UIImage?
14
+    private var targetBgImage: UIImage?
15
+    private var originShadowImage: UIImage?
16
+    
17
+    private var hasChangedBgImage: Bool = false
18
+    private var hasChangedShadow: Bool = false
19
+    private var titleView: UIView?
20
+    
21
+    var needsInteractive: Bool {
22
+        return hasChangedBgImage || hasChangedShadow
23
+    }
24
+    var bounce: Bounce = .none
25
+    var isPush: Bool = true
26
+    
27
+    override var shadowImage: UIImage? {
28
+        didSet {
29
+            originShadowImage = oldValue
30
+            hasChangedShadow = true
31
+        }
32
+    }
33
+    
34
+    lazy var fakeView: UIVisualEffectView = {
35
+        let v = UIVisualEffectView(effect: UIBlurEffect(style: .light))
36
+        v.frame = getNavigationBarBounds()
37
+        v.isUserInteractionEnabled = false
38
+        v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
39
+        
40
+        return v
41
+    }()
42
+    
43
+    lazy var backgroundImageView: UIImageView = {
44
+        let v = UIImageView()
45
+        v.isUserInteractionEnabled = false
46
+        v.frame = getNavigationBarBounds().offsetBy(dx: bounds.width, dy: 0)
47
+        
48
+        return v
49
+    }()
50
+    
51
+    lazy var shadowImageView: UIImageView = {
52
+        let v = UIImageView()
53
+        v.frame = CGRect(x: 0, y: bounds.height, width: bounds.width, height: 0.5)
54
+        
55
+        return v
56
+    }()
57
+    
58
+    override init(frame: CGRect) {
59
+        super.init(frame: frame)
60
+    }
61
+    
62
+    required init?(coder aDecoder: NSCoder) {
63
+        fatalError("init(coder:) has not been implemented")
64
+    }
65
+    override func setBackgroundImage(_ backgroundImage: UIImage?, for barMetrics: UIBarMetrics) {
66
+        currBgImage = self.backgroundImage(for: .default)
67
+        targetBgImage = backgroundImage
68
+        hasChangedBgImage = true
69
+    }
70
+    
71
+    override func setBackgroundImage(_ backgroundImage: UIImage?, for barPosition: UIBarPosition, barMetrics: UIBarMetrics) {
72
+        currBgImage = self.backgroundImage(for: .default)
73
+        targetBgImage = backgroundImage
74
+        hasChangedBgImage = true
75
+    }
76
+    
77
+    func setBackgroundImage() {
78
+        super.setBackgroundImage(targetBgImage, for: .any, barMetrics: .default)
79
+    }
80
+    
81
+    func getBarBackground() -> UIView? {
82
+       return value(forKeyPath: "_backgroundView") as? UIView
83
+    }
84
+    
85
+    func getContentView() -> UIView? {
86
+        for v in subviews {
87
+            if let ContentClass = NSClassFromString("_UINavigationBarContentView"), v.isKind(of: ContentClass) {
88
+                return v
89
+            }
90
+        }
91
+        return nil
92
+    }
93
+    
94
+    func getShadowView() -> UIView? {
95
+        guard let barBackground = getBarBackground() else { return nil }
96
+        for v in barBackground.subviews {
97
+            if (v.bounds.height == 0.5) {
98
+                return v
99
+            }
100
+        }
101
+        return nil
102
+    }
103
+    
104
+    func getNavigationBarBounds() -> CGRect {
105
+        let statusHeight = UIApplication.shared.statusBarFrame.height
106
+        return CGRect(x: 0, y: -statusHeight, width: bounds.width, height: bounds.height + statusHeight)
107
+    }
108
+    
109
+    override func value(forUndefinedKey key: String) -> Any? {
110
+        return nil
111
+    }
112
+}
113
+
114
+/// NavigationBar transition
115
+extension NavigationBar {
116
+    func constructViewHierarchy() {
117
+        setupShadowView()
118
+        setupBackgroundImageView()
119
+        
120
+        guard let barBackground = getBarBackground() else { return }
121
+        
122
+        insertSubview(shadowImageView, aboveSubview: barBackground)
123
+        insertSubview(backgroundImageView, aboveSubview: barBackground)
124
+        insertSubview(fakeView, belowSubview: backgroundImageView)
125
+        layoutIfNeeded()
126
+    }
127
+    
128
+    private func setupShadowView() {
129
+        if let image = originShadowImage, image.size == CGSize.zero {
130
+            shadowImageView.image = image
131
+        } else {
132
+            shadowImageView.backgroundColor = UIColor(red: 0, green: 0, blue: 0,
133
+                                                      alpha: 77.0 / 255)
134
+        }
135
+        
136
+        shadowImageView.alpha = originShadowImage == nil ? 1 : 0
137
+        getShadowView()?.isHidden = true
138
+    }
139
+    
140
+    private func setupBackgroundImageView() {
141
+        if isPush {
142
+            fakeView.alpha = 0
143
+            backgroundImageView.image = targetBgImage
144
+        } else {
145
+            setBackgroundImage()
146
+            fakeView.alpha = 1
147
+            backgroundImageView.image = currBgImage
148
+        }
149
+    }
150
+    
151
+    /// interactivePopGestureRecognizer
152
+    func transitionAnimationWithPercent(_ percent: CGFloat) {
153
+        switch bounce {
154
+        case .forward, .none:
155
+            transitionShadowAnimationWithPercent(percent)
156
+            transitionBackgroundAnimationWithPercent(percent)
157
+            break
158
+        case .backward:
159
+            transitionShadowAnimationWithPercent(1 - percent)
160
+            transitionBackgroundAnimationWithPercent(1 - percent)
161
+            break
162
+        }
163
+    }
164
+    
165
+    func transitionAnimation() {
166
+        transitionShadowAnimation()
167
+        transitionBackgroundAnimation()
168
+    }
169
+    
170
+    private func transitionShadowAnimation() {
171
+        guard hasChangedShadow else { return }
172
+        shadowImageView.alpha = originShadowImage == nil ? 0 : 1
173
+//        if originShadowImage == nil {
174
+//            shadowImageView.alpha = isInteractive ? (1 - percent) * 1 : 0
175
+//        } else {
176
+//            shadowImageView.alpha = isInteractive ? percent * 1 : 1
177
+//        }
178
+    }
179
+    
180
+    private func transitionBackgroundAnimation() {
181
+        guard hasChangedBgImage else { return }
182
+        if isPush {
183
+            fakeView.alpha = 1
184
+            backgroundImageView.frame.origin.x = 0
185
+        } else {
186
+            fakeView.alpha = 0
187
+            backgroundImageView.frame.origin.x = bounds.width
188
+        }
189
+    }
190
+    
191
+    private func transitionShadowAnimationWithPercent(_ percent: CGFloat) {
192
+        guard hasChangedShadow else { return }
193
+        shadowImageView.alpha = originShadowImage == nil ? (1 - percent) * 1 : percent * 1
194
+    }
195
+    
196
+    private func transitionBackgroundAnimationWithPercent(_ percent: CGFloat) {
197
+        guard hasChangedBgImage else { return }
198
+        fakeView.alpha = (1 - percent) * 1
199
+        backgroundImageView.frame.origin.x = percent * bounds.width
200
+    }
201
+    
202
+    func clear() {
203
+        
204
+        if isPush && hasChangedBgImage { setBackgroundImage() }
205
+        
206
+        if !isPush && bounce == .backward && hasChangedBgImage {
207
+            targetBgImage = currBgImage
208
+            setBackgroundImage()
209
+        }
210
+        
211
+        getShadowView()?.isHidden = false
212
+        
213
+        fakeView.removeFromSuperview()
214
+        shadowImageView.removeFromSuperview()
215
+        backgroundImageView.removeFromSuperview()
216
+        
217
+        currBgImage = nil
218
+        targetBgImage = nil
219
+        
220
+        hasChangedBgImage = false
221
+        hasChangedShadow = false
222
+        
223
+        bounce = .none
224
+    }
225
+}
226
+
227
+extension NavigationBar {
228
+    enum Bounce {
229
+        case none
230
+        case backward
231
+        case forward
232
+    }
233
+}

+ 100 - 18
PaiAi/PaiaiUIKit/Reusable/UIKit/NavigationController/NavigationController.swift

@@ -2,28 +2,110 @@
2 2
 //  NavigationController.swift
3 3
 //  PaiaiUIKit
4 4
 //
5
-//  Created by ffib on 2019/4/3.
6
-//  Copyright © 2019 yb. All rights reserved.
5
+//  Created by ffib on 2019/4/23.
6
+//  Copyright © 2019 FFIB. All rights reserved.
7 7
 //
8 8
 
9 9
 import UIKit
10 10
 
11
-class NavigationController: UINavigationController {
11
+public class NavigationController: UINavigationController {
12 12
     
13
+    override public init(rootViewController: UIViewController) {
14
+        super.init(navigationBarClass: NavigationBar.classForCoder(), toolbarClass: nil)
15
+//        super.init(rootViewController: rootViewController)
16
+//        navigationBar.delegate = self
17
+        self.viewControllers = [rootViewController]
18
+    }
19
+    
20
+    required init?(coder aDecoder: NSCoder) {
21
+        super.init(coder: aDecoder)
22
+    }
23
+    
24
+    override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
25
+        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
26
+    }
27
+    
28
+    override public func viewDidLoad() {
29
+        super.viewDidLoad()
30
+        delegate = self
31
+        interactivePopGestureRecognizer?.delegate = self
32
+        interactivePopGestureRecognizer?.isEnabled = true
33
+        
34
+        
35
+        interactivePopGestureRecognizer?.addTarget(self,
36
+                                                   action: #selector(handlePop(gestureRecognizer:)))
37
+    }
38
+    
39
+    @objc
40
+    private func handlePop(gestureRecognizer: UIPanGestureRecognizer) {
41
+        guard let navBar = navigationBar as? NavigationBar else { return }
42
+        if gestureRecognizer.state == .began { navBar.isPush = false }
43
+        
44
+        guard navBar.needsInteractive else { return }
45
+        
46
+        let percent = gestureRecognizer.translation(in: view).x / view.bounds.width
47
+        
48
+        if gestureRecognizer.state == .began || gestureRecognizer.state == .changed {
49
+            navBar.transitionAnimationWithPercent(percent)
50
+        }
51
+        
52
+        guard gestureRecognizer.state == .ended
53
+            || gestureRecognizer.state == .cancelled
54
+            || gestureRecognizer.state == .failed,
55
+            let coordinator = transitionCoordinator else { return }
56
+        
57
+        navBar.bounce = percent < 0.5 ? .backward : .forward
58
+        let durationPercent = Double(percent < 0.5 ? coordinator.percentComplete : (1 - coordinator.percentComplete))
59
+        UIView.animate(withDuration: coordinator.transitionDuration * durationPercent, delay: 0, usingSpringWithDamping: 1,
60
+                       initialSpringVelocity: coordinator.completionVelocity, options: [], animations: {
61
+            navBar.transitionAnimationWithPercent(1)
62
+        }) { _ in
63
+            navBar.clear()
64
+        }
65
+    }
13 66
 }
14 67
 
15
-//class NavigationController: UINavigationController {
16
-//
17
-//    override func viewDidLoad() {
18
-//        super.viewDidLoad()
19
-//
20
-//        // Do any additional setup after loading the view.
21
-//    }
22
-//    
23
-//    func set
24
-//}
25
-//
26
-//
27
-//extension UIViewController {
28
-//    n
29
-//}
68
+extension NavigationController: UINavigationControllerDelegate {
69
+    
70
+    public func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationController.Operation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
71
+        (navigationBar as? NavigationBar)?.isPush = operation == .push
72
+        return nil
73
+    }
74
+    
75
+    public func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
76
+        guard let navBar = navigationBar as? NavigationBar,
77
+            navBar.needsInteractive else { return }
78
+        
79
+        guard let coordinator = transitionCoordinator,
80
+            animated else {
81
+                navBar.setBackgroundImage()
82
+                navBar.clear()
83
+                return
84
+        }
85
+        
86
+        navBar.constructViewHierarchy()
87
+        
88
+        guard !coordinator.isInteractive else { return }
89
+        
90
+        coordinator.animate(alongsideTransition: { (transitionContext) in
91
+            DispatchQueue.main.async {
92
+                UIView.beginAnimations(nil, context: nil)
93
+                UIView.setAnimationCurve(transitionContext.completionCurve)
94
+                UIView.setAnimationDuration(transitionContext.transitionDuration)
95
+                navBar.transitionAnimation()
96
+                UIView.commitAnimations()
97
+            }
98
+        }, completion: { (transitionContext) in
99
+            navBar.clear()
100
+        })
101
+    }
102
+}
103
+
104
+extension NavigationController: UIGestureRecognizerDelegate {
105
+    public func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
106
+        if gestureRecognizer == interactivePopGestureRecognizer {
107
+            return viewControllers.count > 1
108
+        }
109
+        return true
110
+    }
111
+}

+ 8 - 30
PaiAi/PaiaiUIKit/Reusable/UIKit/PageViewController/PageViewController.swift

@@ -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
-}

+ 0 - 1
PaiAi/Paiai_iOS/App/Group/GroupDetail/GroupNameModificationViewController.swift

@@ -86,5 +86,4 @@ extension GroupNameModificationViewController {
86 86
     }
87 87
 }
88 88
 
89
-
90 89
 extension GroupNameModificationViewController: NavigationBackViewController {}

+ 6 - 19
PaiAi/Paiai_iOS/App/Group/GroupViewController.swift

@@ -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([

+ 3 - 2
PaiAi/Paiai_iOS/App/Home/ScanQRViewController.swift

@@ -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) {

+ 1 - 14
PaiAi/Paiai_iOS/App/Message/MessageListViewController.swift

@@ -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
 

+ 0 - 13
PaiAi/Paiai_iOS/App/Mine/MineGroupViewController.swift

@@ -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
 

+ 0 - 13
PaiAi/Paiai_iOS/App/Mine/MineOrderViewController.swift

@@ -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
 

kodo - Gogs: Go Git Service

No Description

admin.py 64B

    from django.contrib import admin # Register your models here.