mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
ec074f650d
commit
9ba7e6e735
@ -12487,3 +12487,6 @@ Sorry for the inconvenience.";
|
||||
"ChatList.DeleteForMe" = "Delete for me";
|
||||
"ChatList.DeleteForAllWhenPossible" = "Delete from both sides where possible";
|
||||
"ChatList.DeleteForAll" = "Delete from both sides";
|
||||
|
||||
"WebApp.Miniapp" = "miniapp";
|
||||
"WebApp.Share" = "Share";
|
||||
|
@ -153,10 +153,9 @@ class BarsComponentController: GeneralChartComponentController {
|
||||
func verticalLimitsLabels(verticalRange: ClosedRange<CGFloat>, secondary: Bool) -> (ClosedRange<CGFloat>, [LinesChartLabel]) {
|
||||
var (range, labels) = super.verticalLimitsLabels(verticalRange: verticalRange)
|
||||
if secondary {
|
||||
let allowedChars = "0123456789\(self.verticalLimitsNumberFormatter.decimalSeparator ?? ".")"
|
||||
var updatedLabels: [LinesChartLabel] = []
|
||||
for label in labels {
|
||||
let convertedValue = (Double(label.text.filter(allowedChars.contains)) ?? 0.0) * self.conversionRate
|
||||
let convertedValue = (self.verticalLimitsNumberFormatter.number(from: label.text) as? Double ?? 0.0) * self.conversionRate
|
||||
let text: String
|
||||
if convertedValue > 1.0 {
|
||||
text = String(format: "%0.1f", convertedValue)
|
||||
|
@ -14,9 +14,12 @@ swift_library(
|
||||
"//submodules/AsyncDisplayKit",
|
||||
"//submodules/Display",
|
||||
"//submodules/TelegramPresentationData",
|
||||
"//submodules/ComponentFlow",
|
||||
"//submodules/AccountContext",
|
||||
"//submodules/UIKitRuntimeUtils",
|
||||
"//submodules/ComponentFlow",
|
||||
"//submodules/Components/MultilineTextComponent",
|
||||
"//submodules/Components/BundleIconComponent",
|
||||
"//submodules/TelegramUI/Components/PlainButtonComponent",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -12,11 +12,11 @@ private let minimizedNavigationHeight: CGFloat = 44.0
|
||||
private let minimizedTopMargin: CGFloat = 3.0
|
||||
|
||||
final class ScrollViewImpl: UIScrollView {
|
||||
var passthrough = false
|
||||
var shouldPassthrough: () -> Bool = { return false }
|
||||
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
let result = super.hitTest(point, with: event)
|
||||
if result === self && self.passthrough {
|
||||
if result === self && self.shouldPassthrough() {
|
||||
return nil
|
||||
}
|
||||
return result
|
||||
@ -36,6 +36,13 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
||||
}
|
||||
}
|
||||
|
||||
final class SnapshotContainerView: UIView {
|
||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||
self.removeFromSuperview()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
final class ItemNode: ASDisplayNode {
|
||||
var theme: PresentationTheme {
|
||||
didSet {
|
||||
@ -54,7 +61,7 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
||||
private let shadowNode: ASImageNode
|
||||
|
||||
private var controllerView: UIView?
|
||||
fileprivate let snapshotContainerView = UIView()
|
||||
fileprivate let snapshotContainerView = SnapshotContainerView()
|
||||
fileprivate var snapshotView: UIView?
|
||||
fileprivate var blurredSnapshotView: UIView?
|
||||
|
||||
@ -372,6 +379,12 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
||||
self.scrollView.alwaysBounceVertical = true
|
||||
self.scrollView.showsVerticalScrollIndicator = false
|
||||
self.scrollView.showsHorizontalScrollIndicator = false
|
||||
self.scrollView.shouldPassthrough = { [weak self] in
|
||||
guard let self else {
|
||||
return true
|
||||
}
|
||||
return !self.isExpanded
|
||||
}
|
||||
|
||||
let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
|
||||
panGestureRecognizer.delegate = self.wrappedGestureRecognizerDelegate
|
||||
@ -648,6 +661,12 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
||||
})
|
||||
])
|
||||
])
|
||||
actionSheet.dismissed = { cancelled in
|
||||
guard cancelled else {
|
||||
return
|
||||
}
|
||||
completion(false)
|
||||
}
|
||||
self.navigationController?.presentOverlay(controller: actionSheet, inGlobal: false, blockInteraction: false)
|
||||
}
|
||||
|
||||
@ -926,7 +945,6 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
||||
if self.scrollView.frame != bounds {
|
||||
self.scrollView.frame = bounds
|
||||
}
|
||||
self.scrollView.passthrough = !self.isExpanded
|
||||
self.scrollView.isScrollEnabled = self.isExpanded
|
||||
self.expandedTapGestureRecoginzer?.isEnabled = self.isExpanded
|
||||
|
||||
@ -1010,10 +1028,11 @@ public class MinimizedContainerImpl: ASDisplayNode, MinimizedContainer, ASScroll
|
||||
|
||||
if let _ = itemNode.snapshotView {
|
||||
let snapshotContainerView = itemNode.snapshotContainerView
|
||||
snapshotContainerView.isUserInteractionEnabled = true
|
||||
snapshotContainerView.layer.allowsGroupOpacity = true
|
||||
snapshotContainerView.center = CGPoint(x: itemNode.item.controller.displayNode.view.bounds.width / 2.0, y: snapshotContainerView.bounds.height / 2.0)
|
||||
itemNode.item.controller.displayNode.view.addSubview(snapshotContainerView)
|
||||
Queue.mainQueue().after(0.15, {
|
||||
Queue.mainQueue().after(0.35, {
|
||||
snapshotContainerView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.25, removeOnCompletion: false, completion: { _ in
|
||||
snapshotContainerView.removeFromSuperview()
|
||||
})
|
||||
|
@ -4,40 +4,62 @@ import AsyncDisplayKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
import ComponentFlow
|
||||
import MultilineTextComponent
|
||||
import BundleIconComponent
|
||||
import PlainButtonComponent
|
||||
|
||||
private final class WeakController {
|
||||
private weak var _value: MinimizableController?
|
||||
|
||||
public var value: MinimizableController? {
|
||||
return self._value
|
||||
}
|
||||
|
||||
public init(_ value: MinimizableController) {
|
||||
self._value = value
|
||||
}
|
||||
}
|
||||
|
||||
final class MinimizedHeaderNode: ASDisplayNode {
|
||||
var theme: NavigationControllerTheme {
|
||||
didSet {
|
||||
self.minimizedBackgroundNode.backgroundColor = self.theme.navigationBar.opaqueBackgroundColor
|
||||
self.minimizedCloseButton.setImage(generateTintedImage(image: UIImage(bundleImageName: "Instant View/Close"), color: self.theme.navigationBar.primaryTextColor), for: .normal)
|
||||
self.backgroundView.backgroundColor = self.theme.navigationBar.opaqueBackgroundColor
|
||||
}
|
||||
}
|
||||
let strings: PresentationStrings
|
||||
|
||||
private let minimizedBackgroundNode: ASDisplayNode
|
||||
private let minimizedTitleNode: ImmediateTextNode
|
||||
private let minimizedCloseButton: HighlightableButtonNode
|
||||
private var minimizedTitleDisposable: Disposable?
|
||||
private let backgroundView = UIView()
|
||||
private var iconView = UIImageView()
|
||||
private let titleLabel = ComponentView<Empty>()
|
||||
private let closeButton = ComponentView<Empty>()
|
||||
private var titleDisposable: Disposable?
|
||||
|
||||
private var _controllers: [Weak<ViewController>] = []
|
||||
var controllers: [ViewController] {
|
||||
private var _controllers: [WeakController] = []
|
||||
var controllers: [MinimizableController] {
|
||||
get {
|
||||
return self._controllers.compactMap { $0.value }
|
||||
}
|
||||
set {
|
||||
if !newValue.isEmpty {
|
||||
if self.controllers.count == 1, let icon = self.controllers.first?.minimizedIcon {
|
||||
self.icon = icon
|
||||
} else {
|
||||
self.icon = nil
|
||||
}
|
||||
|
||||
if newValue.count != self.controllers.count {
|
||||
self._controllers = newValue.map { Weak($0) }
|
||||
self._controllers = newValue.map { WeakController($0) }
|
||||
|
||||
self.minimizedTitleDisposable?.dispose()
|
||||
self.minimizedTitleDisposable = nil
|
||||
self.titleDisposable?.dispose()
|
||||
self.titleDisposable = nil
|
||||
|
||||
var signals: [Signal<String?, NoError>] = []
|
||||
for controller in newValue {
|
||||
signals.append(controller.titleSignal)
|
||||
}
|
||||
|
||||
self.minimizedTitleDisposable = (combineLatest(signals)
|
||||
self.titleDisposable = (combineLatest(signals)
|
||||
|> deliverOnMainQueue).start(next: { [weak self] titles in
|
||||
guard let self else {
|
||||
return
|
||||
@ -54,8 +76,19 @@ final class MinimizedHeaderNode: ASDisplayNode {
|
||||
})
|
||||
}
|
||||
} else {
|
||||
self.minimizedTitleDisposable?.dispose()
|
||||
self.minimizedTitleDisposable = nil
|
||||
self.icon = nil
|
||||
|
||||
self.titleDisposable?.dispose()
|
||||
self.titleDisposable = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var icon: UIImage? {
|
||||
didSet {
|
||||
self.iconView.image = self.icon
|
||||
if let (size, insets, isExpanded) = self.validLayout {
|
||||
self.update(size: size, insets: insets, isExpanded: isExpanded, transition: .immediate)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -77,42 +110,32 @@ final class MinimizedHeaderNode: ASDisplayNode {
|
||||
self.theme = theme
|
||||
self.strings = strings
|
||||
|
||||
self.minimizedBackgroundNode = ASDisplayNode()
|
||||
self.minimizedBackgroundNode.cornerRadius = 10.0
|
||||
self.minimizedBackgroundNode.clipsToBounds = true
|
||||
self.minimizedBackgroundNode.backgroundColor = theme.navigationBar.opaqueBackgroundColor
|
||||
self.backgroundView.clipsToBounds = true
|
||||
self.backgroundView.backgroundColor = theme.navigationBar.opaqueBackgroundColor
|
||||
self.backgroundView.layer.cornerRadius = 10.0
|
||||
if #available(iOS 11.0, *) {
|
||||
self.minimizedBackgroundNode.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
|
||||
self.backgroundView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
|
||||
}
|
||||
|
||||
self.minimizedTitleNode = ImmediateTextNode()
|
||||
|
||||
self.minimizedCloseButton = HighlightableButtonNode()
|
||||
self.minimizedCloseButton.setImage(generateTintedImage(image: UIImage(bundleImageName: "Instant View/Close"), color: self.theme.navigationBar.primaryTextColor), for: .normal)
|
||||
|
||||
self.iconView.clipsToBounds = true
|
||||
self.iconView.layer.cornerRadius = 2.5
|
||||
|
||||
super.init()
|
||||
|
||||
self.clipsToBounds = true
|
||||
|
||||
self.addSubnode(self.minimizedBackgroundNode)
|
||||
self.minimizedBackgroundNode.addSubnode(self.minimizedTitleNode)
|
||||
self.minimizedBackgroundNode.addSubnode(self.minimizedCloseButton)
|
||||
|
||||
self.minimizedCloseButton.addTarget(self, action: #selector(self.closePressed), forControlEvents: .touchUpInside)
|
||||
|
||||
applySmoothRoundedCorners(self.minimizedBackgroundNode.layer)
|
||||
self.view.addSubview(self.backgroundView)
|
||||
self.backgroundView.addSubview(self.iconView)
|
||||
|
||||
applySmoothRoundedCorners(self.backgroundView.layer)
|
||||
}
|
||||
|
||||
override func didLoad() {
|
||||
super.didLoad()
|
||||
|
||||
self.minimizedBackgroundNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.maximizeTapGesture(_:))))
|
||||
self.backgroundView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.maximizeTapGesture(_:))))
|
||||
}
|
||||
|
||||
@objc private func closePressed() {
|
||||
self.requestClose()
|
||||
}
|
||||
|
||||
|
||||
@objc private func maximizeTapGesture(_ recognizer: UITapGestureRecognizer) {
|
||||
if case .ended = recognizer.state {
|
||||
let location = recognizer.location(in: self.view)
|
||||
@ -128,19 +151,74 @@ final class MinimizedHeaderNode: ASDisplayNode {
|
||||
self.validLayout = (size, insets, isExpanded)
|
||||
|
||||
let headerHeight: CGFloat = 44.0
|
||||
let titleSpacing: CGFloat = 4.0
|
||||
var titleSideInset: CGFloat = 56.0
|
||||
if !isExpanded {
|
||||
titleSideInset += insets.left
|
||||
}
|
||||
|
||||
self.minimizedTitleNode.attributedText = NSAttributedString(string: self.title ?? "", font: Font.bold(17.0), textColor: self.theme.navigationBar.primaryTextColor)
|
||||
let iconSize = CGSize(width: 20.0, height: 20.0)
|
||||
|
||||
let titleSize = self.titleLabel.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(
|
||||
MultilineTextComponent(text: .plain(NSAttributedString(string: self.title ?? "", font: Font.bold(17.0), textColor: self.theme.navigationBar.primaryTextColor)), horizontalAlignment: .center, maximumNumberOfLines: 1)
|
||||
),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: size.width - titleSideInset * 2.0, height: headerHeight)
|
||||
)
|
||||
|
||||
let titleSize = self.minimizedTitleNode.updateLayout(CGSize(width: size.width - titleSideInset * 2.0, height: headerHeight))
|
||||
let titleFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - titleSize.width) / 2.0), y: floorToScreenPixels((headerHeight - titleSize.height) / 2.0)), size: titleSize)
|
||||
self.minimizedTitleNode.bounds = CGRect(origin: .zero, size: titleFrame.size)
|
||||
transition.updatePosition(node: self.minimizedTitleNode, position: titleFrame.center)
|
||||
transition.updateFrame(node: self.minimizedCloseButton, frame: CGRect(origin: CGPoint(x: isExpanded ? 0.0 : insets.left, y: 0.0), size: CGSize(width: 44.0, height: 44.0)))
|
||||
var totalWidth = titleSize.width
|
||||
if isExpanded, let icon = self.icon {
|
||||
self.iconView.image = icon
|
||||
totalWidth += iconSize.width + titleSpacing
|
||||
} else {
|
||||
self.iconView.image = nil
|
||||
}
|
||||
|
||||
transition.updateFrame(node: self.minimizedBackgroundNode, frame: CGRect(origin: .zero, size: CGSize(width: size.width, height: 243.0)))
|
||||
let iconFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - totalWidth) / 2.0), y: floorToScreenPixels((headerHeight - iconSize.height) / 2.0)), size: iconSize)
|
||||
transition.updateFrame(view: self.iconView, frame: iconFrame)
|
||||
|
||||
let titleFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - totalWidth) / 2.0) + totalWidth - titleSize.width, y: floorToScreenPixels((headerHeight - titleSize.height) / 2.0)), size: titleSize)
|
||||
if let view = self.titleLabel.view {
|
||||
if view.superview == nil {
|
||||
self.backgroundView.addSubview(view)
|
||||
}
|
||||
|
||||
view.bounds = CGRect(origin: .zero, size: titleFrame.size)
|
||||
transition.updatePosition(layer: view.layer, position: titleFrame.center)
|
||||
}
|
||||
|
||||
let _ = self.closeButton.update(
|
||||
transition: .immediate,
|
||||
component: AnyComponent(
|
||||
PlainButtonComponent(
|
||||
content: AnyComponent(
|
||||
BundleIconComponent(
|
||||
name: "Instant View/Close",
|
||||
tintColor: self.theme.navigationBar.primaryTextColor
|
||||
)
|
||||
),
|
||||
effectAlignment: .center,
|
||||
minSize: CGSize(width: 44.0, height: 44.0),
|
||||
action: { [weak self] in
|
||||
self?.requestClose()
|
||||
},
|
||||
animateScale: false
|
||||
)
|
||||
),
|
||||
environment: {},
|
||||
containerSize: CGSize(width: 44.0, height: 44.0)
|
||||
)
|
||||
let closeButtonFrame = CGRect(origin: CGPoint(x: isExpanded ? 0.0 : insets.left, y: 0.0), size: CGSize(width: 44.0, height: 44.0))
|
||||
if let view = self.closeButton.view {
|
||||
if view.superview == nil {
|
||||
self.backgroundView.addSubview(view)
|
||||
}
|
||||
|
||||
transition.updateFrame(view: view, frame: closeButtonFrame)
|
||||
}
|
||||
|
||||
transition.updateFrame(view: self.backgroundView, frame: CGRect(origin: .zero, size: CGSize(width: size.width, height: 243.0)))
|
||||
}
|
||||
}
|
||||
|
@ -5282,7 +5282,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
||||
}
|
||||
let context = self.context
|
||||
let peerId = self.peerId
|
||||
let params = WebAppParameters(source: .settings, peerId: self.context.account.peerId, botId: bot.peer.id, botName: bot.peer.compactDisplayTitle, url: nil, queryId: nil, payload: nil, buttonText: nil, keepAliveSignal: nil, forceHasSettings: bot.flags.contains(.hasSettings), fullSize: true)
|
||||
let params = WebAppParameters(source: .settings, peerId: self.context.account.peerId, botId: bot.peer.id, botName: bot.peer.compactDisplayTitle, botVerified: bot.peer.isVerified, url: nil, queryId: nil, payload: nil, buttonText: nil, keepAliveSignal: nil, forceHasSettings: bot.flags.contains(.hasSettings), fullSize: true)
|
||||
|
||||
var openUrlImpl: ((String, Bool, @escaping () -> Void) -> Void)?
|
||||
var presentImpl: ((ViewController, Any?) -> Void)?
|
||||
|
@ -1808,7 +1808,7 @@ final class StoryItemSetContainerSendMessage {
|
||||
//TODO:gift controller
|
||||
break
|
||||
case let .app(bot):
|
||||
let params = WebAppParameters(source: .attachMenu, peerId: peer.id, botId: bot.peer.id, botName: bot.shortName, url: nil, queryId: nil, payload: nil, buttonText: nil, keepAliveSignal: nil, forceHasSettings: false, fullSize: true)
|
||||
let params = WebAppParameters(source: .attachMenu, peerId: peer.id, botId: bot.peer.id, botName: bot.shortName, botVerified: bot.peer.isVerified, url: nil, queryId: nil, payload: nil, buttonText: nil, keepAliveSignal: nil, forceHasSettings: false, fullSize: true)
|
||||
let theme = component.theme
|
||||
let updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>) = (component.context.sharedContext.currentPresentationData.with({ $0 }).withUpdated(theme: theme), component.context.sharedContext.presentationData |> map { $0.withUpdated(theme: theme) })
|
||||
let controller = WebAppController(context: component.context, updatedPresentationData: updatedPresentationData, params: params, replyToMessageId: nil, threadId: nil)
|
||||
|
@ -24,12 +24,15 @@ public extension ChatControllerImpl {
|
||||
|
||||
let botName: String
|
||||
let botAddress: String
|
||||
let botVerified: Bool
|
||||
if case let .inline(bot) = source {
|
||||
botName = bot.compactDisplayTitle
|
||||
botAddress = bot.addressName ?? ""
|
||||
botVerified = bot.isVerified
|
||||
} else {
|
||||
botName = EnginePeer(peer).displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder)
|
||||
botAddress = peer.addressName ?? ""
|
||||
botVerified = peer.isVerified
|
||||
}
|
||||
|
||||
if source == .generic {
|
||||
@ -98,7 +101,7 @@ public extension ChatControllerImpl {
|
||||
}
|
||||
|
||||
var presentImpl: ((ViewController, Any?) -> Void)?
|
||||
let params = WebAppParameters(source: .menu, peerId: peerId, botId: peerId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, forceHasSettings: false, fullSize: fullSize)
|
||||
let params = WebAppParameters(source: .menu, peerId: peerId, botId: peerId, botName: botName, botVerified: botVerified, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, forceHasSettings: false, fullSize: fullSize)
|
||||
let controller = standaloneWebAppController(context: self.context, updatedPresentationData: self.updatedPresentationData, params: params, threadId: self.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
||||
ChatControllerImpl.botOpenUrl(context: context, peerId: peerId, controller: self, url: url, concealed: concealed, present: { c, a in
|
||||
presentImpl?(c, a)
|
||||
@ -145,11 +148,13 @@ public extension ChatControllerImpl {
|
||||
var botId = peerId
|
||||
var botName = botName
|
||||
var botAddress = ""
|
||||
var botVerified = false
|
||||
if case let .inline(bot) = source {
|
||||
isInline = true
|
||||
botId = bot.id
|
||||
botName = bot.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder)
|
||||
botAddress = bot.addressName ?? ""
|
||||
botVerified = bot.isVerified
|
||||
}
|
||||
|
||||
self.messageActionCallbackDisposable.set(((self.context.engine.messages.requestSimpleWebView(botId: botId, url: url, source: isInline ? .inline : .generic, themeParams: generateWebAppThemeParams(self.presentationData.theme))
|
||||
@ -162,7 +167,7 @@ public extension ChatControllerImpl {
|
||||
}
|
||||
var presentImpl: ((ViewController, Any?) -> Void)?
|
||||
let context = strongSelf.context
|
||||
let params = WebAppParameters(source: isInline ? .inline : .simple, peerId: peerId, botId: botId, botName: botName, url: result.url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, forceHasSettings: false, fullSize: result.flags.contains(.fullSize))
|
||||
let params = WebAppParameters(source: isInline ? .inline : .simple, peerId: peerId, botId: botId, botName: botName, botVerified: botVerified, url: result.url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, forceHasSettings: false, fullSize: result.flags.contains(.fullSize))
|
||||
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
||||
ChatControllerImpl.botOpenUrl(context: context, peerId: peerId, controller: self, url: url, concealed: concealed, present: { c, a in
|
||||
presentImpl?(c, a)
|
||||
@ -196,7 +201,7 @@ public extension ChatControllerImpl {
|
||||
}
|
||||
var presentImpl: ((ViewController, Any?) -> Void)?
|
||||
let context = strongSelf.context
|
||||
let params = WebAppParameters(source: .button, peerId: peerId, botId: peerId, botName: botName, url: result.url, queryId: result.queryId, payload: nil, buttonText: buttonText, keepAliveSignal: result.keepAliveSignal, forceHasSettings: false, fullSize: result.flags.contains(.fullSize))
|
||||
let params = WebAppParameters(source: .button, peerId: peerId, botId: peerId, botName: botName, botVerified: botVerified, url: result.url, queryId: result.queryId, payload: nil, buttonText: buttonText, keepAliveSignal: result.keepAliveSignal, forceHasSettings: false, fullSize: result.flags.contains(.fullSize))
|
||||
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
||||
ChatControllerImpl.botOpenUrl(context: context, peerId: peerId, controller: self, url: url, concealed: concealed, present: { c, a in
|
||||
presentImpl?(c, a)
|
||||
@ -401,7 +406,7 @@ public extension ChatControllerImpl {
|
||||
return
|
||||
}
|
||||
let context = strongSelf.context
|
||||
let params = WebAppParameters(source: .generic, peerId: peerId, botId: botPeer.id, botName: botApp.title, url: result.url, queryId: 0, payload: payload, buttonText: "", keepAliveSignal: nil, forceHasSettings: botApp.flags.contains(.hasSettings), fullSize: result.flags.contains(.fullSize))
|
||||
let params = WebAppParameters(source: .generic, peerId: peerId, botId: botPeer.id, botName: botApp.title, botVerified: botPeer.isVerified, url: result.url, queryId: 0, payload: payload, buttonText: "", keepAliveSignal: nil, forceHasSettings: botApp.flags.contains(.hasSettings), fullSize: result.flags.contains(.fullSize))
|
||||
var presentImpl: ((ViewController, Any?) -> Void)?
|
||||
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, threadId: strongSelf.chatLocation.threadId, openUrl: { [weak self] url, concealed, commit in
|
||||
ChatControllerImpl.botOpenUrl(context: context, peerId: peerId, controller: self, url: url, concealed: concealed, present: { c, a in
|
||||
|
@ -615,7 +615,7 @@ extension ChatControllerImpl {
|
||||
payload = botPayload
|
||||
fromAttachMenu = false
|
||||
}
|
||||
let params = WebAppParameters(source: fromAttachMenu ? .attachMenu : .generic, peerId: peer.id, botId: bot.peer.id, botName: bot.shortName, url: nil, queryId: nil, payload: payload, buttonText: nil, keepAliveSignal: nil, forceHasSettings: false, fullSize: false)
|
||||
let params = WebAppParameters(source: fromAttachMenu ? .attachMenu : .generic, peerId: peer.id, botId: bot.peer.id, botName: bot.shortName, botVerified: bot.peer.isVerified, url: nil, queryId: nil, payload: payload, buttonText: nil, keepAliveSignal: nil, forceHasSettings: false, fullSize: false)
|
||||
let replyMessageSubject = strongSelf.presentationInterfaceState.interfaceState.replyMessageSubject
|
||||
let controller = WebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, replyToMessageId: replyMessageSubject?.messageId, threadId: strongSelf.chatLocation.threadId)
|
||||
controller.openUrl = { [weak self] url, concealed, commit in
|
||||
|
@ -18,7 +18,6 @@ swift_library(
|
||||
"//submodules/PresentationDataUtils:PresentationDataUtils",
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
"//submodules/AttachmentUI:AttachmentUI",
|
||||
"//submodules/CounterControllerTitleView:CounterControllerTitleView",
|
||||
"//submodules/HexColor:HexColor",
|
||||
"//submodules/PhotoResources:PhotoResources",
|
||||
"//submodules/ShimmerEffect:ShimmerEffect",
|
||||
@ -35,7 +34,11 @@ swift_library(
|
||||
"//submodules/TextFormat:TextFormat",
|
||||
"//submodules/LocalAuth",
|
||||
"//submodules/InstantPageCache",
|
||||
"//submodules/OpenInExternalAppUI"
|
||||
"//submodules/OpenInExternalAppUI",
|
||||
"//submodules/ComponentFlow",
|
||||
"//submodules/TelegramUI/Components/EmojiStatusComponent",
|
||||
"//submodules/ShareController",
|
||||
"//submodules/UndoUI",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
|
@ -9,7 +9,6 @@ import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
import AccountContext
|
||||
import AttachmentUI
|
||||
import CounterControllerTitleView
|
||||
import ContextUI
|
||||
import PresentationDataUtils
|
||||
import HexColor
|
||||
@ -26,6 +25,8 @@ import InstantPageUI
|
||||
import InstantPageCache
|
||||
import LocalAuth
|
||||
import OpenInExternalAppUI
|
||||
import ShareController
|
||||
import UndoUI
|
||||
|
||||
private let durgerKingBotIds: [Int64] = [5104055776, 2200339955]
|
||||
|
||||
@ -204,6 +205,7 @@ public struct WebAppParameters {
|
||||
let peerId: PeerId
|
||||
let botId: PeerId
|
||||
let botName: String
|
||||
let botVerified: Bool
|
||||
let url: String?
|
||||
let queryId: Int64?
|
||||
let payload: String?
|
||||
@ -217,6 +219,7 @@ public struct WebAppParameters {
|
||||
peerId: PeerId,
|
||||
botId: PeerId,
|
||||
botName: String,
|
||||
botVerified: Bool,
|
||||
url: String?,
|
||||
queryId: Int64?,
|
||||
payload: String?,
|
||||
@ -229,6 +232,7 @@ public struct WebAppParameters {
|
||||
self.peerId = peerId
|
||||
self.botId = botId
|
||||
self.botName = botName
|
||||
self.botVerified = botVerified
|
||||
self.url = url
|
||||
self.queryId = queryId
|
||||
self.payload = payload
|
||||
@ -504,7 +508,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
guard let self, let parsedUrl = URL(string: result.url) else {
|
||||
return
|
||||
}
|
||||
self.controller?.titleView?.title = CounterControllerTitle(title: appStart.botApp.title, counter: self.presentationData.strings.Bot_GenericBotStatus)
|
||||
self.controller?.titleView?.title = WebAppTitle(title: appStart.botApp.title, counter: self.presentationData.strings.WebApp_Miniapp, isVerified: controller.botVerified)
|
||||
self.webView?.load(URLRequest(url: parsedUrl))
|
||||
})
|
||||
})
|
||||
@ -1839,7 +1843,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
return self.displayNode as! Node
|
||||
}
|
||||
|
||||
private var titleView: CounterControllerTitleView?
|
||||
private var titleView: WebAppTitleView?
|
||||
fileprivate let cancelButtonNode: WebAppCancelButtonNode
|
||||
fileprivate let moreButtonNode: MoreButtonNode
|
||||
|
||||
@ -1848,6 +1852,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
private let peerId: PeerId
|
||||
public let botId: PeerId
|
||||
private let botName: String
|
||||
private let botVerified: Bool
|
||||
private let url: String?
|
||||
private let queryId: Int64?
|
||||
private let payload: String?
|
||||
@ -1874,6 +1879,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
self.peerId = params.peerId
|
||||
self.botId = params.botId
|
||||
self.botName = params.botName
|
||||
self.botVerified = params.botVerified
|
||||
self.url = params.url
|
||||
self.queryId = params.queryId
|
||||
self.payload = params.payload
|
||||
@ -1910,8 +1916,8 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
self.navigationItem.rightBarButtonItem?.action = #selector(self.moreButtonPressed)
|
||||
self.navigationItem.rightBarButtonItem?.target = self
|
||||
|
||||
let titleView = CounterControllerTitleView(theme: self.presentationData.theme)
|
||||
titleView.title = CounterControllerTitle(title: params.botName, counter: self.presentationData.strings.Bot_GenericBotStatus)
|
||||
let titleView = WebAppTitleView(context: self.context, theme: self.presentationData.theme)
|
||||
titleView.title = WebAppTitle(title: params.botName, counter: self.presentationData.strings.WebApp_Miniapp, isVerified: params.botVerified)
|
||||
self.navigationItem.titleView = titleView
|
||||
self.titleView = titleView
|
||||
|
||||
@ -2020,9 +2026,12 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
|
||||
let hasSettings = self.hasSettings
|
||||
|
||||
let items = context.engine.messages.attachMenuBots()
|
||||
let items = combineLatest(queue: Queue.mainQueue(),
|
||||
context.engine.messages.attachMenuBots(),
|
||||
context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: self.botId))
|
||||
)
|
||||
|> take(1)
|
||||
|> map { [weak self] attachMenuBots -> ContextController.Items in
|
||||
|> map { [weak self] attachMenuBots, botPeer -> ContextController.Items in
|
||||
var items: [ContextMenuItem] = []
|
||||
|
||||
let attachMenuBot = attachMenuBots.first(where: { $0.peer.id == botId && !$0.flags.contains(.notActivated) })
|
||||
@ -2064,6 +2073,24 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
})))
|
||||
}
|
||||
|
||||
if let addressName = botPeer?.addressName {
|
||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.WebApp_Share, icon: { theme in
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: theme.contextMenu.primaryColor)
|
||||
}, action: { [weak self] c, _ in
|
||||
c?.dismiss(completion: nil)
|
||||
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
let shareController = ShareController(context: context, subject: .url("https://t.me/\(addressName)"))
|
||||
shareController.actionCompleted = { [weak self] in
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
self?.present(UndoOverlayController(presentationData: presentationData, content: .linkCopied(text: presentationData.strings.Conversation_LinkCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .window(.root))
|
||||
}
|
||||
self.present(shareController, in: .window(.root))
|
||||
})))
|
||||
}
|
||||
|
||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.WebApp_ReloadPage, icon: { theme in
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Reload"), color: theme.contextMenu.primaryColor)
|
||||
}, action: { [weak self] c, _ in
|
||||
@ -2178,8 +2205,12 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
|
||||
public var isMinimized: Bool = false {
|
||||
didSet {
|
||||
if self.isMinimized != oldValue && self.isMinimized {
|
||||
self.controllerNode.webView?.hideScrollIndicators()
|
||||
if self.isMinimized != oldValue {
|
||||
if self.isMinimized {
|
||||
self.controllerNode.webView?.hideScrollIndicators()
|
||||
} else {
|
||||
self.requestLayout(transition: .immediate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user