-
Notifications
You must be signed in to change notification settings - Fork 3
feat: 모든 탭 열어놓기 #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
The head ref may contain hidden characters: "dev/31-feat-\uBAA8\uB4E0-\uD0ED-\uC5F4\uC5B4\uB193\uAE30/#31"
Merged
feat: 모든 탭 열어놓기 #33
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // | ||
| // PreloadedWebView.swift | ||
| // iBox | ||
| // | ||
| // Created by 이지현 on 1/18/24. | ||
| // | ||
|
|
||
| import UIKit | ||
| import WebKit | ||
|
|
||
| import SnapKit | ||
|
|
||
| class PreloadedWebView: BaseView { | ||
| var selectedWebsite: String? { | ||
| didSet { | ||
| getWebView() | ||
| } | ||
| } | ||
|
|
||
| private var webView: WKWebView? | ||
|
|
||
| override init(frame: CGRect) { | ||
| super.init(frame: frame) | ||
| backgroundColor = .systemBackground | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| private func getWebView() { | ||
| guard let selectedWebsite else { return } | ||
| webView = WebViewPreloader.shared.getWebView(for: URL(string: selectedWebsite)!) | ||
| guard let webView else { return } | ||
| addSubview(webView) | ||
| webView.snp.makeConstraints { make in | ||
| make.edges.equalToSuperview() | ||
| } | ||
| } | ||
|
|
||
| } |
33 changes: 33 additions & 0 deletions
33
iBox/Sources/Presenter/Web/PreloadedWebViewController.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // | ||
| // PreloadedWebViewController.swift | ||
| // iBox | ||
| // | ||
| // Created by 이지현 on 1/18/24. | ||
| // | ||
|
|
||
| import UIKit | ||
|
|
||
| class PreloadedWebViewController: BaseNavigationBarViewController<PreloadedWebView> { | ||
| var selectedWebsite: String? | ||
|
|
||
| override func viewDidLoad() { | ||
| super.viewDidLoad() | ||
| view.backgroundColor = .systemBackground | ||
| navigationItem.largeTitleDisplayMode = .never | ||
|
|
||
| guard let contentView = contentView as? PreloadedWebView else { return } | ||
| contentView.selectedWebsite = selectedWebsite | ||
| } | ||
|
|
||
| override func viewWillDisappear(_ animated: Bool) { | ||
| super.viewWillDisappear(animated) | ||
|
|
||
| guard let selectedWebsite else { return } | ||
| WebViewPreloader.shared.resetWebView(for: URL(string: selectedWebsite)!) | ||
| } | ||
|
|
||
| override func setupNavigationBar() { | ||
| setNavigationBarHidden(true) | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // | ||
| // WebViewPreloader.swift | ||
| // iBox | ||
| // | ||
| // Created by 이지현 on 1/18/24. | ||
| // | ||
|
|
||
| import Foundation | ||
| import WebKit | ||
|
|
||
| class WebViewPreloader { | ||
| static let shared = WebViewPreloader() | ||
| private var webViews: [URL: WKWebView] = [:] | ||
|
|
||
| private init() {} | ||
|
|
||
| func preload(urls: [URL]) { | ||
| for url in urls { | ||
| let webView = WKWebView() | ||
| webView.load(URLRequest(url: url)) | ||
| webViews[url] = webView | ||
| } | ||
| } | ||
|
|
||
| func getWebView(for url: URL) -> WKWebView? { | ||
| return webViews[url] | ||
| } | ||
|
|
||
| func resetWebView(for url: URL) { | ||
| webViews[url]?.load(URLRequest(url: url)) | ||
| } | ||
|
|
||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굳입니당 !