mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various improvements
This commit is contained in:
parent
5451053195
commit
d92c751b6f
@ -31,11 +31,12 @@ extension BotAppSettings {
|
||||
extension BotVerifierSettings {
|
||||
init(apiBotVerifierSettings: Api.BotVerifierSettings) {
|
||||
switch apiBotVerifierSettings {
|
||||
case let .botVerifierSettings(_, iconFileId, companyName, customDescription):
|
||||
case let .botVerifierSettings(flags, iconFileId, companyName, customDescription):
|
||||
self.init(
|
||||
iconFileId: iconFileId,
|
||||
companyName: companyName,
|
||||
customDescription: customDescription
|
||||
customDescription: customDescription,
|
||||
canModifyDescription: (flags & (1 << 1)) != 0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -102,17 +102,20 @@ public struct BotVerifierSettings: PostboxCoding, Equatable {
|
||||
public let iconFileId: Int64
|
||||
public let companyName: String
|
||||
public let customDescription: String?
|
||||
public let canModifyDescription: Bool
|
||||
|
||||
public init(iconFileId: Int64, companyName: String, customDescription: String?) {
|
||||
public init(iconFileId: Int64, companyName: String, customDescription: String?, canModifyDescription: Bool) {
|
||||
self.iconFileId = iconFileId
|
||||
self.companyName = companyName
|
||||
self.customDescription = customDescription
|
||||
self.canModifyDescription = canModifyDescription
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.iconFileId = decoder.decodeInt64ForKey("i", orElse: 0)
|
||||
self.companyName = decoder.decodeStringForKey("cn", orElse: "")
|
||||
self.customDescription = decoder.decodeOptionalStringForKey("d")
|
||||
self.canModifyDescription = decoder.decodeBoolForKey("md", orElse: false)
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
@ -123,6 +126,7 @@ public struct BotVerifierSettings: PostboxCoding, Equatable {
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "d")
|
||||
}
|
||||
encoder.encodeBool(self.canModifyDescription, forKey: "md")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,11 +268,11 @@ public struct PresentationResourcesChatList {
|
||||
public static func locationIcon(_ theme: PresentationTheme) -> UIImage? {
|
||||
return theme.image(PresentationResourceKey.chatListLocationIcon.rawValue, { theme in
|
||||
if let image = UIImage(bundleImageName: "Chat/Attach Menu/Location") {
|
||||
return generateImage(image.size, contextGenerator: { size, context in
|
||||
return generateImage(CGSize(width: 20.0, height: 20.0), contextGenerator: { size, context in
|
||||
if let cgImage = image.cgImage {
|
||||
context.clear(CGRect(origin: CGPoint(), size: size))
|
||||
|
||||
context.clip(to: CGRect(origin: .zero, size: size).insetBy(dx: 5.0, dy: 5.0), mask: cgImage)
|
||||
context.clip(to: CGRect(origin: .zero, size: size), mask: cgImage)
|
||||
context.setFillColor(theme.chatList.muteIconColor.cgColor)
|
||||
context.fill(CGRect(origin: CGPoint(), size: size))
|
||||
}
|
||||
|
@ -413,7 +413,7 @@ public func verifyAlertController(context: AccountContext, updatedPresentationDa
|
||||
})]
|
||||
|
||||
//TODO:localize
|
||||
let contentNode = VerifyAlertContentNode(context: context, theme: AlertControllerTheme(presentationData: presentationData), presentationTheme: presentationData.theme, strings: presentationData.strings, actions: actions, title: "Verify Account", text: "Do you want to verify this account with your verification mark and description?", peer: peer, verifierSettings: verifierSettings, verifierIcon: verifierIcon, hasInput: true)
|
||||
let contentNode = VerifyAlertContentNode(context: context, theme: AlertControllerTheme(presentationData: presentationData), presentationTheme: presentationData.theme, strings: presentationData.strings, actions: actions, title: "Verify Account", text: "Do you want to verify this account with your verification mark and description?", peer: peer, verifierSettings: verifierSettings, verifierIcon: verifierIcon, hasInput: verifierSettings.canModifyDescription)
|
||||
contentNode.complete = {
|
||||
applyImpl?()
|
||||
}
|
||||
|
@ -452,7 +452,7 @@ public extension ChatControllerImpl {
|
||||
self.attachmentController?.dismiss(animated: true, completion: nil)
|
||||
|
||||
if let botApp {
|
||||
let openBotApp: (Bool, Bool) -> Void = { [weak self] allowWrite, justInstalled in
|
||||
let openBotApp: (Bool, Bool, BotAppSettings?) -> Void = { [weak self] allowWrite, justInstalled, appSettings in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
@ -510,7 +510,7 @@ public extension ChatControllerImpl {
|
||||
return
|
||||
}
|
||||
let context = strongSelf.context
|
||||
let params = WebAppParameters(source: .generic, peerId: peerId, botId: botPeer.id, botName: botApp.title, botVerified: botPeer.isVerified, botAddress: botPeer.addressName ?? "", appName: botApp.shortName, url: result.url, queryId: 0, payload: payload, buttonText: "", keepAliveSignal: nil, forceHasSettings: botApp.flags.contains(.hasSettings), fullSize: result.flags.contains(.fullSize), isFullscreen: result.flags.contains(.fullScreen), appSettings: nil)
|
||||
let params = WebAppParameters(source: .generic, peerId: peerId, botId: botPeer.id, botName: botApp.title, botVerified: botPeer.isVerified, botAddress: botPeer.addressName ?? "", appName: botApp.shortName, url: result.url, queryId: 0, payload: payload, buttonText: "", keepAliveSignal: nil, forceHasSettings: botApp.flags.contains(.hasSettings), fullSize: result.flags.contains(.fullSize), isFullscreen: result.flags.contains(.fullScreen), appSettings: appSettings)
|
||||
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, forceUpdate, commit in
|
||||
ChatControllerImpl.botOpenUrl(context: context, peerId: peerId, controller: self, url: url, concealed: concealed, forceUpdate: forceUpdate, present: { c, a in
|
||||
@ -551,8 +551,9 @@ public extension ChatControllerImpl {
|
||||
|> map(Optional.init)
|
||||
|> `catch` { _ -> Signal<AttachMenuBot?, NoError> in
|
||||
return .single(nil)
|
||||
}
|
||||
).startStandalone(next: { [weak self] noticed, attachMenuBots, attachMenuBot in
|
||||
},
|
||||
self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.BotAppSettings(id: botPeer.id))
|
||||
).startStandalone(next: { [weak self] noticed, attachMenuBots, attachMenuBot, appSettings in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
@ -575,17 +576,17 @@ public extension ChatControllerImpl {
|
||||
let _ = (context.engine.messages.addBotToAttachMenu(botId: botPeer.id, allowWrite: allowWrite)
|
||||
|> deliverOnMainQueue).startStandalone(error: { _ in
|
||||
}, completed: {
|
||||
openBotApp(allowWrite, true)
|
||||
openBotApp(allowWrite, true, appSettings)
|
||||
})
|
||||
})
|
||||
self.present(controller, in: .window(.root))
|
||||
} else {
|
||||
openBotApp(false, false)
|
||||
openBotApp(false, false, appSettings)
|
||||
}
|
||||
} else {
|
||||
let controller = webAppLaunchConfirmationController(context: context, updatedPresentationData: self.updatedPresentationData, peer: botPeer, requestWriteAccess: botApp.flags.contains(.notActivated) && botApp.flags.contains(.requiresWriteAccess), completion: { allowWrite in
|
||||
let _ = ApplicationSpecificNotice.setBotGameNotice(accountManager: context.sharedContext.accountManager, peerId: botPeer.id).startStandalone()
|
||||
openBotApp(allowWrite, false)
|
||||
openBotApp(allowWrite, false, appSettings)
|
||||
}, showMore: { [weak self] in
|
||||
if let self {
|
||||
self.openResolved(result: .peer(botPeer._asPeer(), .info(nil)), sourceMessageId: nil)
|
||||
@ -598,7 +599,7 @@ public extension ChatControllerImpl {
|
||||
self.present(controller, in: .window(.root))
|
||||
}
|
||||
} else {
|
||||
openBotApp(false, false)
|
||||
openBotApp(false, false, appSettings)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user