Various fixes

This commit is contained in:
Ilya Laktyushin
2024-06-28 17:45:00 +04:00
parent ed8f1b35e9
commit 9d3cc5996b
12 changed files with 66 additions and 17 deletions

View File

@@ -13,6 +13,7 @@ import BundleIconComponent
import TelegramUIPreferences
import OpenInExternalAppUI
import MultilineTextComponent
import MinimizedContainer
private let settingsTag = GenericComponentViewTag()
@@ -291,6 +292,7 @@ public class BrowserScreen: ViewController {
guard let strongSelf = self else {
return
}
strongSelf.controller?.title = state.title
strongSelf.contentState = state
strongSelf.requestLayout(transition: .immediate)
}).strict()
@@ -318,7 +320,7 @@ public class BrowserScreen: ViewController {
}
self.controller?.present(shareController, in: .window(.root))
case .minimize:
break
self.minimize()
case .openIn:
self.context.sharedContext.applicationBindings.openUrl(url)
case .openSettings:
@@ -441,6 +443,23 @@ public class BrowserScreen: ViewController {
self.requestLayout(transition: animated ? .easeInOut(duration: 0.2) : .immediate)
}
func minimize() {
guard let controller = self.controller, let navigationController = controller.navigationController as? NavigationController else {
return
}
navigationController.minimizeViewController(controller, damping: nil, setupContainer: { [weak self] current in
let minimizedContainer: MinimizedContainerImpl?
if let current = current as? MinimizedContainerImpl {
minimizedContainer = current
} else if let context = self?.controller?.context {
minimizedContainer = MinimizedContainerImpl(sharedContext: context.sharedContext)
} else {
minimizedContainer = nil
}
return minimizedContainer
}, animated: true)
}
func openSettings() {
guard let referenceView = self.componentHost.findTaggedView(tag: settingsTag) as? ReferenceButtonComponent.View else {
return
@@ -535,7 +554,8 @@ public class BrowserScreen: ViewController {
self.context.sharedContext.applicationBindings.openUrl(openInUrl)
}
action(.default)
}))]
}))
]
let contextController = ContextController(presentationData: self.presentationData, source: source, items: .single(ContextController.Items(content: .list(items))))
self.controller?.present(contextController, in: .window(.root))