mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Fix legacy UI insets
This commit is contained in:
parent
8657ea4cb3
commit
51c8ed0810
@ -408,7 +408,7 @@ final class NavigationModalContainer: ASDisplayNode, UIScrollViewDelegate, UIGes
|
||||
enableScrolling = false
|
||||
break
|
||||
} else {
|
||||
if scrollView.isDecelerating && scrollView.contentOffset.y < scrollView.contentInset.top {
|
||||
if scrollView.isDecelerating && scrollView.contentOffset.y < -scrollView.contentInset.top {
|
||||
return self.scrollNode.view
|
||||
}
|
||||
}
|
||||
|
@ -171,14 +171,14 @@ const CGPoint TGLocationPickerPinOffset = { 0.0f, 33.0f };
|
||||
[strongSelf switchToFullscreen];
|
||||
};
|
||||
|
||||
_searchBarOverlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.navigationController.view.frame.size.width, 64)];
|
||||
_searchBarOverlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.navigationController.view.frame.size.width, 44.0f)];
|
||||
_searchBarOverlay.alpha = 0.0f;
|
||||
_searchBarOverlay.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
_searchBarOverlay.backgroundColor = self.pallete != nil ? self.pallete.sectionHeaderBackgroundColor : UIColorRGB(0xf7f7f7);
|
||||
_searchBarOverlay.userInteractionEnabled = false;
|
||||
[self.navigationController.view addSubview:_searchBarOverlay];
|
||||
|
||||
CGFloat safeAreaInset = self.controllerSafeAreaInset.top > FLT_EPSILON ? self.controllerSafeAreaInset.top : 20;
|
||||
CGFloat safeAreaInset = self.controllerSafeAreaInset.top > FLT_EPSILON ? self.controllerSafeAreaInset.top : 0.0f;
|
||||
_searchBarWrapper = [[UIView alloc] initWithFrame:CGRectMake(0, -44 - safeAreaInset, self.navigationController.view.frame.size.width, 44 + safeAreaInset)];
|
||||
_searchBarWrapper.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
_searchBarWrapper.backgroundColor = self.pallete != nil ? self.pallete.backgroundColor : [UIColor whiteColor];
|
||||
|
@ -51,6 +51,10 @@
|
||||
{
|
||||
[super loadView];
|
||||
|
||||
if (self.intrinsicSize.width > FLT_EPSILON) {
|
||||
self.view.frame = CGRectMake(0.0f, 0.0f, self.intrinsicSize.width, self.intrinsicSize.height);
|
||||
}
|
||||
|
||||
self.view.backgroundColor = self.pallete != nil ? self.pallete.backgroundColor : [UIColor whiteColor];
|
||||
|
||||
_wrapperView = [[UIView alloc] initWithFrame:self.view.bounds];
|
||||
@ -262,6 +266,10 @@
|
||||
{
|
||||
UIEdgeInsets contentInset = [self controllerInsetForInterfaceOrientation:self.interfaceOrientation];
|
||||
|
||||
bool hasOnScreenNavigation = false;
|
||||
if (iosMajorVersion() >= 11)
|
||||
hasOnScreenNavigation = (self.viewLoaded && self.view.safeAreaInsets.bottom > FLT_EPSILON) || self.context.safeAreaInset.bottom > FLT_EPSILON;
|
||||
|
||||
CGPoint contentOffset = CGPointMake(0, _collectionView.contentSize.height - _collectionView.frame.size.height + contentInset.bottom);
|
||||
if (contentOffset.y < -contentInset.top)
|
||||
contentOffset.y = -contentInset.top;
|
||||
@ -300,7 +308,7 @@
|
||||
_collectionViewWidth = frame.size.width;
|
||||
_collectionView.frame = frame;
|
||||
|
||||
if (lastInverseOffset < 2)
|
||||
if (lastInverseOffset < 45)
|
||||
{
|
||||
[self _adjustContentOffsetToBottom];
|
||||
}
|
||||
|
@ -108,6 +108,8 @@ typedef enum {
|
||||
|
||||
@property (nonatomic, readonly) UIUserInterfaceSizeClass currentSizeClass;
|
||||
|
||||
@property (nonatomic) CGSize intrinsicSize;
|
||||
|
||||
@property (nonatomic, copy) NSArray<id<UIPreviewActionItem>> *(^externalPreviewActionItems)(void);
|
||||
@property (nonatomic, copy) void (^customRemoveFromParentViewController)(void);
|
||||
@property (nonatomic, copy) void (^customDismissSelf)(void);
|
||||
|
@ -732,7 +732,7 @@ static id<LegacyComponentsContext> _defaultContext = nil;
|
||||
- (UIEdgeInsets)controllerInsetForInterfaceOrientation:(UIInterfaceOrientation)orientation
|
||||
{
|
||||
UIEdgeInsets safeAreaInset = _context.safeAreaInset;
|
||||
CGFloat statusBarHeight = safeAreaInset.top > FLT_EPSILON ? safeAreaInset.top : [TGHacks statusBarHeightForOrientation:orientation];
|
||||
CGFloat statusBarHeight = safeAreaInset.top > FLT_EPSILON ? safeAreaInset.top : 0.0;
|
||||
CGFloat keyboardHeight = [self _currentKeyboardHeight:orientation];
|
||||
|
||||
CGFloat navigationBarHeight = ([self navigationBarShouldBeHidden] || [self shouldIgnoreNavigationBar]) ? 0 : [self navigationBarHeightForInterfaceOrientation:orientation];
|
||||
|
@ -281,6 +281,8 @@ public final class LegacyControllerContext: NSObject, LegacyComponentsContext {
|
||||
}
|
||||
if validLayout.intrinsicInsets.bottom.isEqual(to: 21.0) {
|
||||
safeInsets.bottom = 21.0
|
||||
} else if validLayout.intrinsicInsets.bottom.isEqual(to: 34.0) {
|
||||
safeInsets.bottom = 34.0
|
||||
}
|
||||
if controller.navigationPresentation == .modal {
|
||||
safeInsets.top = 0.0
|
||||
@ -485,6 +487,7 @@ open class LegacyController: ViewController, PresentableController {
|
||||
orientation = .landscapeRight
|
||||
}
|
||||
|
||||
legacyTelegramController.intrinsicSize = layout.size
|
||||
legacyTelegramController._updateInset(for: orientation, force: false, notify: true)
|
||||
if self.enableContainerLayoutUpdates {
|
||||
legacyTelegramController.layoutController(for: layout.size, duration: duration)
|
||||
|
@ -251,6 +251,8 @@ public func legacyLocationController(message: Message?, mapMedia: TelegramMediaM
|
||||
|
||||
controller.onViewDidAppear = { [weak controller] in
|
||||
if let strongController = controller {
|
||||
strongController.view.disablesInteractiveModalDismiss = true
|
||||
strongController.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||
strongController.locationMapView.interactiveTransitionGestureRecognizerTest = { point -> Bool in
|
||||
return point.x > 30.0
|
||||
}
|
||||
@ -267,9 +269,6 @@ public func legacyLocationController(message: Message?, mapMedia: TelegramMediaM
|
||||
}
|
||||
legacyController.bind(controller: controller)
|
||||
|
||||
controller.view.disablesInteractiveModalDismiss = true
|
||||
controller.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||
|
||||
let presentationDisposable = context.sharedContext.presentationData.start(next: { [weak controller] presentationData in
|
||||
if let controller = controller {
|
||||
controller.pallete = legacyLocationPalette(from: presentationData.theme)
|
||||
|
@ -17,10 +17,13 @@ private func generateClearIcon(color: UIColor) -> UIImage? {
|
||||
public func legacyLocationPickerController(context: AccountContext, selfPeer: Peer, peer: Peer, sendLocation: @escaping (CLLocationCoordinate2D, MapVenue?, String?) -> Void, sendLiveLocation: @escaping (CLLocationCoordinate2D, Int32) -> Void, theme: PresentationTheme, customLocationPicker: Bool = false, hasLiveLocation: Bool = true, presentationCompleted: @escaping () -> Void = {}) -> ViewController {
|
||||
let legacyController = LegacyController(presentation: .navigation, theme: theme)
|
||||
legacyController.navigationPresentation = .modal
|
||||
legacyController.presentationCompleted = {
|
||||
presentationCompleted()
|
||||
}
|
||||
let controller = TGLocationPickerController(context: legacyController.context, intent: customLocationPicker ? TGLocationPickerControllerCustomLocationIntent : TGLocationPickerControllerDefaultIntent)!
|
||||
legacyController.presentationCompleted = { [weak controller] in
|
||||
presentationCompleted()
|
||||
|
||||
controller?.view.disablesInteractiveModalDismiss = true
|
||||
controller?.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||
}
|
||||
controller.peer = makeLegacyPeer(selfPeer)
|
||||
controller.receivingPeer = makeLegacyPeer(peer)
|
||||
controller.pallete = legacyLocationPalette(from: theme)
|
||||
@ -32,8 +35,6 @@ public func legacyLocationPickerController(context: AccountContext, selfPeer: Pe
|
||||
if namespacesWithEnabledLiveLocation.contains(peer.id.namespace) && !customLocationPicker && hasLiveLocation {
|
||||
controller.allowLiveLocationSharing = true
|
||||
}
|
||||
controller.view.disablesInteractiveModalDismiss = true
|
||||
controller.view.disablesInteractiveTransitionGestureRecognizer = true
|
||||
let navigationController = TGNavigationController(controllers: [controller])!
|
||||
controller.navigation_setDismiss({ [weak legacyController] in
|
||||
legacyController?.dismiss()
|
||||
|
Loading…
x
Reference in New Issue
Block a user