|
49 | 49 | Any help would be greatly appreciated. |
50 | 50 | */ |
51 | 51 |
|
| 52 | +#if defined(LTH_APP_EXTENSIONS) |
| 53 | +#define LTHMainWindow [UIApplication sharedApplication].keyWindow |
| 54 | +#else |
52 | 55 | #define LTHMainWindow [UIApplication sharedApplication].windows[0] |
| 56 | +#endif |
53 | 57 |
|
54 | 58 | @interface LTHPasscodeViewController () <UITextFieldDelegate> |
55 | 59 | @property (nonatomic, strong) UIView *coverView; |
@@ -1005,7 +1009,6 @@ - (void)showLockscreenWithoutAnimation { |
1005 | 1009 | [self showLockScreenWithAnimation:NO withLogout:NO andLogoutTitle:nil]; |
1006 | 1010 | } |
1007 | 1011 |
|
1008 | | - |
1009 | 1012 | - (void)showLockScreenWithAnimation:(BOOL)animated withLogout:(BOOL)hasLogout andLogoutTitle:(NSString*)logoutTitle { |
1010 | 1013 | [self _prepareAsLockScreen]; |
1011 | 1014 |
|
@@ -1048,7 +1051,60 @@ - (void)showLockScreenWithAnimation:(BOOL)animated withLogout:(BOOL)hasLogout an |
1048 | 1051 | LTHMainWindow.center.y + self.navigationController.navigationBar.frame.size.height / 2); |
1049 | 1052 | } |
1050 | 1053 | } |
| 1054 | + [UIView animateWithDuration: animated ? _lockAnimationDuration : 0 animations: ^{ |
| 1055 | + self.view.center = newCenter; |
| 1056 | + }]; |
| 1057 | + |
| 1058 | + // Add nav bar & logout button if specified |
| 1059 | + if (hasLogout) { |
| 1060 | + _isUsingNavBar = hasLogout; |
| 1061 | + [self _setupNavBarWithLogoutTitle:logoutTitle]; |
| 1062 | + } |
| 1063 | +} |
| 1064 | + |
| 1065 | +- (void)showLockScreenIntoSuperview:(UIView *)superview WithAnimation:(BOOL)animated withLogout:(BOOL)hasLogout andLogoutTitle:(NSString*)logoutTitle { |
| 1066 | + [self _prepareAsLockScreen]; |
1051 | 1067 |
|
| 1068 | + // In case the user leaves the app while the lockscreen is already active. |
| 1069 | + if (_isCurrentlyOnScreen) { return; } |
| 1070 | + _isCurrentlyOnScreen = YES; |
| 1071 | + |
| 1072 | + [superview addSubview: self.view]; |
| 1073 | + |
| 1074 | + // All this hassle because a view added to UIWindow does not rotate automatically |
| 1075 | + // and if we would have added the view anywhere else, it wouldn't display properly |
| 1076 | + // (having a modal on screen when the user leaves the app, for example). |
| 1077 | + [self rotateAccordingToStatusBarOrientationAndSupportedOrientations]; |
| 1078 | + CGPoint superviewCenter = CGPointMake(superview.frame.size.width/2, superview.frame.size.height/2); |
| 1079 | + CGPoint newCenter; |
| 1080 | + [self statusBarFrameOrOrientationChanged:nil]; |
| 1081 | + if (LTHiOS8) { |
| 1082 | + self.view.center = CGPointMake(self.view.center.x, self.view.center.y * -1.f); |
| 1083 | + newCenter = CGPointMake(superviewCenter.x, |
| 1084 | + superviewCenter.y + self.navigationController.navigationBar.frame.size.height / 2); |
| 1085 | + } |
| 1086 | + else { |
| 1087 | + if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft) { |
| 1088 | + self.view.center = CGPointMake(self.view.center.x * -1.f, self.view.center.y); |
| 1089 | + newCenter = CGPointMake(superviewCenter.x - self.navigationController.navigationBar.frame.size.height / 2, |
| 1090 | + superviewCenter.y); |
| 1091 | + } |
| 1092 | + else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight) { |
| 1093 | + self.view.center = CGPointMake(self.view.center.x * 2.f, self.view.center.y); |
| 1094 | + newCenter = CGPointMake(superviewCenter.x + self.navigationController.navigationBar.frame.size.height / 2, |
| 1095 | + superviewCenter.y); |
| 1096 | + } |
| 1097 | + else if ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait) { |
| 1098 | + self.view.center = CGPointMake(self.view.center.x, self.view.center.y * -1.f); |
| 1099 | + newCenter = CGPointMake(superviewCenter.x, |
| 1100 | + superviewCenter.y - self.navigationController.navigationBar.frame.size.height / 2); |
| 1101 | + } |
| 1102 | + else { |
| 1103 | + self.view.center = CGPointMake(self.view.center.x, self.view.center.y * 2.f); |
| 1104 | + newCenter = CGPointMake(superviewCenter.x, |
| 1105 | + superviewCenter.y + self.navigationController.navigationBar.frame.size.height / 2); |
| 1106 | + } |
| 1107 | + } |
1052 | 1108 | [UIView animateWithDuration: animated ? _lockAnimationDuration : 0 animations: ^{ |
1053 | 1109 | self.view.center = newCenter; |
1054 | 1110 | }]; |
|
0 commit comments