From 79beea76a8382fe5f1e0df0b43ca96facb4d6501 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Tue, 26 Jan 2016 13:54:09 +0800 Subject: [PATCH] OpenGraphInfoType --- Yep.xcodeproj/project.pbxproj | 8 ++++---- .../{FeedURLInfoType.swift => OpenGraphInfoType.swift} | 4 ++-- Yep/Realm/Models.swift | 2 +- Yep/Services/YepService.swift | 2 +- .../Conversation/ConversationViewController.swift | 10 +++++----- .../Cells/ChatLeftTextURL/ChatLeftTextURLCell.swift | 2 +- .../Cells/ChatRightTextURL/ChatRightTextURLCell.swift | 2 +- Yep/Views/Cells/Feed/FeedURLCell.swift | 2 +- Yep/Views/ContainerViews/FeedURLContainerView.swift | 10 +++++----- Yep/Views/Feed/FeedView.swift | 6 +++--- 10 files changed, 24 insertions(+), 24 deletions(-) rename Yep/Protocols/{FeedURLInfoType.swift => OpenGraphInfoType.swift} (84%) diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 0e977e62..9969e86c 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -264,7 +264,7 @@ 50CDBE491ACBAD3200459CE0 /* ChatLeftImageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50CDBE471ACBAD3200459CE0 /* ChatLeftImageCell.swift */; }; 50D45FC31C44D2300044C95A /* OpenGraphService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50D45FC21C44D2300044C95A /* OpenGraphService.swift */; }; 50D4D0DB1AFA825B005AEB6F /* MediaControlView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50D4D0DA1AFA825B005AEB6F /* MediaControlView.swift */; }; - 50DBDEF11C48C2240044E21B /* FeedURLInfoType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DBDEF01C48C2240044E21B /* FeedURLInfoType.swift */; }; + 50DBDEF11C48C2240044E21B /* OpenGraphInfoType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DBDEF01C48C2240044E21B /* OpenGraphInfoType.swift */; }; 50DBDEFD1C4CCB030044E21B /* ChatLeftTextURLCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DBDEFB1C4CCB030044E21B /* ChatLeftTextURLCell.swift */; }; 50DBDF011C4CE75E0044E21B /* ChatRightTextURLCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DBDEFF1C4CE75E0044E21B /* ChatRightTextURLCell.swift */; }; 50DBDF051C4DD9530044E21B /* CGSize+Yep.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50DBDF041C4DD9530044E21B /* CGSize+Yep.swift */; }; @@ -637,7 +637,7 @@ 50CDBE471ACBAD3200459CE0 /* ChatLeftImageCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChatLeftImageCell.swift; path = Views/Cells/ChatLeftImage/ChatLeftImageCell.swift; sourceTree = ""; }; 50D45FC21C44D2300044C95A /* OpenGraphService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OpenGraphService.swift; path = Services/OpenGraphService.swift; sourceTree = ""; }; 50D4D0DA1AFA825B005AEB6F /* MediaControlView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MediaControlView.swift; path = Views/Media/MediaControlView.swift; sourceTree = ""; }; - 50DBDEF01C48C2240044E21B /* FeedURLInfoType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FeedURLInfoType.swift; path = Protocols/FeedURLInfoType.swift; sourceTree = ""; }; + 50DBDEF01C48C2240044E21B /* OpenGraphInfoType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OpenGraphInfoType.swift; path = Protocols/OpenGraphInfoType.swift; sourceTree = ""; }; 50DBDEFB1C4CCB030044E21B /* ChatLeftTextURLCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChatLeftTextURLCell.swift; path = Views/Cells/ChatLeftTextURL/ChatLeftTextURLCell.swift; sourceTree = ""; }; 50DBDEFF1C4CE75E0044E21B /* ChatRightTextURLCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChatRightTextURLCell.swift; path = Views/Cells/ChatRightTextURL/ChatRightTextURLCell.swift; sourceTree = ""; }; 50DBDF041C4DD9530044E21B /* CGSize+Yep.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "CGSize+Yep.swift"; path = "Extensions/CGSize+Yep.swift"; sourceTree = ""; }; @@ -2071,7 +2071,7 @@ 50DBDEF21C48C2290044E21B /* Protocols */ = { isa = PBXGroup; children = ( - 50DBDEF01C48C2240044E21B /* FeedURLInfoType.swift */, + 50DBDEF01C48C2240044E21B /* OpenGraphInfoType.swift */, ); name = Protocols; sourceTree = ""; @@ -2872,7 +2872,7 @@ 0A90187E1B01152800AE4B7F /* ProfileSocialAccountCell.swift in Sources */, 50F5AF831BBA67060033C9BC /* NewFeedViewController.swift in Sources */, 50FE29CD1C4786AE0067CA03 /* FeedURLCell.swift in Sources */, - 50DBDEF11C48C2240044E21B /* FeedURLInfoType.swift in Sources */, + 50DBDEF11C48C2240044E21B /* OpenGraphInfoType.swift in Sources */, 50894CF51AEA4A01000981AF /* SettingsUserCell.swift in Sources */, 84385C441B8592120071130D /* ShowStepGeniusViewController.swift in Sources */, 6A5632931BC911CB00397B53 /* DiscoverNormalUserCell.swift in Sources */, diff --git a/Yep/Protocols/FeedURLInfoType.swift b/Yep/Protocols/OpenGraphInfoType.swift similarity index 84% rename from Yep/Protocols/FeedURLInfoType.swift rename to Yep/Protocols/OpenGraphInfoType.swift index f976a754..5f75247a 100644 --- a/Yep/Protocols/FeedURLInfoType.swift +++ b/Yep/Protocols/OpenGraphInfoType.swift @@ -1,5 +1,5 @@ // -// FeedURLInfoType.swift +// OpenGraphInfoType.swift // Yep // // Created by nixzhu on 16/1/15. @@ -8,7 +8,7 @@ import Foundation -protocol FeedURLInfoType { +protocol OpenGraphInfoType { var URL: NSURL { get } diff --git a/Yep/Realm/Models.swift b/Yep/Realm/Models.swift index 61c612fa..44bf1494 100644 --- a/Yep/Realm/Models.swift +++ b/Yep/Realm/Models.swift @@ -864,7 +864,7 @@ class OpenGraphInfo: Object { } } -extension OpenGraphInfo: FeedURLInfoType { +extension OpenGraphInfo: OpenGraphInfoType { var URL: NSURL { return NSURL(string: URLString)! diff --git a/Yep/Services/YepService.swift b/Yep/Services/YepService.swift index 2ea09385..f92dd560 100644 --- a/Yep/Services/YepService.swift +++ b/Yep/Services/YepService.swift @@ -2959,7 +2959,7 @@ struct DiscoveredFeed: Hashable { } } - struct URLInfo: FeedURLInfoType { + struct URLInfo: OpenGraphInfoType { let URL: NSURL diff --git a/Yep/ViewControllers/Conversation/ConversationViewController.swift b/Yep/ViewControllers/Conversation/ConversationViewController.swift index daac0c60..4fc2149b 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController.swift @@ -259,18 +259,18 @@ enum ConversationFeed { return nil } - var URLInfo: FeedURLInfoType? { + var openGraphInfo: OpenGraphInfoType? { switch self { case .DiscoveredFeedType(let discoveredFeed): if let attachment = discoveredFeed.attachment { - if case let .URL(URLInfo) = attachment { - return URLInfo + if case let .URL(openGraphInfo) = attachment { + return openGraphInfo } } case .FeedType(let feed): - if let URLInfo = feed.openGraphInfo { - return URLInfo + if let openGraphInfo = feed.openGraphInfo { + return openGraphInfo } } diff --git a/Yep/Views/Cells/ChatLeftTextURL/ChatLeftTextURLCell.swift b/Yep/Views/Cells/ChatLeftTextURL/ChatLeftTextURLCell.swift index d59fd783..a63a9790 100644 --- a/Yep/Views/Cells/ChatLeftTextURL/ChatLeftTextURLCell.swift +++ b/Yep/Views/Cells/ChatLeftTextURL/ChatLeftTextURLCell.swift @@ -52,7 +52,7 @@ class ChatLeftTextURLCell: ChatLeftTextCell { feedURLContainerView.frame = feedURLContainerViewFrame if let openGraphInfo = message.openGraphInfo { - feedURLContainerView.configureWithFeedURLInfoType(openGraphInfo) + feedURLContainerView.configureWithOpenGraphInfoType(openGraphInfo) openGraphURL = openGraphInfo.URL } } diff --git a/Yep/Views/Cells/ChatRightTextURL/ChatRightTextURLCell.swift b/Yep/Views/Cells/ChatRightTextURL/ChatRightTextURLCell.swift index 39906682..4637ab70 100644 --- a/Yep/Views/Cells/ChatRightTextURL/ChatRightTextURLCell.swift +++ b/Yep/Views/Cells/ChatRightTextURL/ChatRightTextURLCell.swift @@ -53,7 +53,7 @@ class ChatRightTextURLCell: ChatRightTextCell { feedURLContainerView.frame = feedURLContainerViewFrame if let openGraphInfo = message.openGraphInfo { - feedURLContainerView.configureWithFeedURLInfoType(openGraphInfo) + feedURLContainerView.configureWithOpenGraphInfoType(openGraphInfo) openGraphURL = openGraphInfo.URL } } diff --git a/Yep/Views/Cells/Feed/FeedURLCell.swift b/Yep/Views/Cells/Feed/FeedURLCell.swift index 06bc41bc..6bf4c9e4 100644 --- a/Yep/Views/Cells/Feed/FeedURLCell.swift +++ b/Yep/Views/Cells/Feed/FeedURLCell.swift @@ -62,7 +62,7 @@ class FeedURLCell: FeedBasicCell { if let attachment = feed.attachment { if case let .URL(URLInfo) = attachment { - feedURLContainerView.configureWithFeedURLInfoType(URLInfo) + feedURLContainerView.configureWithOpenGraphInfoType(URLInfo) feedURLContainerView.tapAction = { [weak self] in self?.tapURLInfoAction?(URL: URLInfo.URL) diff --git a/Yep/Views/ContainerViews/FeedURLContainerView.swift b/Yep/Views/ContainerViews/FeedURLContainerView.swift index a887d44e..432789f5 100644 --- a/Yep/Views/ContainerViews/FeedURLContainerView.swift +++ b/Yep/Views/ContainerViews/FeedURLContainerView.swift @@ -146,13 +146,13 @@ class FeedURLContainerView: UIView { tapAction?() } - func configureWithFeedURLInfoType(URLInfo: FeedURLInfoType) { + func configureWithOpenGraphInfoType(openGraphInfo: OpenGraphInfoType) { - siteNameLabel.text = URLInfo.siteName - titleLabel.text = URLInfo.title - descriptionLabel.text = URLInfo.infoDescription + siteNameLabel.text = openGraphInfo.siteName + titleLabel.text = openGraphInfo.title + descriptionLabel.text = openGraphInfo.infoDescription - if let thumbnailImageURL = NSURL(string: URLInfo.thumbnailImageURLString) { + if let thumbnailImageURL = NSURL(string: openGraphInfo.thumbnailImageURLString) { thumbnailImageView.kf_setImageWithURL(thumbnailImageURL, placeholderImage: nil) } else { thumbnailImageView.image = nil diff --git a/Yep/Views/Feed/FeedView.swift b/Yep/Views/Feed/FeedView.swift index c0d541b0..716b04f5 100644 --- a/Yep/Views/Feed/FeedView.swift +++ b/Yep/Views/Feed/FeedView.swift @@ -360,8 +360,8 @@ class FeedView: UIView { socialWorkContainerViewHeightConstraint.constant = 80 - if let URLInfo = feed.URLInfo { - feedURLContainerView.configureWithFeedURLInfoType(URLInfo) + if let openGraphInfo = feed.openGraphInfo { + feedURLContainerView.configureWithOpenGraphInfoType(openGraphInfo) } case .Image: @@ -512,7 +512,7 @@ class FeedView: UIView { } func tapURLInfo(sender: UITapGestureRecognizer) { - guard let URL = feed?.URLInfo?.URL else { + guard let URL = feed?.openGraphInfo?.URL else { return }