Skip to content

Commit

Permalink
#5 HomeTableViewCell
Browse files Browse the repository at this point in the history
  • Loading branch information
seondal committed Dec 22, 2021
1 parent 267e3b3 commit 2b29801
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 10 deletions.
16 changes: 16 additions & 0 deletions DalTube/DalTube.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
9A1870852708521500228B78 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9A1870832708521500228B78 /* Main.storyboard */; };
9A1870872708521600228B78 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9A1870862708521600228B78 /* Assets.xcassets */; };
9A18708A2708521600228B78 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9A1870882708521600228B78 /* LaunchScreen.storyboard */; };
9A193E13277333E500231077 /* HomeCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A193E11277333E500231077 /* HomeCollectionViewCell.swift */; };
9A193E14277333E500231077 /* HomeCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9A193E12277333E500231077 /* HomeCollectionViewCell.xib */; };
9A193E172773395C00231077 /* TagCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A193E152773395C00231077 /* TagCollectionViewCell.swift */; };
9A193E182773395C00231077 /* TagCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9A193E162773395C00231077 /* TagCollectionViewCell.xib */; };
9A43F82C27293CDD002DC0D5 /* CustomTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A43F82B27293CDD002DC0D5 /* CustomTabBarController.swift */; };
9A43F838272944A2002DC0D5 /* HomeVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A43F837272944A2002DC0D5 /* HomeVC.swift */; };
9A43F83A272944B6002DC0D5 /* ShortsVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A43F839272944B6002DC0D5 /* ShortsVC.swift */; };
Expand All @@ -39,6 +43,10 @@
9A1870862708521600228B78 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
9A1870892708521600228B78 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
9A18708B2708521600228B78 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9A193E11277333E500231077 /* HomeCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeCollectionViewCell.swift; sourceTree = "<group>"; };
9A193E12277333E500231077 /* HomeCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = HomeCollectionViewCell.xib; sourceTree = "<group>"; };
9A193E152773395C00231077 /* TagCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TagCollectionViewCell.swift; sourceTree = "<group>"; };
9A193E162773395C00231077 /* TagCollectionViewCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = TagCollectionViewCell.xib; sourceTree = "<group>"; };
9A43F82B27293CDD002DC0D5 /* CustomTabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomTabBarController.swift; sourceTree = "<group>"; };
9A43F837272944A2002DC0D5 /* HomeVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeVC.swift; sourceTree = "<group>"; };
9A43F839272944B6002DC0D5 /* ShortsVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortsVC.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -129,6 +137,10 @@
children = (
9A43F837272944A2002DC0D5 /* HomeVC.swift */,
9A04DCA02743E17F0012658D /* HomeTableViewCell.swift */,
9A193E11277333E500231077 /* HomeCollectionViewCell.swift */,
9A193E152773395C00231077 /* TagCollectionViewCell.swift */,
9A193E162773395C00231077 /* TagCollectionViewCell.xib */,
9A193E12277333E500231077 /* HomeCollectionViewCell.xib */,
9A04DCA12743E17F0012658D /* HomeTableViewCell.xib */,
9A04DCA42743E7BA0012658D /* HomeContentDataModel.swift */,
);
Expand Down Expand Up @@ -192,8 +204,10 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9A193E14277333E500231077 /* HomeCollectionViewCell.xib in Resources */,
9A18708A2708521600228B78 /* LaunchScreen.storyboard in Resources */,
9A1870872708521600228B78 /* Assets.xcassets in Resources */,
9A193E182773395C00231077 /* TagCollectionViewCell.xib in Resources */,
9A04DCA32743E17F0012658D /* HomeTableViewCell.xib in Resources */,
9A1870852708521500228B78 /* Main.storyboard in Resources */,
);
Expand All @@ -211,9 +225,11 @@
9A43F838272944A2002DC0D5 /* HomeVC.swift in Sources */,
9A04DCA22743E17F0012658D /* HomeTableViewCell.swift in Sources */,
9A43F82C27293CDD002DC0D5 /* CustomTabBarController.swift in Sources */,
9A193E13277333E500231077 /* HomeCollectionViewCell.swift in Sources */,
9A53B76C270A7DEB00ECE343 /* SigninViewController.swift in Sources */,
9A43F83C272944BF002DC0D5 /* AddVC.swift in Sources */,
9A1870822708521500228B78 /* ViewController.swift in Sources */,
9A193E172773395C00231077 /* TagCollectionViewCell.swift in Sources */,
9A43F840272944D2002DC0D5 /* StoreVC.swift in Sources */,
9A53B76E270A7E0A00ECE343 /* WelcomeViewController.swift in Sources */,
9A43F83E272944C9002DC0D5 /* SubVC.swift in Sources */,
Expand Down
Binary file not shown.
23 changes: 23 additions & 0 deletions DalTube/DalTube/Assets.xcassets/ggamju.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "image 210.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "image [email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "image [email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
10 changes: 10 additions & 0 deletions DalTube/DalTube/Home/HomeContentDataModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ struct HomeContentData {
return UIImage(named: authorImageName)
}
}

