From 76642b89d5cecdfb6bb56f4cd3a5386d8a297310 Mon Sep 17 00:00:00 2001 From: cheykrym Date: Fri, 25 Jul 2025 01:50:39 +0300 Subject: [PATCH] top bar update --- Shared/Components/RefreshableScrollView.swift | 69 ------------------- 1 file changed, 69 deletions(-) delete mode 100644 Shared/Components/RefreshableScrollView.swift diff --git a/Shared/Components/RefreshableScrollView.swift b/Shared/Components/RefreshableScrollView.swift deleted file mode 100644 index 561ee30..0000000 --- a/Shared/Components/RefreshableScrollView.swift +++ /dev/null @@ -1,69 +0,0 @@ -import SwiftUI -import UIKit - -struct RefreshableScrollView: UIViewRepresentable { - var content: Content - var onRefresh: () -> Void - var isRefreshing: Binding - - init(isRefreshing: Binding, onRefresh: @escaping () -> Void, @ViewBuilder content: () -> Content) { - self.content = content() - self.onRefresh = onRefresh - self.isRefreshing = isRefreshing - } - - func makeUIView(context: Context) -> UIScrollView { - let scrollView = UIScrollView() - scrollView.delaysContentTouches = false - - let refreshControl = UIRefreshControl() - refreshControl.addTarget(context.coordinator, action: #selector(Coordinator.handleRefresh), for: .valueChanged) - scrollView.refreshControl = refreshControl - - let hostingController = UIHostingController(rootView: content) - hostingController.view.translatesAutoresizingMaskIntoConstraints = false - scrollView.addSubview(hostingController.view) - - NSLayoutConstraint.activate([ - hostingController.view.leadingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.leadingAnchor), - hostingController.view.trailingAnchor.constraint(equalTo: scrollView.contentLayoutGuide.trailingAnchor), - hostingController.view.topAnchor.constraint(equalTo: scrollView.contentLayoutGuide.topAnchor), - hostingController.view.bottomAnchor.constraint(equalTo: scrollView.contentLayoutGuide.bottomAnchor), - hostingController.view.widthAnchor.constraint(equalTo: scrollView.frameLayoutGuide.widthAnchor) - ]) - - context.coordinator.hostingController = hostingController - - return scrollView - } - - func updateUIView(_ uiView: UIScrollView, context: Context) { - if isRefreshing.wrappedValue { - uiView.refreshControl?.beginRefreshing() - } else { - // Отложенное завершение, чтобы избежать цикла обновлений - DispatchQueue.main.async { - uiView.refreshControl?.endRefreshing() - } - } - - context.coordinator.hostingController?.rootView = content - } - - func makeCoordinator() -> Coordinator { - Coordinator(self) - } - - class Coordinator: NSObject { - var parent: RefreshableScrollView - var hostingController: UIHostingController? - - init(_ parent: RefreshableScrollView) { - self.parent = parent - } - - @objc func handleRefresh() { - parent.onRefresh() - } - } -}