@@ -908,7 +908,9 @@ public class AttachmentTextInputPanelNode: ASDisplayNode, TGCaptionPanelView, AS
908908 }
909909 self . textPlaceholderNode. isHidden = inputHasText
910910
911- let textInputFrame = CGRect ( x: leftInset + textFieldInsets. left, y: textFieldInsets. top, width: baseWidth - textFieldInsets. left - textFieldInsets. right, height: panelHeight - textFieldInsets. top - textFieldInsets. bottom)
911+ let additionalRightInset = self . updateFieldAndButtonsLayout ( inputHasText: inputHasText, panelHeight: panelHeight, transition: transition)
912+
913+ let textInputFrame = CGRect ( x: leftInset + textFieldInsets. left, y: textFieldInsets. top, width: baseWidth - textFieldInsets. left - textFieldInsets. right - additionalRightInset, height: panelHeight - textFieldInsets. top - textFieldInsets. bottom)
912914 transition. updateFrame ( node: self . textInputContainer, frame: textInputFrame)
913915
914916 if let textInputNode = self . textInputNode {
@@ -923,16 +925,14 @@ public class AttachmentTextInputPanelNode: ASDisplayNode, TGCaptionPanelView, AS
923925 }
924926 }
925927
926- self . updateFieldAndButtonsLayout ( inputHasText: inputHasText, panelHeight: panelHeight, transition: transition)
927-
928928 self . actionButtons. updateAccessibility ( )
929929
930930 return panelHeight
931931 }
932932
933- private func updateFieldAndButtonsLayout( inputHasText: Bool , panelHeight: CGFloat , transition: ContainedViewLayoutTransition ) {
933+ private func updateFieldAndButtonsLayout( inputHasText: Bool , panelHeight: CGFloat , transition: ContainedViewLayoutTransition ) -> CGFloat {
934934 guard let ( width, leftInset, rightInset, additionalSideInsets, _, metrics, _) = self . validLayout else {
935- return
935+ return 0.0
936936 }
937937 var textFieldMinHeight : CGFloat = 33.0
938938 if let presentationInterfaceState = self . presentationInterfaceState {
@@ -954,6 +954,11 @@ public class AttachmentTextInputPanelNode: ASDisplayNode, TGCaptionPanelView, AS
954954 let baseWidth = width - leftInset - rightInset
955955 let textInputFrame = self . textInputContainer. frame
956956
957+ var textFieldInsets = self . textFieldInsets ( metrics: metrics)
958+ if additionalSideInsets. right > 0.0 {
959+ textFieldInsets. right += additionalSideInsets. right / 3.0
960+ }
961+
957962 var textBackgroundInset : CGFloat = 0.0
958963 let actionButtonsSize : CGSize
959964 if let presentationInterfaceState = self . presentationInterfaceState {
@@ -968,24 +973,19 @@ public class AttachmentTextInputPanelNode: ASDisplayNode, TGCaptionPanelView, AS
968973 text = presentationInterfaceState. strings. MediaPicker_Send
969974 }
970975 actionButtonsSize = self . actionButtons. updateLayout ( size: CGSize ( width: 44.0 , height: minimalHeight) , transition: transition, minimized: isMinimized, text: text, interfaceState: presentationInterfaceState)
971- textBackgroundInset = 44.0 - actionButtonsSize . width
976+ textBackgroundInset = actionButtonsSize . width - 44.0
972977 } else {
973978 actionButtonsSize = CGSize ( width: 44.0 , height: minimalHeight)
974979 }
975980
976- var textFieldInsets = self . textFieldInsets ( metrics: metrics)
977- if additionalSideInsets. right > 0.0 {
978- textFieldInsets. right += additionalSideInsets. right / 3.0
979- }
980-
981981 let actionButtonsFrame = CGRect ( origin: CGPoint ( x: width - rightInset - actionButtonsSize. width + 1.0 - UIScreenPixel + composeButtonsOffset, y: panelHeight - minimalHeight) , size: actionButtonsSize)
982982 transition. updateFrame ( node: self . actionButtons, frame: actionButtonsFrame)
983983
984- let textInputBackgroundFrame = CGRect ( origin: CGPoint ( ) , size: CGSize ( width: textInputFrame. size. width + composeButtonsOffset + textBackgroundInset , height: textInputFrame. size. height) )
984+ let textInputBackgroundFrame = CGRect ( origin: CGPoint ( ) , size: CGSize ( width: textInputFrame. size. width + composeButtonsOffset, height: textInputFrame. size. height) )
985985 transition. updateFrame ( node: self . textInputContainerBackgroundNode, frame: textInputBackgroundFrame)
986986
987- transition. updateFrame ( layer: self . textInputBackgroundNode. layer, frame: CGRect ( x: leftInset + textFieldInsets. left, y: textFieldInsets. top, width: baseWidth - textFieldInsets. left - textFieldInsets. right + composeButtonsOffset + textBackgroundInset, height: panelHeight - textFieldInsets. top - textFieldInsets. bottom) )
988- transition. updateFrame ( layer: self . textInputBackgroundImageNode. layer, frame: CGRect ( x: 0.0 , y: 0.0 , width: baseWidth - textFieldInsets. left - textFieldInsets. right + composeButtonsOffset + textBackgroundInset, height: panelHeight - textFieldInsets. top - textFieldInsets. bottom) )
987+ transition. updateFrame ( layer: self . textInputBackgroundNode. layer, frame: CGRect ( x: leftInset + textFieldInsets. left, y: textFieldInsets. top, width: baseWidth - textFieldInsets. left - textFieldInsets. right + composeButtonsOffset - textBackgroundInset, height: panelHeight - textFieldInsets. top - textFieldInsets. bottom) )
988+ transition. updateFrame ( layer: self . textInputBackgroundImageNode. layer, frame: CGRect ( x: 0.0 , y: 0.0 , width: baseWidth - textFieldInsets. left - textFieldInsets. right + composeButtonsOffset - textBackgroundInset, height: panelHeight - textFieldInsets. top - textFieldInsets. bottom) )
989989
990990 var textInputViewRealInsets = UIEdgeInsets ( )
991991 if let presentationInterfaceState = self . presentationInterfaceState {
@@ -1027,6 +1027,8 @@ public class AttachmentTextInputPanelNode: ASDisplayNode, TGCaptionPanelView, AS
10271027 placeholderFrame = CGRect ( origin: CGPoint ( x: leftInset + textFieldInsets. left + self . textInputViewInternalInsets. left, y: textFieldInsets. top + self . textInputViewInternalInsets. top + textInputViewRealInsets. top + UIScreenPixel) , size: self . textPlaceholderNode. frame. size)
10281028 }
10291029 transition. updateFrame ( node: self . textPlaceholderNode, frame: placeholderFrame)
1030+
1031+ return textBackgroundInset
10301032 }
10311033
10321034 private var skipUpdate = false
@@ -1387,7 +1389,7 @@ public class AttachmentTextInputPanelNode: ASDisplayNode, TGCaptionPanelView, AS
13871389
13881390 let panelHeight = self . updateTextHeight ( animated: animated)
13891391 if self . isAttachment, let panelHeight = panelHeight {
1390- self . updateFieldAndButtonsLayout ( inputHasText: inputHasText, panelHeight: panelHeight, transition: . animated( duration: 0.2 , curve: . easeInOut) )
1392+ let _ = self . updateFieldAndButtonsLayout ( inputHasText: inputHasText, panelHeight: panelHeight, transition: . animated( duration: 0.2 , curve: . easeInOut) )
13911393 }
13921394 }
13931395
0 commit comments