-
Notifications
You must be signed in to change notification settings - Fork 37
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
[Team10 / iOS / 쑤 & Zeke] Rx를 활용한 ViewModel 구현 #48
Open
lenaios
wants to merge
116
commits into
codesquad-members-2021:team10
Choose a base branch
from
swing-park:dev/iOS
base: team10
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 all commits
Commits
Show all changes
116 commits
Select commit
Hold shift + click to select a range
7bb1667
chore: 🔧 Endpoint에 Label 경로 추가
zekexros d278227
chore: 🔧 NetworkManager가 Networkable 채택하도록 수정
zekexros 6d77a63
chore: 🔧 오토레이아웃 수정
zekexros 9e04c71
chore: 🔧 네이밍 서로 바뀌었던 부분 수정
zekexros 72a52e3
feat: ✨ LabelListViewModel 생성
zekexros 885ef9d
feat: ✨ LabelList DTO 구현
zekexros 8bdc263
feat: ✨ ReactiveX를 이용한 tableView의 dataSource 구현
zekexros e9b4fd0
feat: ✨ AddLabelViewController 추가 및 이름변경
zekexros 319a00f
chore: 🔧 Ovservable에서 BehaviorRelay로 타입변경
zekexros 8a819b4
chore: 🔧 DTO 이름변경
zekexros ec5d0e3
chore: 🔧 Endpoint에 host추가
zekexros a5a2c2b
chore: 🔧 AddViewController 이름변경
zekexros 338d351
chore: 🔧 옵셔널 타입 제거
zekexros 524704c
feat: ✨ AddLabelViewModel생성 및 화면전환 구현
zekexros 4881b0d
feat: add milestone view model, binding (#49)
lenaios b3682b6
feat: add new milestone view model using rx (#49)
lenaios c174b3d
chore: delete comment
lenaios ad35608
feat: ✨ EstimatedLabelView 구현 (#42)
zekexros 6cda9bf
chore: 🔧 불필요한 코드 제거 (#42)
zekexros c9f901c
chore: 🔧 IssueLabel의 id 타입 변경 (#42)
zekexros a7093d1
feat: ✨ NetworkManager의 post 메소드 구현 (#42)
zekexros 608bc6a
chore: 🔧 MarkdownKit 다시 추가 (#42)
zekexros 0245345
feat: ✨ convertHexToString, getRandomColor 메소드 구현 (#42)
zekexros 3c9b404
feat: ✨ AddTableViewCell 구현 (#42)
zekexros ee51a3e
feat: ✨ AddLabelViewModel 구현 (#42)
zekexros 72ddb63
feat: ✨ AddLabelViewController의 오토레이아웃, Rx를 이용한 bind구현 (#42)
zekexros 329d45c
Merge branch 'iOS/feature/rx/viewModel'
lenaios 6ba4117
chore: 🔧 AddMilestoneViewController 삭제
zekexros da27dee
chore: delete add view controller
lenaios 1e1c0af
Merge branch 'iOS/feature/#42/LabelViewModel'
zekexros 8e75f81
chore: 🔧 충돌난 파일 해결
zekexros 22a736b
chore: add AddMilestoneViewController
lenaios c3501f7
feat: ✨ configure SwiftLint (#69)
zekexros 938f209
chore: 🔧 ViewModel폴더의 하위파일들에 SwiftLint 적용 (#69)
zekexros 0d212f2
chore: 🔧 Controller폴더의 하위파일들에 SwiftLint 적용 (#69)
zekexros d74b813
chore: 🔧 Extension폴더의 하위파일들에 SwiftLint 적용 (#69)
zekexros 5464981
chore: 🔧 View/IssueList폴더의 하위파일들에 SwiftLint 적용 (#69)
zekexros c77f9fe
chore: 🔧 View/Label 폴더의 하위파일들에 SwiftLint 적용 (#69)
zekexros 3e81f81
chore: 🔧 View/Milestone 폴더의 하위파일들에 SwiftLint 적용 (#69)
zekexros 8f353a0
chore: 🔧 View/Login 폴더의 하위파일들에 SwiftLint 적용 (#69)
zekexros 662f289
chore: 🔧 View/Model 폴더의 하위파일들에 SwiftLint 적용 (#69)
zekexros f0b4166
chore: 🔧 SwiftLint 적용 (#69)
zekexros 6aaea0a
Merge pull request #70 from swing-park/iOS/feature/#69/SwiftLint
zekexros 9032663
chore: 🔧 Controller폴더의 접근제어 변경 (#68)
zekexros fca1a55
chore: 🔧 View폴더의 접근제어 변경 (#68)
zekexros c82fddd
chore: 🔧 getLabel()메소드 생성
zekexros f409e99
Merge pull request #75 from swing-park/iOS/feature/#68/AccessControl
zekexros 3c19dd9
chore: 🔧 TableViewCell파일 폴더링
zekexros 4ddc279
chore: 🔧 캡쳐리스트 사용 및 불필요한 코드 제거
zekexros 3d183b6
Merge branch 'iOS/feature/modify' into dev/iOS
zekexros 22b3643
chore: 🔧 충돌 파일 삭제
zekexros e9b8f16
chore: add milestone table view cell
lenaios a2a3b14
chore: update directory
lenaios c06c8ec
feat: ✨ IssueListViewModel 구현 (#79)
zekexros 8a478d5
chore: 🔧 IssueList DTO 수정 (#79)
zekexros d4e7ffd
feat: add new issue view model with rx
lenaios b13bbd4
feat: ✨ RxCocoa를 이용한 tableView delegate, dataSource 구현 (#79)
zekexros 1153487
feat: ✨ Rx를 이용하여 UIButton의 action 구현 (#79)
zekexros cfb1990
feat: ✨ selectMode로 전환 가능하게 bind및 로직 구현 (#79)
zekexros b509b4e
chore: 🔧 불필요한 코드 제거 (#79)
zekexros efa4ea1
chore: 🔧 FakeData제거 (#79)
zekexros 0f90edd
chore: 🔧 EndPoint에서 id를 파라미터로 받을 수 있게 수정 (#79)
zekexros e25ee66
feat: ✨ deleteRequest구현 (#79)
zekexros 4121b86
feat: add issue detail view model (#49)
lenaios 264e4fa
feat: add keyboard notification to issue detail view (#83)
lenaios 6cec208
feat: add IssueDetailViewModel (#49)
lenaios 0304a11
feat: add AdditionalInfoViewController
lenaios 403a3f0
feat: ✨ PatchIssue DTO 구현 (#79)
zekexros 5c2a324
chore: 🔧 서버 배포하여 Endpoint 수정 (#79)
zekexros 69f68b3
feat: ✨ NetworkManager의 patchRequest 구현 (#79)
zekexros ef3ca67
chore: 🔧 IssueToolbar 접근제어 변경 (#79)
zekexros fd5e409
chore: 🔧 Issue DTO의 Equatable 채택 (#79)
zekexros 2c264ac
feat: ✨ ToolBar와 SearchViewController의 바인딩 구현 (#79)
zekexros f286a97
feat: add badge, author to issue detail view
lenaios e58da7b
chore: 🔧 레이블의 cornerRadius 변경
zekexros bc1c71d
chore: 🔧 Milestone의 타입 옵셔널로 변경
zekexros 889ecab
chore: 🔧 tableViewCell, collectionViewCell의 사이즈 수정
zekexros d3fc0f1
chore: NetworkManager 메소드 수정
zekexros c1e75e1
chore: 🔧 Milestone DTO 수정
zekexros eb547db
chore: 🔧 tableViewCell에 stackView추가하여 재구현
zekexros 11527c5
chore: clean up code, add app AppTransportSecurity
lenaios 7f75905
Merge pull request #92 from swing-park/iOS/featue/rx/newIssue
lenaios bd3001d
feat: ✨ LeftAlignedCollectionViewFlowLayout 구현
zekexros edc6396
chore: 🔧 collectionView를 스택뷰에 추가하여 구현
zekexros 5321490
chore: 🔧 cellSize 수정
zekexros d9a5441
Merge branch 'iOS/feature/#79/IssueBinding'
zekexros 7d6ec90
chore: add endpoint path
lenaios d63546d
chore: 🔧 AddLabelViewController에서 뒤로가기 구현 (#93)
zekexros 3708dd0
feat: ✨ IssueTableViewCell 수정 (#93)
zekexros 1bdfe37
feat: add github login (#15)
lenaios d98f114
feat: reload data after adding new milestone
lenaios 8477aed
chore: remove achievement label in milestone view
lenaios c4871ef
feat: ✨ CustomAlertView 구현 (#93)
zekexros 92bc9b6
chore: 🔧 Issue DTO 수정 (#93)
zekexros a2a26b0
chore: 🔧 CustomAlertView적용을 위한 NetworkManager수정 (#93)
zekexros 6a323a3
chore: 🔧 CustomAlertView 적용 (#93)
zekexros 813b1e4
Merge pull request #97 from swing-park/iOS/feature/#93/complementUI
zekexros 84e5446
chore: add bar button action
lenaios ff8c8fe
Merge branch 'iOS/feature/login'
lenaios d46779f
chore: add endpoint to github login
lenaios 598d7f0
chore: 🔧 deleteIssue 수정
zekexros 9eb3b83
chore: 🔧 IssueViewController색 변경 및 Endpoint의 url변경
zekexros 9efab2c
Merge branch 'dev/iOS' into iOS/feature/#93/complementUI
zekexros 71ace9d
chore: 🔧 오타 수정
zekexros 8512bc4
chore: 🔧 PatchIssue DTO 수정
zekexros bdc017b
chore: 🔧 셀 간격 수정 및 색상 변경
zekexros 46655f4
Merge pull request #99 from swing-park/iOS/feature/#93/complementUI
zekexros 3aee059
chore: 🔧 clear white space and modify PatchIssue DTO
zekexros d495b8c
feat: add func to delete milestone
lenaios 08d532d
feat: ✨ 라벨 삭제 기능 구현
zekexros 00115e3
chore: 🔧 로그인화면 전환 수정
zekexros 0af96d9
Merge remote-tracking branch 'refs/remotes/origin/dev/iOS'
lenaios a9cd18d
feat: add filter open, closed issues
lenaios 8b05b74
feat: add jwt token in http header
lenaios 2c0dd4a
feat: add delegate to refresh issue list
lenaios 7bf7475
chore: delete print
lenaios 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
Binary file not shown.
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,8 @@ | ||
disabled_rules: | ||
- line_length | ||
- identifier_name | ||
included: | ||
excluded: | ||
- issue-trackerTests | ||
- issue-trackerUITests | ||
|
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
144 changes: 126 additions & 18 deletions
144
iOS/issue-tracker/issue-tracker.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
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
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
138 changes: 138 additions & 0 deletions
138
iOS/issue-tracker/issue-tracker/Controller/AddLabelViewController.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,138 @@ | ||
// | ||
// AddViewController.swift | ||
// issue-tracker | ||
// | ||
// Created by Ador on 2021/06/10. | ||
// | ||
|
||
import UIKit | ||
import RxSwift | ||
import RxCocoa | ||
import SnapKit | ||
|
||
protocol AddLabelViewControllerDelegate: AnyObject { | ||
func fetchData() | ||
} | ||
|
||
final class AddLabelViewController: UIViewController { | ||
private var addLabelViewModel: AddLabelViewModel! | ||
private lazy var tableView: UITableView = { | ||
let tableView = UITableView(frame: .zero, style: .grouped) | ||
tableView.allowsSelection = false | ||
tableView.register(AddLabelTableViewCell.self, forCellReuseIdentifier: AddLabelTableViewCell.identifier) | ||
return tableView | ||
}() | ||
private var estimatedLabelView = EstimatedLabelView() | ||
private var bag = DisposeBag() | ||
private var saveButton = UIBarButtonItem(title: "저장", style: .plain, target: nil, action: nil) | ||
private var cancelButton = UIBarButtonItem(title: "뒤로", style: .plain, target: nil, action: nil) | ||
var reloadDataHandler: (() -> Void)? | ||
weak var delegate: AddLabelViewControllerDelegate? | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
self.view.backgroundColor = #colorLiteral(red: 0.9494308829, green: 0.9485411048, blue: 0.9703034759, alpha: 1) | ||
self.addLabelViewModel = AddLabelViewModel(networkManager: NetworkManager()) | ||
|
||
navigationItem.title = "새로운 레이블" | ||
self.navigationItem.leftBarButtonItem = cancelButton | ||
self.navigationItem.rightBarButtonItem = saveButton | ||
|
||
tableView.dataSource = self | ||
view.addSubview(tableView) | ||
view.addSubview(estimatedLabelView) | ||
configureAutolayout() | ||
binding() | ||
bindButton() | ||
} | ||
|
||
private func binding() { | ||
addLabelViewModel.color | ||
.map { UIColor.hexStringToUIColor(hex: $0)} | ||
.bind(to: estimatedLabelView.getLabel().rx.backgroundColor) | ||
.disposed(by: bag) | ||
} | ||
|
||
func bindButton() { | ||
saveButton.rx.tap | ||
.subscribe { [weak self] _ in | ||
guard let viewModel = self?.addLabelViewModel else { return } | ||
if viewModel.title.value == "" || viewModel.description.value == "" { | ||
CustomAlertView.shared.setUpAlertView(title: "실패", message: "필수 입력란이 비었습니다. 다시 한번 확인해주세요.", buttonTitle: "확인", alertType: .failure, buttonHandler: nil) | ||
} else { | ||
viewModel.postAddedLabel { | ||
self?.dismiss(animated: true, completion: nil) | ||
self?.delegate?.fetchData() | ||
} | ||
} | ||
} | ||
.disposed(by: bag) | ||
|
||
cancelButton.rx.tap | ||
.subscribe { [weak self] _ in | ||
self?.dismiss(animated: true, completion: nil) | ||
} | ||
.disposed(by: bag) | ||
} | ||
|
||
private func configureAutolayout() { | ||
tableView.snp.makeConstraints { view in | ||
view.top.equalToSuperview().inset(40) | ||
view.leading.trailing.bottom.equalToSuperview() | ||
} | ||
|
||
estimatedLabelView.snp.makeConstraints { view in | ||
view.leading.trailing.equalToSuperview().inset(16) | ||
view.centerX.centerY.equalToSuperview() | ||
view.height.equalTo(160) | ||
} | ||
} | ||
} | ||
|
||
extension AddLabelViewController: UITableViewDataSource { | ||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return 3 | ||
} | ||
|
||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
guard let cell = tableView.dequeueReusableCell(withIdentifier: AddLabelTableViewCell.identifier, for: indexPath) as? AddLabelTableViewCell else { return UITableViewCell() } | ||
switch indexPath.row { | ||
case 0: | ||
cell.textLabel?.text = "제목" | ||
cell.configureTextFieldPlaceHolder(text: "(필수입력)") | ||
cell.textField.rx.text | ||
.orEmpty | ||
.distinctUntilChanged() | ||
.observe(on: MainScheduler.instance) | ||
.bind(to: addLabelViewModel.title) | ||
.disposed(by: bag) | ||
return cell | ||
case 1: | ||
cell.textLabel?.text = "설명" | ||
cell.configureTextFieldPlaceHolder(text: "(선택사항)") | ||
cell.textField.rx.text | ||
.orEmpty | ||
.distinctUntilChanged() | ||
.observe(on: MainScheduler.instance) | ||
.bind(to: addLabelViewModel.description) | ||
.disposed(by: bag) | ||
return cell | ||
case 2: | ||
cell.textLabel?.text = "배경색" | ||
|
||
addLabelViewModel.color | ||
.bind(to: cell.textField.rx.text) | ||
.disposed(by: bag) | ||
|
||
cell.reloadButton.rx.tap | ||
.map { UIColor.getRandomColor().convertHexToString() } | ||
.bind(to: addLabelViewModel.color) | ||
.disposed(by: bag) | ||
|
||
cell.configureBackgroundCellMode() | ||
return cell | ||
default: | ||
fatalError() | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
iOS/issue-tracker/issue-tracker/Controller/AddMilestoneViewController.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,83 @@ | ||
// | ||
// AddMilestoneViewController.swift | ||
// issue-tracker | ||
// | ||
// Created by Ador on 2021/06/17. | ||
// | ||
|
||
import UIKit | ||
import RxSwift | ||
|
||
class AddMilestoneViewController: UIViewController { | ||
|
||
private let disposeBag = DisposeBag() | ||
private let viewModel: MilestoneViewModel! = MilestoneViewModel.shared | ||
private lazy var tableView: UITableView = { | ||
let tableView = UITableView(frame: .zero, style: .grouped) | ||
tableView.register(AddMilestoneTableViewCell.self, forCellReuseIdentifier: AddMilestoneTableViewCell.reuseIdentifier) | ||
return tableView | ||
}() | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
navigationItem.title = "새로운 마일스톤" | ||
self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "뒤로", | ||
style: .plain, | ||
target: self, | ||
action: #selector(didTapCancel)) | ||
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "저장", | ||
style: .plain, | ||
target: self, | ||
action: #selector(didTapSave)) | ||
|
||
tableView.dataSource = self | ||
tableView.frame = view.bounds | ||
|
||
view.addSubview(tableView) | ||
viewModel.dismissCompletion = { | ||
self.dismiss(animated: true) | ||
} | ||
} | ||
|
||
@objc | ||
private func didTapSave() { | ||
viewModel.post() | ||
} | ||
|
||
@objc | ||
private func didTapCancel() { | ||
dismiss(animated: true) | ||
} | ||
} | ||
|
||
extension AddMilestoneViewController: UITableViewDataSource { | ||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | ||
return 3 | ||
} | ||
|
||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | ||
guard let cell = tableView.dequeueReusableCell(withIdentifier: AddMilestoneTableViewCell.reuseIdentifier, for: indexPath) as? AddMilestoneTableViewCell else { | ||
fatalError() | ||
} | ||
if indexPath.row == 0 { | ||
cell.becomeFirstResponder() | ||
} | ||
let textLabel = ["제목", "설명", "완료일"] | ||
let keys = ["title", "description", "dueDate"] | ||
cell.textLabel?.text = textLabel[indexPath.row] | ||
cell.bind { textField in | ||
textField.rx.text | ||
.orEmpty | ||
.observe(on: MainScheduler.instance) | ||
.distinctUntilChanged() | ||
.debounce(.milliseconds(500), scheduler: MainScheduler.instance) | ||
.subscribe(onNext: { text in | ||
let key = keys[indexPath.row] | ||
self.viewModel.milestone[key] = text | ||
}) | ||
.disposed(by: disposeBag) | ||
} | ||
return cell | ||
} | ||
} |
62 changes: 0 additions & 62 deletions
62
iOS/issue-tracker/issue-tracker/Controller/AddViewController.swift
This file was deleted.
Oops, something went wrong.
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.
뷰모델을 싱글톤으로 사용하는 것도 안됩니다. 인스턴스 한 뷰들에 대응하는 인스턴스한 뷰모델이 좋아요.