Web app improvements

This commit is contained in:
Ilya Laktyushin 2023-09-07 23:54:47 +04:00
parent d86a8785b0
commit 3881bdff70
5 changed files with 11 additions and 11 deletions

View File

@ -9915,7 +9915,7 @@ Sorry for the inconvenience.";
"Gallery.ViewOnceVideoTooltip" = "This video can only be viewed once."; "Gallery.ViewOnceVideoTooltip" = "This video can only be viewed once.";
"WebApp.DisclaimerTitle" = "Warning"; "WebApp.DisclaimerTitle" = "Warning";
"WebApp.DisclaimerText" = "You are about to use a mini app operated by an independent party not affiliated with Telegram. You must agree to the Terms of Use of mini apps to continue."; "WebApp.DisclaimerText" = "You are about to use a mini app operated by an independent party not affiliated with Telegram. You must agree to the Terms of Use of mini apps to continue.\n\n**%@** shortcuts will be added in your attachment menu and Settings.";
"WebApp.DisclaimerAgree" = "I agree to the [Terms of Use]()"; "WebApp.DisclaimerAgree" = "I agree to the [Terms of Use]()";
"WebApp.DisclaimerContinue" = "Continue"; "WebApp.DisclaimerContinue" = "Continue";
"WebApp.Disclaimer_URL" = "https://telegram.org/tos/mini-apps"; "WebApp.Disclaimer_URL" = "https://telegram.org/tos/mini-apps";

View File

