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

[Fix] 블로그 리뷰 웹뷰로 변경 #235

Merged
merged 3 commits into from
Sep 5, 2022
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
6 changes: 6 additions & 0 deletions HealthFoodMe/HealthFoodMe.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
3B07FD3128BFD845004D84A8 /* WebViewVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3B07FD3028BFD845004D84A8 /* WebViewVC.swift */; };
3B089C4A287D877B00DA80B9 /* GodoB.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3B089C49287D876F00DA80B9 /* GodoB.ttf */; };
3B089C4B287D877F00DA80B9 /* GodoB.otf in Resources */ = {isa = PBXBuildFile; fileRef = 3B089C48287D876F00DA80B9 /* GodoB.otf */; };
3B0B25542876BBE400950539 /* NotoSansCJKkr-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 3B0B254E2876BBE300950539 /* NotoSansCJKkr-Regular.otf */; };
Expand Down Expand Up @@ -243,6 +244,9 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
10784F48AA025AF791D137F1 /* Pods_HealthFoodMe.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HealthFoodMe.framework; sourceTree = BUILT_PRODUCTS_DIR; };
20F003D15CC754E358383110 /* Pods-HealthFoodMe.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HealthFoodMe.release.xcconfig"; path = "Target Support Files/Pods-HealthFoodMe/Pods-HealthFoodMe.release.xcconfig"; sourceTree = "<group>"; };
3B07FD3028BFD845004D84A8 /* WebViewVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewVC.swift; sourceTree = "<group>"; };
3B089C48287D876F00DA80B9 /* GodoB.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = GodoB.otf; sourceTree = "<group>"; };
3B089C49287D876F00DA80B9 /* GodoB.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = GodoB.ttf; sourceTree = "<group>"; };
3B0B254D28757C7100950539 /* HealthFoodMe.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = HealthFoodMe.entitlements; sourceTree = "<group>"; };
Expand Down Expand Up @@ -561,6 +565,7 @@
children = (
3B723CA22881AB8A00822B7C /* ReviewDetailVC.swift */,
3B723CA42881B36F00822B7C /* ReviewDetail.storyboard */,
3B07FD3028BFD845004D84A8 /* WebViewVC.swift */,
);
path = VC;
sourceTree = "<group>";
Expand Down Expand Up @@ -2237,6 +2242,7 @@
3B723C8B287FF81800822B7C /* TagCVC.swift in Sources */,
FDA54A3B287DEAB2009D5BCE /* CustomSegementControl.swift in Sources */,
EBF66AF0287227F500DE0ED1 /* BaseVC.swift in Sources */,
3B07FD3128BFD845004D84A8 /* WebViewVC.swift in Sources */,
EB6A44D328737CC400749582 /* MainDetailModel.swift in Sources */,
A93252B5287F2CA6001EDF50 /* ScrapCVC.swift in Sources */,
EBF66ABE287227F500DE0ED1 /* UITextView+.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ extension ReviewDetailVC {
self.reviewCV.reloadData()
}
}

// MARK: - loadWebview
private func didTabBlogReview(blogReviewURL: String) {
guard let blogURL = URL(string: blogReviewURL) else {return}
let vc = WebViewVC(url: blogURL)
let navVC = UINavigationController(rootViewController: vc)
present(navVC, animated: true)
}
}

extension ReviewDetailVC: UIScrollViewDelegate {
Expand Down Expand Up @@ -443,7 +451,7 @@ extension ReviewDetailVC: UICollectionViewDataSource {
if selectedCustomSegment == 0 {

} else if selectedCustomSegment == 1 {
URLSchemeManager.shared.loadSafariApp(blogLink: blogReviewData[indexPath.row].blogURL)
didTabBlogReview(blogReviewURL: blogReviewData[indexPath.row].blogURL)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// WebViewVC.swift
// HealthFoodMe
//
// Created by 강윤서 on 2022/09/01.
//

import UIKit
import WebKit

class WebViewVC: UIViewController {

// MARK: - Properties

private var url = URL(string: "")

// MARK: - UI Components

private let webView: WKWebView = {
let preferences = WKWebpagePreferences()
preferences.allowsContentJavaScript = true
let configuration = WKWebViewConfiguration()
configuration.defaultWebpagePreferences = preferences
let webView = WKWebView(frame: .zero, configuration: configuration)
return webView
}()

init(url: URL) {
self.url = url
super.init(nibName: nil, bundle: nil)
}

required init?(coder: NSCoder) {
fatalError()
}

// MARK: - View Life Cycle

override func viewDidLoad() {
super.viewDidLoad()
setUI()
setConfigureButton()
}

override func viewDidLayoutSubviews() {
webView.frame = view.bounds
}
}

// MARK: - Extensions

extension WebViewVC {
private func setUI() {
view.addSubviews(webView)
view.backgroundColor = .systemBackground
webView.load(URLRequest(url: url!))
}

private func setConfigureButton() {
navigationItem.leftBarButtonItem = UIBarButtonItem(
title: "Done",
style: .done,
target: self,
action: #selector(didTapDone)
)
navigationItem.rightBarButtonItem = UIBarButtonItem(
barButtonSystemItem: .refresh,
target: self,
action: #selector(didTapRefresh))
}

@objc private func didTapDone() {
dismiss(animated: true, completion: nil)
}

@objc private func didTapRefresh() {
webView.load(URLRequest(url: url!))
}
}