Various improvements

This commit is contained in:
Ilya Laktyushin 2026-05-28 16:50:05 +02:00
parent 5fbe230308
commit 3e6363abf9
351 changed files with 11565 additions and 12031 deletions

View file

@ -79,6 +79,7 @@ public struct WebAppParameters {
let forceHasSettings: Bool
let fullSize: Bool
let isFullscreen: Bool
let sameOrigin: Bool
let appSettings: BotAppSettings?
public init(
@ -97,6 +98,7 @@ public struct WebAppParameters {
forceHasSettings: Bool,
fullSize: Bool,
isFullscreen: Bool = false,
sameOrigin: Bool = false,
appSettings: BotAppSettings? = nil
) {
self.source = source
@ -114,6 +116,7 @@ public struct WebAppParameters {
self.forceHasSettings = forceHasSettings
self.fullSize = fullSize || isFullscreen
self.isFullscreen = isFullscreen
self.sameOrigin = sameOrigin
self.appSettings = appSettings
}
}
@ -520,7 +523,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
}
#endif*/
if !"".isEmpty {
if self.controller?.sameOrigin == true {
self.webView?.bindTrustedOrigin(from: url)
} else {
self.webView?.setupEventProxySource()
@ -566,6 +569,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
}
if let parsedUrl = URL(string: result.url) {
strongSelf.queryId = result.queryId
strongSelf.controller?.sameOrigin = result.flags.contains(.sameOrigin)
strongSelf.load(url: parsedUrl)
}
})
@ -586,6 +590,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
return
}
self.controller?.titleView?.title = WebAppTitle(title: botApp.title, counter: self.presentationData.strings.WebApp_Miniapp, isVerified: controller.botVerified)
self.controller?.sameOrigin = result.flags.contains(.sameOrigin)
self.load(url: parsedUrl)
})
})
@ -596,6 +601,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
return
}
strongSelf.queryId = result.queryId
strongSelf.controller?.sameOrigin = result.flags.contains(.sameOrigin)
strongSelf.load(url: parsedUrl)
if let keepAliveSignal = result.keepAliveSignal {
@ -3562,6 +3568,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
private let replyToMessageId: EngineMessage.Id?
private let threadId: Int64?
public var isFullscreen: Bool
private var sameOrigin: Bool
private var pendingExternalUrl: String?
private var presentationData: PresentationData
@ -3596,6 +3603,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
self.replyToMessageId = replyToMessageId
self.threadId = threadId
self.isFullscreen = params.isFullscreen
self.sameOrigin = params.sameOrigin
self.updatedPresentationData = updatedPresentationData
@ -3708,9 +3716,9 @@ public final class WebAppController: ViewController, AttachmentContainable {
id: "close",
component: AnyComponent(GlassBarButtonComponent(
size: barButtonSize,
backgroundColor: self.presentationData.theme.rootController.navigationBar.glassBarButtonBackgroundColor,
backgroundColor: nil,
isDark: self.presentationData.theme.overallDarkAppearance,
state: .generic,
state: .glass,
component: AnyComponentWithIdentity(id: self.controllerNode.hasBackButton ? "back" : "close", component: AnyComponent(
BundleIconComponent(
name: self.controllerNode.hasBackButton ? "Navigation/Back" : "Navigation/Close",
@ -3727,9 +3735,9 @@ public final class WebAppController: ViewController, AttachmentContainable {
id: "more",
component: AnyComponent(GlassBarButtonComponent(
size: barButtonSize,
backgroundColor: self.presentationData.theme.rootController.navigationBar.glassBarButtonBackgroundColor,
backgroundColor: nil,
isDark: self.presentationData.theme.overallDarkAppearance,
state: .generic,
state: .glass,
component: AnyComponentWithIdentity(id: "more", component: AnyComponent(
LottieComponent(
content: LottieComponent.AppBundleContent(
@ -4135,23 +4143,18 @@ public final class WebAppController: ViewController, AttachmentContainable {
public func requestDismiss(completion: @escaping () -> Void) {
if self.controllerNode.needDismissConfirmation {
let actionSheet = ActionSheetController(presentationData: self.presentationData)
actionSheet.setItemGroups([
ActionSheetItemGroup(items: [
ActionSheetTextItem(title: self.presentationData.strings.WebApp_CloseConfirmation),
ActionSheetButtonItem(title: self.presentationData.strings.WebApp_CloseAnyway, color: .destructive, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
let alertController = textAlertController(
context: self.context,
title: nil,
text: self.presentationData.strings.WebApp_CloseConfirmation,
actions: [
TextAlertAction(type: .genericAction, title: self.presentationData.strings.Common_Cancel, action: {}),
TextAlertAction(type: .destructiveAction, title: self.presentationData.strings.WebApp_CloseAnyway, action: {
completion()
})
]),
ActionSheetItemGroup(items: [
ActionSheetButtonItem(title: self.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
actionSheet?.dismissAnimated()
})
])
])
self.present(actionSheet, in: .window(.root))
]
)
self.present(alertController, in: .window(.root))
} else {
completion()
}

View file

@ -222,8 +222,6 @@ private final class SheetContent: CombinedComponent {
transition: .immediate
)
context.add(button
.clipsToBounds(true)
.cornerRadius(10.0)
.position(CGPoint(x: context.availableSize.width / 2.0, y: contentSize.height + button.size.height / 2.0))
)
contentSize.height += button.size.height

View file

@ -70,7 +70,7 @@ private func securedEventProxySource(trustedOrigin: String) -> String {
"""
}
private let selectionSource = "var css = '*{-webkit-touch-callout:none;} :not(input):not(textarea):not([\"contenteditable\"=\"true\"]){-webkit-user-select:none;}';"
private let selectionSource = "var css = '*{-webkit-touch-callout:none;} :not(input):not(textarea):not([contenteditable=\"true\"]){-webkit-user-select:none;}';"
+ " var head = document.head || document.getElementsByTagName('head')[0];"
+ " var style = document.createElement('style'); style.type = 'text/css';" +
" style.appendChild(document.createTextNode(css)); head.appendChild(style);"