Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Yerin Hwang committed Aug 30, 2017
2 parents 7f688b2 + 2760625 commit 964c74e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 44 deletions.
4 changes: 2 additions & 2 deletions fling/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="nId-NT-Pi0">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12121" systemVersion="16D30" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="nId-NT-Pi0">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
Expand Down Expand Up @@ -93,7 +93,7 @@
<constraint firstItem="xFW-7y-EIM" firstAttribute="leading" secondItem="aMf-54-ErX" secondAttribute="trailing" constant="86" id="vTi-Wl-D5o"/>
</constraints>
</view>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="WYK-4L-NE7">
<collectionView clipsSubviews="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="WYK-4L-NE7">
<rect key="frame" x="0.0" y="44" width="375" height="571"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="10" minimumInteritemSpacing="10" id="7Yr-aM-1dp">
Expand Down
10 changes: 0 additions & 10 deletions fling/Home view/HomeRecipeCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,10 @@ class HomeRecipeCollectionViewCell: UICollectionViewCell {

var clickHandler:(() -> Void)!

@IBAction func imageTapped(_ sender: UIImageView) {
self.clickHandler()
}

override func awakeFromNib() {
let cgSize = CGSize.init(width: 187.5, height: 227.5)
self.frame.size = cgSize
// self.backgroundColor = UIColor.darkGray

self.sampleRecipeImage.frame.size = CGSize(width: 167.5, height: 167.5)
self.sampleRecipeImage.isUserInteractionEnabled = true

let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(imageTapped))
sampleRecipeImage.addGestureRecognizer(tapRecognizer)
sampleRecipeImage.layer.masksToBounds = true
}

Expand Down
54 changes: 22 additions & 32 deletions fling/Home view/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class HomeViewController: UIViewController {
var recipe = Recipe.init()
var recipeSearchList = SearchList.init()
var keyword = ""
var flagForCollectionView = true
let keywordHighlight = KeywordHighlight()

let failedView = UIView()
Expand Down Expand Up @@ -80,6 +81,10 @@ class HomeViewController: UIViewController {
network.getFlingRecipe()
network.getSeason()
}

override func viewDidAppear(_ animated: Bool) {
self.flagForCollectionView = false
}

override func viewWillDisappear(_ animated: Bool) {
homeView.endEditing(true)
Expand Down Expand Up @@ -161,35 +166,6 @@ class HomeViewController: UIViewController {
homeView.endEditing(true)
}
}

func drawFailureView() {
failedView.frame = CGRect.init(x: 0, y: 0, width: 250, height: 200)
failedView.center.x = self.view.center.x
failedView.center.y = self.view.center.y
failedView.backgroundColor = UIColor.white
self.view.addSubview(failedView)

let none = UIImage.init(named: "none.png")
noneView.image = none
noneView.frame = CGRect.init(x: 0, y: 0, width: 80, height: 140)
noneView.center.x = self.view.center.x
noneView.center.y = self.view.center.y - 10
self.view.addSubview(noneView)

message.font = UIFont.systemFont(ofSize: 14)
message.text = "플링이 찾지 못한 레시피에요."
message.textAlignment = .center
message.frame = CGRect.init(x: 0, y: 0, width: 250, height: 30)
message.center.x = self.view.center.x
message.center.y = self.view.center.y + 80
self.view.addSubview(message)
}

func hideFailureView() {
failedView.isHidden = true
noneView.isHidden = true
message.isHidden = true
}
}

extension HomeViewController: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
Expand Down Expand Up @@ -272,9 +248,6 @@ extension HomeViewController: UICollectionViewDelegate, UICollectionViewDataSour
}
cell.sampleRecipeLabel.text = recipeCell.title
cell.sampleRecipeSubtitleLabel.text = recipeCell.subtitle
cell.clickHandler = { () -> Void in
self.network.getRecipeWith(recipeId: recipeCell.rid)
}
}

return cell
Expand All @@ -287,6 +260,23 @@ extension HomeViewController: UICollectionViewDelegate, UICollectionViewDataSour
homeView.endEditing(true)
}
}

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

if(self.flagForCollectionView == true){
return;
} else {
self.flagForCollectionView = false;
var recipeCell = Recipe()
if indexPath.section == 0 {
recipeCell = self.recipes[indexPath.row]
} else {
recipeCell = self.seasonRecipes[indexPath.row]
}
self.network.getRecipeWith(recipeId: recipeCell.rid)
}

}
}

extension HomeViewController: UITableViewDelegate, UITableViewDataSource {
Expand Down

0 comments on commit 964c74e

Please sign in to comment.