mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Fix keyboard
This commit is contained in:
@@ -522,6 +522,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
|
|
||||||
var peer: Peer?
|
var peer: Peer?
|
||||||
var displayAsMessage = false
|
var displayAsMessage = false
|
||||||
|
var enablePreview = true
|
||||||
switch item.content {
|
switch item.content {
|
||||||
case let .peer(message, peerValue, _, _, _, _, _, _, _, _, displayAsMessageValue):
|
case let .peer(message, peerValue, _, _, _, _, _, _, _, _, displayAsMessageValue):
|
||||||
displayAsMessage = displayAsMessageValue
|
displayAsMessage = displayAsMessageValue
|
||||||
@@ -530,6 +531,9 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
} else {
|
} else {
|
||||||
peer = peerValue.chatMainPeer
|
peer = peerValue.chatMainPeer
|
||||||
}
|
}
|
||||||
|
if peerValue.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||||
|
enablePreview = false
|
||||||
|
}
|
||||||
case let .groupReference(groupReference):
|
case let .groupReference(groupReference):
|
||||||
if let previousItem = previousItem, case let .groupReference(previousGroupReference) = previousItem.content, groupReference.hiddenByDefault != previousGroupReference.hiddenByDefault {
|
if let previousItem = previousItem, case let .groupReference(previousGroupReference) = previousItem.content, groupReference.hiddenByDefault != previousGroupReference.hiddenByDefault {
|
||||||
UIView.transition(with: self.avatarNode.view, duration: 0.3, options: [.transitionCrossDissolve], animations: {
|
UIView.transition(with: self.avatarNode.view, duration: 0.3, options: [.transitionCrossDissolve], animations: {
|
||||||
@@ -547,6 +551,8 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||||||
}
|
}
|
||||||
self.avatarNode.setPeer(account: item.context.account, theme: item.presentationData.theme, peer: peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads)
|
self.avatarNode.setPeer(account: item.context.account, theme: item.presentationData.theme, peer: peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.contextContainer.isGestureEnabled = enablePreview
|
||||||
}
|
}
|
||||||
|
|
||||||
override func layoutForParams(_ params: ListViewItemLayoutParams, item: ListViewItem, previousItem: ListViewItem?, nextItem: ListViewItem?) {
|
override func layoutForParams(_ params: ListViewItemLayoutParams, item: ListViewItem, previousItem: ListViewItem?, nextItem: ListViewItem?) {
|
||||||
|
|||||||
@@ -566,7 +566,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
|
|||||||
|
|
||||||
let contentContainerOffset = CGPoint(x: localSourceFrame.center.x - self.contentContainerNode.frame.center.x, y: localSourceFrame.center.y - self.contentContainerNode.frame.center.y)
|
let contentContainerOffset = CGPoint(x: localSourceFrame.center.x - self.contentContainerNode.frame.center.x, y: localSourceFrame.center.y - self.contentContainerNode.frame.center.y)
|
||||||
if let contentNode = self.contentContainerNode.contentNode, case let .controller(controller) = contentNode {
|
if let contentNode = self.contentContainerNode.contentNode, case let .controller(controller) = contentNode {
|
||||||
let snapshotView = controller.sourceNode.view.snapshotContentTree()
|
let snapshotView: UIView? = nil// controller.sourceNode.view.snapshotContentTree()
|
||||||
if let snapshotView = snapshotView {
|
if let snapshotView = snapshotView {
|
||||||
controller.sourceNode.isHidden = true
|
controller.sourceNode.isHidden = true
|
||||||
|
|
||||||
@@ -859,7 +859,7 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
|
|||||||
|
|
||||||
let localSourceFrame = self.view.convert(CGRect(origin: CGPoint(x: originalProjectedContentViewFrame.1.minX, y: originalProjectedContentViewFrame.1.minY), size: CGSize(width: originalProjectedContentViewFrame.1.width, height: originalProjectedContentViewFrame.1.height)), to: self.scrollNode.view)
|
let localSourceFrame = self.view.convert(CGRect(origin: CGPoint(x: originalProjectedContentViewFrame.1.minX, y: originalProjectedContentViewFrame.1.minY), size: CGSize(width: originalProjectedContentViewFrame.1.width, height: originalProjectedContentViewFrame.1.height)), to: self.scrollNode.view)
|
||||||
|
|
||||||
if let snapshotView = targetNode.view.snapshotContentTree(unhide: true, keepTransform: true) {
|
if let snapshotView = targetNode.view.snapshotContentTree(unhide: true, keepTransform: true), false {
|
||||||
self.view.addSubview(snapshotView)
|
self.view.addSubview(snapshotView)
|
||||||
snapshotView.layer.animatePosition(from: CGPoint(x: self.contentContainerNode.frame.midX, y: self.contentContainerNode.frame.minY + localSourceFrame.height / 2.0), to: localSourceFrame.center, duration: transitionDuration * animationDurationFactor, timingFunction: transitionCurve.timingFunction, removeOnCompletion: false)
|
snapshotView.layer.animatePosition(from: CGPoint(x: self.contentContainerNode.frame.midX, y: self.contentContainerNode.frame.minY + localSourceFrame.height / 2.0), to: localSourceFrame.center, duration: transitionDuration * animationDurationFactor, timingFunction: transitionCurve.timingFunction, removeOnCompletion: false)
|
||||||
snapshotView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2 * animationDurationFactor, removeOnCompletion: false, completion: { _ in
|
snapshotView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2 * animationDurationFactor, removeOnCompletion: false, completion: { _ in
|
||||||
|
|||||||
@@ -145,6 +145,13 @@ class KeyboardManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func endAnimations(view: UIView) {
|
||||||
|
view.layer.removeAllAnimations()
|
||||||
|
for subview in view.subviews {
|
||||||
|
endAnimations(view: subview)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final class KeyboardViewManager {
|
final class KeyboardViewManager {
|
||||||
private let host: StatusBarHost
|
private let host: StatusBarHost
|
||||||
|
|
||||||
@@ -152,12 +159,23 @@ final class KeyboardViewManager {
|
|||||||
self.host = host
|
self.host = host
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func dismissEditingWithoutAnimation(view: UIView) {
|
||||||
|
view.endEditing(true)
|
||||||
|
if let keyboardWindow = self.host.keyboardWindow {
|
||||||
|
for view in keyboardWindow.subviews {
|
||||||
|
endAnimations(view: view)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func update(leftEdge: CGFloat, transition: ContainedViewLayoutTransition) {
|
func update(leftEdge: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||||
|
print("leftEdge: \(leftEdge) canSet: \(self.host.keyboardWindow != nil)")
|
||||||
guard let keyboardWindow = self.host.keyboardWindow else {
|
guard let keyboardWindow = self.host.keyboardWindow else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let t = keyboardWindow.layer.sublayerTransform
|
let t = keyboardWindow.layer.sublayerTransform
|
||||||
let currentOffset = CGPoint(x: t.m41, y: t.m42)
|
let currentOffset = CGPoint(x: t.m41, y: t.m42)
|
||||||
transition.updateSublayerTransformOffset(layer: keyboardWindow.layer, offset: CGPoint(x: leftEdge, y: currentOffset.y))
|
transition.updateSublayerTransformOffset(layer: keyboardWindow.layer, offset: CGPoint(x: leftEdge, y: currentOffset.y), completion: { _ in
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
panRecognizer.cancelsTouchesInView = true
|
panRecognizer.cancelsTouchesInView = true
|
||||||
self.view.addGestureRecognizer(panRecognizer)
|
self.view.addGestureRecognizer(panRecognizer)
|
||||||
|
|
||||||
self.view.disablesInteractiveTransitionGestureRecognizerNow = { [weak self] in
|
/*self.view.disablesInteractiveTransitionGestureRecognizerNow = { [weak self] in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||||
@@ -196,9 +196,7 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
|
|
||||||
let topController = top.value
|
let topController = top.value
|
||||||
let bottomController = transition.previous.value
|
let bottomController = transition.previous.value
|
||||||
UIView.setAnimationsEnabled(false)
|
strongSelf.keyboardViewManager?.dismissEditingWithoutAnimation(view: topController.view)
|
||||||
topController.view.endEditing(true)
|
|
||||||
UIView.setAnimationsEnabled(true)
|
|
||||||
|
|
||||||
strongSelf.state.transition = nil
|
strongSelf.state.transition = nil
|
||||||
|
|
||||||
@@ -370,6 +368,7 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
guard let strongSelf = self, let topTransition = topTransition, strongSelf.state.transition === topTransition else {
|
guard let strongSelf = self, let topTransition = topTransition, strongSelf.state.transition === topTransition else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
strongSelf.keyboardViewManager?.dismissEditingWithoutAnimation(view: topTransition.previous.value.view)
|
||||||
strongSelf.state.transition = nil
|
strongSelf.state.transition = nil
|
||||||
|
|
||||||
topTransition.previous.value.setIgnoreAppearanceMethodInvocations(true)
|
topTransition.previous.value.setIgnoreAppearanceMethodInvocations(true)
|
||||||
@@ -422,6 +421,10 @@ final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
|
|||||||
case .push:
|
case .push:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if isMaster {
|
||||||
|
shouldSyncKeyboard = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if child.value.displayNode.frame != childFrame {
|
if child.value.displayNode.frame != childFrame {
|
||||||
transition.updateFrame(node: child.value.displayNode, frame: childFrame)
|
transition.updateFrame(node: child.value.displayNode, frame: childFrame)
|
||||||
|
|||||||
@@ -9,7 +9,13 @@ enum NavigationTransition {
|
|||||||
private let shadowWidth: CGFloat = 16.0
|
private let shadowWidth: CGFloat = 16.0
|
||||||
|
|
||||||
private func generateShadow() -> UIImage? {
|
private func generateShadow() -> UIImage? {
|
||||||
return UIImage(named: "NavigationShadow", in: getAppBundle(), compatibleWith: nil)?.precomposed().resizableImage(withCapInsets: UIEdgeInsets(), resizingMode: .tile)
|
return generateImage(CGSize(width: 16.0, height: 1.0), rotatedContext: { size, context in
|
||||||
|
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||||
|
context.setFillColor(UIColor.black.cgColor)
|
||||||
|
context.setShadow(offset: CGSize(), blur: 16.0, color: UIColor(white: 0.0, alpha: 0.5).cgColor)
|
||||||
|
context.fill(CGRect(origin: CGPoint(x: size.width, y: 0.0), size: CGSize(width: 16.0, height: 1.0)))
|
||||||
|
})
|
||||||
|
//return UIImage(named: "NavigationShadow", in: getAppBundle(), compatibleWith: nil)?.precomposed().resizableImage(withCapInsets: UIEdgeInsets(), resizingMode: .tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
private let shadowImage = generateShadow()
|
private let shadowImage = generateShadow()
|
||||||
|
|||||||
@@ -1059,18 +1059,6 @@ public class Window1 {
|
|||||||
let currentLocation = location
|
let currentLocation = location
|
||||||
let deltaY = keyboardGestureBeginLocation.y - location.y
|
let deltaY = keyboardGestureBeginLocation.y - location.y
|
||||||
if deltaY * deltaY >= 3.0 * 3.0 || self.windowLayout.upperKeyboardInputPositionBound != nil {
|
if deltaY * deltaY >= 3.0 * 3.0 || self.windowLayout.upperKeyboardInputPositionBound != nil {
|
||||||
if self.windowLayout.upperKeyboardInputPositionBound == nil {
|
|
||||||
var enableGesture = true
|
|
||||||
if let view = self.hostView.containerView.hitTest(location, with: nil) {
|
|
||||||
if doesViewTreeDisableInteractiveTransitionGestureRecognizer(view) {
|
|
||||||
enableGesture = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !enableGesture {
|
|
||||||
self.keyboardGestureBeginLocation = nil
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.updateLayout {
|
self.updateLayout {
|
||||||
$0.update(upperKeyboardInputPositionBound: currentLocation.y + (self.keyboardGestureAccessoryHeight ?? 0.0), transition: .immediate, overrideTransition: false)
|
$0.update(upperKeyboardInputPositionBound: currentLocation.y + (self.keyboardGestureAccessoryHeight ?? 0.0), transition: .immediate, overrideTransition: false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode
|
|||||||
self.tapRecognizer = recognizer
|
self.tapRecognizer = recognizer
|
||||||
self.view.addGestureRecognizer(recognizer)
|
self.view.addGestureRecognizer(recognizer)
|
||||||
|
|
||||||
/*let replyRecognizer = ChatSwipeToReplyRecognizer(target: self, action: #selector(self.swipeToReplyGesture(_:)))
|
let replyRecognizer = ChatSwipeToReplyRecognizer(target: self, action: #selector(self.swipeToReplyGesture(_:)))
|
||||||
replyRecognizer.shouldBegin = { [weak self] in
|
replyRecognizer.shouldBegin = { [weak self] in
|
||||||
if let strongSelf = self, let item = strongSelf.item {
|
if let strongSelf = self, let item = strongSelf.item {
|
||||||
if strongSelf.selectionNode != nil {
|
if strongSelf.selectionNode != nil {
|
||||||
@@ -404,9 +404,9 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
self.view.addGestureRecognizer(replyRecognizer)*/
|
self.view.addGestureRecognizer(replyRecognizer)
|
||||||
|
|
||||||
let reactionRecognizer = ReactionSwipeGestureRecognizer(target: nil, action: nil)
|
/*let reactionRecognizer = ReactionSwipeGestureRecognizer(target: nil, action: nil)
|
||||||
self.reactionRecognizer = reactionRecognizer
|
self.reactionRecognizer = reactionRecognizer
|
||||||
reactionRecognizer.availableReactions = { [weak self] in
|
reactionRecognizer.availableReactions = { [weak self] in
|
||||||
guard let strongSelf = self, let item = strongSelf.item, !item.presentationData.isPreview && !Namespaces.Message.allScheduled.contains(item.message.id.namespace) else {
|
guard let strongSelf = self, let item = strongSelf.item, !item.presentationData.isPreview && !Namespaces.Message.allScheduled.contains(item.message.id.namespace) else {
|
||||||
@@ -559,7 +559,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.view.addGestureRecognizer(reactionRecognizer)
|
self.view.addGestureRecognizer(reactionRecognizer)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
override func asyncLayout() -> (_ item: ChatMessageItem, _ params: ListViewItemLayoutParams, _ mergedTop: ChatMessageMerge, _ mergedBottom: ChatMessageMerge, _ dateHeaderAtBottom: Bool) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, Bool) -> Void) {
|
override func asyncLayout() -> (_ item: ChatMessageItem, _ params: ListViewItemLayoutParams, _ mergedTop: ChatMessageMerge, _ mergedBottom: ChatMessageMerge, _ dateHeaderAtBottom: Bool) -> (ListViewItemNodeLayout, (ListViewItemUpdateAnimation, Bool) -> Void) {
|
||||||
@@ -2739,7 +2739,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc func swipeToReplyGesture(_ recognizer: ChatSwipeToReplyRecognizer) {
|
@objc func swipeToReplyGesture(_ recognizer: ChatSwipeToReplyRecognizer) {
|
||||||
/*switch recognizer.state {
|
switch recognizer.state {
|
||||||
case .began:
|
case .began:
|
||||||
self.currentSwipeToReplyTranslation = 0.0
|
self.currentSwipeToReplyTranslation = 0.0
|
||||||
if self.swipeToReplyFeedback == nil {
|
if self.swipeToReplyFeedback == nil {
|
||||||
@@ -2798,7 +2798,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePrevewItemNode
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var absoluteRect: (CGRect, CGSize)?
|
private var absoluteRect: (CGRect, CGSize)?
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ private enum WalletSendScreenEntry: ItemListNodeEntry {
|
|||||||
case let .commentHeader(theme, text):
|
case let .commentHeader(theme, text):
|
||||||
return ItemListSectionHeaderItem(theme: theme, text: text, sectionId: self.section)
|
return ItemListSectionHeaderItem(theme: theme, text: text, sectionId: self.section)
|
||||||
case let .comment(theme, placeholder, value):
|
case let .comment(theme, placeholder, value):
|
||||||
return ItemListMultilineInputItem(theme: theme, text: value, placeholder: placeholder, maxLength: ItemListMultilineInputItemTextLimit(value: 128, display: true), sectionId: self.section, style: .blocks, returnKeyType: .send, textUpdated: { text in
|
return ItemListMultilineInputItem(theme: theme, text: value, placeholder: placeholder, maxLength: ItemListMultilineInputItemTextLimit(value: 124, display: true), sectionId: self.section, style: .blocks, returnKeyType: .send, textUpdated: { text in
|
||||||
arguments.updateText(WalletSendScreenEntryTag.comment, text)
|
arguments.updateText(WalletSendScreenEntryTag.comment, text)
|
||||||
}, tag: WalletSendScreenEntryTag.comment, action: {
|
}, tag: WalletSendScreenEntryTag.comment, action: {
|
||||||
arguments.proceed()
|
arguments.proceed()
|
||||||
@@ -412,7 +412,7 @@ public func walletSendScreen(context: AccountContext, tonContext: TonContext, ra
|
|||||||
let amount = amountValue(state.amount)
|
let amount = amountValue(state.amount)
|
||||||
var sendEnabled = false
|
var sendEnabled = false
|
||||||
if let balance = balance {
|
if let balance = balance {
|
||||||
sendEnabled = isValidAddress(state.address, exactLength: true) && amount > 0 && amount <= balance.balance && state.comment.count <= 128
|
sendEnabled = isValidAddress(state.address, exactLength: true) && amount > 0 && amount <= balance.balance && state.comment.count <= 124
|
||||||
}
|
}
|
||||||
let rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Wallet_Send_Send), style: .bold, enabled: sendEnabled, action: {
|
let rightNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Wallet_Send_Send), style: .bold, enabled: sendEnabled, action: {
|
||||||
arguments.proceed()
|
arguments.proceed()
|
||||||
|
|||||||
Reference in New Issue
Block a user