-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
프로젝트 매니저 [STEP 2-1] Moon #307
Open
hojun-jo
wants to merge
24
commits into
yagom-academy:ic_9_etialmoon
Choose a base branch
from
hojun-jo:step2-1
base: ic_9_etialmoon
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
04eb67b
chore: MVVM 폴더 구조 생성
d1af0ff
refactor: ViewController에서 ListViewController로 네이밍 수정
4749fcc
feat: ListViewController에 tableView 추가
9ecf43d
chore: ListViewController 파일 이름 수정
55d04a8
feat: ListViewCell 생성 및 구현
e7f8af1
feat: ListViewHeader 생성 및 구현
c3c89b7
refactor: ListViewCell의 subView들을 contentView의 subView로 수정
d1eedda
feat: ListViewController의 TableView에 Cell 사이 간격 추가
6ee0f75
refactor: 뷰들의 배경색 수정
35a2646
refactor: ListViewCell의 deadlineLabel 네이밍 수정
9f35f8e
feat: Todo 모델 생성
2ca8a15
feat: ListViewModel 생성
eadf176
refactor: ListHeader, ListCell 네이밍 수정
0941e91
feat: identifier를 위한 Reusable 프로토콜 생성
d2fdb28
feat: ListCellViewModel 생성
5b4b6ec
refactor: ListHeader와 바인딩할 수 있도록 수정
5b4b5cd
feat: ListCell과 ListCellViewModel 바인딩
15cc06c
feat: ListHeader와 ListViewModel 바인딩
76e9c4f
refactor: ListViewController에서 ViewModel을 사용할 수 있도록 수정
ddc2e9b
feat: TodoDateFormatter, DateFormat 생성
0752eea
refactor: Cell에서 ViewModel을 사용하지 않도록 수정
588d154
refactor: todoList 모델 로드 시점 수정
cfbe0fd
feat: Array extension 생성 및 safe subscript 구현
5693a3a
refactor: 배열 접근을 safe subscript로 하도록 수정
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
File renamed without changes.
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
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,14 @@ | ||
// | ||
// Todo.swift | ||
// ProjectManager | ||
// | ||
// Created by Moon on 2023/09/25. | ||
// | ||
|
||
import Foundation | ||
|
||
struct Todo { | ||
var title: String | ||
var description: String | ||
var deadline: Date | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,18 @@ | ||
// | ||
// Reusable.swift | ||
// ProjectManager | ||
// | ||
// Created by Moon on 2023/09/25. | ||
// | ||
|
||
import UIKit | ||
|
||
protocol Reusable { } | ||
|
||
extension Reusable where Self: UIView { | ||
static var identifier: String { | ||
return String(describing: self) | ||
} | ||
} | ||
|
||
extension UITableViewCell: Reusable { } |
File renamed without changes.
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,127 @@ | ||
// | ||
// ListCell.swift | ||
// ProjectManager | ||
// | ||
// Created by Moon on 2023/09/25. | ||
// | ||
|
||
import UIKit | ||
|
||
final class ListCell: UITableViewCell { | ||
private let titleLabel: UILabel = { | ||
let label = UILabel() | ||
label.font = UIFont.preferredFont(forTextStyle: .title3) | ||
|
||
return label | ||
}() | ||
|
||
private let descriptionLabel: UILabel = { | ||
let label = UILabel() | ||
label.font = UIFont.preferredFont(forTextStyle: .body) | ||
label.textColor = .systemGray3 | ||
label.numberOfLines = 3 | ||
|
||
return label | ||
}() | ||
|
||
private let deadlineLabel: UILabel = { | ||
let label = UILabel() | ||
label.font = UIFont.preferredFont(forTextStyle: .callout) | ||
|
||
return label | ||
}() | ||
|
||
private let contentStackView: UIStackView = { | ||
let stackView = UIStackView() | ||
stackView.axis = .vertical | ||
stackView.alignment = .leading | ||
|
||
return stackView | ||
}() | ||
|
||
// ListCell이 재사용 될 때마다 setUpViewModel을 통해 값이 들어오면 바인딩 함 | ||
private var listCellViewModel: ListCellViewModel? { | ||
didSet { | ||
setUpBindings() | ||
} | ||
} | ||
havilog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
|
||
configureUI() | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
override func layoutSubviews() { | ||
super.layoutSubviews() | ||
|
||
contentView.frame = contentView.frame | ||
.inset(by: UIEdgeInsets( | ||
top: 8, | ||
left: .zero, | ||
bottom: .zero, | ||
right: .zero) | ||
) | ||
} | ||
|
||
// ListCell이 재사용 될 때 ListCellViewModel을 받아옴 | ||
func setUpViewModel(_ viewModel: ListCellViewModel) { | ||
self.listCellViewModel = viewModel | ||
} | ||
|
||
// viewModel을 받을 때마다 바인딩할 것 | ||
private func setUpBindings() { | ||
listCellViewModel?.bindTitle { [weak self] viewModel in | ||
self?.titleLabel.text = viewModel.title | ||
} | ||
|
||
listCellViewModel?.bindDescription { [weak self] viewModel in | ||
self?.descriptionLabel.text = viewModel.description | ||
} | ||
|
||
listCellViewModel?.bindDeadline { [weak self] viewModel in | ||
self?.deadlineLabel.text = viewModel.deadline | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Configure UI | ||
extension ListCell { | ||
private func configureUI() { | ||
addSubviews() | ||
setUpContentStackViewConstraints() | ||
setUpBackgroundColors() | ||
} | ||
|
||
private func addSubviews() { | ||
[titleLabel, descriptionLabel, deadlineLabel].forEach { | ||
contentStackView.addArrangedSubview($0) | ||
} | ||
|
||
contentView.addSubview(contentStackView) | ||
} | ||
|
||
private func setUpContentStackViewConstraints() { | ||
contentStackView.translatesAutoresizingMaskIntoConstraints = false | ||
|
||
NSLayoutConstraint.activate([ | ||
contentStackView.leadingAnchor | ||
.constraint(equalTo: contentView.leadingAnchor, constant: 8), | ||
contentStackView.trailingAnchor | ||
.constraint(equalTo: contentView.trailingAnchor, constant: -8), | ||
contentStackView.topAnchor | ||
.constraint(equalTo: contentView.topAnchor, constant: 8), | ||
contentStackView.bottomAnchor | ||
.constraint(equalTo: contentView.bottomAnchor, constant: -8) | ||
]) | ||
} | ||
|
||
private func setUpBackgroundColors() { | ||
backgroundColor = .systemGray6 | ||
contentView.backgroundColor = .systemBackground | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요 아이들을 variable로 선언하신 이유가 있을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
할 일을 수정할 수 있기 때문에 계속 변경될 거라 생각해 variable로 선언했습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사실 프로퍼티의 값이 변경될 일이 잦으면 class가 더 적합한 거 같고,
할 일을 수정하는건 할 일을 담당하는 객체가 가지고 있는 todo의 인스턴스가 변경될거 같아요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아아 변경될 일이 잦으면 class가 더 적합하겠군요
코어데이터를 사용하면 지금의 구조체를 사용하지 않고 NSManagedObject인 todo를 사용해서 값이 변경되면 뷰모델이 데이터매니저에게 저장하도록 만들 것 같습니다!