Various fixes

This commit is contained in:
Ilya Laktyushin 2024-08-01 11:43:00 +02:00
parent bef45240bd
commit b06aacbacb
7 changed files with 27 additions and 16 deletions

View File

@ -755,7 +755,7 @@ public class MediaEditorTransitionOutExternalState {
}
public protocol MediaEditorScreenResult {
var target: Stories.PendingTarget { get }
}
public protocol TelegramRootControllerInterface: NavigationController {

View File

@ -367,7 +367,7 @@ public final class BrowserBookmarksScreen: ViewController {
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Back, style: .plain, target: nil, action: nil)
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Cancel, style: .plain, target: self, action: #selector(self.cancelPressed))
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Close, style: .plain, target: self, action: #selector(self.cancelPressed))
self.title = self.presentationData.strings.WebBrowser_Bookmarks_Title
self.searchContentNode = NavigationBarSearchContentNode(theme: self.presentationData.theme, placeholder: self.presentationData.strings.Common_Search, activate: { [weak self] in

View File

@ -384,13 +384,13 @@ private final class BrowserScreenComponent: CombinedComponent {
bottomInset: toolbarBottomInset,
sideInset: environment.safeInsets.left,
item: toolbarContent,
collapseFraction: collapseFraction
collapseFraction: 0.0
),
availableSize: context.availableSize,
transition: context.transition
)
context.add(toolbar
.position(CGPoint(x: context.availableSize.width / 2.0, y: context.availableSize.height - toolbar.size.height / 2.0))
.position(CGPoint(x: context.availableSize.width / 2.0, y: context.availableSize.height - toolbar.size.height / 2.0 + toolbar.size.height * collapseFraction))
.appear(ComponentTransition.Appear { _, view, transition in
transition.animatePosition(view: view, from: CGPoint(x: 0.0, y: view.frame.height), to: CGPoint(), additive: true)
})

View File

@ -244,7 +244,7 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
self.errorView = ComponentHostView()
self._state = BrowserContentState(title: title, url: url, estimatedProgress: 0.0, readingProgress: 0.0, contentType: .webPage)
self._state = BrowserContentState(title: title, url: url, estimatedProgress: 0.1, readingProgress: 0.0, contentType: .webPage)
self.statePromise = Promise<BrowserContentState>(self._state)
super.init(frame: .zero)
@ -725,7 +725,12 @@ final class BrowserWebContent: UIView, BrowserContent, WKNavigationDelegate, WKU
}
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
self.currentError = nil
if let _ = self.currentError {
self.currentError = nil
if let (size, insets, fullInsets, safeInsets) = self.validLayout {
self.updateLayout(size: size, insets: insets, fullInsets: fullInsets, safeInsets: safeInsets, transition: .immediate)
}
}
self.updateFontState(self.currentFontState, force: true)
}

View File

@ -120,7 +120,7 @@ private final class SheetContent: CombinedComponent {
let explicitLink = explicitUrl(context.component.link)
var isValidLink = false
if isValidUrl(explicitLink) {
if isValidUrl(explicitLink, validSchemes: ["http": true, "https": true, "tonsite": true]) {
isValidLink = true
}

View File

@ -735,8 +735,22 @@ public final class TelegramRootController: NavigationController, TelegramRootCon
//Xcode 16
#if canImport(ContactProvider)
extension MediaEditorScreen.Result: @retroactive MediaEditorScreenResult {
public var target: Stories.PendingTarget {
if let sendAsPeerId = self.options.sendAsPeerId {
return .peer(sendAsPeerId)
} else {
return .myStories
}
}
}
#else
extension MediaEditorScreen.Result: MediaEditorScreenResult {
public var target: Stories.PendingTarget {
if let sendAsPeerId = self.options.sendAsPeerId {
return .peer(sendAsPeerId)
} else {
return .myStories
}
}
}
#endif

View File

@ -1164,15 +1164,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
transitionOut: nil
)
let controller = self.context.sharedContext.makeStoryMediaEditorScreen(context: self.context, source: source, text: text, link: linkUrl.flatMap { ($0, linkName) }, completion: { result, commit in
// let targetPeerId: EnginePeer.Id
let target: Stories.PendingTarget
// if let sendAsPeerId = result.options.sendAsPeerId {
// target = .peer(sendAsPeerId)
// targetPeerId = sendAsPeerId
// } else {
target = .myStories
// targetPeerId = self.context.account.peerId
// }
let target: Stories.PendingTarget = result.target
externalState.storyTarget = target
if let rootController = self.context.sharedContext.mainWindow?.viewController as? TelegramRootControllerInterface {