mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
7d95c0a512
commit
ccf6956beb
@ -1575,6 +1575,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.moreButtonNode = MoreButtonNode(theme: self.presentationData.theme)
|
self.moreButtonNode = MoreButtonNode(theme: self.presentationData.theme)
|
||||||
|
self.moreButtonNode.iconNode.enqueueState(.more, animated: false)
|
||||||
|
|
||||||
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: presentationData))
|
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: presentationData))
|
||||||
|
|
||||||
@ -1647,11 +1648,11 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
|||||||
if collection == nil {
|
if collection == nil {
|
||||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
|
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
|
||||||
|
|
||||||
if mode == .story || mode == .addImage {
|
// if mode == .story || mode == .addImage {
|
||||||
self.navigationItem.rightBarButtonItem = UIBarButtonItem(customDisplayNode: self.moreButtonNode)
|
// self.navigationItem.rightBarButtonItem = UIBarButtonItem(customDisplayNode: self.moreButtonNode)
|
||||||
self.navigationItem.rightBarButtonItem?.action = #selector(self.rightButtonPressed)
|
// self.navigationItem.rightBarButtonItem?.action = #selector(self.rightButtonPressed)
|
||||||
self.navigationItem.rightBarButtonItem?.target = self
|
// self.navigationItem.rightBarButtonItem?.target = self
|
||||||
}
|
// }
|
||||||
} else {
|
} else {
|
||||||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(backButtonAppearanceWithTitle: self.presentationData.strings.Common_Back, target: self, action: #selector(self.backPressed))
|
self.navigationItem.leftBarButtonItem = UIBarButtonItem(backButtonAppearanceWithTitle: self.presentationData.strings.Common_Back, target: self, action: #selector(self.backPressed))
|
||||||
}
|
}
|
||||||
@ -1785,11 +1786,11 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
|||||||
|
|
||||||
self.updateSelectionState(count: Int32(selectionContext.count()))
|
self.updateSelectionState(count: Int32(selectionContext.count()))
|
||||||
|
|
||||||
self.longTapWithTabBar = { [weak self] in
|
// self.longTapWithTabBar = { [weak self] in
|
||||||
if let self, self.groupsController == nil {
|
// if let self, self.groupsController == nil {
|
||||||
self.presentSearch(activateOnDisplay: false)
|
// self.presentSearch(activateOnDisplay: false)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
required init(coder aDecoder: NSCoder) {
|
required init(coder aDecoder: NSCoder) {
|
||||||
@ -1966,18 +1967,22 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
|||||||
fileprivate func updateSelectionState(count: Int32) {
|
fileprivate func updateSelectionState(count: Int32) {
|
||||||
self.selectionCount = count
|
self.selectionCount = count
|
||||||
|
|
||||||
|
var moreIsVisible = false
|
||||||
if case let .media(media) = self.subject {
|
if case let .media(media) = self.subject {
|
||||||
self.titleView.title = media.count == 1 ? self.presentationData.strings.Attachment_Pasteboard : self.presentationData.strings.Attachment_SelectedMedia(count)
|
self.titleView.title = media.count == 1 ? self.presentationData.strings.Attachment_Pasteboard : self.presentationData.strings.Attachment_SelectedMedia(count)
|
||||||
self.titleView.segmentsHidden = true
|
self.titleView.segmentsHidden = true
|
||||||
self.moreButtonNode.iconNode.enqueueState(.more, animated: false)
|
moreIsVisible = true
|
||||||
|
// self.moreButtonNode.iconNode.enqueueState(.more, animated: false)
|
||||||
} else {
|
} else {
|
||||||
if count > 0 {
|
if count > 0 {
|
||||||
self.titleView.segments = [self.presentationData.strings.Attachment_AllMedia, self.presentationData.strings.Attachment_SelectedMedia(count)]
|
self.titleView.segments = [self.presentationData.strings.Attachment_AllMedia, self.presentationData.strings.Attachment_SelectedMedia(count)]
|
||||||
self.titleView.segmentsHidden = false
|
self.titleView.segmentsHidden = false
|
||||||
self.moreButtonNode.iconNode.enqueueState(.more, animated: true)
|
moreIsVisible = true
|
||||||
|
// self.moreButtonNode.iconNode.enqueueState(.more, animated: true)
|
||||||
} else {
|
} else {
|
||||||
self.titleView.segmentsHidden = true
|
self.titleView.segmentsHidden = true
|
||||||
self.moreButtonNode.iconNode.enqueueState(.search, animated: true)
|
moreIsVisible = false
|
||||||
|
// self.moreButtonNode.iconNode.enqueueState(.search, animated: true)
|
||||||
|
|
||||||
if self.titleView.index != 0 {
|
if self.titleView.index != 0 {
|
||||||
Queue.mainQueue().after(0.3) {
|
Queue.mainQueue().after(0.3) {
|
||||||
@ -1986,6 +1991,10 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let transition = ContainedViewLayoutTransition.animated(duration: 0.25, curve: .easeInOut)
|
||||||
|
transition.updateAlpha(node: self.moreButtonNode.iconNode, alpha: moreIsVisible ? 1.0 : 0.0)
|
||||||
|
transition.updateTransformScale(node: self.moreButtonNode.iconNode, scale: moreIsVisible ? 1.0 : 0.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateThemeAndStrings() {
|
private func updateThemeAndStrings() {
|
||||||
@ -2149,7 +2158,8 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
|||||||
@objc private func searchOrMorePressed(node: ContextReferenceContentNode, gesture: ContextGesture?) {
|
@objc private func searchOrMorePressed(node: ContextReferenceContentNode, gesture: ContextGesture?) {
|
||||||
switch self.moreButtonNode.iconNode.iconState {
|
switch self.moreButtonNode.iconNode.iconState {
|
||||||
case .search:
|
case .search:
|
||||||
self.presentSearch(activateOnDisplay: true)
|
// self.presentSearch(activateOnDisplay: true)
|
||||||
|
break
|
||||||
case .more:
|
case .more:
|
||||||
let strings = self.presentationData.strings
|
let strings = self.presentationData.strings
|
||||||
let selectionCount = self.selectionCount
|
let selectionCount = self.selectionCount
|
||||||
|
@ -145,7 +145,10 @@ public final class MoreButtonNode: ASDisplayNode {
|
|||||||
override public func calculateSizeThatFits(_ constrainedSize: CGSize) -> CGSize {
|
override public func calculateSizeThatFits(_ constrainedSize: CGSize) -> CGSize {
|
||||||
let animationSize = CGSize(width: 30.0, height: 30.0)
|
let animationSize = CGSize(width: 30.0, height: 30.0)
|
||||||
let inset: CGFloat = 0.0
|
let inset: CGFloat = 0.0
|
||||||
self.iconNode.frame = CGRect(origin: CGPoint(x: inset + 6.0, y: floor((constrainedSize.height - animationSize.height) / 2.0) + 1.0), size: animationSize)
|
let iconFrame = CGRect(origin: CGPoint(x: inset + 6.0, y: floor((constrainedSize.height - animationSize.height) / 2.0) + 1.0), size: animationSize)
|
||||||
|
|
||||||
|
self.iconNode.position = iconFrame.center
|
||||||
|
self.iconNode.bounds = CGRect(origin: .zero, size: iconFrame.size)
|
||||||
|
|
||||||
let size = CGSize(width: animationSize.width + inset * 2.0, height: constrainedSize.height)
|
let size = CGSize(width: animationSize.width + inset * 2.0, height: constrainedSize.height)
|
||||||
let bounds = CGRect(origin: CGPoint(), size: size)
|
let bounds = CGRect(origin: CGPoint(), size: size)
|
||||||
|
@ -307,7 +307,7 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let (messageButtonWidth, messageContinueLayout) = makeMessageButtonLayout(constrainedSize.width, nil, false, item.presentationData.strings.Conversation_ContactMessage.uppercased(), mainColor, false, false)
|
let (messageButtonWidth, messageContinueLayout) = makeMessageButtonLayout(constrainedSize.width, nil, false, item.presentationData.strings.Conversation_ContactMessage.uppercased(), mainColor, false, false)
|
||||||
let (addButtonWidth, addContinueLayout) = makeAddButtonLayout(constrainedSize.width, nil, false, item.presentationData.strings.Conversation_ContactAddContact.uppercased(), mainColor, false, false)
|
let (addButtonWidth, addContinueLayout) = makeAddButtonLayout(constrainedSize.width, nil, false, !canMessage && !canAdd ? item.presentationData.strings.Conversation_ViewContactDetails.uppercased() : item.presentationData.strings.Conversation_ContactAddContact.uppercased(), mainColor, false, false)
|
||||||
|
|
||||||
let maxButtonWidth = max(messageButtonWidth, addButtonWidth)
|
let maxButtonWidth = max(messageButtonWidth, addButtonWidth)
|
||||||
var maxContentWidth: CGFloat = avatarSize.width + 7.0
|
var maxContentWidth: CGFloat = avatarSize.width + 7.0
|
||||||
@ -326,13 +326,10 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
|
|
||||||
let lineWidth: CGFloat = 3.0
|
let lineWidth: CGFloat = 3.0
|
||||||
|
|
||||||
var buttonCount = 0
|
var buttonCount = 1
|
||||||
if canMessage {
|
if canMessage {
|
||||||
buttonCount += 1
|
buttonCount += 1
|
||||||
}
|
}
|
||||||
if canAdd {
|
|
||||||
buttonCount += 1
|
|
||||||
}
|
|
||||||
var buttonWidth = floor((boundingWidth - layoutConstants.text.bubbleInsets.right * 2.0 - lineWidth))
|
var buttonWidth = floor((boundingWidth - layoutConstants.text.bubbleInsets.right * 2.0 - lineWidth))
|
||||||
if buttonCount > 1 {
|
if buttonCount > 1 {
|
||||||
buttonWidth /= CGFloat(buttonCount)
|
buttonWidth /= CGFloat(buttonCount)
|
||||||
@ -385,7 +382,7 @@ public class ChatMessageContactBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
strongSelf.textNode.frame = CGRect(origin: CGPoint(x: avatarFrame.maxX + 7.0, y: avatarFrame.minY + 20.0), size: textLayout.size)
|
strongSelf.textNode.frame = CGRect(origin: CGPoint(x: avatarFrame.maxX + 7.0, y: avatarFrame.minY + 20.0), size: textLayout.size)
|
||||||
|
|
||||||
strongSelf.addButtonNode.frame = addButtonFrame
|
strongSelf.addButtonNode.frame = addButtonFrame
|
||||||
strongSelf.addButtonNode.isHidden = !canAdd
|
strongSelf.addButtonNode.isHidden = !canAdd && canMessage
|
||||||
strongSelf.messageButtonNode.frame = messageButtonFrame
|
strongSelf.messageButtonNode.frame = messageButtonFrame
|
||||||
strongSelf.messageButtonNode.isHidden = !canMessage
|
strongSelf.messageButtonNode.isHidden = !canMessage
|
||||||
|
|
||||||
|
@ -649,7 +649,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
transition.updateFrame(node: self.topOverscrollNode, frame: CGRect(origin: CGPoint(x: 0.0, y: -1000.0), size: CGSize(width: layout.size.width, height: 1000.0)))
|
transition.updateFrame(node: self.topOverscrollNode, frame: CGRect(origin: CGPoint(x: 0.0, y: -1000.0), size: CGSize(width: layout.size.width, height: 1000.0)))
|
||||||
|
|
||||||
if let webView = self.webView {
|
if let webView = self.webView {
|
||||||
let frame = CGRect(origin: CGPoint(x: layout.safeInsets.left, y: navigationBarHeight), size: CGSize(width: layout.size.width - layout.safeInsets.left - layout.safeInsets.right, height: max(1.0, layout.size.height - navigationBarHeight - layout.intrinsicInsets.bottom)))
|
var scrollInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: layout.intrinsicInsets.bottom, right: 0.0)
|
||||||
|
var frameBottomInset: CGFloat = 0.0
|
||||||
|
if scrollInset.bottom > 40.0 {
|
||||||
|
frameBottomInset = scrollInset.bottom
|
||||||
|
scrollInset.bottom = 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
let frame = CGRect(origin: CGPoint(x: layout.safeInsets.left, y: navigationBarHeight), size: CGSize(width: layout.size.width - layout.safeInsets.left - layout.safeInsets.right, height: max(1.0, layout.size.height - navigationBarHeight - frameBottomInset)))
|
||||||
|
|
||||||
var bottomInset = layout.intrinsicInsets.bottom + layout.additionalInsets.bottom
|
var bottomInset = layout.intrinsicInsets.bottom + layout.additionalInsets.bottom
|
||||||
if let inputHeight = self.validLayout?.0.inputHeight, inputHeight > 44.0 {
|
if let inputHeight = self.validLayout?.0.inputHeight, inputHeight > 44.0 {
|
||||||
@ -657,6 +664,11 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
let viewportFrame = CGRect(origin: CGPoint(x: layout.safeInsets.left, y: navigationBarHeight), size: CGSize(width: layout.size.width - layout.safeInsets.left - layout.safeInsets.right, height: max(1.0, layout.size.height - navigationBarHeight - bottomInset)))
|
let viewportFrame = CGRect(origin: CGPoint(x: layout.safeInsets.left, y: navigationBarHeight), size: CGSize(width: layout.size.width - layout.safeInsets.left - layout.safeInsets.right, height: max(1.0, layout.size.height - navigationBarHeight - bottomInset)))
|
||||||
|
|
||||||
|
if webView.scrollView.contentInset != scrollInset {
|
||||||
|
webView.scrollView.contentInset = scrollInset
|
||||||
|
webView.scrollView.scrollIndicatorInsets = scrollInset
|
||||||
|
}
|
||||||
|
|
||||||
if previousLayout != nil && (previousLayout?.inputHeight ?? 0.0).isZero, let inputHeight = layout.inputHeight, inputHeight > 44.0, transition.isAnimated {
|
if previousLayout != nil && (previousLayout?.inputHeight ?? 0.0).isZero, let inputHeight = layout.inputHeight, inputHeight > 44.0, transition.isAnimated {
|
||||||
webView.scrollToActiveElement(layout: layout, completion: { [weak self] contentOffset in
|
webView.scrollToActiveElement(layout: layout, completion: { [weak self] contentOffset in
|
||||||
self?.targetContentOffset = contentOffset
|
self?.targetContentOffset = contentOffset
|
||||||
|
Loading…
x
Reference in New Issue
Block a user