Skip to content
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

[Feat] #208 - 웹뷰 네비바 툴바 수정사항 반영 #211

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "ic_share.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion TOASTER-iOS/Present/LinkWeb/View/LinkWebNavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class LinkWebNavigationView: UIView {
// MARK: - UI Components

private let popButton = UIButton()
private let addressLabel = UILabel()
private let addressLabel = UITextField()
private let reloadButton = UIButton()

// MARK: - Life Cycles
Expand Down Expand Up @@ -71,6 +71,7 @@ private extension LinkWebNavigationView {
$0.font = .suitSemiBold(size: 14)
$0.textColor = .black900
$0.textAlignment = .center
$0.inputView = UIView()
}

reloadButton.do {
Expand All @@ -95,6 +96,7 @@ private extension LinkWebNavigationView {
$0.centerY.equalTo(popButton)
$0.leading.equalTo(popButton.snp.trailing).offset(13)
$0.trailing.equalTo(reloadButton.snp.leading).inset(-13)
$0.height.equalTo(36)
}

reloadButton.snp.makeConstraints {
Expand Down
26 changes: 20 additions & 6 deletions TOASTER-iOS/Present/LinkWeb/View/LinkWebToolBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,27 @@ final class LinkWebToolBarView: UIView {
private var canGoBack: Bool = false {
didSet {
backButton.isEnabled = canGoBack
backButton.tintColor = canGoBack ? .gray700 : .gray150
backButton.tintColor = canGoBack ? .gray700 : .gray200
}
}

private var canGoForward: Bool = false {
didSet {
forwardButton.isEnabled = canGoForward
forwardButton.tintColor = canGoForward ? .gray700 : .gray150
forwardButton.tintColor = canGoForward ? .gray700 : .gray200
}
}

private(set) var isRead: Bool = false {
didSet {
readLinkCheckButton.tintColor = isRead ? .gray700 : .gray150
toolBar.setItems([backButton, flexibleSpace, forwardButton, flexibleSpace, readLinkCheckButton, flexibleSpace, safariButton], animated: false)
readLinkCheckButton.tintColor = isRead ? .toasterPrimary : .gray200
toolBar.setItems([backButton, flexibleSpace, forwardButton, flexibleSpace, readLinkCheckButton, flexibleSpace, shareLinkButton, flexibleSpace, safariButton], animated: false)
}
}

private var backButtonAction: (() -> Void)?
private var forwardButtonAction: (() -> Void)?
private var shareButtonAction: (() -> Void)?
private var safariButtonAction: (() -> Void)?

lazy var readLinkButtonTap = readLinkCheckButton.publisher()
Expand All @@ -48,6 +49,7 @@ final class LinkWebToolBarView: UIView {
private let backButton = UIBarButtonItem()
private let forwardButton = UIBarButtonItem()
private let readLinkCheckButton = UIBarButtonItem()
private let shareLinkButton = UIBarButtonItem()
private let safariButton = UIBarButtonItem()

// MARK: - Life Cycles
Expand Down Expand Up @@ -78,6 +80,10 @@ extension LinkWebToolBarView {
forwardButtonAction = action
}

func shareButtonTapped(_ action: @escaping () -> Void) {
shareButtonAction = action
}

func safariButtonTapped(_ action: @escaping () -> Void) {
safariButtonAction = action
}
Expand Down Expand Up @@ -122,6 +128,12 @@ private extension LinkWebToolBarView {
$0.style = .plain
}

shareLinkButton.do {
$0.tintColor = .gray700
$0.image = .icShare
$0.style = .plain
}

safariButton.do {
$0.tintColor = .gray700
$0.image = .icSafari24
Expand All @@ -131,7 +143,7 @@ private extension LinkWebToolBarView {

func setupHierarchy() {
addSubview(toolBar)
toolBar.setItems([backButton, flexibleSpace, forwardButton, flexibleSpace, safariButton], animated: false)
toolBar.setItems([backButton, flexibleSpace, forwardButton, flexibleSpace, shareLinkButton, flexibleSpace, safariButton], animated: false)
}

func setupLayout() {
Expand All @@ -141,7 +153,7 @@ private extension LinkWebToolBarView {
}

func setupAddTarget() {
[backButton, forwardButton, readLinkCheckButton, safariButton].forEach {
[backButton, forwardButton, readLinkCheckButton, shareLinkButton, safariButton].forEach {
$0.target = self
$0.action = #selector(barButtonTapped)
}
Expand All @@ -154,6 +166,8 @@ private extension LinkWebToolBarView {
backButtonAction?()
case forwardButton:
forwardButtonAction?()
case shareLinkButton:
shareButtonAction?()
case safariButton:
safariButtonAction?()
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ private extension LinkWebViewController {
if self.webView.canGoForward { self.webView.goForward() }
}

/// 툴바 공유 버튼 클릭 액션 클로저
toolBar.shareButtonTapped {
guard let url = self.webView.url else { return }
let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
self.present(activityViewController, animated: true, completion: nil)
}

/// 툴바 사파리 버튼 클릭 액션 클로저
toolBar.safariButtonTapped {
if let url = self.webView.url { UIApplication.shared.open(url) }
Expand Down