Skip to content

Commit

Permalink
refactor. item select 기능 리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter1119 committed Jan 16, 2024
1 parent d3b29f8 commit 183dcb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions RaiseMeUp/RaiseMeUp/Sources/Features/Main/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ final class MainViewController: UIViewController {

override func loadView() {
self.view = MainView()

mainView.programListView.delegate = self
configureDataSource()
}

Expand Down Expand Up @@ -101,3 +103,13 @@ extension MainViewController {
}
}
}

extension MainViewController: UICollectionViewDelegate {
func collectionView(
_ collectionView: UICollectionView,
didSelectItemAt indexPath: IndexPath
) {
guard let selectedItemIdentifier = dataSource.itemIdentifier(for: indexPath) else { return }
self.viewModel.didSelectItemAt(selectedItemIdentifier)
}
}
5 changes: 3 additions & 2 deletions RaiseMeUp/RaiseMeUp/Sources/Features/Main/MainViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ final class MainViewModel {
}
}

func didSelectRowAt(at indexPath: IndexPath) {

func didSelectItemAt(_ itemID: DailyRoutine.ID) {
guard let routine = routineStore.fetchByID(itemID) else { return }
coordinator?.presentExerciseCounter(routine: routine.routine)
}
}

0 comments on commit 183dcb9

Please sign in to comment.