mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Gift setup improvements
This commit is contained in:
@@ -417,6 +417,33 @@ final class GiftSetupScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc private func previewTap() {
|
||||||
|
func hasFirstResponder(_ view: UIView) -> Bool {
|
||||||
|
if view.isFirstResponder {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
for subview in view.subviews {
|
||||||
|
if hasFirstResponder(subview) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
self.currentInputMode = .keyboard
|
||||||
|
if hasFirstResponder(self) {
|
||||||
|
if let titleView = self.introSection.findTaggedView(tag: self.textInputTag) as? ListMultilineTextFieldItemComponent.View {
|
||||||
|
if titleView.isActive {
|
||||||
|
titleView.deactivateInput()
|
||||||
|
} else {
|
||||||
|
self.endEditing(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
self.state?.updated(transition: .spring(duration: 0.4))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func update(component: GiftSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
func update(component: GiftSetupScreenComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
||||||
self.isUpdating = true
|
self.isUpdating = true
|
||||||
defer {
|
defer {
|
||||||
@@ -693,28 +720,7 @@ final class GiftSetupScreenComponent: Component {
|
|||||||
))))
|
))))
|
||||||
self.resetText = nil
|
self.resetText = nil
|
||||||
|
|
||||||
|
|
||||||
var inputHeight: CGFloat = 0.0
|
|
||||||
inputHeight += self.updateInputMediaNode(
|
|
||||||
component: component,
|
|
||||||
availableSize: availableSize,
|
|
||||||
bottomInset: environment.safeInsets.bottom,
|
|
||||||
inputHeight: 0.0,
|
|
||||||
effectiveInputHeight: environment.deviceMetrics.standardInputHeight(inLandscape: false),
|
|
||||||
metrics: environment.metrics,
|
|
||||||
deviceMetrics: environment.deviceMetrics,
|
|
||||||
transition: transition
|
|
||||||
)
|
|
||||||
if self.inputMediaNode == nil {
|
|
||||||
if environment.inputHeight.isZero && self.textInputState.isEditing, let previousInputHeight = self.previousInputHeight {
|
|
||||||
inputHeight = previousInputHeight
|
|
||||||
} else {
|
|
||||||
inputHeight = environment.inputHeight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let peerName = self.peerMap[component.peerId]?.compactDisplayTitle ?? ""
|
let peerName = self.peerMap[component.peerId]?.compactDisplayTitle ?? ""
|
||||||
|
|
||||||
let introFooter: AnyComponent<Empty>?
|
let introFooter: AnyComponent<Empty>?
|
||||||
switch component.subject {
|
switch component.subject {
|
||||||
case .premium:
|
case .premium:
|
||||||
@@ -751,7 +757,26 @@ final class GiftSetupScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
contentHeight += introSectionSize.height
|
contentHeight += introSectionSize.height
|
||||||
contentHeight += sectionSpacing
|
contentHeight += sectionSpacing
|
||||||
|
|
||||||
|
var inputHeight: CGFloat = 0.0
|
||||||
|
inputHeight += self.updateInputMediaNode(
|
||||||
|
component: component,
|
||||||
|
availableSize: availableSize,
|
||||||
|
bottomInset: environment.safeInsets.bottom,
|
||||||
|
inputHeight: 0.0,
|
||||||
|
effectiveInputHeight: environment.deviceMetrics.standardInputHeight(inLandscape: false),
|
||||||
|
metrics: environment.metrics,
|
||||||
|
deviceMetrics: environment.deviceMetrics,
|
||||||
|
transition: transition
|
||||||
|
)
|
||||||
|
if self.inputMediaNode == nil {
|
||||||
|
if environment.inputHeight.isZero && self.textInputState.isEditing, let previousInputHeight = self.previousInputHeight {
|
||||||
|
inputHeight = previousInputHeight
|
||||||
|
} else {
|
||||||
|
inputHeight = environment.inputHeight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let listItemParams = ListViewItemLayoutParams(width: availableSize.width - sideInset * 2.0, leftInset: 0.0, rightInset: 0.0, availableHeight: 10000.0, isStandalone: true)
|
let listItemParams = ListViewItemLayoutParams(width: availableSize.width - sideInset * 2.0, leftInset: 0.0, rightInset: 0.0, availableHeight: 10000.0, isStandalone: true)
|
||||||
if let accountPeer = self.peerMap[component.context.account.peerId] {
|
if let accountPeer = self.peerMap[component.context.account.peerId] {
|
||||||
let subject: ChatGiftPreviewItem.Subject
|
let subject: ChatGiftPreviewItem.Subject
|
||||||
@@ -793,6 +818,8 @@ final class GiftSetupScreenComponent: Component {
|
|||||||
if introContentView.superview == nil {
|
if introContentView.superview == nil {
|
||||||
if let placeholderView = self.introSection.findTaggedView(tag: self.introPlaceholderTag) {
|
if let placeholderView = self.introSection.findTaggedView(tag: self.introPlaceholderTag) {
|
||||||
placeholderView.addSubview(introContentView)
|
placeholderView.addSubview(introContentView)
|
||||||
|
|
||||||
|
placeholderView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.previewTap)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
transition.setFrame(view: introContentView, frame: CGRect(origin: CGPoint(), size: introContentSize))
|
transition.setFrame(view: introContentView, frame: CGRect(origin: CGPoint(), size: introContentSize))
|
||||||
|
|||||||
@@ -227,12 +227,26 @@ public final class ListMultilineTextFieldItemComponent: Component {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var isActive: Bool {
|
||||||
|
if let textFieldView = self.textField.view as? TextFieldComponent.View {
|
||||||
|
return textFieldView.isActive
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func activateInput() {
|
public func activateInput() {
|
||||||
if let textFieldView = self.textField.view as? TextFieldComponent.View {
|
if let textFieldView = self.textField.view as? TextFieldComponent.View {
|
||||||
textFieldView.activateInput()
|
textFieldView.activateInput()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func deactivateInput() {
|
||||||
|
if let textFieldView = self.textField.view as? TextFieldComponent.View {
|
||||||
|
textFieldView.deactivateInput()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func insertText(text: NSAttributedString) {
|
public func insertText(text: NSAttributedString) {
|
||||||
if let textFieldView = self.textField.view as? TextFieldComponent.View {
|
if let textFieldView = self.textField.view as? TextFieldComponent.View {
|
||||||
textFieldView.insertText(text)
|
textFieldView.insertText(text)
|
||||||
|
|||||||
Reference in New Issue
Block a user