This commit is contained in:
Evgeny @ SimpleX Chat
2026-08-13 05:51:44 +00:00
parent c936782fe8
commit 2362167efe
2 changed files with 52 additions and 1 deletions
@@ -810,7 +810,7 @@ fileprivate struct GetStakeView: View {
@EnvironmentObject var chatModel: ChatModel
var body: some View {
ScrollView {
ZoomablePageView {
VStack(alignment: .leading, spacing: 18) {
Text("Get a stake in SimpleX Chat")
.font(.largeTitle)
@@ -58,3 +58,54 @@ struct ZoomableScrollView<Content: View>: UIViewRepresentable {
}
}
}
struct ZoomablePageView<Content: View>: UIViewRepresentable {
private var content: Content
init(@ViewBuilder content: () -> Content) {
self.content = content()
}
func makeUIView(context: Context) -> UIScrollView {
let scrollView = UIScrollView()
scrollView.delegate = context.coordinator
scrollView.maximumZoomScale = 5
scrollView.minimumZoomScale = 1
scrollView.bouncesZoom = true
scrollView.backgroundColor = .clear
let hostedView = context.coordinator.hostingController.view!
hostedView.backgroundColor = .clear
hostedView.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(hostedView)
NSLayoutConstraint.activate([
hostedView.leadingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.leadingAnchor),
hostedView.trailingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.trailingAnchor),
hostedView.topAnchor.constraint(equalTo: scrollView.contentLayoutGuide.topAnchor),
hostedView.bottomAnchor.constraint(equalTo: scrollView.contentLayoutGuide.bottomAnchor),
hostedView.widthAnchor.constraint(equalTo: scrollView.frameLayoutGuide.widthAnchor)
])
return scrollView
}
func makeCoordinator() -> Coordinator {
Coordinator(hostingController: UIHostingController(rootView: self.content))
}
func updateUIView(_ uiView: UIScrollView, context: Context) {
context.coordinator.hostingController.rootView = self.content
}
class Coordinator: NSObject, UIScrollViewDelegate {
var hostingController: UIHostingController<Content>
init(hostingController: UIHostingController<Content>) {
self.hostingController = hostingController
}
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
hostingController.view
}
}
}