diff --git a/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/SyllabusFilePreviewController.swift b/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/SyllabusFilePreviewController.swift index dac7f395..28536f15 100644 --- a/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/SyllabusFilePreviewController.swift +++ b/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/SyllabusFilePreviewController.swift @@ -15,17 +15,17 @@ final class SyllabusFilePreviewController: QLPreviewController { dataSource = self } - required init?(coder: NSCoder) { + @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } } extension SyllabusFilePreviewController: QLPreviewControllerDataSource { - func numberOfPreviewItems(in controller: QLPreviewController) -> Int { + func numberOfPreviewItems(in _: QLPreviewController) -> Int { 1 } - func previewController(_ controller: QLPreviewController, previewItemAt index: Int) -> any QLPreviewItem { + func previewController(_: QLPreviewController, previewItemAt _: Int) -> any QLPreviewItem { item } } diff --git a/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/SyllabusWebView.swift b/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/SyllabusWebView.swift index 257b76aa..5ea519b6 100644 --- a/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/SyllabusWebView.swift +++ b/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/SyllabusWebView.swift @@ -5,11 +5,11 @@ // Created by 최유림 on 2022/10/11. // -import SwiftUI -import WebKit -import UIKit import Combine import QuickLook +import SwiftUI +import UIKit +import WebKit struct SyllabusWebView: UIViewControllerRepresentable { let lectureTitle: String @@ -37,9 +37,11 @@ final class SyllabusWebViewController: UIViewController { static let homeURL = URL(string: "https://sugang.snu.ac.kr")! static let referer = "https://sugang.snu.ac.kr/sugang/cc/cc100InterfaceExcel.action" } + private enum Design { static let bottomViewHeight = 50.0 } + private let entryURL: URL private lazy var webView: WKWebView = { let config = WKWebViewConfiguration() @@ -59,7 +61,7 @@ final class SyllabusWebViewController: UIViewController { super.init(nibName: nil, bundle: nil) } - required init?(coder: NSCoder) { + @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -132,11 +134,11 @@ final class SyllabusWebViewController: UIViewController { } extension SyllabusWebViewController: WKNavigationDelegate { - func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction) async -> WKNavigationActionPolicy { + func webView(_: WKWebView, decidePolicyFor _: WKNavigationAction) async -> WKNavigationActionPolicy { return .allow } - func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse) async -> WKNavigationResponsePolicy { + func webView(_: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse) async -> WKNavigationResponsePolicy { guard let mimeType = navigationResponse.response.mimeType else { return .cancel } if mimeType == "text/html" { return .allow @@ -144,13 +146,13 @@ extension SyllabusWebViewController: WKNavigationDelegate { return .download } - func webView(_ webView: WKWebView, navigationResponse: WKNavigationResponse, didBecome download: WKDownload) { + func webView(_: WKWebView, navigationResponse _: WKNavigationResponse, didBecome download: WKDownload) { download.delegate = self } } extension SyllabusWebViewController: WKDownloadDelegate { - func download(_ download: WKDownload, decideDestinationUsing response: URLResponse, suggestedFilename: String) async -> URL? { + func download(_ download: WKDownload, decideDestinationUsing _: URLResponse, suggestedFilename: String) async -> URL? { let percentDecoded = suggestedFilename.removingPercentEncoding ?? suggestedFilename let fileManager = FileManager.default let url = fileManager.temporaryDirectory.appendingPathComponent(percentDecoded) @@ -158,6 +160,7 @@ extension SyllabusWebViewController: WKDownloadDelegate { downloadLocalURLs[download] = url return url } + func downloadDidFinish(_ download: WKDownload) { guard let localURL = downloadLocalURLs.removeValue(forKey: download) else { return } let previewController = SyllabusFilePreviewController(item: localURL as QLPreviewItem) @@ -170,11 +173,10 @@ extension UIControl { for controlEvents: UIControl.Event = .touchUpInside, _ closure: @MainActor @escaping () -> Void ) { - addAction(UIAction { (action: UIAction) in closure() }, for: controlEvents) + addAction(UIAction { (_: UIAction) in closure() }, for: controlEvents) } } - @available(iOS 17.0, *) #Preview { SyllabusWebView(lectureTitle: "수강스누", urlString: .constant("https://sugang.snu.ac.kr/sugang/cc/cc103.action?openSchyy=2024&openShtmFg=U000200002&openDetaShtmFg=U000300002&sbjtCd=M3500.002000<No=001&sbjtSubhCd=000")) diff --git a/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/WebBottomNavigationView.swift b/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/WebBottomNavigationView.swift index 8b79cfbf..fa6e256e 100644 --- a/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/WebBottomNavigationView.swift +++ b/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/WebBottomNavigationView.swift @@ -5,8 +5,8 @@ // Created by 박신홍 on 10/19/24. // -import UIKit import Combine +import UIKit final class WebBottomNavigationView: UIView { private var buttons = [ButtonType: UIButton]() @@ -22,7 +22,7 @@ final class WebBottomNavigationView: UIView { setupButtons() } - required init?(coder: NSCoder) { + @available(*, unavailable) required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -61,7 +61,7 @@ final class WebBottomNavigationView: UIView { divider.topAnchor.constraint(equalTo: blurView.topAnchor), divider.leadingAnchor.constraint(equalTo: blurView.leadingAnchor), divider.trailingAnchor.constraint(equalTo: blurView.trailingAnchor), - divider.heightAnchor.constraint(equalToConstant: 1) + divider.heightAnchor.constraint(equalToConstant: 1), ]) return blurView }() @@ -92,7 +92,7 @@ final class WebBottomNavigationView: UIView { } } -extension WebBottomNavigationView{ +extension WebBottomNavigationView { enum ButtonType: CaseIterable { case back case forward diff --git a/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/WebProgressView.swift b/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/WebProgressView.swift index ab65b6eb..6fd58b08 100644 --- a/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/WebProgressView.swift +++ b/SNUTT-2022/SNUTT/Views/Components/WebViews/SyllabusWebView/WebProgressView.swift @@ -20,7 +20,7 @@ final class WebProgressView: UIView { setupView() } - required init?(coder: NSCoder) { + @available(*, unavailable) required init?(coder _: NSCoder) { fatalError() } @@ -48,7 +48,7 @@ final class WebProgressView: UIView { self.progressBar.alpha = 0 } } else { - self.progressBar.alpha = 1 + progressBar.alpha = 1 } }