Skip to content

Commit

Permalink
[Design] #47 메모편집과 연결
Browse files Browse the repository at this point in the history
- 바뀐 데이터 소스 기준으로 조건을 수정해야함
  • Loading branch information
heydoy committed Oct 23, 2022
1 parent 593630d commit 6838e17
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions MemoProject/Presentation/List/CompListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ class CompListViewController: BaseViewController {

var isSearching: Bool {
get {
return searchController.isActive
let searchable = searchController.isActive
navigationItem.backButtonTitle = searchable ? "검색" : "메모"
return searchable
}
}

Expand Down Expand Up @@ -81,7 +83,7 @@ class CompListViewController: BaseViewController {
}

override func configure() {
//mainView.collectionView.delegate = self
mainView.collectionView.delegate = self
mainView.collectionView.collectionViewLayout = createLayout()
configureDataSource()
}
Expand Down Expand Up @@ -194,6 +196,26 @@ extension CompListViewController {
dataSource.apply(snapshot)
}
}
// MARK: - Collection View Delegate
extension CompListViewController: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let vc = WriteViewController()
vc.delegate = self
vc.isEditing = false
vc.editingMode = true // 기존메모 수정이므로 editingMode는 참
if isSearching {
let memo = filterResult[indexPath.row]
vc.updateTextview(memo: memo)
vc.editingMemo = memo
} else {
let memo = indexPath.section == 0 ? pinList[indexPath.row] : unpinList[indexPath.row]
vc.updateTextview(memo: memo)
vc.editingMemo = memo
}
self.navigationController?.pushViewController(vc, animated: true)
}
}

// MARK: - Search Bar Result Update
extension CompListViewController: UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController) {
Expand Down

0 comments on commit 6838e17

Please sign in to comment.