diff --git a/Toonie.xcodeproj/project.pbxproj b/Toonie.xcodeproj/project.pbxproj index 6efd7a1..c588162 100644 --- a/Toonie.xcodeproj/project.pbxproj +++ b/Toonie.xcodeproj/project.pbxproj @@ -19,6 +19,8 @@ 92D88D4D5D1ACC0BB983D7797079C87C /* DetailToonService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E371E0D955FBC2867AD25C4BD72ABF4 /* DetailToonService.swift */; }; 687C00FF78A900251B747635F98172EC /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E4C42DB5B38C27C2E993254790693BDF /* DetailViewController.swift */; }; 558FAE24BC1D46AEE96A7839D2EECDF9 /* FavoriteCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6181A5BE3CAF62901728B8DEC5745044 /* FavoriteCollectionViewCell.swift */; }; + 1FDC495E51E4103A48DBE746A3B5742F /* FavoriteService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 384EC31B5698BBD32C8427B4D3D3FA9E /* FavoriteService.swift */; }; + AEEF2D26F2272450934285EA171238A5 /* FavoriteToon.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9A15E6123D0B310EBC6C8200A8A7BCE /* FavoriteToon.swift */; }; 461C3F46EE79F602B9C6DC249B3A419C /* Feed.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 482A114E8A6A879454C3CB47C1BA9443 /* Feed.storyboard */; }; C9355A5FA67D262F35C7B8B185D2CA62 /* FeedViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7BD45CDB0C7E1A8A0FE2DB9C0C25B75 /* FeedViewController.swift */; }; 6931E65B235D9EF98AF252FC0326C078 /* ForYouCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3C59DFBC67BAFC0446C4ACC3CD30166 /* ForYouCollectionViewCell.swift */; }; @@ -108,6 +110,8 @@ 2E371E0D955FBC2867AD25C4BD72ABF4 /* DetailToonService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailToonService.swift; sourceTree = ""; }; E4C42DB5B38C27C2E993254790693BDF /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = ""; }; 6181A5BE3CAF62901728B8DEC5745044 /* FavoriteCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteCollectionViewCell.swift; sourceTree = ""; }; + 384EC31B5698BBD32C8427B4D3D3FA9E /* FavoriteService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteService.swift; sourceTree = ""; }; + B9A15E6123D0B310EBC6C8200A8A7BCE /* FavoriteToon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavoriteToon.swift; sourceTree = ""; }; 482A114E8A6A879454C3CB47C1BA9443 /* Feed.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Feed.storyboard; sourceTree = ""; }; D7BD45CDB0C7E1A8A0FE2DB9C0C25B75 /* FeedViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedViewController.swift; sourceTree = ""; }; C3C59DFBC67BAFC0446C4ACC3CD30166 /* ForYouCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForYouCollectionViewCell.swift; sourceTree = ""; }; @@ -326,6 +330,7 @@ isa = PBXGroup; children = ( 5C0F9FDA6D7EDBB6CC18F7B48E4304F5 /* DetailToon.swift */, + B9A15E6123D0B310EBC6C8200A8A7BCE /* FavoriteToon.swift */, 92086364F206D590B0D7FF7BD726FD80 /* ForYouToonLists.swift */, 9222FD8324DC3A507BC365062CF19A15 /* Keywords.swift */, 7ACAA8940643DB9FC71B7E231C435FD6 /* Recommends.swift */, @@ -380,6 +385,7 @@ children = ( F0DFADE2E74674626C62C5847756D7C3 /* CurationTagService.swift */, 2E371E0D955FBC2867AD25C4BD72ABF4 /* DetailToonService.swift */, + 384EC31B5698BBD32C8427B4D3D3FA9E /* FavoriteService.swift */, 919CB7352060E4267D23B8B6D5169BEC /* ForYouToonListService.swift */, BF827ADC08C996D3C51D60BE675C7641 /* KeywordsService.swift */, FBB7847F6E2C082500A180183EDA27D6 /* RecommendService.swift */, @@ -737,6 +743,8 @@ 92D88D4D5D1ACC0BB983D7797079C87C /* DetailToonService.swift in Sources */, 687C00FF78A900251B747635F98172EC /* DetailViewController.swift in Sources */, 558FAE24BC1D46AEE96A7839D2EECDF9 /* FavoriteCollectionViewCell.swift in Sources */, + 1FDC495E51E4103A48DBE746A3B5742F /* FavoriteService.swift in Sources */, + AEEF2D26F2272450934285EA171238A5 /* FavoriteToon.swift in Sources */, C9355A5FA67D262F35C7B8B185D2CA62 /* FeedViewController.swift in Sources */, 6931E65B235D9EF98AF252FC0326C078 /* ForYouCollectionViewCell.swift in Sources */, EB475B47E259D7432C73537026F9FF8D /* ForYouToonListService.swift in Sources */, diff --git a/Toonie/Detail/Controller/DetailViewController.swift b/Toonie/Detail/Controller/DetailViewController.swift index 503be91..22fadf8 100644 --- a/Toonie/Detail/Controller/DetailViewController.swift +++ b/Toonie/Detail/Controller/DetailViewController.swift @@ -64,13 +64,22 @@ final class DetailToonViewController: GestureViewController { as? ToonWebViewController { viewController.modalTransitionStyle = UIModalTransitionStyle.coverVertical viewController.toonUrl = detailToon?.instaUrl - viewController.instaID = detailToon?.instaID self.present(viewController, animated: true, completion: nil) } } /// 툰 찜하기 - @IBAction func addToMyCollection(_ sender: UIButton) { + @IBAction func addToMyFavorite(_ sender: UIButton) { + let body = [ + "workListName": "default", + "workListInfo": "찜한 목록", + "toonId": detailToon?.toonID + ] + + FavoriteService.shared.postFavoriteToon(params: body as [String : Any], + completion: { + print("Success to add favorite toon") + }) } // MARK: - Life Cycle diff --git a/Toonie/Detail/Controller/ToonWebViewController.swift b/Toonie/Detail/Controller/ToonWebViewController.swift index fe74751..0abc638 100644 --- a/Toonie/Detail/Controller/ToonWebViewController.swift +++ b/Toonie/Detail/Controller/ToonWebViewController.swift @@ -15,7 +15,6 @@ final class ToonWebViewController: UIViewController, WKNavigationDelegate { // MARK: - Property var toonUrl: String? - var instaID: String? // MARK: - IBOutlet @@ -30,8 +29,8 @@ final class ToonWebViewController: UIViewController, WKNavigationDelegate { override func viewDidLoad() { super.viewDidLoad() + instagramWebView.navigationDelegate = self loadWebView() - setLabel(instaId: instaID ?? "", url: toonUrl ?? "https://www.instagram.com/") } override var preferredStatusBarStyle: UIStatusBarStyle { @@ -48,13 +47,11 @@ final class ToonWebViewController: UIViewController, WKNavigationDelegate { /// 웹 화면 이동 @IBAction func backButtonDidTap(_ sender: UIButton) { instagramWebView.goBack() - instagramWebView.reload() } /// 웹 화면 이동 @IBAction func forwardButtonDidTap(_ sender: UIButton) { instagramWebView.goForward() - instagramWebView.reload() } // MARK: - Function @@ -66,19 +63,25 @@ final class ToonWebViewController: UIViewController, WKNavigationDelegate { let request = URLRequest(url: url) instagramWebView.load(request) } - instagramWebView.navigationDelegate = self - instagramWebView.allowsBackForwardNavigationGestures = true } - /// 웹뷰 정보 넣기 - private func setLabel(instaId: String, url: String) { - idLabel.text = instaId - urlLabel.text = url + /// 웹뷰 타이틀, url 넣기 + private func setLabel() { + let javascript = "document.title\n" + + instagramWebView.evaluateJavaScript(javascript) { (result, error) -> Void in + if error == nil { + self.idLabel.text = result as? String + } + } + urlLabel.text = instagramWebView.url?.absoluteString } - /// 웹뷰 버튼 설정 - private func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { + /// 웹뷰 버튼, 레이블 설정 + func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) { backButton.isEnabled = instagramWebView.canGoBack forwardButton.isEnabled = instagramWebView.canGoForward + setLabel() } + } diff --git a/Toonie/Detail/View/Detail.storyboard b/Toonie/Detail/View/Detail.storyboard index 5124d42..06dcafd 100644 --- a/Toonie/Detail/View/Detail.storyboard +++ b/Toonie/Detail/View/Detail.storyboard @@ -20,7 +20,7 @@ @@ -160,7 +160,7 @@ - + @@ -182,7 +182,7 @@ - + @@ -250,13 +250,13 @@ -