Skip to content

Commit

Permalink
Merge pull request #100 from ebPark9511/QurationTag
Browse files Browse the repository at this point in the history
ํ๋ ˆ์ด์…˜ํƒœ๊ทธ API
  • Loading branch information
Jae-eun authored May 4, 2019
2 parents 1c93752 + 7a9b5b9 commit bb15248
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 38 deletions.
52 changes: 47 additions & 5 deletions Toonie/Feed/RecommendView/RecommendCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,66 @@ import UIKit
// '์ง€๊ธˆ๋‚˜๋Š”
final class RecommendCollectionViewCell: UICollectionViewCell {

// MARK: - Properties
var toonID: String = ""
var toonName: String = ""
var instaID: String = ""
var instaUrl: String = ""
var instaThumnailUrl: String = ""
var instafollowerCnt: String = ""
var instaLatestPostUrl: String = ""

// MARK: - IBOutlets

@IBOutlet private weak var recentToonImageView: UIImageView!
@IBOutlet private weak var artistLabel: UILabel!
@IBOutlet private weak var toonNameTitle: UILabel!
@IBOutlet private weak var bookMarkButton: UIButton!
@IBOutlet weak var curationTagList: UILabel!

override func prepareForReuse() {
super.prepareForReuse()
recentToonImageView.image = nil
artistLabel.text = nil
toonNameTitle.text = nil
bookMarkButton.isSelected = false
}

// MARK: - Functions

/// ์ปฌ๋ ‰์…˜๋ทฐ์…€ ๋ฐ์ดํ„ฐ ์„ค์ •
func setRecommendCollectionViewCellProperties() {
recentToonImageView.image = UIImage(named: "sample2")
artistLabel.text = "์ž„์œ ๋ผ"
func setRecommendCollectionViewCellProperties(curationInfoList: ToonInfoList?) {
prepareForReuse()

if let info = curationInfoList {
DispatchQueue.main.async {
if let url = URL(string: info.instaThumnailUrl ?? "") {
do {
let data = try Data(contentsOf: url)
self.recentToonImageView.image = UIImage(data: data)
} catch let error {
print("Error : \(error.localizedDescription)")
}
}
}
if let nameString = info.toonName {
toonNameTitle.text = nameString
}

var tagList = ""
if let toonTagList = info.toonTagList {
for index in 0..<toonTagList.count {
tagList += "#" + toonTagList[index] + " "
}
curationTagList.text = tagList
}

toonID = info.toonID ?? ""
toonName = info.toonName ?? ""
instaID = info.instaID ?? ""
instaUrl = info.instaUrl ?? ""
instaThumnailUrl = info.instaThumnailUrl ?? ""
instafollowerCnt = info.instafollowerCount ?? ""
instaLatestPostUrl = info.instaLatestPostUrl ?? ""

}
}
}
11 changes: 6 additions & 5 deletions Toonie/Feed/RecommendView/RecommendCollectionViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -20,8 +20,9 @@
<rect key="frame" x="0.0" y="0.0" width="220" height="228"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="sampleImg" translatesAutoresizingMaskIntoConstraints="NO" id="vyT-Im-UWv">
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="vyT-Im-UWv">
<rect key="frame" x="0.0" y="0.0" width="220" height="228"/>
<color key="backgroundColor" cocoaTouchSystemColor="tableCellGroupedBackgroundColor"/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XsH-S1-CT3">
<rect key="frame" x="0.0" y="148" width="220" height="80"/>
Expand Down Expand Up @@ -72,16 +73,16 @@
</constraints>
<viewLayoutGuide key="safeArea" id="T1S-cw-jwq"/>
<connections>
<outlet property="artistLabel" destination="jqO-5V-FEi" id="gKn-vI-VPf"/>
<outlet property="bookMarkButton" destination="q7H-ju-Wv1" id="iRl-gb-7ZP"/>
<outlet property="curationTagList" destination="moK-Vb-p8R" id="Pfd-Yo-pYa"/>
<outlet property="recentToonImageView" destination="vyT-Im-UWv" id="egQ-Yb-28I"/>
<outlet property="toonNameTitle" destination="jqO-5V-FEi" id="gKn-vI-VPf"/>
</connections>
</collectionViewCell>
</objects>
<resources>
<image name="Bookmark" width="15" height="18"/>
<image name="BookmarkOn" width="15" height="18"/>
<image name="sampleImg" width="335" height="335"/>
<namedColor name="defaultText">
<color red="0.13333333333333333" green="0.13333333333333333" blue="0.13333333333333333" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
Expand Down
50 changes: 43 additions & 7 deletions Toonie/Feed/RecommendView/RecommendTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import UIKit
// '์ง€๊ธˆ ๋‚˜๋Š”' ํ…Œ์ด๋ธ”๋ทฐ ์…€ - storyboard์—์„œ collectionView ์†Œ์Šค๋ถ„๋ฆฌ๊ฐ€ ๋˜์ง€์•Š์•„ xib๋กœ ๋ถ„๋ฆฌ.
final class RecommendTableViewCell: UITableViewCell {

// MARK: - Properties
private var titleString: String? = ""
private var curationTagArray: [ToonInfoList]?

// MARK: - IBOutlet

@IBOutlet private weak var recommentTitleLabel: UILabel!
Expand All @@ -20,6 +24,7 @@ final class RecommendTableViewCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
setRecommendCollectionView()

}

override func setSelected(_ selected: Bool, animated: Bool) {
Expand All @@ -29,24 +34,44 @@ final class RecommendTableViewCell: UITableViewCell {
// MARK: - Function

///delegate์„ธํŒ… ๋ฐ xib(nib) ์„ธํŒ…
func setRecommendCollectionView() {
private func setRecommendCollectionView() {
recommendCollectionView.delegate = self
recommendCollectionView.dataSource = self

let nibName = UINib(nibName: "RecommendCollectionViewCell", bundle: nil)
recommendCollectionView.register(nibName, forCellWithReuseIdentifier: "RecommendCollectionViewCell")
recommendCollectionView.register(nibName,
forCellWithReuseIdentifier: "RecommendCollectionViewCell")
}

func setRecommentTitleLabel(titleString: String?) {
recommentTitleLabel.text = titleString
if let title = titleString {
recommentTitleLabel.text = "#\(title)"
}
self.titleString = titleString
setCurationTag()
}

private func setCurationTag() {
if let string = titleString {
CurationTagService.shared.getCurationTagList(tagName: string) { (result) in
if let curationTagArray = result {
self.curationTagArray = curationTagArray
}

self.recommendCollectionView.reloadData()

}

}

}
}

// MARK: - UICollectionViewDataSource
extension RecommendTableViewCell: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView,
numberOfItemsInSection section: Int) -> Int {
return 3
return curationTagArray?.count ?? 0
}

func collectionView(_ collectionView: UICollectionView,
Expand All @@ -55,15 +80,26 @@ extension RecommendTableViewCell: UICollectionViewDataSource {
for: indexPath) as? RecommendCollectionViewCell else {
return UICollectionViewCell()
}
cell.setRecommendCollectionViewCellProperties()
cell.setRecommendCollectionViewCellProperties(curationInfoList: curationTagArray?[indexPath.row])

return cell
}
}

// MARK: - UICollectionViewDelegate
extension RecommendTableViewCell: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// print("์„ ํƒ \(indexPath.row)")
func collectionView(_ collectionView: UICollectionView,
didSelectItemAt indexPath: IndexPath) {

let storyboard = UIStoryboard(name: "Detail", bundle: nil)
if let viewController = storyboard
.instantiateViewController(withIdentifier: "DetailToonView")
as? DetailToonViewController {
viewController.detailToonID = curationTagArray?[indexPath.row].toonID
CommonUtility.sharedInstance.mainNavigationViewController?
.pushViewController(viewController,
animated: true)
}

}
}
18 changes: 9 additions & 9 deletions Toonie/Feed/RecommendView/RecommendTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -26,13 +26,7 @@
<constraint firstAttribute="height" constant="0.5" id="6hI-9L-Bix"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="#๊ท€์—ฌ์šด ๊ณ ์–‘์ด๊ฐ€ ๋‚˜์˜ค๋Š” " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AhC-vW-eRP">
<rect key="frame" x="20" y="26.5" width="220" height="27"/>
<fontDescription key="fontDescription" name="AppleSDGothicNeo-Bold" family="Apple SD Gothic Neo" pointSize="22"/>
<color key="textColor" name="main"/>
<nil key="highlightedColor"/>
</label>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="jeJ-Zu-TGA">
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="jeJ-Zu-TGA">
<rect key="frame" x="16" y="70" width="343" height="228"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
Expand Down Expand Up @@ -67,6 +61,12 @@
<outlet property="delegate" destination="-1" id="YPG-AM-ZU2"/>
</connections>
</collectionView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="#๊ท€์—ฌ์šด ๊ณ ์–‘์ด๊ฐ€ ๋‚˜์˜ค๋Š” " textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AhC-vW-eRP">
<rect key="frame" x="16" y="26" width="220" height="27"/>
<fontDescription key="fontDescription" name="AppleSDGothicNeo-Bold" family="Apple SD Gothic Neo" pointSize="22"/>
<color key="textColor" name="main"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="o1x-dp-omx" firstAttribute="leading" secondItem="uID-d1-nYh" secondAttribute="leadingMargin" constant="23" id="3IG-73-zS8"/>
Expand Down
Loading

0 comments on commit bb15248

Please sign in to comment.