Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "SP_1920774 3.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion Projects/Feature/HomeFeature/Sources/Cell/MoviesCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class MoviesCell: UICollectionViewCell {
self.addSubview(moviesImageView)
moviesImageView.snp.makeConstraints {
$0.edges.equalToSuperview()

}
}

Expand Down
68 changes: 47 additions & 21 deletions Projects/Feature/HomeFeature/Sources/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var bannerImageSources = [
DesignSystemAsset.Images.testImage.image,
DesignSystemAsset.Images.testImage.image,
DesignSystemAsset.Images.testImage.image,
DesignSystemAsset.Images.testImage.image
DesignSystemAsset.Images.testImage2.image
]

var segConArray = ["최근", "추천", "인기"]
Expand All @@ -27,7 +27,7 @@ class HomeViewController: BaseVC<HomeViewModel> {
flowLayout.minimumLineSpacing = 9
let view = UICollectionView(frame: .zero, collectionViewLayout: flowLayout)
view.register(MoviesCell.self, forCellWithReuseIdentifier: MoviesCell.identifier)

return view
}()

Expand All @@ -51,6 +51,11 @@ class HomeViewController: BaseVC<HomeViewModel> {
$0.layer.cornerRadius = 10
}

private let viewAllButton = UIButton().then {
$0.titleLabel?.font = DesignSystemFontFamily.Suit.regular.font(size: 10)
$0.setTitle("전체 보기 >", for: .normal)
}

private let segCon = UISegmentedControl(items: segConArray).then {
$0.clipsToBounds = false
$0.selectedSegmentIndex = 0
Expand Down Expand Up @@ -87,24 +92,18 @@ class HomeViewController: BaseVC<HomeViewModel> {
default:
break
}

UIView.transition(
with: owner.bannerImageView,
duration: 0.3,
options: .transitionCrossDissolve,
animations: {
owner.bannerImageView.image = bannerImageSources[owner.pageControl.currentPage]
})
owner.bannerAnimation()
}.disposed(by: disposeBag)
}

func bindUI() {
moviesData
.asDriver()
.drive(moviesCollectionView.rx.items(cellIdentifier: MoviesCell.identifier,
cellType: MoviesCell.self)) { (row, data, cell) in
cell.prepare(model: data)
}.disposed(by: disposeBag)
.drive(moviesCollectionView.rx.items(
cellIdentifier: MoviesCell.identifier,
cellType: MoviesCell.self)) { (row, data, cell) in
cell.prepare(model: data)
}.disposed(by: disposeBag)

segCon.rx.selectedSegmentIndex.changed
.bind(with: self) { owner, _ in
Expand All @@ -115,11 +114,29 @@ class HomeViewController: BaseVC<HomeViewModel> {
self.underlineView.frame.origin.x = underlineFinalXPosition
}
)
switch owner.segCon.selectedSegmentIndex {

default:
return
}.disposed(by: disposeBag)
}

func bannerAnimation() {
UIView.transition(
with: bannerImageView,
duration: 0.3,
options: .transitionCrossDissolve,
animations: {
print(self.pageControl.currentPage)
self.bannerImageView.image = bannerImageSources[self.pageControl.currentPage]
})
}

private func bannerMovetimer() {
Observable<Int>.interval(.seconds(4), scheduler: MainScheduler.instance)
.bind(with: self) { owner, _ in
if owner.pageControl.currentPage == 3 {
owner.pageControl.currentPage = 0
} else {
owner.pageControl.currentPage += 1
}
owner.bannerAnimation()
}.disposed(by: disposeBag)
}

Expand All @@ -129,9 +146,9 @@ class HomeViewController: BaseVC<HomeViewModel> {

override func configureVC() {
navigationController?.navigationBar.prefersLargeTitles = false
navigationItem.title = "hihi"
setGesture()
bindUI()
bannerMovetimer()

let width = segCon.bounds.size.width / CGFloat(segCon.numberOfSegments)
let height: CGFloat = 2.0
Expand All @@ -143,9 +160,13 @@ class HomeViewController: BaseVC<HomeViewModel> {
}

override func addView() {
view.addSubviews(bannerImageView, pageControl, segCon, moviesCollectionView)
view.addSubviews(
bannerImageView, pageControl,
segCon, moviesCollectionView,
viewAllButton
)
}

override func setLayout() {
bannerImageView.snp.makeConstraints {
$0.top.equalTo(view.safeAreaLayoutGuide).inset(21)
Expand All @@ -164,6 +185,11 @@ class HomeViewController: BaseVC<HomeViewModel> {
$0.height.equalTo(23)
}

viewAllButton.snp.makeConstraints {
$0.centerY.equalTo(segCon)
$0.trailing.equalToSuperview().inset(15)
}

moviesCollectionView.snp.makeConstraints {
$0.top.equalTo(segCon.snp.bottom).offset(10)
$0.leading.equalToSuperview().inset(15)
Expand Down