struct HomeTopData {
let name : String

let iconImageName: String

func makeIconImage() -> UIImage? {
return UIImage(named: iconImageName)
}
}
9 changes: 5 additions & 4 deletions DalTube/DalTube/Home/HomeTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19455" 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="18093"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
Expand All @@ -16,8 +17,8 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="306"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ytU-Ho-tHq">
<rect key="frame" x="0.0" y="0.0" width="375" height="212"/>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ytU-Ho-tHq">
<rect key="frame" x="1" y="0.0" width="375" height="212"/>
<constraints>
<constraint firstAttribute="height" constant="212" id="E7X-lm-nWt"/>
<constraint firstAttribute="width" constant="375" id="u32-kq-Vvj"/>
Expand Down
63 changes: 57 additions & 6 deletions DalTube/DalTube/Home/HomeVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,49 @@ class HomeVC: UIViewController {
@IBOutlet weak var alarmBUtton: UIButton!
@IBOutlet weak var searchButton: UIButton!

@IBOutlet weak var homeCollectionView: UICollectionView!
@IBOutlet weak var homeTableView: UITableView!
@IBOutlet weak var homeCollectionView: UICollectionView!

var homeContentList : [HomeContentData] = []

//MARK : TableViewDataList
var homeContentList : [HomeContentData] = []
var homeTopList : [HomeTopData] = []

override func viewDidLoad() {
super.viewDidLoad()
initHomeContentList()
initContentList()
registerXib()
homeTableView.dataSource = self
homeTableView.delegate = self
homeCollectionView.dataSource = self
homeCollectionView.delegate = self
}

func registerXib(){
let xibName = UINib(nibName: HomeTableViewCell.identifier, bundle: nil)
homeTableView.register(xibName, forCellReuseIdentifier: HomeTableViewCell.identifier)
homeTableView.register(UINib(nibName: HomeTableViewCell.identifier, bundle: nil), forCellReuseIdentifier: HomeTableViewCell.identifier)

homeCollectionView.register(UINib(nibName: HomeCollectionViewCell.identifier, bundle: .main), forCellWithReuseIdentifier: HomeCollectionViewCell.identifier)

}

func initHomeContentList() {
func initContentList() {
homeContentList.append(contentsOf: [
HomeContentData(title: "1차 iOS 세미나 : iOS 컴포넌트 이해, Xcode 기본 사용법, View 화면전환", information: "WE SOPT ・조회수 100만회 ・ 3주 전", authorImageName: "wesoptProfile", thumbImageName: "wesoptiOSPart"),
HomeContentData(title: "2차 iOS 세미나 : AutoLayout, StackView, TabBarController", information: "WE SOPT ・조회수 100만회 ・ 3주 전", authorImageName: "wesoptProfile", thumbImageName: "wesoptiOSPart"),
HomeContentData(title: "3차 iOS 세미나 : ScrollView, Delegate Pattern, TableView, CollectionView", information: "WE SOPT ・조회수 100만회 ・ 3주 전", authorImageName: "wesoptProfile", thumbImageName: "wesoptiOSPart"),
HomeContentData(title: "4차 iOS 세미나 : Cocoapods & Networking, REST API", information: "WE SOPT ・조회수 100만회 ・ 3주 전", authorImageName: "wesoptProfile", thumbImageName: "wesoptiOSPart"),
HomeContentData(title: "7차 iOS 세미나 : Animation과 제스쳐, 데이터 전달 심화 ", information: "WE SOPT ・조회수 100만회 ・ 3주 전", authorImageName: "wesoptProfile", thumbImageName: "wesoptiOSPart")
])

homeTopList.append(contentsOf: [
HomeTopData(name: "iOSPart", iconImageName: "ggamju"),
HomeTopData(name: "ServerPart", iconImageName: "ggamju"),
HomeTopData(name: "WebPart", iconImageName: "ggamju"),
HomeTopData(name: "AndroidPart", iconImageName: "ggamju"),
HomeTopData(name: "DesignPart", iconImageName: "ggamju"),
HomeTopData(name: "PlanPart", iconImageName: "ggamju"),

])
}
}

Expand All @@ -62,6 +79,40 @@ extension HomeVC: UITableViewDataSource{

return cell
}
}

//MARK : CollectionViewDataList

extension HomeVC: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: HomeCollectionViewCell.identifier, for: indexPath) as? HomeCollectionViewCell else {return UICollectionViewCell()}

cell.setData(appName: homeTopList[indexPath.row].name, appImage: homeTopList[indexPath.row].makeIconImage())

return cell
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return homeTopList.count
}


}

extension HomeVC: UICollectionViewDelegateFlowLayout{
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
return CGSize(width: 75, height: 105)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets.zero
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionView, minimumLineSpacingForSectiont section : Int) -> CGFloat {
return 0
}

func collectionVIew(_ collectionView: UICollectionView, layout collectionVIewLayout: UICollectionView, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
}

0 comments on commit 2b29801

Please sign in to comment.