@@ -328,11 +328,9 @@ @implementation HUDRootViewController {
328
328
NSLayoutConstraint *_centerXConstraint;
329
329
NSLayoutConstraint *_leadingConstraint;
330
330
NSLayoutConstraint *_trailingConstraint;
331
+ UIInterfaceOrientation _orientation;
331
332
#if !NO_TROLL
332
- FBSOrientationObserver *_remoteOrientationObserver;
333
- UIInterfaceOrientation _remoteOrientation;
334
- #else
335
- UIInterfaceOrientation _localOrientation;
333
+ FBSOrientationObserver *_orientationObserver;
336
334
#endif
337
335
}
338
336
@@ -441,17 +439,11 @@ + (BOOL)passthroughMode
441
439
442
440
- (BOOL )isLandscapeOrientation
443
441
{
444
- UIInterfaceOrientation orientation;
445
- #if !NO_TROLL
446
- orientation = _remoteOrientation;
447
- #else
448
- orientation = _localOrientation;
449
- #endif
450
442
BOOL isLandscape;
451
- if (orientation == UIInterfaceOrientationUnknown) {
443
+ if (_orientation == UIInterfaceOrientationUnknown) {
452
444
isLandscape = CGRectGetWidth (self.view .bounds ) > CGRectGetHeight (self.view .bounds );
453
445
} else {
454
- isLandscape = UIInterfaceOrientationIsLandscape (orientation );
446
+ isLandscape = UIInterfaceOrientationIsLandscape (_orientation );
455
447
}
456
448
return isLandscape;
457
449
}
@@ -559,9 +551,9 @@ - (instancetype)init
559
551
_constraints = [NSMutableArray array ];
560
552
[self registerNotifications ];
561
553
#if !NO_TROLL
562
- _remoteOrientationObserver = [[objc_getClass (" FBSOrientationObserver" ) alloc ] init ];
554
+ _orientationObserver = [[objc_getClass (" FBSOrientationObserver" ) alloc ] init ];
563
555
__weak HUDRootViewController *weakSelf = self;
564
- [_remoteOrientationObserver setHandler: ^(FBSOrientationUpdate *orientationUpdate) {
556
+ [_orientationObserver setHandler: ^(FBSOrientationUpdate *orientationUpdate) {
565
557
HUDRootViewController *strongSelf = weakSelf;
566
558
dispatch_async (dispatch_get_main_queue (), ^{
567
559
[strongSelf updateOrientation: (UIInterfaceOrientation)orientationUpdate.orientation animateWithDuration: orientationUpdate.duration];
@@ -575,16 +567,17 @@ - (instancetype)init
575
567
- (void )dealloc
576
568
{
577
569
#if !NO_TROLL
578
- [_remoteOrientationObserver invalidate ];
570
+ [_orientationObserver invalidate ];
579
571
#endif
580
572
}
581
573
582
574
- (void )updateSpeedLabel
583
575
{
584
576
log_debug (OS_LOG_DEFAULT, " updateSpeedLabel" );
585
577
NSAttributedString *attributedText = formattedAttributedString (_isFocused);
586
- if (attributedText)
578
+ if (attributedText) {
587
579
[_speedLabel setAttributedText: attributedText];
580
+ }
588
581
[_speedLabel sizeToFit ];
589
582
}
590
583
@@ -672,21 +665,14 @@ - (void)updateViewConstraints
672
665
[_constraints removeAllObjects ];
673
666
674
667
#if NO_TROLL
675
- _localOrientation = [self .view.window.windowScene interfaceOrientation ];
676
- #endif
677
-
678
- UIInterfaceOrientation orientation;
679
- #if !NO_TROLL
680
- orientation = _remoteOrientation;
681
- #else
682
- orientation = _localOrientation;
668
+ _orientation = [self .view.window.windowScene interfaceOrientation ];
683
669
#endif
684
670
685
671
BOOL isLandscape;
686
- if (orientation == UIInterfaceOrientationUnknown) {
672
+ if (_orientation == UIInterfaceOrientationUnknown) {
687
673
isLandscape = CGRectGetWidth (self.view .bounds ) > CGRectGetHeight (self.view .bounds );
688
674
} else {
689
- isLandscape = UIInterfaceOrientationIsLandscape (orientation );
675
+ isLandscape = UIInterfaceOrientationIsLandscape (_orientation );
690
676
}
691
677
692
678
HUDPresetPosition selectedMode = [self selectedModeForCurrentOrientation ];
@@ -718,8 +704,8 @@ - (void)updateViewConstraints
718
704
#endif
719
705
720
706
[_constraints addObjectsFromArray: @[
721
- [_contentView.leadingAnchor constraintEqualToAnchor: layoutGuide.leadingAnchor constant: (orientation == UIInterfaceOrientationLandscapeLeft ? -paddingFarFromNotch : paddingNearNotch)],
722
- [_contentView.trailingAnchor constraintEqualToAnchor: layoutGuide.trailingAnchor constant: (orientation == UIInterfaceOrientationLandscapeLeft ? -paddingNearNotch : paddingFarFromNotch)],
707
+ [_contentView.leadingAnchor constraintEqualToAnchor: layoutGuide.leadingAnchor constant: (_orientation == UIInterfaceOrientationLandscapeLeft ? -paddingFarFromNotch : paddingNearNotch)],
708
+ [_contentView.trailingAnchor constraintEqualToAnchor: layoutGuide.trailingAnchor constant: (_orientation == UIInterfaceOrientationLandscapeLeft ? -paddingNearNotch : paddingFarFromNotch)],
723
709
]];
724
710
725
711
CGFloat minimumLandscapeTopConstant = 0 ;
@@ -1000,13 +986,7 @@ - (void)panGestureRecognized:(UIPanGestureRecognizer *)sender
1000
986
1001
987
if (sender.state == UIGestureRecognizerStateEnded)
1002
988
{
1003
- UIInterfaceOrientation orientation;
1004
- #if !NO_TROLL
1005
- orientation = _remoteOrientation;
1006
- #else
1007
- orientation = _localOrientation;
1008
- #endif
1009
- if (UIInterfaceOrientationIsLandscape (orientation))
989
+ if (UIInterfaceOrientationIsLandscape (_orientation))
1010
990
[self setCurrentLandscapePositionY: _topConstraint.constant];
1011
991
else
1012
992
[self setCurrentPositionY: _topConstraint.constant];
@@ -1089,11 +1069,11 @@ - (void)updateOrientation:(UIInterfaceOrientation)orientation animateWithDuratio
1089
1069
return ;
1090
1070
}
1091
1071
1092
- if (orientation == _remoteOrientation ) {
1072
+ if (orientation == _orientation ) {
1093
1073
return ;
1094
1074
}
1095
1075
1096
- _remoteOrientation = orientation;
1076
+ _orientation = orientation;
1097
1077
[self cancelPreviousPerformRequestsWithTarget: _contentView];
1098
1078
1099
1079
CGRect bounds = orientationBounds (orientation, [UIScreen mainScreen ].bounds );
0 commit comments