mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various improvements
This commit is contained in:
parent
a2872a6189
commit
8304a9c0a0
@ -143,6 +143,7 @@ final class ContextMenuActionNode: ASDisplayNode {
|
|||||||
|
|
||||||
override func calculateSizeThatFits(_ constrainedSize: CGSize) -> CGSize {
|
override func calculateSizeThatFits(_ constrainedSize: CGSize) -> CGSize {
|
||||||
if let textNode = self.textNode {
|
if let textNode = self.textNode {
|
||||||
|
let constrainedSize = CGSize(width: constrainedSize.width - 36.0 - 24.0, height: constrainedSize.height)
|
||||||
let textSize = textNode.updateLayout(constrainedSize)
|
let textSize = textNode.updateLayout(constrainedSize)
|
||||||
self.textSize = textSize
|
self.textSize = textSize
|
||||||
|
|
||||||
@ -151,7 +152,7 @@ final class ContextMenuActionNode: ASDisplayNode {
|
|||||||
totalWidth += textSize.width
|
totalWidth += textSize.width
|
||||||
|
|
||||||
if let subtitleNode = self.subtitleNode {
|
if let subtitleNode = self.subtitleNode {
|
||||||
let subtitleSize = subtitleNode.updateLayout(constrainedSize)
|
let subtitleSize = subtitleNode.updateLayout(CGSize(width: constrainedSize.width * 0.75, height: constrainedSize.height))
|
||||||
self.subtitleSize = subtitleSize
|
self.subtitleSize = subtitleSize
|
||||||
totalWidth = max(totalWidth, subtitleSize.width)
|
totalWidth = max(totalWidth, subtitleSize.width)
|
||||||
totalHeight += 14.0
|
totalHeight += 14.0
|
||||||
|
@ -204,6 +204,14 @@ private final class SheetContent: CombinedComponent {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
state.selectLink = {
|
||||||
|
if let controller = controller() as? CreateLinkScreen {
|
||||||
|
if let view = controller.node.hostView.findTaggedView(tag: linkTag) as? LinkFieldComponent.View {
|
||||||
|
view.selectAll()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let urlSection = urlSection.update(
|
let urlSection = urlSection.update(
|
||||||
component: ListSectionComponent(
|
component: ListSectionComponent(
|
||||||
theme: theme,
|
theme: theme,
|
||||||
@ -325,6 +333,8 @@ private final class CreateLinkSheetComponent: CombinedComponent {
|
|||||||
private let linkDisposable = MetaDisposable()
|
private let linkDisposable = MetaDisposable()
|
||||||
private let linkPromise = ValuePromise<String>()
|
private let linkPromise = ValuePromise<String>()
|
||||||
|
|
||||||
|
var selectLink: () -> Void = {}
|
||||||
|
|
||||||
init(
|
init(
|
||||||
context: AccountContext,
|
context: AccountContext,
|
||||||
link: CreateLinkScreen.Link?
|
link: CreateLinkScreen.Link?
|
||||||
@ -340,6 +350,20 @@ private final class CreateLinkSheetComponent: CombinedComponent {
|
|||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
|
if link == nil {
|
||||||
|
Queue.mainQueue().after(0.1, {
|
||||||
|
let pasteboard = UIPasteboard.general
|
||||||
|
if pasteboard.hasURLs {
|
||||||
|
if let url = pasteboard.url?.absoluteString, !url.isEmpty {
|
||||||
|
self.link = url
|
||||||
|
self.updated()
|
||||||
|
|
||||||
|
self.selectLink()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
self.linkDisposable.set((self.linkPromise.get()
|
self.linkDisposable.set((self.linkPromise.get()
|
||||||
|> delay(1.5, queue: Queue.mainQueue())
|
|> delay(1.5, queue: Queue.mainQueue())
|
||||||
|> deliverOnMainQueue).startStrict(next: { [weak self] link in
|
|> deliverOnMainQueue).startStrict(next: { [weak self] link in
|
||||||
@ -707,6 +731,10 @@ private final class LinkFieldComponent: Component {
|
|||||||
self.textField.becomeFirstResponder()
|
self.textField.becomeFirstResponder()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func selectAll() {
|
||||||
|
self.textField.selectAll(nil)
|
||||||
|
}
|
||||||
|
|
||||||
func update(component: LinkFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
func update(component: LinkFieldComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<EnvironmentType>, transition: ComponentTransition) -> CGSize {
|
||||||
self.textField.textColor = component.textColor
|
self.textField.textColor = component.textColor
|
||||||
self.textField.text = component.text
|
self.textField.text = component.text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user