Skip to content

Commit

Permalink
feat. SwiftUI로 리팩토링한 뷰 호출하는 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter1119 committed Feb 13, 2024
1 parent 4a8ce3e commit c760a08
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3563A74B2AF085270037C029"
BuildableName = "RaiseMeUp.app"
BlueprintName = "RaiseMeUp"
BuildableName = "RaiseMeUp-PROD.app"
BlueprintName = "RaiseMeUp-PROD"
ReferencedContainer = "container:RaiseMeUp.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand Down Expand Up @@ -68,8 +68,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3563A74B2AF085270037C029"
BuildableName = "RaiseMeUp.app"
BlueprintName = "RaiseMeUp"
BuildableName = "RaiseMeUp-PROD.app"
BlueprintName = "RaiseMeUp-PROD"
ReferencedContainer = "container:RaiseMeUp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
Expand All @@ -91,8 +91,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3563A74B2AF085270037C029"
BuildableName = "RaiseMeUp.app"
BlueprintName = "RaiseMeUp"
BuildableName = "RaiseMeUp-PROD.app"
BlueprintName = "RaiseMeUp-PROD"
ReferencedContainer = "container:RaiseMeUp.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import UIKit
import SwiftUI

final class MainCoordinator: MainCoordinatorProtocol, CoordinatorFinishDelegate {
var finishDelegate: CoordinatorFinishDelegate?
Expand All @@ -30,6 +31,18 @@ final class MainCoordinator: MainCoordinatorProtocol, CoordinatorFinishDelegate
self.navigationController.viewControllers = [viewController]
}

func startAtSwiftUI() {
let dataSource = TrainingDataSource()
let repository = TrainingRepository(trainingDataSource: dataSource)
let useCase = Training(repository: repository)
let viewModel = ExerciseViewModel(useCase: useCase)
viewModel.coordinator = self
let viewController = UIHostingController(
rootView: ExerciseList(viewModel: viewModel)
)
self.navigationController.viewControllers = [viewController]
}

func presentExerciseCounter(routine: [Int]) {
let coordinator = ExerciseCounterRouter(
navigationController: navigationController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class RootCoordinator: RootCoordinatorProtocol {
let mainCoordinator = MainCoordinator(navigationController: navigationController)
self.finishDelegate = self
self.childCoordinators.append(mainCoordinator)
mainCoordinator.start()
mainCoordinator.startAtSwiftUI()
}

func openLoginCoordinator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ struct ExerciseList: View {
)
) {
ForEach(program.routine) { routine in
let rowModel = ProgramTableViewCellModel(routine)
ExerciseRow(
routine: rowModel
)
Button(action: {
viewModel.selectRoutine(routine)
}, label: {
let rowModel = ProgramTableViewCellModel(routine)
ExerciseRow(
routine: rowModel
)
})
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import OSLog

class ExerciseViewModel: ObservableObject {
private let useCase: TrainingUseCase
public weak var coordinator: MainCoordinatorProtocol?

@Published var program: [TrainingLevel] = []

Expand All @@ -30,4 +31,8 @@ class ExerciseViewModel: ObservableObject {
}
}
}

func selectRoutine(_ routine: DailyRoutine) {
coordinator?.presentExerciseCounter(routine: routine.routine)
}
}

0 comments on commit c760a08

Please sign in to comment.