diff --git a/submodules/LocationUI/Sources/LocationMapHeaderNode.swift b/submodules/LocationUI/Sources/LocationMapHeaderNode.swift index e00593386e..8ed12e8b16 100644 --- a/submodules/LocationUI/Sources/LocationMapHeaderNode.swift +++ b/submodules/LocationUI/Sources/LocationMapHeaderNode.swift @@ -57,7 +57,7 @@ public final class LocationMapHeaderNode: ASDisplayNode { private let placesButtonNode: HighlightableButtonNode private let shadowNode: ASImageNode - private var validLayout: (ContainerViewLayout, CGFloat, CGFloat, CGFloat, CGSize)? + private var validLayout: (ContainerViewLayout, CGFloat, CGFloat, CGFloat, CGFloat, CGSize)? public init(presentationData: PresentationData, toggleMapModeSelection: @escaping () -> Void, goToUserLocation: @escaping () -> Void, setupProximityNotification: @escaping (Bool) -> Void = { _ in }, showPlacesInThisArea: @escaping () -> Void = {}) { self.presentationData = presentationData @@ -143,9 +143,9 @@ public final class LocationMapHeaderNode: ASDisplayNode { self.displayingPlacesButton = displayingPlacesButton self.proximityNotification = proximityNotification - if updateLayout, let (layout, navigationBarHeight, topPadding, offset, size) = self.validLayout { + if updateLayout, let (layout, navigationBarHeight, topPadding, controlsTopPadding, offset, size) = self.validLayout { let transition: ContainedViewLayoutTransition = animated ? .animated(duration: 0.3, curve: .spring) : .immediate - self.updateLayout(layout: layout, navigationBarHeight: navigationBarHeight, topPadding: topPadding, offset: offset, size: size, transition: transition) + self.updateLayout(layout: layout, navigationBarHeight: navigationBarHeight, topPadding: topPadding, controlsTopPadding: controlsTopPadding, offset: offset, size: size, transition: transition) } } @@ -177,8 +177,8 @@ public final class LocationMapHeaderNode: ASDisplayNode { } } - public func updateLayout(layout: ContainerViewLayout, navigationBarHeight: CGFloat, topPadding: CGFloat, offset: CGFloat, size: CGSize, transition: ContainedViewLayoutTransition) { - self.validLayout = (layout, navigationBarHeight, topPadding, offset, size) + public func updateLayout(layout: ContainerViewLayout, navigationBarHeight: CGFloat, topPadding: CGFloat, controlsTopPadding: CGFloat, offset: CGFloat, size: CGSize, transition: ContainedViewLayoutTransition) { + self.validLayout = (layout, navigationBarHeight, topPadding, controlsTopPadding, offset, size) let mapHeight: CGFloat = floor(layout.size.height * 1.3) + layout.intrinsicInsets.top * 2.0 let mapFrame = CGRect(x: 0.0, y: floorToScreenPixels((size.height - mapHeight + navigationBarHeight) / 2.0) + offset + floor(layout.intrinsicInsets.top * 0.5), width: size.width, height: mapHeight) @@ -209,7 +209,7 @@ public final class LocationMapHeaderNode: ASDisplayNode { transition.updateAlpha(node: self.notificationButtonNode, alpha: self.proximityNotification != nil ? 1.0 : 0.0) transition.updateAlpha(node: self.optionsSecondSeparatorNode, alpha: self.proximityNotification != nil ? 1.0 : 0.0) - transition.updateFrame(node: self.optionsBackgroundNode, frame: CGRect(x: size.width - inset - panelButtonSize.width - panelInset * 2.0 - layout.safeInsets.right, y: navigationBarHeight + topPadding + inset, width: panelButtonSize.width + panelInset * 2.0, height: panelHeight + panelInset * 2.0)) + transition.updateFrame(node: self.optionsBackgroundNode, frame: CGRect(x: size.width - inset - panelButtonSize.width - panelInset * 2.0 - layout.safeInsets.right, y: navigationBarHeight + controlsTopPadding + inset, width: panelButtonSize.width + panelInset * 2.0, height: panelHeight + panelInset * 2.0)) let alphaTransition = ContainedViewLayoutTransition.animated(duration: 0.2, curve: .easeInOut) let optionsAlpha: CGFloat = size.height > 160.0 + navigationBarHeight && !self.forceIsHidden ? 1.0 : 0.0 @@ -218,8 +218,8 @@ public final class LocationMapHeaderNode: ASDisplayNode { public var forceIsHidden: Bool = false { didSet { - if let (layout, navigationBarHeight, topPadding, offset, size) = self.validLayout { - self.updateLayout(layout: layout, navigationBarHeight: navigationBarHeight, topPadding: topPadding, offset: offset, size: size, transition: .immediate) + if let (layout, navigationBarHeight, topPadding, controlsTopPadding, offset, size) = self.validLayout { + self.updateLayout(layout: layout, navigationBarHeight: navigationBarHeight, topPadding: topPadding, controlsTopPadding: controlsTopPadding, offset: offset, size: size, transition: .immediate) } } } diff --git a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift index 3cd747948b..5e8ff2ca93 100644 --- a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift @@ -902,7 +902,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM strongSelf.listOffset = max(0.0, offset) let headerFrame = CGRect(origin: CGPoint(), size: CGSize(width: layout.size.width, height: max(0.0, offset + overlap))) listTransition.updateFrame(node: strongSelf.headerNode, frame: headerFrame) - strongSelf.headerNode.updateLayout(layout: layout, navigationBarHeight: navigationBarHeight, topPadding: strongSelf.state.displayingMapModeOptions ? 38.0 : 0.0, offset: 0.0, size: headerFrame.size, transition: listTransition) + strongSelf.headerNode.updateLayout(layout: layout, navigationBarHeight: navigationBarHeight, topPadding: strongSelf.state.displayingMapModeOptions ? 38.0 : 0.0, controlsTopPadding: strongSelf.state.displayingMapModeOptions ? 38.0 : 0.0, offset: 0.0, size: headerFrame.size, transition: listTransition) strongSelf.layoutEmptyResultsPlaceholder(transition: listTransition) } @@ -1116,7 +1116,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM let headerFrame = CGRect(origin: CGPoint(), size: CGSize(width: layout.size.width, height: headerHeight)) transition.updateFrame(node: self.headerNode, frame: headerFrame) - self.headerNode.updateLayout(layout: layout, navigationBarHeight: navigationHeight, topPadding: self.state.displayingMapModeOptions ? optionsHeight : 0.0, offset: 0.0, size: headerFrame.size, transition: transition) + self.headerNode.updateLayout(layout: layout, navigationBarHeight: navigationHeight, topPadding: self.state.displayingMapModeOptions ? optionsHeight : 0.0, controlsTopPadding: self.state.displayingMapModeOptions ? optionsHeight : 0.0, offset: 0.0, size: headerFrame.size, transition: transition) let (duration, curve) = listViewAnimationDurationAndCurve(transition: transition) let scrollToItem: ListViewScrollToItem? diff --git a/submodules/LocationUI/Sources/LocationViewControllerNode.swift b/submodules/LocationUI/Sources/LocationViewControllerNode.swift index b7c93634a2..8a5ebd03ec 100644 --- a/submodules/LocationUI/Sources/LocationViewControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationViewControllerNode.swift @@ -714,7 +714,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan strongSelf.listOffset = max(0.0, offset) let headerFrame = CGRect(origin: CGPoint(), size: CGSize(width: layout.size.width, height: max(0.0, offset + overlap))) listTransition.updateFrame(node: strongSelf.headerNode, frame: headerFrame) - strongSelf.headerNode.updateLayout(layout: layout, navigationBarHeight: navigationBarHeight, topPadding: strongSelf.state.displayingMapModeOptions ? 38.0 : 0.0, offset: 0.0, size: headerFrame.size, transition: listTransition) + strongSelf.headerNode.updateLayout(layout: layout, navigationBarHeight: navigationBarHeight, topPadding: strongSelf.state.displayingMapModeOptions ? 38.0 : 0.0, controlsTopPadding: strongSelf.state.displayingMapModeOptions ? 38.0 : 0.0, offset: 0.0, size: headerFrame.size, transition: listTransition) } self.listNode.beganInteractiveDragging = { [weak self] _ in @@ -952,7 +952,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan let headerFrame = CGRect(origin: CGPoint(), size: CGSize(width: layout.size.width, height: headerHeight)) transition.updateFrame(node: self.headerNode, frame: headerFrame) - self.headerNode.updateLayout(layout: layout, navigationBarHeight: navigationHeight, topPadding: self.state.displayingMapModeOptions ? optionsHeight : 0.0, offset: 0.0, size: headerFrame.size, transition: transition) + self.headerNode.updateLayout(layout: layout, navigationBarHeight: navigationHeight, topPadding: self.state.displayingMapModeOptions ? optionsHeight : 0.0, controlsTopPadding: self.state.displayingMapModeOptions ? optionsHeight : 0.0, offset: 0.0, size: headerFrame.size, transition: transition) let (duration, curve) = listViewAnimationDurationAndCurve(transition: transition) diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift index ee65e91346..eb93196820 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoVisualMediaPaneNode/Sources/PeerInfoStoryPaneNode.swift @@ -2715,16 +2715,20 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr } private func updateHistory(items: SparseItemGrid.Items, pinnedIds: Set, synchronous: Bool, reloadAtTop: Bool) { + var transition: ContainedViewLayoutTransition = .immediate + if case .location = self.scope, let previousItems = self.items, previousItems.items.count == 0, previousItems.count != 0, items.items.count == 0, items.count == 0 { + transition = .animated(duration: 0.3, curve: .spring) + } + self.items = items self.pinnedIds = pinnedIds - self.isEmptyUpdated(self.isEmpty) if let (size, topInset, sideInset, bottomInset, deviceMetrics, visibleHeight, isScrollingLockedAtTop, expandProgress, navigationHeight, presentationData) = self.currentParams { var gridSnapshot: UIView? if reloadAtTop { gridSnapshot = self.itemGrid.view.snapshotView(afterScreenUpdates: false) } - self.update(size: size, topInset: topInset, sideInset: sideInset, bottomInset: bottomInset, deviceMetrics: deviceMetrics, visibleHeight: visibleHeight, isScrollingLockedAtTop: isScrollingLockedAtTop, expandProgress: expandProgress, navigationHeight: navigationHeight, presentationData: presentationData, synchronous: false, transition: .immediate) + self.update(size: size, topInset: topInset, sideInset: sideInset, bottomInset: bottomInset, deviceMetrics: deviceMetrics, visibleHeight: visibleHeight, isScrollingLockedAtTop: isScrollingLockedAtTop, expandProgress: expandProgress, navigationHeight: navigationHeight, presentationData: presentationData, synchronous: false, transition: transition) self.updateSelectedItems(animated: false) if let gridSnapshot = gridSnapshot { self.view.addSubview(gridSnapshot) @@ -2733,6 +2737,8 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr }) } } + + self.isEmptyUpdated(self.isEmpty) if !self.didSetReady { self.didSetReady = true @@ -3074,27 +3080,39 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr private func gridScrollingOffsetUpdated(transition: ContainedViewLayoutTransition) { if let _ = self.mapNode, let currentParams = self.currentParams { - self.updateMapLayout(size: currentParams.size, topInset: currentParams.topInset, deviceMetrics: currentParams.deviceMetrics, transition: transition) + self.updateMapLayout(size: currentParams.size, topInset: currentParams.topInset, bottomInset: currentParams.bottomInset, deviceMetrics: currentParams.deviceMetrics, transition: transition) } } private var effectiveMapHeight: CGFloat = 0.0 - private func updateMapLayout(size: CGSize, topInset: CGFloat, deviceMetrics: DeviceMetrics, transition: ContainedViewLayoutTransition) { + private func updateMapLayout(size: CGSize, topInset: CGFloat, bottomInset: CGFloat, deviceMetrics: DeviceMetrics, transition: ContainedViewLayoutTransition) { guard let mapNode = self.mapNode else { return } - let mapOverscrollInset: CGFloat = 300.0 - var mapHeight = min(size.width, size.height) mapHeight = min(mapHeight, floor(size.height * 0.389)) + let mapOverscrollInset: CGFloat = size.height - mapHeight + self.effectiveMapHeight = mapHeight - self.additionalNavigationHeight let mapSize = CGSize(width: size.width, height: mapHeight + mapOverscrollInset) - let mapFrame = CGRect(origin: CGPoint(x: 0.0, y: topInset - mapOverscrollInset - self.itemGrid.scrollingOffset - self.additionalNavigationHeight), size: mapSize) + var controlsTopPadding = mapOverscrollInset + self.additionalNavigationHeight + + let effectiveScrollingOffset: CGFloat + if let items = self.items, items.items.isEmpty, items.count == 0 { + effectiveScrollingOffset = -size.height * 0.5 + 60.0 + bottomInset + } else { + effectiveScrollingOffset = self.itemGrid.scrollingOffset + } + controlsTopPadding += min(0.0, effectiveScrollingOffset) + + let mapFrame = CGRect(origin: CGPoint(x: 0.0, y: topInset - mapOverscrollInset - effectiveScrollingOffset - self.additionalNavigationHeight), size: mapSize) transition.updateFrame(node: mapNode, frame: mapFrame) + let mapOffset = min(floorToScreenPixels(effectiveScrollingOffset * 0.5), mapSize.height) + mapNode.updateLayout( layout: ContainerViewLayout( size: mapSize, @@ -3110,7 +3128,8 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr ), navigationBarHeight: 0.0, topPadding: mapOverscrollInset + self.additionalNavigationHeight, - offset: min(floorToScreenPixels(self.itemGrid.scrollingOffset * 0.5), mapSize.height), + controlsTopPadding: controlsTopPadding, + offset: mapOffset, size: mapSize, transition: transition ) @@ -3162,7 +3181,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr let mapInfoTopInset: CGFloat = -6.0 let mapInfoFrame = CGRect(origin: CGPoint(x: 0.0, y: mapFrame.maxY + mapInfoTopInset), size: mapInfoLayout.contentSize) - mapInfoNode.frame = mapInfoFrame + transition.updateFrame(node: mapInfoNode, frame: mapInfoFrame) mapInfoReadyAndApply().1(ListViewItemApply(isOnScreen: true)) self.effectiveMapHeight += mapInfoLayout.contentSize.height + mapInfoTopInset @@ -3217,7 +3236,7 @@ public final class PeerInfoStoryPaneNode: ASDisplayNode, PeerInfoPaneNode, ASScr var gridTopInset = topInset if self.mapNode != nil { - self.updateMapLayout(size: size, topInset: topInset, deviceMetrics: deviceMetrics, transition: transition) + self.updateMapLayout(size: size, topInset: topInset, bottomInset: bottomInset, deviceMetrics: deviceMetrics, transition: transition) gridTopInset += self.effectiveMapHeight let mapOptionsNode: LocationOptionsNode