|
15 | 15 | #import "LNPopupImageView+Private.h"
|
16 | 16 | #import "UIView+LNPopupSupportPrivate.h"
|
17 | 17 |
|
| 18 | +const CGFloat LNPopupBarHeightCompact = 40.0; |
| 19 | +const CGFloat LNPopupBarHeightProminent = 64.0; |
| 20 | +const CGFloat LNPopupBarHeightFloating = 64.0; |
| 21 | +const CGFloat LNPopupBarProminentImageWidth = 48.0; |
| 22 | +const CGFloat LNPopupBarFloatingImageWidth = 40.0; |
| 23 | +const CGFloat LNPopupBarFloatingPadImageWidth = 44.0; |
| 24 | +const CGFloat LNPopupBarFloatingPadWidthLimit = 954.0; |
| 25 | + |
18 | 26 | #ifdef DEBUG
|
19 | 27 | #import "LNPopupDebug.h"
|
20 | 28 |
|
@@ -65,214 +73,6 @@ CGFloat _LNPopupBarHeightForPopupBar(LNPopupBar* popupBar)
|
65 | 73 | }
|
66 | 74 | }
|
67 | 75 |
|
68 |
| -#ifndef LNPopupControllerEnforceStrictClean |
69 |
| -static SEL _effectWithStyle_tintColor_invertAutomaticStyle_SEL; |
70 |
| -static id(*_effectWithStyle_tintColor_invertAutomaticStyle)(id, SEL, NSUInteger, UIColor*, BOOL); |
71 |
| - |
72 |
| -__attribute__((constructor)) |
73 |
| -static void __setupFunction(void) |
74 |
| -{ |
75 |
| - _effectWithStyle_tintColor_invertAutomaticStyle_SEL = NSSelectorFromString(LNPopupHiddenString("_effectWithStyle:tintColor:invertAutomaticStyle:")); |
76 |
| - Method m = class_getClassMethod(UIBlurEffect.class, _effectWithStyle_tintColor_invertAutomaticStyle_SEL); |
77 |
| - _effectWithStyle_tintColor_invertAutomaticStyle = reinterpret_cast<decltype(_effectWithStyle_tintColor_invertAutomaticStyle)>(method_getImplementation(m)); |
78 |
| -} |
79 |
| -#endif |
80 |
| - |
81 |
| -@interface _LNPopupBarContentView : _LNPopupBarBackgroundView @end |
82 |
| -@implementation _LNPopupBarContentView @end |
83 |
| - |
84 |
| -@interface _LNPopupBarTitlesView : UIStackView @end |
85 |
| -@implementation _LNPopupBarTitlesView @end |
86 |
| - |
87 |
| -@interface _LNPopupTitleLabelWrapper: UIView |
88 |
| - |
89 |
| -@property (nonatomic, strong) UILabel* wrapped; |
90 |
| -@property (nonatomic, strong) NSLayoutConstraint* wrappedWidthConstraint; |
91 |
| - |
92 |
| -@end |
93 |
| - |
94 |
| -@implementation _LNPopupTitleLabelWrapper |
95 |
| - |
96 |
| -+ (instancetype)wrapperForLabel:(UILabel*)wrapped |
97 |
| -{ |
98 |
| - _LNPopupTitleLabelWrapper* rv = [[_LNPopupTitleLabelWrapper alloc] initWithFrame:wrapped.frame]; |
99 |
| - rv.wrapped = wrapped; |
100 |
| - |
101 |
| - rv.translatesAutoresizingMaskIntoConstraints = wrapped.translatesAutoresizingMaskIntoConstraints; |
102 |
| - [rv addSubview:wrapped]; |
103 |
| - |
104 |
| - rv.wrappedWidthConstraint = [wrapped.widthAnchor constraintEqualToConstant:rv.bounds.size.width]; |
105 |
| - |
106 |
| - [NSLayoutConstraint activateConstraints:@[ |
107 |
| - [rv.leadingAnchor constraintEqualToAnchor:wrapped.leadingAnchor], |
108 |
| - [rv.heightAnchor constraintEqualToAnchor:wrapped.heightAnchor], |
109 |
| - rv->_wrappedWidthConstraint |
110 |
| - ]]; |
111 |
| - |
112 |
| - return rv; |
113 |
| -} |
114 |
| - |
115 |
| -- (void)setBounds:(CGRect)bounds |
116 |
| -{ |
117 |
| - [super setBounds:bounds]; |
118 |
| - |
119 |
| - if(_wrappedWidthConstraint.constant == bounds.size.width) |
120 |
| - { |
121 |
| - return; |
122 |
| - } |
123 |
| - |
124 |
| - if(UIView.inheritedAnimationDuration == 0.0) |
125 |
| - { |
126 |
| - _wrappedWidthConstraint.constant = bounds.size.width; |
127 |
| - [_wrapped layoutSubviews]; |
128 |
| - } |
129 |
| - else |
130 |
| - { |
131 |
| - [UIView transitionWithView:_wrapped |
132 |
| - duration:UIView.inheritedAnimationDuration / 2.0 |
133 |
| - options:UIViewAnimationOptionTransitionCrossDissolve | UIViewAnimationOptionCurveEaseOut |
134 |
| - animations:^{ |
135 |
| - _wrappedWidthConstraint.constant = bounds.size.width; |
136 |
| - [_wrapped layoutSubviews]; |
137 |
| - } completion:nil]; |
138 |
| - } |
139 |
| -} |
140 |
| - |
141 |
| -@end |
142 |
| - |
143 |
| -@interface _LNPopupBarShadowView : UIImageView @end |
144 |
| -@implementation _LNPopupBarShadowView |
145 |
| - |
146 |
| -#if DEBUG |
147 |
| - |
148 |
| -- (void)setAlpha:(CGFloat)alpha |
149 |
| -{ |
150 |
| - [super setAlpha:alpha]; |
151 |
| -} |
152 |
| - |
153 |
| -- (void)setHidden:(BOOL)hidden |
154 |
| -{ |
155 |
| - [super setHidden:hidden]; |
156 |
| -} |
157 |
| - |
158 |
| -#endif |
159 |
| - |
160 |
| -@end |
161 |
| - |
162 |
| -@protocol _LNPopupToolbarLayoutDelegate <NSObject> |
163 |
| - |
164 |
| -- (void)_toolbarDidLayoutSubviews; |
165 |
| - |
166 |
| -@end |
167 |
| - |
168 |
| -@interface _LNPopupToolbar : UIToolbar |
169 |
| - |
170 |
| -@property (nonatomic, weak) id<_LNPopupToolbarLayoutDelegate> _layoutDelegate; |
171 |
| - |
172 |
| -@end |
173 |
| -@implementation _LNPopupToolbar |
174 |
| - |
175 |
| -- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event |
176 |
| -{ |
177 |
| - UIView* rv = [super hitTest:point withEvent:event]; |
178 |
| - |
179 |
| - if(rv != nil && [rv isKindOfClass:UIControl.class] == NO && [NSStringFromClass(rv.class) containsString:@"BarItemView"] == NO) |
180 |
| - { |
181 |
| - rv = nil; |
182 |
| - } |
183 |
| - |
184 |
| - return rv; |
185 |
| -} |
186 |
| - |
187 |
| -- (void)layoutSubviews |
188 |
| -{ |
189 |
| - [super layoutSubviews]; |
190 |
| - |
191 |
| - //On iOS 11 and above reset the semantic content attribute to make sure it propagades to all subviews. |
192 |
| - [self setSemanticContentAttribute:self.semanticContentAttribute]; |
193 |
| - |
194 |
| - [self._layoutDelegate _toolbarDidLayoutSubviews]; |
195 |
| -} |
196 |
| - |
197 |
| -- (void)_deepSetSemanticContentAttribute:(UISemanticContentAttribute)semanticContentAttribute toView:(UIView*)view startingFromView:(UIView*)staringView; |
198 |
| -{ |
199 |
| - if(view == staringView) |
200 |
| - { |
201 |
| - [super setSemanticContentAttribute:semanticContentAttribute]; |
202 |
| - } |
203 |
| - else |
204 |
| - { |
205 |
| - [view setSemanticContentAttribute:semanticContentAttribute]; |
206 |
| - } |
207 |
| - |
208 |
| - [view.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { |
209 |
| - [self _deepSetSemanticContentAttribute:semanticContentAttribute toView:obj startingFromView:staringView]; |
210 |
| - }]; |
211 |
| -} |
212 |
| - |
213 |
| -- (void)setSemanticContentAttribute:(UISemanticContentAttribute)semanticContentAttribute |
214 |
| -{ |
215 |
| - //On iOS 11, due to a bug in UIKit, the semantic content attribute must be propagaded recursively to all subviews, so that the system behaves correctly. |
216 |
| - [self _deepSetSemanticContentAttribute:semanticContentAttribute toView:self startingFromView:self]; |
217 |
| -} |
218 |
| - |
219 |
| -@end |
220 |
| - |
221 |
| -@protocol LNMarqueeLabel <NSObject> |
222 |
| - |
223 |
| -- (void)resetLabel; |
224 |
| -- (void)unpauseLabel; |
225 |
| -- (void)pauseLabel; |
226 |
| -- (void)restartLabel; |
227 |
| -- (BOOL)isPaused; |
228 |
| -- (void)shutdownLabel; |
229 |
| - |
230 |
| -@property (nonatomic, assign) CGFloat rate; |
231 |
| -@property (nonatomic, assign) CGFloat animationDelay; |
232 |
| -@property (nonatomic, weak) MarqueeLabel* synchronizedLabel; |
233 |
| -@property (nonatomic, readonly) NSTimeInterval animationDuration; |
234 |
| -@property (nonatomic, assign) BOOL holdScrolling; |
235 |
| - |
236 |
| -@end |
237 |
| - |
238 |
| -@interface LNNonMarqueeLabel : UILabel <LNMarqueeLabel> @end |
239 |
| -@implementation LNNonMarqueeLabel |
240 |
| - |
241 |
| -- (void)resetLabel {} |
242 |
| -- (void)unpauseLabel {} |
243 |
| -- (void)pauseLabel {} |
244 |
| -- (void)restartLabel {} |
245 |
| -- (void)shutdownLabel {} |
246 |
| -- (BOOL)isPaused { return YES; } |
247 |
| -- (NSTimeInterval)animationDuration { return 0.0; } |
248 |
| - |
249 |
| -@synthesize rate=_rate, animationDelay=_animationDelay, synchronizedLabel=_synchronizedLabel, holdScrolling=_holdScrolling; |
250 |
| - |
251 |
| -@end |
252 |
| - |
253 |
| -@interface MarqueeLabel () <LNMarqueeLabel> @end |
254 |
| - |
255 |
| -const CGFloat LNPopupBarHeightCompact = 40.0; |
256 |
| -const CGFloat LNPopupBarHeightProminent = 64.0; |
257 |
| -const CGFloat LNPopupBarHeightFloating = 64.0; |
258 |
| -const CGFloat LNPopupBarProminentImageWidth = 48.0; |
259 |
| -const CGFloat LNPopupBarFloatingImageWidth = 40.0; |
260 |
| -const CGFloat LNPopupBarFloatingPadImageWidth = 44.0; |
261 |
| -const CGFloat LNPopupBarFloatingPadWidthLimit = 954.0; |
262 |
| - |
263 |
| -static BOOL __animatesItemSetter = NO; |
264 |
| - |
265 |
| -@interface LNPopupBar () <_LNPopupToolbarLayoutDelegate> |
266 |
| - |
267 |
| -- (void)_windowWillRotate:(NSNotification*)note; |
268 |
| -- (void)_windowDidRotate:(NSNotification*)note; |
269 |
| -- (UIFont*)_titleFont; |
270 |
| -- (UIColor*)_titleColor; |
271 |
| -- (UIFont*)_subtitleFont; |
272 |
| -- (UIColor*)_subtitleColor; |
273 |
| - |
274 |
| -@end |
275 |
| - |
276 | 76 | __attribute__((objc_direct_members))
|
277 | 77 | @implementation LNPopupBar
|
278 | 78 | {
|
@@ -300,6 +100,7 @@ @implementation LNPopupBar
|
300 | 100 | UIWindow* _swiftHacksWindow2;
|
301 | 101 | }
|
302 | 102 |
|
| 103 | +static BOOL __animatesItemSetter = NO; |
303 | 104 | + (void)setAnimatesItemSetter:(BOOL)animate
|
304 | 105 | {
|
305 | 106 | __animatesItemSetter = animate;
|
@@ -538,6 +339,15 @@ - (nonnull instancetype)initWithFrame:(CGRect)frame
|
538 | 339 | return self;
|
539 | 340 | }
|
540 | 341 |
|
| 342 | +#if DEBUG |
| 343 | + |
| 344 | +- (void)setFrame:(CGRect)frame |
| 345 | +{ |
| 346 | + [super setFrame:frame]; |
| 347 | +} |
| 348 | + |
| 349 | +#endif |
| 350 | + |
541 | 351 | - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
|
542 | 352 | {
|
543 | 353 | [super traitCollectionDidChange:previousTraitCollection];
|
|
0 commit comments