mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 21:16:35 +00:00
Web app improvements
This commit is contained in:
parent
2894c8ca0b
commit
1dd34bb4a8
@ -86,7 +86,7 @@ public enum ParsedInternalUrl {
|
|||||||
case share(url: String?, text: String?, to: String?)
|
case share(url: String?, text: String?, to: String?)
|
||||||
case wallpaper(WallpaperUrlParameter)
|
case wallpaper(WallpaperUrlParameter)
|
||||||
case theme(String)
|
case theme(String)
|
||||||
case phone(String)
|
case phone(String, String?, String?)
|
||||||
case startAttach(String, String?)
|
case startAttach(String, String?)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +223,21 @@ public func parseInternalUrl(query: String) -> ParsedInternalUrl? {
|
|||||||
} else if pathComponents[0].hasPrefix("+") || pathComponents[0].hasPrefix("%20") {
|
} else if pathComponents[0].hasPrefix("+") || pathComponents[0].hasPrefix("%20") {
|
||||||
let component = pathComponents[0].replacingOccurrences(of: "%20", with: "+")
|
let component = pathComponents[0].replacingOccurrences(of: "%20", with: "+")
|
||||||
if component.rangeOfCharacter(from: CharacterSet(charactersIn: "0123456789+").inverted) == nil {
|
if component.rangeOfCharacter(from: CharacterSet(charactersIn: "0123456789+").inverted) == nil {
|
||||||
return .phone(component.replacingOccurrences(of: "+", with: ""))
|
var attach: String?
|
||||||
|
var startAttach: String?
|
||||||
|
if let queryItems = components.queryItems {
|
||||||
|
for queryItem in queryItems {
|
||||||
|
if let value = queryItem.value {
|
||||||
|
if queryItem.name == "attach" {
|
||||||
|
attach = value
|
||||||
|
} else if queryItem.name == "startattach" {
|
||||||
|
startAttach = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return .phone(component.replacingOccurrences(of: "+", with: ""), attach, startAttach)
|
||||||
} else {
|
} else {
|
||||||
return .join(String(component.dropFirst()))
|
return .join(String(component.dropFirst()))
|
||||||
}
|
}
|
||||||
@ -422,14 +436,26 @@ public func parseInternalUrl(query: String) -> ParsedInternalUrl? {
|
|||||||
|
|
||||||
private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) -> Signal<ResolvedUrl?, NoError> {
|
private func resolveInternalUrl(context: AccountContext, url: ParsedInternalUrl) -> Signal<ResolvedUrl?, NoError> {
|
||||||
switch url {
|
switch url {
|
||||||
case let .phone(phone):
|
case let .phone(phone, attach, startAttach):
|
||||||
return context.engine.peers.resolvePeerByPhone(phone: phone)
|
return context.engine.peers.resolvePeerByPhone(phone: phone)
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> map { peer -> ResolvedUrl? in
|
|> mapToSignal { peer -> Signal<ResolvedUrl?, NoError> in
|
||||||
if let peer = peer?._asPeer() {
|
if let peer = peer?._asPeer() {
|
||||||
return .peer(peer.id, .chat(textInputState: nil, subject: nil, peekData: nil))
|
if let attach = attach {
|
||||||
|
return context.engine.peers.resolvePeerByName(name: attach)
|
||||||
|
|> take(1)
|
||||||
|
|> map { botPeer -> ResolvedUrl? in
|
||||||
|
if let botPeer = botPeer?._asPeer() {
|
||||||
|
return .peer(peer.id, .withAttachBot(ChatControllerInitialAttachBotStart(botId: botPeer.id, payload: startAttach)))
|
||||||
|
} else {
|
||||||
|
return .peer(peer.id, .chat(textInputState: nil, subject: nil, peekData: nil))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return .single(.peer(peer.id, .chat(textInputState: nil, subject: nil, peekData: nil)))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return .peer(nil, .info)
|
return .single(.peer(nil, .info))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case let .peerName(name, parameter):
|
case let .peerName(name, parameter):
|
||||||
|
|||||||
@ -85,14 +85,34 @@ final class WebAppWebView: WKWebView {
|
|||||||
|
|
||||||
|
|
||||||
func updateFrame(frame: CGRect, panning: Bool, transition: ContainedViewLayoutTransition) {
|
func updateFrame(frame: CGRect, panning: Bool, transition: ContainedViewLayoutTransition) {
|
||||||
|
let reset = { [weak self] in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for (_, view, snapshotView) in strongSelf.currentFixedViews {
|
||||||
|
view.isHidden = false
|
||||||
|
snapshotView.removeFromSuperview()
|
||||||
|
}
|
||||||
|
strongSelf.currentFixedViews = []
|
||||||
|
}
|
||||||
|
|
||||||
|
let update = { [weak self] in
|
||||||
|
guard let strongSelf = self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for (_, view, snapshotView) in strongSelf.currentFixedViews {
|
||||||
|
view.isHidden = true
|
||||||
|
|
||||||
|
var snapshotFrame = view.frame
|
||||||
|
snapshotFrame.origin.y = frame.height - snapshotFrame.height
|
||||||
|
transition.updateFrame(view: snapshotView, frame: snapshotFrame)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if panning {
|
if panning {
|
||||||
let fixedPositionViews = findFixedPositionViews(webView: self, classes: self.fixedPositionClasses)
|
let fixedPositionViews = findFixedPositionViews(webView: self, classes: self.fixedPositionClasses)
|
||||||
if fixedPositionViews.count != self.currentFixedViews.count {
|
if fixedPositionViews.count != self.currentFixedViews.count {
|
||||||
for (_, view, snapshotView) in self.currentFixedViews {
|
reset()
|
||||||
view.alpha = 1.0
|
|
||||||
snapshotView.removeFromSuperview()
|
|
||||||
}
|
|
||||||
self.currentFixedViews = []
|
|
||||||
|
|
||||||
var updatedFixedViews: [(String, UIView, UIView)] = []
|
var updatedFixedViews: [(String, UIView, UIView)] = []
|
||||||
for (className, view) in fixedPositionViews {
|
for (className, view) in fixedPositionViews {
|
||||||
@ -103,31 +123,12 @@ final class WebAppWebView: WKWebView {
|
|||||||
}
|
}
|
||||||
self.currentFixedViews = updatedFixedViews
|
self.currentFixedViews = updatedFixedViews
|
||||||
}
|
}
|
||||||
|
|
||||||
transition.updateFrame(view: self, frame: frame)
|
transition.updateFrame(view: self, frame: frame)
|
||||||
|
update()
|
||||||
for (_, view, snapshotView) in self.currentFixedViews {
|
|
||||||
view.alpha = 0.0
|
|
||||||
|
|
||||||
var snapshotFrame = view.frame
|
|
||||||
snapshotFrame.origin.y = frame.height - snapshotFrame.height
|
|
||||||
transition.updateFrame(view: snapshotView, frame: snapshotFrame)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
for (_, view, snapshotView) in self.currentFixedViews {
|
update()
|
||||||
view.alpha = 0.0
|
|
||||||
|
|
||||||
var snapshotFrame = view.frame
|
|
||||||
snapshotFrame.origin.y = frame.height - snapshotFrame.height
|
|
||||||
transition.updateFrame(view: snapshotView, frame: snapshotFrame)
|
|
||||||
}
|
|
||||||
|
|
||||||
transition.updateFrame(view: self, frame: frame, completion: { _ in
|
transition.updateFrame(view: self, frame: frame, completion: { _ in
|
||||||
for (_, view, snapshotView) in self.currentFixedViews {
|
reset()
|
||||||
view.alpha = 1.0
|
|
||||||
snapshotView.removeFromSuperview()
|
|
||||||
}
|
|
||||||
self.currentFixedViews = []
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user