Skip to content

Commit

Permalink
Merge pull request #25 from yangsubinn/feature/#16
Browse files Browse the repository at this point in the history
[Feat] #16 - 피드뷰 레이아웃 구현
  • Loading branch information
yangsubinn authored Jan 12, 2022
2 parents efd36e0 + e260519 commit 70f60ac
Show file tree
Hide file tree
Showing 6 changed files with 487 additions and 4 deletions.
12 changes: 12 additions & 0 deletions Spark-iOS/Spark-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
objects = {

/* Begin PBXBuildFile section */
2B69E7E5278E22F4000F927F /* FeedHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B69E7E4278E22F4000F927F /* FeedHeaderView.swift */; };
2B69E7E7278E28B2000F927F /* FeedCVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B69E7E6278E28B2000F927F /* FeedCVC.swift */; };
2B9471F9278BE922005484C5 /* NotoSansKR-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 2B9471F6278BE922005484C5 /* NotoSansKR-Bold.otf */; };
2B9471FA278BE922005484C5 /* NotoSansKR-Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = 2B9471F7278BE922005484C5 /* NotoSansKR-Medium.otf */; };
2B9471FB278BE922005484C5 /* NotoSansKR-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = 2B9471F8278BE922005484C5 /* NotoSansKR-Regular.otf */; };
2B947203278CB00E005484C5 /* Futura Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = 2B947200278CB00E005484C5 /* Futura Medium.otf */; };
2B947204278CB00E005484C5 /* Futura Medium Italic.otf in Resources */ = {isa = PBXBuildFile; fileRef = 2B947201278CB00E005484C5 /* Futura Medium Italic.otf */; };
2B947205278CB00E005484C5 /* Futura Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = 2B947202278CB00E005484C5 /* Futura Bold.otf */; };
2BC1726D278E8F1000BA3029 /* UIView+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2BC1726C278E8F1000BA3029 /* UIView+Extension.swift */; };
76CFA86ADD8A78B244A43E61 /* Pods_Spark_iOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E41C0A73912FEE9D1B2F72ED /* Pods_Spark_iOS.framework */; };
EBA77239278A2E14002958A5 /* Colors.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EBA77238278A2E14002958A5 /* Colors.xcassets */; };
F8096F042784107D00B71D38 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8096F032784107D00B71D38 /* AppDelegate.swift */; };
Expand Down Expand Up @@ -43,12 +46,15 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
2B69E7E4278E22F4000F927F /* FeedHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedHeaderView.swift; sourceTree = "<group>"; };
2B69E7E6278E28B2000F927F /* FeedCVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedCVC.swift; sourceTree = "<group>"; };
2B9471F6278BE922005484C5 /* NotoSansKR-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NotoSansKR-Bold.otf"; sourceTree = "<group>"; };
2B9471F7278BE922005484C5 /* NotoSansKR-Medium.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NotoSansKR-Medium.otf"; sourceTree = "<group>"; };
2B9471F8278BE922005484C5 /* NotoSansKR-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "NotoSansKR-Regular.otf"; sourceTree = "<group>"; };
2B947200278CB00E005484C5 /* Futura Medium.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Futura Medium.otf"; sourceTree = "<group>"; };
2B947201278CB00E005484C5 /* Futura Medium Italic.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Futura Medium Italic.otf"; sourceTree = "<group>"; };
2B947202278CB00E005484C5 /* Futura Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Futura Bold.otf"; sourceTree = "<group>"; };
2BC1726C278E8F1000BA3029 /* UIView+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIView+Extension.swift"; sourceTree = "<group>"; };
3F3E6E986D8C9F3A27A30253 /* Pods-Spark-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Spark-iOS.release.xcconfig"; path = "Target Support Files/Pods-Spark-iOS/Pods-Spark-iOS.release.xcconfig"; sourceTree = "<group>"; };
C35EB7FFC7E2CF05E63983A7 /* Pods-Spark-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Spark-iOS.debug.xcconfig"; path = "Target Support Files/Pods-Spark-iOS/Pods-Spark-iOS.debug.xcconfig"; sourceTree = "<group>"; };
E41C0A73912FEE9D1B2F72ED /* Pods_Spark_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Spark_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -255,6 +261,7 @@
children = (
F8096F3B2784211D00B71D38 /* UIColor+Extension.swift */,
F8096F3D2784213700B71D38 /* UIFont+Extension.swift */,
2BC1726C278E8F1000BA3029 /* UIView+Extension.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand All @@ -263,6 +270,8 @@
isa = PBXGroup;
children = (
F8096F3F2784214000B71D38 /* TempCell.swift */,
2B69E7E4278E22F4000F927F /* FeedHeaderView.swift */,
2B69E7E6278E28B2000F927F /* FeedCVC.swift */,
);
path = Cells;
sourceTree = "<group>";
Expand Down Expand Up @@ -414,13 +423,16 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2BC1726D278E8F1000BA3029 /* UIView+Extension.swift in Sources */,
F8096F422784214900B71D38 /* TempAppModel.swift in Sources */,
F8096F3227841FE100B71D38 /* ViewController.swift in Sources */,
F8096F042784107D00B71D38 /* AppDelegate.swift in Sources */,
2B69E7E5278E22F4000F927F /* FeedHeaderView.swift in Sources */,
F80A3E55278C1C1F00728E07 /* StorageVC.swift in Sources */,
F8096F3A2784210A00B71D38 /* TempModel.swift in Sources */,
F8096F3C2784211D00B71D38 /* UIColor+Extension.swift in Sources */,
F8096F34278420F100B71D38 /* TempView.swift in Sources */,
2B69E7E7278E28B2000F927F /* FeedCVC.swift in Sources */,
F8096F2B27841F4100B71D38 /* Storyboard.swift in Sources */,
F8096F442784221900B71D38 /* Xib.swift in Sources */,
F80A3E4F278C18BA00728E07 /* MainTBC.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down
152 changes: 152 additions & 0 deletions Spark-iOS/Spark-iOS/Source/Cells/FeedCVC.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
//
// FeedCVC.swift
// Spark-iOS
//
// Created by 양수빈 on 2022/01/12.
//

import UIKit

import SnapKit

class FeedCVC: UICollectionViewCell {
static let identifier = "FeedCVC"

// MARK: - Properties

let feedImageView = UIImageView()
let fadeImageView = UIImageView()
let timeLabel = UILabel()
let profileImageView = UIImageView()
let nameLabel = UILabel() /// 힛이

let titleStackView = UIStackView() /// titleLabel, doneImageView
let titleLabel = UILabel() /// 아침 독서
let doneImageView = UIImageView() /// done

let sparkStackView = UIStackView() /// 받은 스파크 + icon + 12
let sparkLabel = UILabel() /// 받은 스파크 개수
let sparkIconImageView = UIImageView()
let sparkCountLabel = UILabel() /// 12

let heartImageView = UIImageView()
let heartCountLabel = UILabel()

// MARK: - View Life Cycles

override init(frame: CGRect) {
super.init(frame: frame)
setUI()
setStackView()
setLayout()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Methods
func setUI() {
feedImageView.backgroundColor = .yellow
profileImageView.backgroundColor = .black
fadeImageView.backgroundColor = .sparkBlack.withAlphaComponent(0.15)

profileImageView.layer.cornerRadius = 32

sparkLabel.text = "받은 스파크"
// TODO: - 서버 데이터 연결 후 삭제
timeLabel.text = "00:30:18"
nameLabel.text = "힛이"
titleLabel.text = "아침 독서"
sparkCountLabel.text = "12"
heartCountLabel.text = "21"

timeLabel.font = .enBoldFont(ofSize: 40)
nameLabel.font = .p1Title
titleLabel.font = .krBoldFont(ofSize: 20)
sparkCountLabel.font = .p2SubtitleEng
heartCountLabel.font = .h2TitleEng

timeLabel.textColor = .sparkWhite
nameLabel.textColor = .sparkDeepGray
titleLabel.textColor = .sparkDeepGray
sparkLabel.textColor = .sparkDarkGray
sparkCountLabel.textColor = .sparkDarkGray
heartCountLabel.textColor = .sparkGray

doneImageView.image = UIImage(named: "tagDone")
sparkIconImageView.image = UIImage(named: "icFire")
heartImageView.image = UIImage(named: "icHeartInactive")
}

func setStackView() {
titleStackView.axis = .horizontal
titleStackView.alignment = .fill
titleStackView.distribution = .equalSpacing
titleStackView.spacing = 8
titleStackView.addArrangedSubview(titleLabel)
titleStackView.addArrangedSubview(doneImageView)

sparkStackView.axis = .horizontal
sparkStackView.alignment = .fill
sparkStackView.distribution = .equalSpacing
sparkStackView.spacing = 3
sparkStackView.addArrangedSubview(sparkLabel)
sparkStackView.addArrangedSubview(sparkIconImageView)
sparkStackView.addArrangedSubview(sparkCountLabel)
}

func setLayout() {
self.addSubviews([feedImageView, fadeImageView, profileImageView,
nameLabel, titleStackView, timeLabel,
sparkStackView, heartImageView, heartCountLabel])

feedImageView.snp.makeConstraints { make in
make.top.leading.trailing.equalToSuperview()
make.height.equalTo(feedImageView.snp.width).multipliedBy(1.0 / 1.0)
}

fadeImageView.snp.makeConstraints { make in
make.edges.equalTo(feedImageView.snp.edges)
}

timeLabel.snp.makeConstraints { make in
make.center.equalTo(feedImageView.snp.center)
}

profileImageView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.centerY.equalTo(feedImageView.snp.bottom)
make.width.height.equalTo(64)
}

nameLabel.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(profileImageView.snp.bottom).offset(4)
}

titleStackView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(nameLabel.snp.bottom).offset(8)
}

sparkStackView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(titleStackView.snp.bottom).offset(8)
}

sparkIconImageView.snp.makeConstraints { make in
make.width.height.equalTo(16)
}

heartImageView.snp.makeConstraints { make in
make.top.equalTo(feedImageView.snp.bottom).offset(20)
make.trailing.equalToSuperview().inset(50)
}

heartCountLabel.snp.makeConstraints { make in
make.leading.equalTo(heartImageView.snp.trailing).offset(5)
make.centerY.equalTo(heartImageView.snp.centerY)
}
}
}
58 changes: 58 additions & 0 deletions Spark-iOS/Spark-iOS/Source/Cells/FeedHeaderView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// FeedHeaderView.swift
// Spark-iOS
//
// Created by 양수빈 on 2022/01/12.
//

import UIKit

import SwiftUI
import SnapKit

class FeedHeaderView: UICollectionReusableView {
static let identifier = "FeedHeaderView"

// MARK: - Properties

let dateLabel = UILabel()
let dayLabel = UILabel()

// MARK: - View Life Cycles
override init(frame: CGRect) {
super.init(frame: frame)

setUI()
setLayout()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

// MARK: - Methods

func setUI() {
self.backgroundColor = .sparkWhite
dateLabel.font = .h3SubtitleEng
dateLabel.text = "2022년 1월 7일"
dateLabel.textColor = .sparkDeepGray

dayLabel.font = .p1TitleLight
dayLabel.text = "금요일"
dayLabel.textColor = .sparkDarkGray
}

func setLayout() {
self.addSubviews([dayLabel, dateLabel])

dateLabel.snp.makeConstraints { make in
make.top.leading.equalToSuperview().offset(20)
}

dayLabel.snp.makeConstraints { make in
make.leading.equalToSuperview().offset(20)
make.top.equalTo(dateLabel.snp.bottom)
}
}
}
14 changes: 14 additions & 0 deletions Spark-iOS/Spark-iOS/Source/Extensions/UIView+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// UIView+Extension.swift
// Spark-iOS
//
// Created by 양수빈 on 2022/01/12.
//

import UIKit

extension UIView {
func addSubviews(_ views: [UIView]) {
views.forEach { self.addSubview($0) }
}
}
Loading

0 comments on commit 70f60ac

Please sign in to comment.