Skip to content

Commit

Permalink
Apply SwiftFormat changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shp7724 authored and github-actions[bot] committed Oct 19, 2024
1 parent c1f48d7 commit f3cedbd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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")
}

Expand Down Expand Up @@ -132,32 +134,33 @@ 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
}
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)
try? fileManager.removeItem(at: url)
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)
Expand All @@ -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&ltNo=001&sbjtSubhCd=000"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]()
Expand All @@ -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")
}

Expand Down Expand Up @@ -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
}()
Expand Down Expand Up @@ -92,7 +92,7 @@ final class WebBottomNavigationView: UIView {
}
}

extension WebBottomNavigationView{
extension WebBottomNavigationView {
enum ButtonType: CaseIterable {
case back
case forward
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class WebProgressView: UIView {
setupView()
}

required init?(coder: NSCoder) {
@available(*, unavailable) required init?(coder _: NSCoder) {
fatalError()
}

Expand Down Expand Up @@ -48,7 +48,7 @@ final class WebProgressView: UIView {
self.progressBar.alpha = 0
}
} else {
self.progressBar.alpha = 1
progressBar.alpha = 1
}
}

Expand Down

0 comments on commit f3cedbd

Please sign in to comment.