mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Context UI improvements
This commit is contained in:
@@ -164,12 +164,17 @@ private final class ContextControllerActionsListActionItemNode: HighlightTrackin
|
||||
case let .secondLineWithValue(subtitleValue):
|
||||
self.titleLabelNode.maximumNumberOfLines = 1
|
||||
subtitle = subtitleValue
|
||||
case .multiline:
|
||||
self.titleLabelNode.maximumNumberOfLines = 0
|
||||
}
|
||||
|
||||
let titleFont: UIFont
|
||||
switch self.item.textFont {
|
||||
case let .custom(font):
|
||||
titleFont = font
|
||||
case .small:
|
||||
let smallTextFont = Font.regular(floor(presentationData.listsFontSize.baseDisplaySize * 14.0 / 17.0))
|
||||
titleFont = smallTextFont
|
||||
case .regular:
|
||||
titleFont = Font.regular(presentationData.listsFontSize.baseDisplaySize)
|
||||
}
|
||||
@@ -479,7 +484,7 @@ final class ContextControllerActionsListStackItem: ContextControllerActionsStack
|
||||
|
||||
let itemNodeLayout = item.node.update(
|
||||
presentationData: presentationData,
|
||||
constrainedSize: constrainedSize
|
||||
constrainedSize: CGSize(width: standardWidth, height: constrainedSize.height)
|
||||
)
|
||||
itemNodeLayouts.append(itemNodeLayout)
|
||||
combinedSize.width = max(combinedSize.width, itemNodeLayout.minSize.width)
|
||||
@@ -677,7 +682,15 @@ func makeContextControllerActionsStackItem(items: ContextController.Items) -> Co
|
||||
}
|
||||
|
||||
final class ContextControllerActionsStackNode: ASDisplayNode {
|
||||
enum Presentation {
|
||||
case modal
|
||||
case inline
|
||||
}
|
||||
|
||||
final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
||||
let backgroundNode: NavigationBackgroundNode
|
||||
let parentShadowNode: ASImageNode
|
||||
|
||||
var requestUpdate: ((ContainedViewLayoutTransition) -> Void)?
|
||||
var requestPop: (() -> Void)?
|
||||
var transitionFraction: CGFloat = 0.0
|
||||
@@ -691,8 +704,14 @@ final class ContextControllerActionsStackNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
override init() {
|
||||
self.backgroundNode = NavigationBackgroundNode(color: .clear, enableBlur: false)
|
||||
self.parentShadowNode = ASImageNode()
|
||||
self.parentShadowNode.image = UIImage(bundleImageName: "Components/Context Menu/Shadow")?.stretchableImage(withLeftCapWidth: 60, topCapHeight: 60)
|
||||
|
||||
super.init()
|
||||
|
||||
self.addSubnode(self.backgroundNode)
|
||||
|
||||
self.clipsToBounds = true
|
||||
self.cornerRadius = 14.0
|
||||
|
||||
@@ -748,7 +767,16 @@ final class ContextControllerActionsStackNode: ASDisplayNode {
|
||||
}
|
||||
}
|
||||
|
||||
func update(presentationData: PresentationData, size: CGSize, transition: ContainedViewLayoutTransition) {
|
||||
func update(presentationData: PresentationData, presentation: Presentation, size: CGSize, transition: ContainedViewLayoutTransition) {
|
||||
switch presentation {
|
||||
case .modal:
|
||||
self.backgroundNode.updateColor(color: presentationData.theme.contextMenu.backgroundColor, enableBlur: false, forceKeepBlur: false, transition: transition)
|
||||
self.parentShadowNode.isHidden = true
|
||||
case .inline:
|
||||
self.backgroundNode.updateColor(color: presentationData.theme.contextMenu.backgroundColor, enableBlur: true, forceKeepBlur: true, transition: transition)
|
||||
self.parentShadowNode.isHidden = false
|
||||
}
|
||||
self.backgroundNode.update(size: size, transition: transition)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -895,6 +923,7 @@ final class ContextControllerActionsStackNode: ASDisplayNode {
|
||||
|
||||
super.init()
|
||||
|
||||
self.addSubnode(self.navigationContainer.parentShadowNode)
|
||||
self.addSubnode(self.navigationContainer)
|
||||
|
||||
self.navigationContainer.requestUpdate = { [weak self] transition in
|
||||
@@ -999,12 +1028,11 @@ final class ContextControllerActionsStackNode: ASDisplayNode {
|
||||
func update(
|
||||
presentationData: PresentationData,
|
||||
constrainedSize: CGSize,
|
||||
presentation: Presentation,
|
||||
transition: ContainedViewLayoutTransition
|
||||
) -> CGSize {
|
||||
let tipSpacing: CGFloat = 10.0
|
||||
|
||||
self.navigationContainer.backgroundColor = presentationData.theme.contextMenu.backgroundColor
|
||||
|
||||
let animateAppearingContainers = transition.isAnimated && !self.dismissingItemContainers.isEmpty
|
||||
|
||||
struct ItemLayout {
|
||||
@@ -1083,7 +1111,10 @@ final class ContextControllerActionsStackNode: ASDisplayNode {
|
||||
|
||||
let navigationContainerFrame = CGRect(origin: CGPoint(), size: CGSize(width: topItemWidth, height: max(14 * 2.0, topItemApparentHeight)))
|
||||
transition.updateFrame(node: self.navigationContainer, frame: navigationContainerFrame, beginWithCurrentState: true)
|
||||
self.navigationContainer.update(presentationData: presentationData, size: navigationContainerFrame.size, transition: transition)
|
||||
self.navigationContainer.update(presentationData: presentationData, presentation: presentation, size: navigationContainerFrame.size, transition: transition)
|
||||
|
||||
let navigationContainerShadowFrame = navigationContainerFrame.insetBy(dx: -30.0, dy: -30.0)
|
||||
transition.updateFrame(node: self.navigationContainer.parentShadowNode, frame: navigationContainerShadowFrame, beginWithCurrentState: true)
|
||||
|
||||
for i in 0 ..< self.itemContainers.count {
|
||||
let xOffset: CGFloat
|
||||
|
||||
Reference in New Issue
Block a user