@@ -10,46 +10,59 @@ import UIKit |
||
10 | 10 |
|
11 | 11 |
public protocol NavigationBarInOutAnimator: class { |
12 | 12 |
var navigationView: UIView { get } |
13 |
- func navigationBarFadeIn() |
|
14 |
- func navigationBarFadeOut() |
|
15 |
- func navigationBarFadeAndMoveIn() |
|
16 |
- func navigationBarFadeAndMoveOut() |
|
13 |
+ func navigationBarFadeIn(percentage: CGFloat) |
|
14 |
+ func navigationBarFadeOut(percentage: CGFloat) |
|
15 |
+ func navigationBarFadeAndMoveIn(percentage: CGFloat) |
|
16 |
+ func navigationBarFadeAndMoveOut(percentage: CGFloat) |
|
17 | 17 |
func navigationBarFadeOutWithPercentage(_ percentage: CGFloat) |
18 | 18 |
func navigationBarFadeInWithPercentage(_ percentage: CGFloat) |
19 | 19 |
} |
20 | 20 |
|
21 | 21 |
public extension NavigationBarInOutAnimator where Self: UIViewController & NavigationBarPushAndPopDelegate { |
22 |
- func navigationBarFadeIn() { |
|
23 |
- UIView.animate(withDuration: 0.3, animations: { |
|
22 |
+ func navigationBarFadeIn(percentage: CGFloat) { |
|
23 |
+ UIView.animate(withDuration: TimeInterval(0.3 * percentage), |
|
24 |
+ animations: { |
|
24 | 25 |
self.navigationView.alpha = 1 |
25 | 26 |
}, completion: nil) |
26 | 27 |
} |
27 | 28 |
|
28 |
- func navigationBarFadeOut() { |
|
29 |
- UIView.animate(withDuration: 0.3, animations: { |
|
29 |
+ func navigationBarFadeOut(percentage: CGFloat) { |
|
30 |
+ UIView.animate(withDuration: TimeInterval(0.3 * percentage), |
|
31 |
+ animations: { |
|
30 | 32 |
self.navigationView.alpha = 0 |
31 | 33 |
}, completion: nil) |
32 | 34 |
} |
33 | 35 |
|
34 |
- func navigationBarFadeAndMoveIn() { |
|
35 |
- setNavigationBar() |
|
36 |
- navigationController?.navigationBar.layoutIfNeeded() |
|
36 |
+ func navigationBarFadeAndMoveIn(percentage: CGFloat) { |
|
37 |
+// setNavigationBar() |
|
38 |
+// navigationController?.navigationBar.layoutIfNeeded() |
|
37 | 39 |
|
38 |
- let originX = navigationView.center.x |
|
39 |
- navigationView.center.x = UIScreen.main.bounds.width |
|
40 |
+// let originX = navigationView.center.x |
|
41 |
+// navigationView.center.x = UIScreen.main.bounds.width |
|
40 | 42 |
|
41 |
- UIView.animate(withDuration: 0.3, animations: { |
|
43 |
+ UIView.animate(withDuration: TimeInterval(0.3 * percentage), |
|
44 |
+ animations: { |
|
42 | 45 |
self.navigationView.alpha = 1 |
43 |
- self.navigationView.center.x = originX |
|
44 |
- }, completion: nil) |
|
46 |
+ self.navigationView.center.x = UIScreen.main.bounds.width / 2 |
|
47 |
+ }, completion: { flag in |
|
48 |
+// if flag { |
|
49 |
+ self.setNavigationBar() |
|
50 |
+// } |
|
51 |
+ print("move in \(flag)") |
|
52 |
+ }) |
|
45 | 53 |
} |
46 | 54 |
|
47 |
- func navigationBarFadeAndMoveOut() { |
|
48 |
- UIView.animate(withDuration: 0.3, animations: { |
|
55 |
+ func navigationBarFadeAndMoveOut(percentage: CGFloat) { |
|
56 |
+ print(self.navigationView.center) |
|
57 |
+ UIView.animate(withDuration: TimeInterval(0.3 * percentage), |
|
58 |
+ animations: { |
|
49 | 59 |
self.navigationView.alpha = 0 |
50 | 60 |
self.navigationView.center.x = UIScreen.main.bounds.width |
51 |
- }, completion: { _ in |
|
52 |
- self.navigationView.removeFromSuperview() |
|
61 |
+ }, completion: { flag in |
|
62 |
+// if flag { |
|
63 |
+ self.navigationView.removeFromSuperview() |
|
64 |
+// } |
|
65 |
+ print("move out \(flag)") |
|
53 | 66 |
}) |
54 | 67 |
} |
55 | 68 |
|
@@ -29,8 +29,9 @@ extension UIViewController { |
||
29 | 29 |
/// navigationController?.visibleViewController == self pop to viewController |
30 | 30 |
|
31 | 31 |
let percentageAnimation: ((CGFloat) -> Void) |
32 |
- let fadeInAnimation: (() -> Void) |
|
33 |
- let fadeOutAnimation: (() -> Void) |
|
32 |
+ let fadeInAnimation: ((CGFloat) -> Void) |
|
33 |
+ let fadeOutAnimation: ((CGFloat) -> Void) |
|
34 |
+ |
|
34 | 35 |
if navigationController == nil { |
35 | 36 |
percentageAnimation = self.navigationBarFadeOutWithPercentage |
36 | 37 |
fadeInAnimation = self.navigationBarFadeAndMoveIn |
@@ -49,10 +50,10 @@ extension UIViewController { |
||
49 | 50 |
|
50 | 51 |
if (percentage > 0.5 && navigationController == nil) || |
51 | 52 |
(percentage < 0.5 && navigationController?.visibleViewController == self) { |
52 |
- fadeOutAnimation() |
|
53 |
+ fadeOutAnimation(1 - percentage) |
|
53 | 54 |
} else if (percentage < 0.5 && navigationController == nil) || |
54 | 55 |
(percentage > 0.5 && navigationController?.visibleViewController == self) { |
55 |
- fadeInAnimation() |
|
56 |
+ fadeInAnimation(percentage) |
|
56 | 57 |
} |
57 | 58 |
} |
58 | 59 |
|
@@ -29,11 +29,11 @@ public extension NavigationControllerDelegate where Self: UIViewController { |
||
29 | 29 |
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? { |
30 | 30 |
|
31 | 31 |
if operation == .push { |
32 |
- (toVC as? NavigationBarInOutAnimator)?.navigationBarFadeAndMoveIn() |
|
33 |
- (fromVC as? NavigationBarInOutAnimator)?.navigationBarFadeOut() |
|
32 |
+ (toVC as? NavigationBarInOutAnimator)?.navigationBarFadeAndMoveIn(percentage: 1) |
|
33 |
+ (fromVC as? NavigationBarInOutAnimator)?.navigationBarFadeOut(percentage: 1) |
|
34 | 34 |
} else { |
35 |
- (toVC as? NavigationBarInOutAnimator)?.navigationBarFadeIn() |
|
36 |
- (fromVC as? NavigationBarInOutAnimator)?.navigationBarFadeAndMoveOut() |
|
35 |
+ (toVC as? NavigationBarInOutAnimator)?.navigationBarFadeIn(percentage: 1) |
|
36 |
+ (fromVC as? NavigationBarInOutAnimator)?.navigationBarFadeAndMoveOut(percentage: 1) |
|
37 | 37 |
} |
38 | 38 |
|
39 | 39 |
return nil |
@@ -0,0 +1,29 @@ |
||
1 |
+// |
|
2 |
+// NavigationController.swift |
|
3 |
+// PaiaiUIKit |
|
4 |
+// |
|
5 |
+// Created by ffib on 2019/4/3. |
|
6 |
+// Copyright © 2019 yb. All rights reserved. |
|
7 |
+// |
|
8 |
+ |
|
9 |
+import UIKit |
|
10 |
+ |
|
11 |
+class NavigationController: UINavigationController { |
|
12 |
+ |
|
13 |
+} |
|
14 |
+ |
|
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 |
+//} |
@@ -72,7 +72,6 @@ open class PageViewController: UIViewController { |
||
72 | 72 |
constructViewHierarchy() |
73 | 73 |
activateConstraints() |
74 | 74 |
setMenuGestureRecognizer() |
75 |
- setupNavigationBarPushAndPopDelegate() |
|
76 | 75 |
setupNavigationBarInteractivePopDelegate() |
77 | 76 |
} |
78 | 77 |
|
@@ -74,6 +74,10 @@ final class GroupViewController: UIViewController { |
||
74 | 74 |
} |
75 | 75 |
collectionView.startRefreshing(at: .top) |
76 | 76 |
} |
77 |
+ |
|
78 |
+ deinit { |
|
79 |
+ collectionView.endAllRefreshing() |
|
80 |
+ } |
|
77 | 81 |
} |
78 | 82 |
|
79 | 83 |
/// UI bindings |
@@ -60,6 +60,10 @@ final class HomeViewController: UIViewController { |
||
60 | 60 |
self.viewModel.preload() |
61 | 61 |
} |
62 | 62 |
} |
63 |
+ |
|
64 |
+ deinit { |
|
65 |
+ collectionView.endAllRefreshing() |
|
66 |
+ } |
|
63 | 67 |
} |
64 | 68 |
|
65 | 69 |
/// UI bindings |
@@ -88,6 +88,10 @@ final class MessageListViewController: UIViewController { |
||
88 | 88 |
})) |
89 | 89 |
presentController(alert) |
90 | 90 |
} |
91 |
+ |
|
92 |
+ deinit { |
|
93 |
+ tableView.endAllRefreshing() |
|
94 |
+ } |
|
91 | 95 |
} |
92 | 96 |
|
93 | 97 |
fileprivate extension MessageListViewController { |
@@ -56,6 +56,10 @@ final class MineGroupViewController: UIViewController { |
||
56 | 56 |
self.viewModel.preload() |
57 | 57 |
} |
58 | 58 |
} |
59 |
+ |
|
60 |
+ deinit { |
|
61 |
+ tableView.endAllRefreshing() |
|
62 |
+ } |
|
59 | 63 |
} |
60 | 64 |
|
61 | 65 |
fileprivate extension MineGroupViewController { |
@@ -53,6 +53,10 @@ final class MineOrderViewController: UIViewController { |
||
53 | 53 |
self.viewModel.preload() |
54 | 54 |
} |
55 | 55 |
} |
56 |
+ |
|
57 |
+ deinit { |
|
58 |
+ tableView.endAllRefreshing() |
|
59 |
+ } |
|
56 | 60 |
} |
57 | 61 |
|
58 | 62 |
/// binding UI |