|
|
@@ -2,13 +2,8 @@
|
|
2
|
2
|
#import "RNNNavigationButtons.h"
|
|
3
|
3
|
#import "RNNCustomTitleView.h"
|
|
4
|
4
|
|
|
5
|
|
-extern const NSInteger BLUR_TOPBAR_TAG;
|
|
6
|
|
-const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
|
|
7
|
|
-
|
|
8
|
|
-
|
|
9
|
5
|
@interface RNNTopBarOptions ()
|
|
10
|
6
|
|
|
11
|
|
-@property (nonatomic, strong) NSMutableDictionary* originalTopBarImages;
|
|
12
|
7
|
@property (nonatomic, strong) RNNNavigationButtons* navigationButtons;
|
|
13
|
8
|
|
|
14
|
9
|
@end
|
|
|
@@ -75,7 +70,6 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
|
|
75
|
70
|
}
|
|
76
|
71
|
|
|
77
|
72
|
- (void)applyOnNavigationController:(UINavigationController *)navigationController {
|
|
78
|
|
- [self.background applyOnNavigationController:navigationController];
|
|
79
|
73
|
if (self.testID) {
|
|
80
|
74
|
navigationController.navigationBar.accessibilityIdentifier = self.testID;
|
|
81
|
75
|
}
|
|
|
@@ -102,66 +96,13 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
|
|
102
|
96
|
}
|
|
103
|
97
|
}
|
|
104
|
98
|
|
|
105
|
|
- if ([self.blur boolValue]) {
|
|
106
|
|
- if (![navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG]) {
|
|
107
|
|
-
|
|
108
|
|
- [navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
|
109
|
|
- navigationController.navigationBar.shadowImage = [UIImage new];
|
|
110
|
|
- UIVisualEffectView *blur = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
|
|
111
|
|
- CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
|
|
112
|
|
- blur.frame = CGRectMake(0, -1 * statusBarFrame.size.height, navigationController.navigationBar.frame.size.width, navigationController.navigationBar.frame.size.height + statusBarFrame.size.height);
|
|
113
|
|
- blur.userInteractionEnabled = NO;
|
|
114
|
|
- blur.tag = BLUR_TOPBAR_TAG;
|
|
115
|
|
- [navigationController.navigationBar insertSubview:blur atIndex:0];
|
|
116
|
|
- [navigationController.navigationBar sendSubviewToBack:blur];
|
|
117
|
|
- }
|
|
118
|
|
- } else {
|
|
119
|
|
- UIView *blur = [navigationController.navigationBar viewWithTag:BLUR_TOPBAR_TAG];
|
|
120
|
|
- if (blur) {
|
|
121
|
|
- [navigationController.navigationBar setBackgroundImage: nil forBarMetrics:UIBarMetricsDefault];
|
|
122
|
|
- navigationController.navigationBar.shadowImage = nil;
|
|
123
|
|
- [blur removeFromSuperview];
|
|
124
|
|
- }
|
|
125
|
|
- }
|
|
126
|
|
-
|
|
127
|
|
- void (^disableTopBarTransparent)(void) = ^ {
|
|
128
|
|
- UIView *transparentView = [navigationController.navigationBar viewWithTag:TOP_BAR_TRANSPARENT_TAG];
|
|
129
|
|
- if (transparentView){
|
|
130
|
|
- [transparentView removeFromSuperview];
|
|
131
|
|
- [navigationController.navigationBar setBackgroundImage:self.originalTopBarImages[@"backgroundImage"] forBarMetrics:UIBarMetricsDefault];
|
|
132
|
|
- navigationController.navigationBar.shadowImage = self.originalTopBarImages[@"shadowImage"];
|
|
133
|
|
- self.originalTopBarImages = nil;
|
|
134
|
|
- }
|
|
135
|
|
- };
|
|
136
|
|
-
|
|
137
|
|
- if (self.transparent) {
|
|
138
|
|
- if ([self.transparent boolValue]) {
|
|
139
|
|
- if (![navigationController.navigationBar viewWithTag:TOP_BAR_TRANSPARENT_TAG]){
|
|
140
|
|
- [self storeOriginalTopBarImages:navigationController];
|
|
141
|
|
- [navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
|
|
142
|
|
- navigationController.navigationBar.shadowImage = [UIImage new];
|
|
143
|
|
- UIView *transparentView = [[UIView alloc] initWithFrame:CGRectZero];
|
|
144
|
|
- transparentView.tag = TOP_BAR_TRANSPARENT_TAG;
|
|
145
|
|
- [navigationController.navigationBar insertSubview:transparentView atIndex:0];
|
|
146
|
|
- }
|
|
147
|
|
- } else {
|
|
148
|
|
- disableTopBarTransparent();
|
|
149
|
|
- }
|
|
150
|
|
- } else {
|
|
151
|
|
- disableTopBarTransparent();
|
|
152
|
|
- }
|
|
153
|
|
-
|
|
154
|
99
|
if (self.barStyle) {
|
|
155
|
100
|
navigationController.navigationBar.barStyle = [RCTConvert UIBarStyle:self.barStyle];
|
|
156
|
101
|
} else {
|
|
157
|
102
|
navigationController.navigationBar.barStyle = UIBarStyleDefault;
|
|
158
|
103
|
}
|
|
159
|
104
|
|
|
160
|
|
- if (self.translucent) {
|
|
161
|
|
- navigationController.navigationBar.translucent = [self.translucent boolValue];
|
|
162
|
|
- } else {
|
|
163
|
|
- navigationController.navigationBar.translucent = NO;
|
|
164
|
|
- }
|
|
|
105
|
+ [self.background applyOnNavigationController:navigationController];
|
|
165
|
106
|
}
|
|
166
|
107
|
|
|
167
|
108
|
- (void)setRightButtonColor:(NSNumber *)rightButtonColor {
|
|
|
@@ -212,17 +153,4 @@ const NSInteger TOP_BAR_TRANSPARENT_TAG = 78264803;
|
|
212
|
153
|
}
|
|
213
|
154
|
}
|
|
214
|
155
|
|
|
215
|
|
--(void)storeOriginalTopBarImages:(UINavigationController *)navigationController {
|
|
216
|
|
- NSMutableDictionary *originalTopBarImages = [@{} mutableCopy];
|
|
217
|
|
- UIImage *bgImage = [navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault];
|
|
218
|
|
- if (bgImage != nil) {
|
|
219
|
|
- originalTopBarImages[@"backgroundImage"] = bgImage;
|
|
220
|
|
- }
|
|
221
|
|
- UIImage *shadowImage = navigationController.navigationBar.shadowImage;
|
|
222
|
|
- if (shadowImage != nil) {
|
|
223
|
|
- originalTopBarImages[@"shadowImage"] = shadowImage;
|
|
224
|
|
- }
|
|
225
|
|
- self.originalTopBarImages = originalTopBarImages;
|
|
226
|
|
-}
|
|
227
|
|
-
|
|
228
|
156
|
@end
|