mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +00:00
Various improvements
This commit is contained in:
parent
888fd0254e
commit
9025c8f74d
@ -63,6 +63,7 @@ public final class PeerSelectionControllerParams {
|
|||||||
public let hasTypeHeaders: Bool
|
public let hasTypeHeaders: Bool
|
||||||
public let selectForumThreads: Bool
|
public let selectForumThreads: Bool
|
||||||
public let hasCreation: Bool
|
public let hasCreation: Bool
|
||||||
|
public let immediatelyActivateMultipleSelection: Bool
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
context: AccountContext,
|
context: AccountContext,
|
||||||
@ -82,7 +83,8 @@ public final class PeerSelectionControllerParams {
|
|||||||
forwardedMessageIds: [EngineMessage.Id] = [],
|
forwardedMessageIds: [EngineMessage.Id] = [],
|
||||||
hasTypeHeaders: Bool = false,
|
hasTypeHeaders: Bool = false,
|
||||||
selectForumThreads: Bool = false,
|
selectForumThreads: Bool = false,
|
||||||
hasCreation: Bool = false
|
hasCreation: Bool = false,
|
||||||
|
immediatelyActivateMultipleSelection: Bool = false
|
||||||
) {
|
) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.updatedPresentationData = updatedPresentationData
|
self.updatedPresentationData = updatedPresentationData
|
||||||
@ -102,6 +104,7 @@ public final class PeerSelectionControllerParams {
|
|||||||
self.hasTypeHeaders = hasTypeHeaders
|
self.hasTypeHeaders = hasTypeHeaders
|
||||||
self.selectForumThreads = selectForumThreads
|
self.selectForumThreads = selectForumThreads
|
||||||
self.hasCreation = hasCreation
|
self.hasCreation = hasCreation
|
||||||
|
self.immediatelyActivateMultipleSelection = immediatelyActivateMultipleSelection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -644,14 +644,18 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
|
|||||||
status: status,
|
status: status,
|
||||||
requiresPremiumForMessaging: peerEntry.requiresPremiumForMessaging,
|
requiresPremiumForMessaging: peerEntry.requiresPremiumForMessaging,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
selection: .none,
|
selection: editing ? .selectable(selected: selected) : .none,
|
||||||
editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false),
|
editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false),
|
||||||
index: nil,
|
index: nil,
|
||||||
header: nil,
|
header: nil,
|
||||||
action: { _ in
|
action: { _ in
|
||||||
if let chatPeer = chatPeer {
|
if let chatPeer = chatPeer {
|
||||||
|
if editing {
|
||||||
|
nodeInteraction.togglePeerSelected(chatPeer, nil)
|
||||||
|
} else {
|
||||||
nodeInteraction.peerSelected(chatPeer, nil, nil, nil)
|
nodeInteraction.peerSelected(chatPeer, nil, nil, nil)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, disabledAction: peerEntry.requiresPremiumForMessaging ? { _ in
|
}, disabledAction: peerEntry.requiresPremiumForMessaging ? { _ in
|
||||||
if let chatPeer {
|
if let chatPeer {
|
||||||
nodeInteraction.disabledPeerSelected(chatPeer, nil, .premiumRequired)
|
nodeInteraction.disabledPeerSelected(chatPeer, nil, .premiumRequired)
|
||||||
@ -984,14 +988,18 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
|
|||||||
status: status,
|
status: status,
|
||||||
requiresPremiumForMessaging: peerEntry.requiresPremiumForMessaging,
|
requiresPremiumForMessaging: peerEntry.requiresPremiumForMessaging,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
selection: .none,
|
selection: editing ? .selectable(selected: selected) : .none,
|
||||||
editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false),
|
editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false),
|
||||||
index: nil,
|
index: nil,
|
||||||
header: nil,
|
header: nil,
|
||||||
action: { _ in
|
action: { _ in
|
||||||
if let chatPeer = chatPeer {
|
if let chatPeer = chatPeer {
|
||||||
|
if editing {
|
||||||
|
nodeInteraction.togglePeerSelected(chatPeer, nil)
|
||||||
|
} else {
|
||||||
nodeInteraction.peerSelected(chatPeer, nil, nil, nil)
|
nodeInteraction.peerSelected(chatPeer, nil, nil, nil)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, disabledAction: peerEntry.requiresPremiumForMessaging ? { _ in
|
}, disabledAction: peerEntry.requiresPremiumForMessaging ? { _ in
|
||||||
if let chatPeer {
|
if let chatPeer {
|
||||||
nodeInteraction.disabledPeerSelected(chatPeer, nil, .premiumRequired)
|
nodeInteraction.disabledPeerSelected(chatPeer, nil, .premiumRequired)
|
||||||
|
|||||||
@ -737,7 +737,7 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
|
|||||||
var nextContentOrigin = floor((buttonFrame.width - contentWidth) / 2.0)
|
var nextContentOrigin = floor((buttonFrame.width - contentWidth) / 2.0)
|
||||||
|
|
||||||
let iconFrame: CGRect
|
let iconFrame: CGRect
|
||||||
let titleFrame: CGRect
|
var titleFrame: CGRect
|
||||||
switch self.iconPosition {
|
switch self.iconPosition {
|
||||||
case .left:
|
case .left:
|
||||||
iconFrame = CGRect(origin: CGPoint(x: buttonFrame.minX + nextContentOrigin, y: floor((buttonFrame.height - iconSize.height) / 2.0)), size: iconSize)
|
iconFrame = CGRect(origin: CGPoint(x: buttonFrame.minX + nextContentOrigin, y: floor((buttonFrame.height - iconSize.height) / 2.0)), size: iconSize)
|
||||||
@ -757,7 +757,6 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
|
|||||||
if let animationNode = self.animationNode {
|
if let animationNode = self.animationNode {
|
||||||
transition.updateFrame(node: animationNode, frame: iconFrame)
|
transition.updateFrame(node: animationNode, frame: iconFrame)
|
||||||
}
|
}
|
||||||
transition.updateFrame(node: self.titleNode, frame: titleFrame)
|
|
||||||
|
|
||||||
if let badge = self.badge {
|
if let badge = self.badge {
|
||||||
let badgeNode: BadgeNode
|
let badgeNode: BadgeNode
|
||||||
@ -770,12 +769,15 @@ public final class SolidRoundedButtonNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
badgeNode.text = badge
|
badgeNode.text = badge
|
||||||
let badgeSize = badgeNode.update(CGSize(width: 100.0, height: 100.0))
|
let badgeSize = badgeNode.update(CGSize(width: 100.0, height: 100.0))
|
||||||
transition.updateFrame(node: badgeNode, frame: CGRect(origin: CGPoint(x: titleFrame.maxX + 4.0, y: titleFrame.minY + floor((titleFrame.height - badgeSize.height) * 0.5)), size: badgeSize))
|
titleFrame.origin.x -= badgeSize.width / 2.0
|
||||||
|
transition.updateFrame(node: badgeNode, frame: CGRect(origin: CGPoint(x: titleFrame.maxX + 6.0, y: titleFrame.minY + floorToScreenPixels((titleFrame.height - badgeSize.height) * 0.5)), size: badgeSize))
|
||||||
} else if let badgeNode = self.badgeNode {
|
} else if let badgeNode = self.badgeNode {
|
||||||
self.badgeNode = nil
|
self.badgeNode = nil
|
||||||
badgeNode.removeFromSupernode()
|
badgeNode.removeFromSupernode()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
transition.updateFrame(node: self.titleNode, frame: titleFrame)
|
||||||
|
|
||||||
if self.subtitle != self.subtitleNode.attributedText?.string {
|
if self.subtitle != self.subtitleNode.attributedText?.string {
|
||||||
self.subtitleNode.attributedText = NSAttributedString(string: self.subtitle ?? "", font: Font.regular(14.0), textColor: self.theme.foregroundColor)
|
self.subtitleNode.attributedText = NSAttributedString(string: self.subtitle ?? "", font: Font.regular(14.0), textColor: self.theme.foregroundColor)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -83,7 +83,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
|||||||
dict[1262359766] = { return Api.Boost.parse_boost($0) }
|
dict[1262359766] = { return Api.Boost.parse_boost($0) }
|
||||||
dict[-1778593322] = { return Api.BotApp.parse_botApp($0) }
|
dict[-1778593322] = { return Api.BotApp.parse_botApp($0) }
|
||||||
dict[1571189943] = { return Api.BotApp.parse_botAppNotModified($0) }
|
dict[1571189943] = { return Api.BotApp.parse_botAppNotModified($0) }
|
||||||
dict[-2103898979] = { return Api.BotAppSettings.parse_botAppSettings($0) }
|
dict[-912582320] = { return Api.BotAppSettings.parse_botAppSettings($0) }
|
||||||
dict[-1989921868] = { return Api.BotBusinessConnection.parse_botBusinessConnection($0) }
|
dict[-1989921868] = { return Api.BotBusinessConnection.parse_botBusinessConnection($0) }
|
||||||
dict[-1032140601] = { return Api.BotCommand.parse_botCommand($0) }
|
dict[-1032140601] = { return Api.BotCommand.parse_botCommand($0) }
|
||||||
dict[-1180016534] = { return Api.BotCommandScope.parse_botCommandScopeChatAdmins($0) }
|
dict[-1180016534] = { return Api.BotCommandScope.parse_botCommandScopeChatAdmins($0) }
|
||||||
|
|||||||
@ -1114,16 +1114,16 @@ public extension Api {
|
|||||||
}
|
}
|
||||||
public extension Api {
|
public extension Api {
|
||||||
enum BotAppSettings: TypeConstructorDescription {
|
enum BotAppSettings: TypeConstructorDescription {
|
||||||
case botAppSettings(flags: Int32, placeholderDocument: Api.Document?, backgroundColor: Int32?, backgroundDarkColor: Int32?, headerColor: Int32?, headerDarkColor: Int32?)
|
case botAppSettings(flags: Int32, placeholderPath: Buffer?, backgroundColor: Int32?, backgroundDarkColor: Int32?, headerColor: Int32?, headerDarkColor: Int32?)
|
||||||
|
|
||||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||||
switch self {
|
switch self {
|
||||||
case .botAppSettings(let flags, let placeholderDocument, let backgroundColor, let backgroundDarkColor, let headerColor, let headerDarkColor):
|
case .botAppSettings(let flags, let placeholderPath, let backgroundColor, let backgroundDarkColor, let headerColor, let headerDarkColor):
|
||||||
if boxed {
|
if boxed {
|
||||||
buffer.appendInt32(-2103898979)
|
buffer.appendInt32(-912582320)
|
||||||
}
|
}
|
||||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||||
if Int(flags) & Int(1 << 0) != 0 {placeholderDocument!.serialize(buffer, true)}
|
if Int(flags) & Int(1 << 0) != 0 {serializeBytes(placeholderPath!, buffer: buffer, boxed: false)}
|
||||||
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(backgroundColor!, buffer: buffer, boxed: false)}
|
if Int(flags) & Int(1 << 1) != 0 {serializeInt32(backgroundColor!, buffer: buffer, boxed: false)}
|
||||||
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(backgroundDarkColor!, buffer: buffer, boxed: false)}
|
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(backgroundDarkColor!, buffer: buffer, boxed: false)}
|
||||||
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(headerColor!, buffer: buffer, boxed: false)}
|
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(headerColor!, buffer: buffer, boxed: false)}
|
||||||
@ -1134,18 +1134,16 @@ public extension Api {
|
|||||||
|
|
||||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||||
switch self {
|
switch self {
|
||||||
case .botAppSettings(let flags, let placeholderDocument, let backgroundColor, let backgroundDarkColor, let headerColor, let headerDarkColor):
|
case .botAppSettings(let flags, let placeholderPath, let backgroundColor, let backgroundDarkColor, let headerColor, let headerDarkColor):
|
||||||
return ("botAppSettings", [("flags", flags as Any), ("placeholderDocument", placeholderDocument as Any), ("backgroundColor", backgroundColor as Any), ("backgroundDarkColor", backgroundDarkColor as Any), ("headerColor", headerColor as Any), ("headerDarkColor", headerDarkColor as Any)])
|
return ("botAppSettings", [("flags", flags as Any), ("placeholderPath", placeholderPath as Any), ("backgroundColor", backgroundColor as Any), ("backgroundDarkColor", backgroundDarkColor as Any), ("headerColor", headerColor as Any), ("headerDarkColor", headerDarkColor as Any)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func parse_botAppSettings(_ reader: BufferReader) -> BotAppSettings? {
|
public static func parse_botAppSettings(_ reader: BufferReader) -> BotAppSettings? {
|
||||||
var _1: Int32?
|
var _1: Int32?
|
||||||
_1 = reader.readInt32()
|
_1 = reader.readInt32()
|
||||||
var _2: Api.Document?
|
var _2: Buffer?
|
||||||
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
|
if Int(_1!) & Int(1 << 0) != 0 {_2 = parseBytes(reader) }
|
||||||
_2 = Api.parse(reader, signature: signature) as? Api.Document
|
|
||||||
} }
|
|
||||||
var _3: Int32?
|
var _3: Int32?
|
||||||
if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() }
|
if Int(_1!) & Int(1 << 1) != 0 {_3 = reader.readInt32() }
|
||||||
var _4: Int32?
|
var _4: Int32?
|
||||||
@ -1161,7 +1159,7 @@ public extension Api {
|
|||||||
let _c5 = (Int(_1!) & Int(1 << 3) == 0) || _5 != nil
|
let _c5 = (Int(_1!) & Int(1 << 3) == 0) || _5 != nil
|
||||||
let _c6 = (Int(_1!) & Int(1 << 4) == 0) || _6 != nil
|
let _c6 = (Int(_1!) & Int(1 << 4) == 0) || _6 != nil
|
||||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||||
return Api.BotAppSettings.botAppSettings(flags: _1!, placeholderDocument: _2, backgroundColor: _3, backgroundDarkColor: _4, headerColor: _5, headerDarkColor: _6)
|
return Api.BotAppSettings.botAppSettings(flags: _1!, placeholderPath: _2, backgroundColor: _3, backgroundDarkColor: _4, headerColor: _5, headerDarkColor: _6)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -16,9 +16,9 @@ extension BotMenuButton {
|
|||||||
extension BotAppSettings {
|
extension BotAppSettings {
|
||||||
init(apiBotAppSettings: Api.BotAppSettings) {
|
init(apiBotAppSettings: Api.BotAppSettings) {
|
||||||
switch apiBotAppSettings {
|
switch apiBotAppSettings {
|
||||||
case let .botAppSettings(_, placeholderDocument, backgroundColor, backgroundDarkColor, headerColor, headerDarkColor):
|
case let .botAppSettings(_, placeholder, backgroundColor, backgroundDarkColor, headerColor, headerDarkColor):
|
||||||
self.init(
|
self.init(
|
||||||
placeholder: placeholderDocument.flatMap { telegramMediaFileFromApiDocument($0, altDocuments: []) },
|
placeholderData: placeholder.flatMap { $0.makeData() },
|
||||||
backgroundColor: backgroundColor,
|
backgroundColor: backgroundColor,
|
||||||
backgroundDarkColor: backgroundDarkColor,
|
backgroundDarkColor: backgroundDarkColor,
|
||||||
headerColor: headerColor,
|
headerColor: headerColor,
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import Foundation
|
||||||
import Postbox
|
import Postbox
|
||||||
|
|
||||||
public struct BotCommand: PostboxCoding, Hashable {
|
public struct BotCommand: PostboxCoding, Hashable {
|
||||||
@ -46,14 +47,14 @@ public enum BotMenuButton: PostboxCoding, Hashable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public struct BotAppSettings: PostboxCoding, Equatable {
|
public struct BotAppSettings: PostboxCoding, Equatable {
|
||||||
public let placeholder: TelegramMediaFile?
|
public let placeholderData: Data?
|
||||||
public let backgroundColor: Int32?
|
public let backgroundColor: Int32?
|
||||||
public let backgroundDarkColor: Int32?
|
public let backgroundDarkColor: Int32?
|
||||||
public let headerColor: Int32?
|
public let headerColor: Int32?
|
||||||
public let headerDarkColor: Int32?
|
public let headerDarkColor: Int32?
|
||||||
|
|
||||||
public init(placeholder: TelegramMediaFile?, backgroundColor: Int32?, backgroundDarkColor: Int32?, headerColor: Int32?, headerDarkColor: Int32?) {
|
public init(placeholderData: Data?, backgroundColor: Int32?, backgroundDarkColor: Int32?, headerColor: Int32?, headerDarkColor: Int32?) {
|
||||||
self.placeholder = placeholder
|
self.placeholderData = placeholderData
|
||||||
self.backgroundColor = backgroundColor
|
self.backgroundColor = backgroundColor
|
||||||
self.backgroundDarkColor = backgroundDarkColor
|
self.backgroundDarkColor = backgroundDarkColor
|
||||||
self.headerColor = headerColor
|
self.headerColor = headerColor
|
||||||
@ -61,11 +62,7 @@ public struct BotAppSettings: PostboxCoding, Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
if let placeholder = decoder.decodeObjectForKey("p", decoder: { TelegramMediaFile(decoder: $0) }) as? TelegramMediaFile {
|
self.placeholderData = decoder.decodeDataForKey("pd")
|
||||||
self.placeholder = placeholder
|
|
||||||
} else {
|
|
||||||
self.placeholder = nil
|
|
||||||
}
|
|
||||||
self.backgroundColor = decoder.decodeOptionalInt32ForKey("b")
|
self.backgroundColor = decoder.decodeOptionalInt32ForKey("b")
|
||||||
self.backgroundDarkColor = decoder.decodeOptionalInt32ForKey("bd")
|
self.backgroundDarkColor = decoder.decodeOptionalInt32ForKey("bd")
|
||||||
self.headerColor = decoder.decodeOptionalInt32ForKey("h")
|
self.headerColor = decoder.decodeOptionalInt32ForKey("h")
|
||||||
@ -73,10 +70,10 @@ public struct BotAppSettings: PostboxCoding, Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func encode(_ encoder: PostboxEncoder) {
|
public func encode(_ encoder: PostboxEncoder) {
|
||||||
if let placeholder = self.placeholder {
|
if let placeholderData = self.placeholderData {
|
||||||
encoder.encodeObject(placeholder, forKey: "p")
|
encoder.encodeData(placeholderData, forKey: "pd")
|
||||||
} else {
|
} else {
|
||||||
encoder.encodeNil(forKey: "p")
|
encoder.encodeNil(forKey: "pd")
|
||||||
}
|
}
|
||||||
if let backgroundColor = self.backgroundColor {
|
if let backgroundColor = self.backgroundColor {
|
||||||
encoder.encodeInt32(backgroundColor, forKey: "b")
|
encoder.encodeInt32(backgroundColor, forKey: "b")
|
||||||
|
|||||||
@ -244,7 +244,7 @@ func _internal_requestWebView(postbox: Postbox, network: Network, stateManager:
|
|||||||
if (webViewFlags & (1 << 1)) != 0 {
|
if (webViewFlags & (1 << 1)) != 0 {
|
||||||
resultFlags.insert(.fullSize)
|
resultFlags.insert(.fullSize)
|
||||||
}
|
}
|
||||||
if (flags & (1 << 2)) != 0 {
|
if (webViewFlags & (1 << 2)) != 0 {
|
||||||
resultFlags.insert(.fullScreen)
|
resultFlags.insert(.fullScreen)
|
||||||
}
|
}
|
||||||
let keepAlive: Signal<Never, KeepWebViewError>?
|
let keepAlive: Signal<Never, KeepWebViewError>?
|
||||||
|
|||||||
@ -65,6 +65,7 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon
|
|||||||
private let hasTypeHeaders: Bool
|
private let hasTypeHeaders: Bool
|
||||||
private let requestPeerType: [ReplyMarkupButtonRequestPeerType]?
|
private let requestPeerType: [ReplyMarkupButtonRequestPeerType]?
|
||||||
private let hasCreation: Bool
|
private let hasCreation: Bool
|
||||||
|
let immediatelyActivateMultipleSelection: Bool
|
||||||
|
|
||||||
override public var _presentedInModal: Bool {
|
override public var _presentedInModal: Bool {
|
||||||
get {
|
get {
|
||||||
@ -105,6 +106,7 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon
|
|||||||
self.selectForumThreads = params.selectForumThreads
|
self.selectForumThreads = params.selectForumThreads
|
||||||
self.requestPeerType = params.requestPeerType
|
self.requestPeerType = params.requestPeerType
|
||||||
self.hasCreation = params.hasCreation
|
self.hasCreation = params.hasCreation
|
||||||
|
self.immediatelyActivateMultipleSelection = params.immediatelyActivateMultipleSelection
|
||||||
|
|
||||||
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData))
|
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData))
|
||||||
|
|
||||||
@ -167,7 +169,11 @@ public final class PeerSelectionControllerImpl: ViewController, PeerSelectionCon
|
|||||||
})
|
})
|
||||||
self.navigationBar?.setContentNode(self.searchContentNode, animated: false)
|
self.navigationBar?.setContentNode(self.searchContentNode, animated: false)
|
||||||
|
|
||||||
if params.multipleSelection {
|
if params.immediatelyActivateMultipleSelection {
|
||||||
|
Queue.mainQueue().after(0.1) {
|
||||||
|
self.beginSelection()
|
||||||
|
}
|
||||||
|
} else if params.multipleSelection {
|
||||||
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Select, style: .plain, target: self, action: #selector(self.beginSelection))
|
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Select, style: .plain, target: self, action: #selector(self.beginSelection))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -95,6 +95,8 @@ final class PeerSelectionControllerNode: ASDisplayNode {
|
|||||||
private let animationCache: AnimationCache
|
private let animationCache: AnimationCache
|
||||||
private let animationRenderer: MultiAnimationRenderer
|
private let animationRenderer: MultiAnimationRenderer
|
||||||
|
|
||||||
|
private var countPanelNode: PeersCountPanelNode?
|
||||||
|
|
||||||
private var readyValue = Promise<Bool>()
|
private var readyValue = Promise<Bool>()
|
||||||
var ready: Signal<Bool, NoError> {
|
var ready: Signal<Bool, NoError> {
|
||||||
return self.readyValue.get()
|
return self.readyValue.get()
|
||||||
@ -853,6 +855,26 @@ final class PeerSelectionControllerNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func beginSelection() {
|
func beginSelection() {
|
||||||
|
guard let controller = self.controller else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if controller.immediatelyActivateMultipleSelection {
|
||||||
|
let countPanelNode = PeersCountPanelNode(theme: self.presentationData.theme, strings: self.presentationData.strings, action: { [weak self] in
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
let (selectedPeers, selectedPeerMap) = self.selectedPeers
|
||||||
|
if !self.isEmpty {
|
||||||
|
self.requestSend?(selectedPeers, selectedPeerMap, NSAttributedString(), .generic, nil, nil)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
self.addSubnode(countPanelNode)
|
||||||
|
self.countPanelNode = countPanelNode
|
||||||
|
|
||||||
|
if let (layout, navigationBarHeight, actualNavigationBarHeight) = self.containerLayout {
|
||||||
|
self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, actualNavigationBarHeight: actualNavigationBarHeight, transition: .immediate)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if let _ = self.textInputPanelNode {
|
if let _ = self.textInputPanelNode {
|
||||||
} else {
|
} else {
|
||||||
let forwardAccessoryPanelNode = ForwardAccessoryPanelNode(context: self.context, messageIds: self.forwardedMessageIds, theme: self.presentationData.theme, strings: self.presentationData.strings, fontSize: self.presentationData.chatFontSize, nameDisplayOrder: self.presentationData.nameDisplayOrder, forwardOptionsState: self.presentationInterfaceState.interfaceState.forwardOptionsState, animationCache: nil, animationRenderer: nil)
|
let forwardAccessoryPanelNode = ForwardAccessoryPanelNode(context: self.context, messageIds: self.forwardedMessageIds, theme: self.presentationData.theme, strings: self.presentationData.strings, fontSize: self.presentationData.chatFontSize, nameDisplayOrder: self.presentationData.nameDisplayOrder, forwardOptionsState: self.presentationInterfaceState.interfaceState.forwardOptionsState, animationCache: nil, animationRenderer: nil)
|
||||||
@ -884,6 +906,7 @@ final class PeerSelectionControllerNode: ASDisplayNode {
|
|||||||
self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, actualNavigationBarHeight: actualNavigationBarHeight, transition: .animated(duration: 0.3, curve: .spring))
|
self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, actualNavigationBarHeight: actualNavigationBarHeight, transition: .animated(duration: 0.3, curve: .spring))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if self.contactListActive {
|
if self.contactListActive {
|
||||||
self.contactListNode?.multipleSelection = true
|
self.contactListNode?.multipleSelection = true
|
||||||
@ -901,6 +924,14 @@ final class PeerSelectionControllerNode: ASDisplayNode {
|
|||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
} else if let chatListNode = self.chatListNode {
|
} else if let chatListNode = self.chatListNode {
|
||||||
|
chatListNode.selectionCountChanged = { [weak self] count in
|
||||||
|
if let self {
|
||||||
|
self.countPanelNode?.count = count
|
||||||
|
if let (layout, navigationBarHeight, actualNavigationBarHeight) = self.containerLayout {
|
||||||
|
self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, actualNavigationBarHeight: actualNavigationBarHeight, transition: .animated(duration: 0.3, curve: .spring))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
chatListNode.updateState { state in
|
chatListNode.updateState { state in
|
||||||
var state = state
|
var state = state
|
||||||
state.editing = true
|
state.editing = true
|
||||||
@ -979,7 +1010,15 @@ final class PeerSelectionControllerNode: ASDisplayNode {
|
|||||||
transition.updateFrame(node: forwardAccessoryPanelNode, frame: panelFrame)
|
transition.updateFrame(node: forwardAccessoryPanelNode, frame: panelFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let segmentedControlNode = self.segmentedControlNode, let toolbarBackgroundNode = self.toolbarBackgroundNode, let toolbarSeparatorNode = self.toolbarSeparatorNode {
|
if let countPanelNode = self.countPanelNode {
|
||||||
|
let countPanelHeight = countPanelNode.updateLayout(width: layout.size.width, sideInset: layout.safeInsets.left, bottomInset: layout.intrinsicInsets.bottom, transition: transition)
|
||||||
|
if countPanelNode.count == 0 {
|
||||||
|
transition.updateFrame(node: countPanelNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height), size: CGSize(width: layout.size.width, height: countPanelHeight)))
|
||||||
|
} else {
|
||||||
|
toolbarHeight = countPanelHeight
|
||||||
|
transition.updateFrame(node: countPanelNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height - countPanelHeight), size: CGSize(width: layout.size.width, height: countPanelHeight)))
|
||||||
|
}
|
||||||
|
} else if let segmentedControlNode = self.segmentedControlNode, let toolbarBackgroundNode = self.toolbarBackgroundNode, let toolbarSeparatorNode = self.toolbarSeparatorNode {
|
||||||
if let textPanelHeight = textPanelHeight {
|
if let textPanelHeight = textPanelHeight {
|
||||||
toolbarHeight = textPanelHeight + accessoryHeight
|
toolbarHeight = textPanelHeight + accessoryHeight
|
||||||
} else {
|
} else {
|
||||||
@ -1740,3 +1779,64 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
|
|||||||
func animatedIn() {
|
func animatedIn() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final class PeersCountPanelNode: ASDisplayNode {
|
||||||
|
private let theme: PresentationTheme
|
||||||
|
private let strings: PresentationStrings
|
||||||
|
|
||||||
|
private let separatorNode: ASDisplayNode
|
||||||
|
private let button: SolidRoundedButtonNode
|
||||||
|
|
||||||
|
private var validLayout: (CGFloat, CGFloat, CGFloat)?
|
||||||
|
|
||||||
|
var count: Int = 0 {
|
||||||
|
didSet {
|
||||||
|
if self.count != oldValue && self.count > 0 {
|
||||||
|
//TODO:localize
|
||||||
|
self.button.title = "Send"
|
||||||
|
self.button.badge = "\(self.count)"
|
||||||
|
|
||||||
|
if let (width, sideInset, bottomInset) = self.validLayout {
|
||||||
|
let _ = self.updateLayout(width: width, sideInset: sideInset, bottomInset: bottomInset, transition: .immediate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init(theme: PresentationTheme, strings: PresentationStrings, action: @escaping () -> Void) {
|
||||||
|
self.theme = theme
|
||||||
|
self.strings = strings
|
||||||
|
|
||||||
|
self.separatorNode = ASDisplayNode()
|
||||||
|
self.separatorNode.backgroundColor = theme.rootController.navigationBar.separatorColor
|
||||||
|
|
||||||
|
self.button = SolidRoundedButtonNode(theme: SolidRoundedButtonTheme(theme: theme), height: 48.0, cornerRadius: 10.0)
|
||||||
|
|
||||||
|
super.init()
|
||||||
|
|
||||||
|
self.backgroundColor = theme.rootController.navigationBar.opaqueBackgroundColor
|
||||||
|
|
||||||
|
self.addSubnode(self.button)
|
||||||
|
self.addSubnode(self.separatorNode)
|
||||||
|
|
||||||
|
self.button.pressed = {
|
||||||
|
action()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func updateLayout(width: CGFloat, sideInset: CGFloat, bottomInset: CGFloat, transition: ContainedViewLayoutTransition) -> CGFloat {
|
||||||
|
self.validLayout = (width, sideInset, bottomInset)
|
||||||
|
let topInset: CGFloat = 9.0
|
||||||
|
var bottomInset = bottomInset
|
||||||
|
bottomInset += topInset - (bottomInset.isZero ? 0.0 : 4.0)
|
||||||
|
|
||||||
|
let buttonInset: CGFloat = 16.0 + sideInset
|
||||||
|
let buttonWidth = width - buttonInset * 2.0
|
||||||
|
let buttonHeight = self.button.updateLayout(width: buttonWidth, transition: transition)
|
||||||
|
transition.updateFrame(node: self.button, frame: CGRect(x: buttonInset, y: topInset, width: buttonWidth, height: buttonHeight))
|
||||||
|
|
||||||
|
transition.updateFrame(node: self.separatorNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: width, height: UIScreenPixel)))
|
||||||
|
|
||||||
|
return topInset + buttonHeight + bottomInset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
12
submodules/TelegramUI/Images.xcassets/Chat/Context Menu/AddSquare.imageset/Contents.json
vendored
Normal file
12
submodules/TelegramUI/Images.xcassets/Chat/Context Menu/AddSquare.imageset/Contents.json
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "sqadd.pdf",
|
||||||
|
"idiom" : "universal"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
submodules/TelegramUI/Images.xcassets/Chat/Context Menu/AddSquare.imageset/sqadd.pdf
vendored
Normal file
BIN
submodules/TelegramUI/Images.xcassets/Chat/Context Menu/AddSquare.imageset/sqadd.pdf
vendored
Normal file
Binary file not shown.
@ -601,9 +601,5 @@ func updateChatPresentationInterfaceStateImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let cachedData = selfController.peerView?.cachedData as? CachedUserData, let appSettings = cachedData.botInfo?.appSettings {
|
|
||||||
let _ = WebAppController.preloadAppPlaceholder(context: selfController.context, appSettings: appSettings).startStandalone()
|
|
||||||
}
|
|
||||||
|
|
||||||
selfController.stateUpdated?(transition)
|
selfController.stateUpdated?(transition)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1462,6 +1462,10 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let height = adPanelNode.updateLayout(width: layout.size.width, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: transition, interfaceState: self.chatPresentationInterfaceState)
|
let height = adPanelNode.updateLayout(width: layout.size.width, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: transition, interfaceState: self.chatPresentationInterfaceState)
|
||||||
|
if let adMessage = self.chatPresentationInterfaceState.adMessage, let opaqueId = adMessage.adAttribute?.opaqueId {
|
||||||
|
self.historyNode.markAdAsSeen(opaqueId: opaqueId)
|
||||||
|
}
|
||||||
|
|
||||||
adPanelHeight = height
|
adPanelHeight = height
|
||||||
if transition.isAnimated && animateAppearance {
|
if transition.isAnimated && animateAppearance {
|
||||||
adPanelNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
adPanelNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||||
|
|||||||
@ -49,6 +49,7 @@ swift_library(
|
|||||||
"//submodules/TelegramUI/Components/ListSectionComponent",
|
"//submodules/TelegramUI/Components/ListSectionComponent",
|
||||||
"//submodules/TelegramUI/Components/Chat/ChatMessageItemImpl",
|
"//submodules/TelegramUI/Components/Chat/ChatMessageItemImpl",
|
||||||
"//submodules/DeviceLocationManager",
|
"//submodules/DeviceLocationManager",
|
||||||
|
"//submodules/TelegramUI/Components/Utils/GenerateStickerPlaceholderImage",
|
||||||
],
|
],
|
||||||
visibility = [
|
visibility = [
|
||||||
"//visibility:public",
|
"//visibility:public",
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import TelegramUIPreferences
|
|||||||
import CoreMotion
|
import CoreMotion
|
||||||
import DeviceLocationManager
|
import DeviceLocationManager
|
||||||
import LegacyMediaPickerUI
|
import LegacyMediaPickerUI
|
||||||
|
import GenerateStickerPlaceholderImage
|
||||||
|
|
||||||
private let durgerKingBotIds: [Int64] = [5104055776, 2200339955]
|
private let durgerKingBotIds: [Int64] = [5104055776, 2200339955]
|
||||||
|
|
||||||
@ -259,8 +260,8 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let placeholderFile = controller.botAppSettings?.placeholder {
|
if let _ = controller.botAppSettings?.placeholderData {
|
||||||
placeholder = .single((.standalone(media: placeholderFile), false))
|
placeholder = .single(nil)
|
||||||
} else if durgerKingBotIds.contains(controller.botId.id._internalGetInt64Value()) {
|
} else if durgerKingBotIds.contains(controller.botId.id._internalGetInt64Value()) {
|
||||||
placeholder = .single(nil)
|
placeholder = .single(nil)
|
||||||
|> delay(0.05, queue: Queue.mainQueue())
|
|> delay(0.05, queue: Queue.mainQueue())
|
||||||
@ -293,6 +294,17 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let placeholderData = controller.botAppSettings?.placeholderData {
|
||||||
|
Queue.mainQueue().justDispatch {
|
||||||
|
let size = CGSize(width: 75.0, height: 75.0)
|
||||||
|
if let image = generateStickerPlaceholderImage(data: placeholderData, size: size, scale: min(2.0, UIScreenScale), imageSize: CGSize(width: 512.0, height: 512.0), backgroundColor: nil, foregroundColor: .white) {
|
||||||
|
self.placeholderIcon = (image.withRenderingMode(.alwaysTemplate), false)
|
||||||
|
if let (layout, navigationBarHeight) = self.validLayout {
|
||||||
|
self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .immediate)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
self.placeholderDisposable.set((placeholder
|
self.placeholderDisposable.set((placeholder
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] fileReferenceAndIsPlaceholder in
|
|> deliverOnMainQueue).start(next: { [weak self] fileReferenceAndIsPlaceholder in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
@ -333,6 +345,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
self.iconDisposable = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: controller.botId))
|
self.iconDisposable = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: controller.botId))
|
||||||
|> mapToSignal { peer -> Signal<UIImage?, NoError> in
|
|> mapToSignal { peer -> Signal<UIImage?, NoError> in
|
||||||
@ -768,6 +781,16 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
transition.updateFrame(view: webView, frame: webViewFrame)
|
transition.updateFrame(view: webView, frame: webViewFrame)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let snapshotView = self.fullscreenSwitchSnapshotView {
|
||||||
|
self.fullscreenSwitchSnapshotView = nil
|
||||||
|
|
||||||
|
transition.updatePosition(layer: snapshotView.layer, position: webViewFrame.center)
|
||||||
|
transition.updateTransform(layer: snapshotView.layer, transform: CATransform3DMakeScale(webViewFrame.width / snapshotView.frame.width, webViewFrame.height / snapshotView.frame.height, 1.0))
|
||||||
|
transition.updateAlpha(layer: snapshotView.layer, alpha: 0.0, completion: { _ in
|
||||||
|
snapshotView.removeFromSuperview()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
var customInsets: UIEdgeInsets = .zero
|
var customInsets: UIEdgeInsets = .zero
|
||||||
if controller.isFullscreen {
|
if controller.isFullscreen {
|
||||||
customInsets.top = layout.statusBarHeight ?? 0.0
|
customInsets.top = layout.statusBarHeight ?? 0.0
|
||||||
@ -1410,8 +1433,8 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
self.setIsGyroscopeActive(false)
|
self.setIsGyroscopeActive(false)
|
||||||
case "web_app_set_emoji_status":
|
case "web_app_set_emoji_status":
|
||||||
if let json = json, let emojiIdString = json["custom_emoji_id"] as? String, let emojiId = Int64(emojiIdString) {
|
if let json = json, let emojiIdString = json["custom_emoji_id"] as? String, let emojiId = Int64(emojiIdString) {
|
||||||
let expirationDate = json["expiration_date"] as? Double
|
let duration = json["duration"] as? Double
|
||||||
self.setEmojiStatus(emojiId, expirationDate: expirationDate.flatMap { Int32($0) })
|
self.setEmojiStatus(emojiId, duration: duration.flatMap { Int32($0) })
|
||||||
}
|
}
|
||||||
case "web_app_add_to_home_screen":
|
case "web_app_add_to_home_screen":
|
||||||
self.addToHomeScreen()
|
self.addToHomeScreen()
|
||||||
@ -2066,6 +2089,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var fullscreenSwitchSnapshotView: UIView?
|
||||||
fileprivate func setIsFullscreen(_ isFullscreen: Bool) {
|
fileprivate func setIsFullscreen(_ isFullscreen: Bool) {
|
||||||
guard let controller = self.controller else {
|
guard let controller = self.controller else {
|
||||||
return
|
return
|
||||||
@ -2079,6 +2103,14 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
self.webView?.sendEvent(name: "fullscreen_changed", data: paramsString)
|
self.webView?.sendEvent(name: "fullscreen_changed", data: paramsString)
|
||||||
|
|
||||||
controller.isFullscreen = isFullscreen
|
controller.isFullscreen = isFullscreen
|
||||||
|
|
||||||
|
if let (layout, _) = self.validLayout, case .regular = layout.metrics.widthClass {
|
||||||
|
if let snapshotView = self.webView?.snapshotView(afterScreenUpdates: false) {
|
||||||
|
self.webView?.superview?.addSubview(snapshotView)
|
||||||
|
self.fullscreenSwitchSnapshotView = snapshotView
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(controller.parentController() as? AttachmentController)?.requestLayout(transition: .animated(duration: 0.4, curve: .spring))
|
(controller.parentController() as? AttachmentController)?.requestLayout(transition: .animated(duration: 0.4, curve: .spring))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2467,7 +2499,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func setEmojiStatus(_ fileId: Int64, expirationDate: Int32? = nil) {
|
fileprivate func setEmojiStatus(_ fileId: Int64, duration: Int32? = nil) {
|
||||||
guard let controller = self.controller else {
|
guard let controller = self.controller else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -2489,6 +2521,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
botName: controller.botName,
|
botName: controller.botName,
|
||||||
accountPeer: accountPeer,
|
accountPeer: accountPeer,
|
||||||
file: file,
|
file: file,
|
||||||
|
duration: duration,
|
||||||
completion: { [weak self, weak controller] result in
|
completion: { [weak self, weak controller] result in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
@ -2509,6 +2542,10 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var expirationDate: Int32?
|
||||||
|
if let duration {
|
||||||
|
expirationDate = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970) + duration
|
||||||
|
}
|
||||||
let _ = (self.context.engine.accountData.setEmojiStatus(file: file, expirationDate: expirationDate)
|
let _ = (self.context.engine.accountData.setEmojiStatus(file: file, expirationDate: expirationDate)
|
||||||
|> deliverOnMainQueue).start(completed: { [weak self] in
|
|> deliverOnMainQueue).start(completed: { [weak self] in
|
||||||
self?.webView?.sendEvent(name: "emoji_status_set", data: nil)
|
self?.webView?.sendEvent(name: "emoji_status_set", data: nil)
|
||||||
@ -2550,7 +2587,13 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
if let name = controller.appName {
|
if let name = controller.appName {
|
||||||
appName = "/\(name)"
|
appName = "/\(name)"
|
||||||
}
|
}
|
||||||
let url = URL(string: "x-safari-https://t.me/\(addressName)\(appName)?startapp&addToHomeScreen")!
|
let scheme: String
|
||||||
|
if #available(iOS 18.0, *) {
|
||||||
|
scheme = "x-safari-https"
|
||||||
|
} else {
|
||||||
|
scheme = "https"
|
||||||
|
}
|
||||||
|
let url = URL(string: "\(scheme)://t.me/\(addressName)\(appName)?startapp&addToHomeScreen")!
|
||||||
UIApplication.shared.open(url)
|
UIApplication.shared.open(url)
|
||||||
|
|
||||||
controller.dismiss()
|
controller.dismiss()
|
||||||
@ -2986,7 +3029,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
//TODO:localize
|
//TODO:localize
|
||||||
if let _ = self?.appName {
|
if let _ = self?.appName {
|
||||||
items.append(.action(ContextMenuActionItem(text: "Add to Home Screen", icon: { theme in
|
items.append(.action(ContextMenuActionItem(text: "Add to Home Screen", icon: { theme in
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/AddCircle"), color: theme.contextMenu.primaryColor)
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/AddSquare"), color: theme.contextMenu.primaryColor)
|
||||||
}, action: { [weak self] c, _ in
|
}, action: { [weak self] c, _ in
|
||||||
c?.dismiss(completion: nil)
|
c?.dismiss(completion: nil)
|
||||||
|
|
||||||
@ -3141,7 +3184,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
self.controllerNode.webView?.setNeedsLayout()
|
self.controllerNode.webView?.setNeedsLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.controllerNode.webView?.sendEvent(name: "visibility_changed", data: "{is_visible: \"\(self.isMinimized ? "false" : "true")\"}")
|
self.controllerNode.webView?.sendEvent(name: "visibility_changed", data: "{is_visible: \(self.isMinimized ? "false" : "true")}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3195,30 +3238,6 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
})
|
})
|
||||||
return imageView
|
return imageView
|
||||||
}
|
}
|
||||||
|
|
||||||
public static func preloadAppPlaceholder(context: AccountContext, appSettings: BotAppSettings) -> Signal<Never, NoError> {
|
|
||||||
guard let file = appSettings.placeholder else {
|
|
||||||
return .complete()
|
|
||||||
}
|
|
||||||
let path = context.account.postbox.mediaBox.cachedRepresentationCompletePath(file.resource.id, representation: CachedPreparedSvgRepresentation())
|
|
||||||
if !FileManager.default.fileExists(atPath: path) {
|
|
||||||
let accountFullSizeData = Signal<(Data?, Bool), NoError> { subscriber in
|
|
||||||
let accountResource = context.account.postbox.mediaBox.cachedResourceRepresentation(file.resource, representation: CachedPreparedSvgRepresentation(), complete: false, fetch: true)
|
|
||||||
|
|
||||||
let fetchedFullSize = fetchedMediaResource(mediaBox: context.account.postbox.mediaBox, userLocation: .other, userContentType: MediaResourceUserContentType(file: file), reference: .standalone(resource: file.resource))
|
|
||||||
let fetchedFullSizeDisposable = fetchedFullSize.start()
|
|
||||||
let fullSizeDisposable = accountResource.start()
|
|
||||||
|
|
||||||
return ActionDisposable {
|
|
||||||
fetchedFullSizeDisposable.dispose()
|
|
||||||
fullSizeDisposable.dispose()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return accountFullSizeData
|
|
||||||
|> ignoreValues
|
|
||||||
}
|
|
||||||
return .complete()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class WebAppPickerContext: AttachmentMediaPickerContext {
|
final class WebAppPickerContext: AttachmentMediaPickerContext {
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import PresentationDataUtils
|
|||||||
import ListSectionComponent
|
import ListSectionComponent
|
||||||
import ListItemComponentAdaptor
|
import ListItemComponentAdaptor
|
||||||
import TelegramStringFormatting
|
import TelegramStringFormatting
|
||||||
|
import UndoUI
|
||||||
|
|
||||||
private final class SheetContent: CombinedComponent {
|
private final class SheetContent: CombinedComponent {
|
||||||
typealias EnvironmentType = ViewControllerComponentContainer.Environment
|
typealias EnvironmentType = ViewControllerComponentContainer.Environment
|
||||||
@ -408,18 +409,47 @@ public final class WebAppMessagePreviewScreen: ViewControllerComponentContainer
|
|||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
fileprivate func complete(peer: EnginePeer) {
|
fileprivate func complete(peers: [EnginePeer]) {
|
||||||
self.completeWithResult(true)
|
for peer in peers {
|
||||||
self.dismiss()
|
|
||||||
|
|
||||||
let _ = self.context.engine.messages.enqueueOutgoingMessage(
|
let _ = self.context.engine.messages.enqueueOutgoingMessage(
|
||||||
to: peer.id,
|
to: peer.id,
|
||||||
replyTo: nil,
|
replyTo: nil,
|
||||||
storyId: nil,
|
storyId: nil,
|
||||||
content: .preparedInlineMessage(preparedMessage)
|
content: .preparedInlineMessage(self.preparedMessage)
|
||||||
).start()
|
).start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let text: String
|
||||||
|
let presentationData = self.context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
if peers.count == 1, let peer = peers.first {
|
||||||
|
let peerName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||||
|
text = presentationData.strings.Conversation_ForwardTooltip_Chat_One(peerName).string
|
||||||
|
} else if peers.count == 2, let firstPeer = peers.first, let secondPeer = peers.last {
|
||||||
|
let firstPeerName = firstPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||||
|
let secondPeerName = secondPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||||
|
text = presentationData.strings.Conversation_ForwardTooltip_TwoChats_One(firstPeerName, secondPeerName).string
|
||||||
|
} else if let peer = peers.first {
|
||||||
|
let peerName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||||
|
text = presentationData.strings.Conversation_ForwardTooltip_ManyChats_One(peerName, "\(peers.count - 1)").string
|
||||||
|
} else {
|
||||||
|
text = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if let navigationController = self.navigationController as? NavigationController {
|
||||||
|
Queue.mainQueue().after(1.0) {
|
||||||
|
guard let lastController = navigationController.viewControllers.last as? ViewController else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
lastController.present(UndoOverlayController(presentationData: presentationData, content: .forward(savedMessages: false, text: text), elevatedLayout: false, position: .top, animateInAsReplacement: true, action: { action in
|
||||||
|
return false
|
||||||
|
}), in: .window(.root))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.completeWithResult(true)
|
||||||
|
self.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
private var completed = false
|
private var completed = false
|
||||||
fileprivate func completeWithResult(_ result: Bool) {
|
fileprivate func completeWithResult(_ result: Bool) {
|
||||||
guard !self.completed else {
|
guard !self.completed else {
|
||||||
@ -430,15 +460,17 @@ public final class WebAppMessagePreviewScreen: ViewControllerComponentContainer
|
|||||||
|
|
||||||
fileprivate func proceed() {
|
fileprivate func proceed() {
|
||||||
let requestPeerType = self.preparedMessage.peerTypes.requestPeerTypes
|
let requestPeerType = self.preparedMessage.peerTypes.requestPeerTypes
|
||||||
let controller = self.context.sharedContext.makePeerSelectionController(PeerSelectionControllerParams(context: self.context, filter: [.excludeRecent, .doNotSearchMessages], requestPeerType: requestPeerType, hasContactSelector: false))
|
|
||||||
|
|
||||||
controller.peerSelected = { [weak self, weak controller] peer, _ in
|
let controller = self.context.sharedContext.makePeerSelectionController(PeerSelectionControllerParams(context: self.context, filter: [.excludeRecent, .doNotSearchMessages], requestPeerType: requestPeerType, hasContactSelector: false, multipleSelection: true, immediatelyActivateMultipleSelection: true))
|
||||||
|
|
||||||
|
controller.multiplePeersSelected = { [weak self, weak controller] peers, _, _, _, _, _ in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.complete(peer: peer)
|
self.complete(peers: peers)
|
||||||
controller?.dismiss()
|
controller?.dismiss()
|
||||||
}
|
}
|
||||||
|
|
||||||
self.push(controller)
|
self.push(controller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ private final class SheetContent: CombinedComponent {
|
|||||||
let botName: String
|
let botName: String
|
||||||
let accountPeer: EnginePeer
|
let accountPeer: EnginePeer
|
||||||
let file: TelegramMediaFile
|
let file: TelegramMediaFile
|
||||||
|
let duration: Int32?
|
||||||
let dismiss: () -> Void
|
let dismiss: () -> Void
|
||||||
|
|
||||||
init(
|
init(
|
||||||
@ -32,12 +33,14 @@ private final class SheetContent: CombinedComponent {
|
|||||||
botName: String,
|
botName: String,
|
||||||
accountPeer: EnginePeer,
|
accountPeer: EnginePeer,
|
||||||
file: TelegramMediaFile,
|
file: TelegramMediaFile,
|
||||||
|
duration: Int32?,
|
||||||
dismiss: @escaping () -> Void
|
dismiss: @escaping () -> Void
|
||||||
) {
|
) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.botName = botName
|
self.botName = botName
|
||||||
self.accountPeer = accountPeer
|
self.accountPeer = accountPeer
|
||||||
self.file = file
|
self.file = file
|
||||||
|
self.duration = duration
|
||||||
self.dismiss = dismiss
|
self.dismiss = dismiss
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,10 +152,18 @@ private final class SheetContent: CombinedComponent {
|
|||||||
return (TelegramTextAttributes.URL, contents)
|
return (TelegramTextAttributes.URL, contents)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var textString: String
|
||||||
|
if let _ = component.duration {
|
||||||
|
//TODO:localize
|
||||||
|
textString = "Do you want to set this emoji status suggested by **\(component.botName)** for **5 minutes**?"
|
||||||
|
} else {
|
||||||
|
textString = "Do you want to set this emoji status suggested by **\(component.botName)**?"
|
||||||
|
}
|
||||||
|
|
||||||
let text = text.update(
|
let text = text.update(
|
||||||
component: BalancedTextComponent(
|
component: BalancedTextComponent(
|
||||||
text: .markdown(
|
text: .markdown(
|
||||||
text: "Do you want to set this emoji status suggested by **\(component.botName)**?",
|
text: textString,
|
||||||
attributes: markdownAttributes
|
attributes: markdownAttributes
|
||||||
),
|
),
|
||||||
horizontalAlignment: .center,
|
horizontalAlignment: .center,
|
||||||
@ -229,17 +240,20 @@ private final class WebAppSetEmojiStatusSheetComponent: CombinedComponent {
|
|||||||
private let botName: String
|
private let botName: String
|
||||||
private let accountPeer: EnginePeer
|
private let accountPeer: EnginePeer
|
||||||
private let file: TelegramMediaFile
|
private let file: TelegramMediaFile
|
||||||
|
private let duration: Int32?
|
||||||
|
|
||||||
init(
|
init(
|
||||||
context: AccountContext,
|
context: AccountContext,
|
||||||
botName: String,
|
botName: String,
|
||||||
accountPeer: EnginePeer,
|
accountPeer: EnginePeer,
|
||||||
file: TelegramMediaFile
|
file: TelegramMediaFile,
|
||||||
|
duration: Int32?
|
||||||
) {
|
) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.botName = botName
|
self.botName = botName
|
||||||
self.accountPeer = accountPeer
|
self.accountPeer = accountPeer
|
||||||
self.file = file
|
self.file = file
|
||||||
|
self.duration = duration
|
||||||
}
|
}
|
||||||
|
|
||||||
static func ==(lhs: WebAppSetEmojiStatusSheetComponent, rhs: WebAppSetEmojiStatusSheetComponent) -> Bool {
|
static func ==(lhs: WebAppSetEmojiStatusSheetComponent, rhs: WebAppSetEmojiStatusSheetComponent) -> Bool {
|
||||||
@ -252,6 +266,9 @@ private final class WebAppSetEmojiStatusSheetComponent: CombinedComponent {
|
|||||||
if lhs.accountPeer != rhs.accountPeer {
|
if lhs.accountPeer != rhs.accountPeer {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.duration != rhs.duration {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,6 +288,7 @@ private final class WebAppSetEmojiStatusSheetComponent: CombinedComponent {
|
|||||||
botName: context.component.botName,
|
botName: context.component.botName,
|
||||||
accountPeer: context.component.accountPeer,
|
accountPeer: context.component.accountPeer,
|
||||||
file: context.component.file,
|
file: context.component.file,
|
||||||
|
duration: context.component.duration,
|
||||||
dismiss: {
|
dismiss: {
|
||||||
animateOut.invoke(Action { _ in
|
animateOut.invoke(Action { _ in
|
||||||
if let controller = controller() as? WebAppSetEmojiStatusScreen {
|
if let controller = controller() as? WebAppSetEmojiStatusScreen {
|
||||||
@ -331,6 +349,7 @@ public final class WebAppSetEmojiStatusScreen: ViewControllerComponentContainer
|
|||||||
botName: String,
|
botName: String,
|
||||||
accountPeer: EnginePeer,
|
accountPeer: EnginePeer,
|
||||||
file: TelegramMediaFile,
|
file: TelegramMediaFile,
|
||||||
|
duration: Int32?,
|
||||||
completion: @escaping (Bool) -> Void
|
completion: @escaping (Bool) -> Void
|
||||||
) {
|
) {
|
||||||
self.context = context
|
self.context = context
|
||||||
@ -342,7 +361,8 @@ public final class WebAppSetEmojiStatusScreen: ViewControllerComponentContainer
|
|||||||
context: context,
|
context: context,
|
||||||
botName: botName,
|
botName: botName,
|
||||||
accountPeer: accountPeer,
|
accountPeer: accountPeer,
|
||||||
file: file
|
file: file,
|
||||||
|
duration: duration
|
||||||
),
|
),
|
||||||
navigationBarAppearance: .none,
|
navigationBarAppearance: .none,
|
||||||
statusBarStyle: .ignore,
|
statusBarStyle: .ignore,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user