-
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.
* feat: WorkoutPearTypeSelectCell 생성 * feat: WorkoutViewController생성 * feat: PageControll 버그 수정 * feat: 뷰 구현 * feat: 오타 수정 pear -> peer * feat: pageControl move prev 구현 * feat: gesture recognizer를 통한 * chor: 오타 수정 * feat: PageControl 버그 수정 * feat: backGround Color 오탈자 수정 * chore: Public 함수 이름 변경 * chore: GWPageControl 함수 이름 수정
- Loading branch information
1 parent
985af7d
commit 0e4957e
Showing
8 changed files
with
483 additions
and
77 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
118 changes: 118 additions & 0 deletions
118
...cts/Features/Record/Sources/WorkoutSelectScene/View/WorkoutPeerSelectViewController.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,118 @@ | ||
// | ||
// WorkoutPeerSelectViewController.swift | ||
// RecordFeature | ||
// | ||
// Created by MaraMincho on 11/19/23. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import DesignSystem | ||
import UIKit | ||
|
||
// MARK: - WorkoutPeerSelectViewController | ||
|
||
final class WorkoutPeerSelectViewController: UIViewController { | ||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
view.backgroundColor = DesignSystemColor.primaryBackground | ||
|
||
setup() | ||
} | ||
|
||
var dataSource: UICollectionViewDiffableDataSource<Int, UUID>! | ||
|
||
private let workoutSelectDescriptionLabel: UILabel = { | ||
let label = UILabel() | ||
label.font = .preferredFont(forTextStyle: .title1, with: .traitBold) | ||
label.textAlignment = .left | ||
|
||
label.text = "2. 누구랑 할까요?" | ||
|
||
label.translatesAutoresizingMaskIntoConstraints = false | ||
return label | ||
}() | ||
|
||
private let startButton: UIButton = { | ||
let button = UIButton() | ||
button.configurationUpdateHandler = UIButton.Configuration.mainCircular(label: "출발") | ||
|
||
button.translatesAutoresizingMaskIntoConstraints = false | ||
return button | ||
}() | ||
|
||
lazy var pearTypeSelectCollectionView: UICollectionView = { | ||
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: makeCollectionViewLayout()) | ||
collectionView.register(WorkoutPeerTypeSelectCell.self, forCellWithReuseIdentifier: WorkoutPeerTypeSelectCell.identifier) | ||
collectionView.backgroundColor = .clear | ||
collectionView.isScrollEnabled = false | ||
|
||
collectionView.translatesAutoresizingMaskIntoConstraints = false | ||
return collectionView | ||
}() | ||
} | ||
|
||
private extension WorkoutPeerSelectViewController { | ||
func makeCollectionViewLayout() -> UICollectionViewCompositionalLayout { | ||
let item = NSCollectionLayoutItem(layoutSize: .init(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(1))) | ||
item.contentInsets = .init(top: Metrics.itemInsets, leading: Metrics.itemInsets, bottom: Metrics.itemInsets, trailing: Metrics.itemInsets) | ||
|
||
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1), heightDimension: .fractionalHeight(0.15)) | ||
let group = NSCollectionLayoutGroup.vertical(layoutSize: groupSize, subitems: [item]) | ||
|
||
let section = NSCollectionLayoutSection(group: group) | ||
|
||
return UICollectionViewCompositionalLayout(section: section) | ||
} | ||
|
||
func setup() { | ||
setHierarchyAndConstraints() | ||
|
||
dataSource = .init(collectionView: pearTypeSelectCollectionView, cellProvider: { collectionView, indexPath, _ in | ||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: WorkoutPeerTypeSelectCell.identifier, for: indexPath) | ||
|
||
return cell | ||
}) | ||
|
||
tempInitDataSource() | ||
} | ||
|
||
func setHierarchyAndConstraints() { | ||
let safeArea = view.safeAreaLayoutGuide | ||
|
||
view.addSubview(workoutSelectDescriptionLabel) | ||
workoutSelectDescriptionLabel.topAnchor.constraint(equalTo: safeArea.topAnchor).isActive = true | ||
workoutSelectDescriptionLabel.leadingAnchor | ||
.constraint(equalTo: safeArea.leadingAnchor, constant: ConstraintsGuideLine.value).isActive = true | ||
workoutSelectDescriptionLabel.trailingAnchor | ||
.constraint(equalTo: safeArea.trailingAnchor, constant: -ConstraintsGuideLine.value).isActive = true | ||
|
||
view.addSubview(startButton) | ||
startButton.bottomAnchor.constraint(equalTo: safeArea.bottomAnchor, constant: -50).isActive = true | ||
startButton.centerXAnchor.constraint(equalTo: safeArea.centerXAnchor).isActive = true | ||
startButton.widthAnchor.constraint(equalToConstant: Metrics.buttonHeight).isActive = true | ||
startButton.heightAnchor.constraint(equalToConstant: Metrics.buttonHeight).isActive = true | ||
|
||
view.addSubview(pearTypeSelectCollectionView) | ||
pearTypeSelectCollectionView.topAnchor | ||
.constraint(equalTo: workoutSelectDescriptionLabel.bottomAnchor, constant: 15).isActive = true | ||
pearTypeSelectCollectionView.leadingAnchor | ||
.constraint(equalTo: safeArea.leadingAnchor, constant: ConstraintsGuideLine.secondaryValue).isActive = true | ||
pearTypeSelectCollectionView.trailingAnchor | ||
.constraint(equalTo: safeArea.trailingAnchor, constant: -ConstraintsGuideLine.secondaryValue).isActive = true | ||
pearTypeSelectCollectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true | ||
} | ||
|
||
func tempInitDataSource() { | ||
var snapshot = dataSource.snapshot() | ||
snapshot.appendSections([0]) | ||
snapshot.appendItems([.init(), .init(), .init()]) | ||
dataSource.apply(snapshot) | ||
} | ||
|
||
enum Metrics { | ||
static let buttonHeight: CGFloat = 150 | ||
static let buttonWidth: CGFloat = 150 | ||
|
||
static let itemInsets: CGFloat = 9 | ||
} | ||
} |
Oops, something went wrong.