@ -13418,7 +13418,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} else { } else {
let _ = (context.engine.messages.getAttachMenuBot(botId: botId) let _ = (context.engine.messages.getAttachMenuBot(botId: botId)
|> deliverOnMainQueue).start(next: { bot in |> deliverOnMainQueue).start(next: { bot in
let controller = webAppTermsAlertController(context: context, updatedPresentationData: strongSelf.updatedPresentationData, peer: bot.peer, requestWriteAccess: bot.flags.contains(.requiresWriteAccess), completion: { allowWrite in let controller = webAppTermsAlertController(context: context, updatedPresentationData: strongSelf.updatedPresentationData, bot: bot, completion: { allowWrite in
let _ = (context.engine.messages.addBotToAttachMenu(botId: botId, allowWrite: allowWrite) let _ = (context.engine.messages.addBotToAttachMenu(botId: botId, allowWrite: allowWrite)
|> deliverOnMainQueue).start(error: { _ in |> deliverOnMainQueue).start(error: { _ in

View File

@ -669,7 +669,7 @@ func openResolvedUrlImpl(_ resolvedUrl: ResolvedUrl, context: AccountContext, ur
|> deliverOnMainQueue).start(next: { bot in |> deliverOnMainQueue).start(next: { bot in
let choose = filterChooseTypes(choose, peerTypes: bot.peerTypes) let choose = filterChooseTypes(choose, peerTypes: bot.peerTypes)
let controller = webAppTermsAlertController(context: context, updatedPresentationData: updatedPresentationData, peer: bot.peer, requestWriteAccess: bot.flags.contains(.requiresWriteAccess), completion: { allowWrite in let controller = webAppTermsAlertController(context: context, updatedPresentationData: updatedPresentationData, bot: bot, completion: { allowWrite in
let _ = (context.engine.messages.addBotToAttachMenu(botId: peerId, allowWrite: allowWrite) let _ = (context.engine.messages.addBotToAttachMenu(botId: peerId, allowWrite: allowWrite)
|> deliverOnMainQueue).start(error: { _ in |> deliverOnMainQueue).start(error: { _ in
presentError(presentationData.strings.WebApp_AddToAttachmentUnavailableError) presentError(presentationData.strings.WebApp_AddToAttachmentUnavailableError)

View File

@ -4665,8 +4665,8 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
})) }))
} }
if bot.flags.contains(.showInSettingsDisclaimer) { if bot.flags.contains(.notActivated) || bot.flags.contains(.showInSettingsDisclaimer) {
let alertController = webAppTermsAlertController(context: self.context, updatedPresentationData: controller.updatedPresentationData, peer: bot.peer, requestWriteAccess: bot.flags.contains(.requiresWriteAccess), completion: { [weak self] allowWrite in let alertController = webAppTermsAlertController(context: self.context, updatedPresentationData: controller.updatedPresentationData, bot: bot, completion: { [weak self] allowWrite in
guard let self else { guard let self else {
return return
} }

View File

@ -17,8 +17,8 @@ import TextFormat
private let textFont = Font.regular(13.0) private let textFont = Font.regular(13.0)
private let boldTextFont = Font.semibold(13.0) private let boldTextFont = Font.semibold(13.0)
private func formattedText(_ text: String, color: UIColor, linkColor: UIColor, textAlignment: NSTextAlignment = .natural) -> NSAttributedString { private func formattedText(_ text: String, fontSize: CGFloat, color: UIColor, linkColor: UIColor, textAlignment: NSTextAlignment = .natural) -> NSAttributedString {
return parseMarkdownIntoAttributedString(text, attributes: MarkdownAttributes(body: MarkdownAttributeSet(font: textFont, textColor: color), bold: MarkdownAttributeSet(font: boldTextFont, textColor: color), link: MarkdownAttributeSet(font: textFont, textColor: linkColor), linkAttribute: { _ in return (TelegramTextAttributes.URL, "") }), textAlignment: textAlignment) return parseMarkdownIntoAttributedString(text, attributes: MarkdownAttributes(body: MarkdownAttributeSet(font: Font.regular(fontSize), textColor: color), bold: MarkdownAttributeSet(font: Font.semibold(fontSize), textColor: color), link: MarkdownAttributeSet(font: Font.regular(fontSize), textColor: linkColor), linkAttribute: { _ in return (TelegramTextAttributes.URL, "") }), textAlignment: textAlignment)
} }
private final class WebAppTermsAlertContentNode: AlertContentNode, UIGestureRecognizerDelegate { private final class WebAppTermsAlertContentNode: AlertContentNode, UIGestureRecognizerDelegate {
@ -67,6 +67,7 @@ private final class WebAppTermsAlertContentNode: AlertContentNode, UIGestureReco
self.textNode.maximumNumberOfLines = 0 self.textNode.maximumNumberOfLines = 0
self.textNode.displaysAsynchronously = false self.textNode.displaysAsynchronously = false
self.textNode.lineSpacing = 0.1 self.textNode.lineSpacing = 0.1
self.textNode.textAlignment = .center
self.acceptTermsCheckNode = InteractiveCheckNode(theme: CheckNodeTheme(backgroundColor: theme.accentColor, strokeColor: theme.contrastColor, borderColor: theme.controlBorderColor, overlayBorder: false, hasInset: false, hasShadow: false)) self.acceptTermsCheckNode = InteractiveCheckNode(theme: CheckNodeTheme(backgroundColor: theme.accentColor, strokeColor: theme.contrastColor, borderColor: theme.controlBorderColor, overlayBorder: false, hasInset: false, hasShadow: false))
self.acceptTermsLabelNode = ImmediateTextNode() self.acceptTermsLabelNode = ImmediateTextNode()
@ -177,7 +178,7 @@ private final class WebAppTermsAlertContentNode: AlertContentNode, UIGestureReco
override func updateTheme(_ theme: AlertControllerTheme) { override func updateTheme(_ theme: AlertControllerTheme) {
self.titleNode.attributedText = NSAttributedString(string: self.title, font: Font.semibold(17.0), textColor: theme.primaryColor, paragraphAlignment: .center) self.titleNode.attributedText = NSAttributedString(string: self.title, font: Font.semibold(17.0), textColor: theme.primaryColor, paragraphAlignment: .center)
self.textNode.attributedText = NSAttributedString(string: self.text, font: Font.regular(13.0), textColor: theme.primaryColor, paragraphAlignment: .center) self.textNode.attributedText = formattedText(self.text, fontSize: 13.0, color: theme.primaryColor, linkColor: theme.accentColor, textAlignment: .center)
let attributedAgreeText = parseMarkdownIntoAttributedString( let attributedAgreeText = parseMarkdownIntoAttributedString(
self.strings.WebApp_DisclaimerAgree, self.strings.WebApp_DisclaimerAgree,
@ -328,8 +329,7 @@ private final class WebAppTermsAlertContentNode: AlertContentNode, UIGestureReco
public func webAppTermsAlertController( public func webAppTermsAlertController(
context: AccountContext, context: AccountContext,
updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?,
peer: EnginePeer, bot: AttachMenuBot,
requestWriteAccess: Bool,
completion: @escaping (Bool) -> Void completion: @escaping (Bool) -> Void
) -> AlertController { ) -> AlertController {
let theme = defaultDarkColorPresentationTheme let theme = defaultDarkColorPresentationTheme
@ -350,7 +350,7 @@ public func webAppTermsAlertController(
})] })]
let title = presentationData.strings.WebApp_DisclaimerTitle let title = presentationData.strings.WebApp_DisclaimerTitle
let text = presentationData.strings.WebApp_DisclaimerText let text = presentationData.strings.WebApp_DisclaimerText(bot.peer.compactDisplayTitle).string
let contentNode = WebAppTermsAlertContentNode(context: context, theme: AlertControllerTheme(presentationData: presentationData), ptheme: theme, strings: strings, title: title, text: text, actions: actions) let contentNode = WebAppTermsAlertContentNode(context: context, theme: AlertControllerTheme(presentationData: presentationData), ptheme: theme, strings: strings, title: title, text: text, actions: actions)
contentNode.openTerms = { contentNode.openTerms = {