forked from CDS-Mobile1/CDS_iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request CDS-Mobile1#32 from sarang3009/feat/24-story-ui
[Feat] CDS-Mobile1#24 - story UI 레이아웃 구현
- Loading branch information
Showing
6 changed files
with
212 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+31.5 KB
(140%)
...eproj/project.xcworkspace/xcuserdata/kimsarang.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
Instagram-iOS/Instagram-iOS/Screens/MainFeed/StoryCollection/StoryCollectionView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// | ||
// StoryCollectionView.swift | ||
// Instagram-iOS | ||
// | ||
// Created by 김사랑 on 2023/05/23. | ||
// | ||
|
||
import Foundation | ||
import UIKit | ||
import SnapKit | ||
|
||
final class StoryCollectionView: UIView { | ||
|
||
// MARK: - Property | ||
|
||
private let dummyData: [UIColor] = [ | ||
.systemGray, | ||
.systemGray2, | ||
.systemGray3, | ||
.systemGray4, | ||
.systemGray5, | ||
] | ||
|
||
private enum Size { | ||
static let cellWidth = 71 | ||
static let cellHeight = 93 | ||
} | ||
|
||
// MARK: - UI Property | ||
|
||
private lazy var storyCollectionView: UICollectionView = { | ||
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: flowLayout) | ||
collectionView.isScrollEnabled = true | ||
collectionView.showsHorizontalScrollIndicator = false | ||
collectionView.showsVerticalScrollIndicator = false | ||
collectionView.register(StoryCollectionViewCell.self, forCellWithReuseIdentifier: StoryCollectionViewCell.identifier) | ||
return collectionView | ||
}() | ||
|
||
private let flowLayout: UICollectionViewFlowLayout = { | ||
let layout = UICollectionViewFlowLayout() | ||
layout.scrollDirection = .horizontal | ||
layout.itemSize = .init(width: Size.cellWidth, height: Size.cellHeight) | ||
layout.minimumLineSpacing = 16 | ||
return layout | ||
}() | ||
|
||
// MARK: - Life Cycle | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
setDelegate() | ||
setLayout() | ||
} | ||
|
||
@available(*, unavailable) | ||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: - Setting | ||
|
||
private func setDelegate() { | ||
storyCollectionView.delegate = self | ||
storyCollectionView.dataSource = self | ||
} | ||
|
||
private func setLayout() { | ||
addSubview(storyCollectionView) | ||
storyCollectionView.snp.makeConstraints { | ||
$0.leading.equalToSuperview().inset(8) | ||
$0.trailing.equalToSuperview().inset(0) | ||
$0.top.equalToSuperview().inset(10) | ||
$0.bottom.equalToSuperview().inset(12) | ||
} | ||
} | ||
|
||
} | ||
|
||
|
||
// MARK: - UICollectionView Delegate | ||
|
||
extension StoryCollectionView: UICollectionViewDelegate { | ||
|
||
} | ||
|
||
|
||
// MARK: - UICollectionView Datasource | ||
|
||
extension StoryCollectionView: UICollectionViewDataSource { | ||
|
||
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
return dummyData.count | ||
} | ||
|
||
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | ||
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: StoryCollectionViewCell.identifier, for: indexPath) as? StoryCollectionViewCell | ||
else { return UICollectionViewCell() } | ||
cell.configureCell(with: dummyData[indexPath.row]) | ||
return cell | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
Instagram-iOS/Instagram-iOS/Screens/MainFeed/StoryCollection/StoryCollectionViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// StoryCollectionViewCell.swift | ||
// Instagram-iOS | ||
// | ||
// Created by 김사랑 on 2023/05/23. | ||
// | ||
|
||
import UIKit | ||
import SnapKit | ||
|
||
class StoryCollectionViewCell: BaseCollectionViewCell { | ||
|
||
// MARK: - UI Property | ||
|
||
private let colorView: UIView = { | ||
let view = UIView() | ||
view.layer.masksToBounds = true | ||
return view | ||
}() | ||
|
||
// MARK: - Life Cycle | ||
|
||
override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
|
||
} | ||
|
||
@available(*, unavailable) | ||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
// MARK: - Setting | ||
|
||
override func setLayout() { | ||
addSubview(colorView) | ||
colorView.snp.makeConstraints { | ||
$0.edges.equalToSuperview() | ||
} | ||
} | ||
|
||
// MARK: - Custom Method | ||
|
||
func configureCell(with color: UIColor) { | ||
colorView.backgroundColor = color | ||
} | ||
|
||
|
||
} |