-
Notifications
You must be signed in to change notification settings - Fork 147
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] BMO #311
base: ic_9_bmo94
Are you sure you want to change the base?
Changes from 9 commits
dce3811
5244625
37f400f
1d71613
5f5c5bd
712f872
b746187
93144aa
08db61b
e9e1043
b3cd7ef
47a592b
bf25526
a47913a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Work.swift | ||
// ProjectManager | ||
// | ||
// Created by BMO on 2023/10/01. | ||
// | ||
|
||
import Foundation | ||
|
||
struct Work { | ||
let title: String | ||
let description: String | ||
let deadline: Date | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// ProjectManager - MainViewController.swift | ||
// Created by yagom. | ||
// Copyright © yagom. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
final class MainViewController: UIViewController { | ||
private let todoView: WorkView | ||
private let doingView: WorkView | ||
private let doneView: WorkView | ||
|
||
init() { | ||
self.todoView = WorkView(workType: .todo) | ||
self.doingView = WorkView(workType: .doing) | ||
self.doneView = WorkView(workType: .done) | ||
|
||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
private let mainStackView: UIStackView = { | ||
let stackView = UIStackView() | ||
stackView.translatesAutoresizingMaskIntoConstraints = false | ||
stackView.axis = .horizontal | ||
stackView.spacing = 10 | ||
stackView.distribution = .fillEqually | ||
|
||
return stackView | ||
}() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
setNavigationItem() | ||
setUI() | ||
} | ||
|
||
private func setNavigationItem() { | ||
navigationItem.title = "Project Manager" | ||
|
||
let addAction = UIAction { _ in | ||
// TODO: + 버튼 터치 시 동작 작성 | ||
|
||
print("touch addAction") | ||
} | ||
|
||
navigationItem.rightBarButtonItem = UIBarButtonItem(systemItem: .add, primaryAction: addAction) | ||
} | ||
|
||
private func setUI() { | ||
view.backgroundColor = .systemBackground | ||
|
||
view.addSubview(mainStackView) | ||
mainStackView.addArrangedSubview(todoView) | ||
mainStackView.addArrangedSubview(doingView) | ||
mainStackView.addArrangedSubview(doneView) | ||
|
||
mainStackView.backgroundColor = .systemGray4 | ||
|
||
NSLayoutConstraint.activate([ | ||
mainStackView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor), | ||
mainStackView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor), | ||
mainStackView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), | ||
mainStackView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor) | ||
]) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// WorkCell.swift | ||
// ProjectManager | ||
// | ||
// Created by BMO on 2023/09/25. | ||
// | ||
|
||
import UIKit | ||
|
||
final class WorkCell: UITableViewCell { | ||
static let identifier: String = "WorkCell" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요런건 항상 프로토콜을 사용하는 습관이 좋을 듯 합니당 |
||
|
||
private let stackView: UIStackView = { | ||
let stackView = UIStackView() | ||
stackView.translatesAutoresizingMaskIntoConstraints = false | ||
stackView.axis = .vertical | ||
stackView.spacing = 8 | ||
stackView.distribution = .equalSpacing | ||
|
||
return stackView | ||
}() | ||
|
||
private let titleLabel: UILabel = { | ||
let label = UILabel() | ||
label.numberOfLines = 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1은 굳이 안해줘도 될 걸요? |
||
|
||
return label | ||
}() | ||
|
||
private let descriptionLabel: UILabel = { | ||
let label = UILabel() | ||
label.numberOfLines = 3 | ||
label.textColor = .gray | ||
|
||
return label | ||
}() | ||
|
||
private let deadlineLabel: UILabel = { | ||
let label = UILabel() | ||
label.numberOfLines = 1 | ||
|
||
return label | ||
}() | ||
|
||
required init?(coder: NSCoder) { | ||
super.init(coder: coder) | ||
setUI() | ||
} | ||
|
||
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
setUI() | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prepare for reuse를 처리하는 부분이 없네요 |
||
private func setUI() { | ||
separatorInset = UIEdgeInsets.zero | ||
|
||
addSubview(stackView) | ||
|
||
stackView.addArrangedSubview(titleLabel) | ||
stackView.addArrangedSubview(descriptionLabel) | ||
stackView.addArrangedSubview(deadlineLabel) | ||
|
||
NSLayoutConstraint.activate([ | ||
stackView.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor), | ||
stackView.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor), | ||
stackView.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor), | ||
stackView.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor) | ||
]) | ||
} | ||
|
||
func config(title: String, description: String, deadline: Date) { | ||
titleLabel.text = title | ||
descriptionLabel.text = description | ||
deadlineLabel.text = deadline.description | ||
} | ||
} |
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.
모델들은 앵간하면 equatable, identifiable, sendable하면 좋아요
설계할 때 고려해주세요