Skip to content
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

모듈화 작업 #23

Merged
merged 11 commits into from
Mar 20, 2024
8 changes: 8 additions & 0 deletions RaiseMeUp/Data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
28 changes: 28 additions & 0 deletions RaiseMeUp/Data/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Data",
platforms: [.iOS(.v15)],
products: [
.library(
name: "Data",
targets: ["Data"]
)
],
dependencies: [
.package(path: "../RMNetwork"),
.package(path: "../Domain")
],
targets: [
.target(
name: "Data",
dependencies: [
.product(name: "RMNetwork", package: "RMNetwork"),
.product(name: "Domain", package: "Domain")
]
)
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Foundation
import Shared

struct TrainingDataSource: TrainingDataSourceProtocol {
private let provider: Provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//

import UIKit
import Shared
import Domain

struct TrainingRepository: TrainingRepositoryProtocol {

Expand Down
8 changes: 8 additions & 0 deletions RaiseMeUp/Domain/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
23 changes: 23 additions & 0 deletions RaiseMeUp/Domain/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Domain",
platforms: [.iOS(.v15)],
products: [
.library(
name: "Domain",
targets: ["Domain"])
],
dependencies: [
.package(path: "../Shared")
],
targets: [
.target(
name: "Domain",
dependencies: [.product(name: "Shared", package: "Shared")]
)
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,41 @@ import Foundation

public struct PullUpProgram {
public let program: [TrainingLevel]

public init(program: [TrainingLevel]) {
self.program = program
}
}

public struct TrainingLevel: Identifiable {
public var id: String
public var name: String
public var description: String
public var routine: [DailyRoutine]

public init(
id: String,
name: String,
description: String,
routine: [DailyRoutine]
) {
self.id = id
self.name = name
self.description = description
self.routine = routine
}
}

public struct DailyRoutine: Identifiable {
public let id: UUID = UUID()
public let day: String
public let routine: [Int]

public init(
day: String,
routine: [Int]
) {
self.day = day
self.routine = routine
}
}
21 changes: 21 additions & 0 deletions RaiseMeUp/Domain/Sources/Domain/Entities/User.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// User.swift
// RaiseMeUp
//
// Created by 홍석현 on 11/23/23.
//

import Foundation

public struct User {
public let name: String
public let email: String

public init(
name: String,
email: String
) {
self.name = name
self.email = email
}
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,21 @@
//
// ExerciseList.swift
// RaiseMeUp-PROD
// TrainingRepositoryProtocol.swift
// RaiseMeUp
//
// Created by 홍석현 on 2/10/24.
// Created by 홍석현 on 11/28/23.
//

import SwiftUI
import Foundation

struct ExerciseList: View {
@ObservedObject var viewModel: ExerciseViewModel

var body: some View {
List {
ForEach(viewModel.program) { program in
Section(
header: ExerciseListHeader(
title: program.name,
subTitle: program.description
)
) {
ForEach(program.routine) { routine in
Button(action: {
viewModel.selectRoutine(routine)
}, label: {
let rowModel = ProgramTableViewCellModel(routine)
ExerciseRow(
routine: rowModel
)
})
.buttonStyle(.plain)
}
}
}
}
}
}

#Preview {
ExerciseList(viewModel: MockViewModel())
public protocol TrainingRepositoryProtocol {
func trainingProgram() async throws -> PullUpProgram
}

final class MockViewModel: ExerciseViewModel {
init() {
super.init(
useCase: Training(
repository: TrainingRepository(
trainingDataSource: TrainingDataSource())
)
)

self.program = [
public class MockTrainingRepository: TrainingRepositoryProtocol {

public init() { }
public func trainingProgram() async throws -> PullUpProgram {
return PullUpProgram(program: [
TrainingLevel(
id: UUID().uuidString,
name: "Starter",
Expand Down Expand Up @@ -86,6 +52,6 @@ final class MockViewModel: ExerciseViewModel {
DailyRoutine(day: "Day 01", routine: [3,2,1,1])
]
)
]
])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@

import Foundation
import AuthenticationServices
import Shared

struct Auth: AuthUseCase {
func saveAppleIDToken(with credential: ASAuthorizationAppleIDCredential) -> Result<User, KeychainError> {
public struct Auth: AuthUseCase {

public init() {}

public func saveAppleIDToken(with credential: ASAuthorizationAppleIDCredential) -> Result<User, KeychainError> {
let familyName = credential.fullName?.familyName ?? String()
let givenName = credential.fullName?.givenName ?? String()
let fullName = familyName + givenName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import Foundation
import AuthenticationServices
import Shared

protocol AuthUseCase {
public protocol AuthUseCase {
func saveAppleIDToken(with credential: ASAuthorizationAppleIDCredential) -> Result<User, KeychainError>
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public enum TrainingError: Error {
case unknown
}

protocol TrainingUseCase {
public protocol TrainingUseCase {
func getProgramList() async -> Result<PullUpProgram, TrainingError>
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
//

import Foundation
import Shared

public struct Training: TrainingUseCase {

private let repository: TrainingRepositoryProtocol

init(repository: TrainingRepositoryProtocol) {
public init(repository: TrainingRepositoryProtocol) {
self.repository = repository
}

Expand Down
8 changes: 8 additions & 0 deletions RaiseMeUp/Features/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
49 changes: 49 additions & 0 deletions RaiseMeUp/Features/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Features",
platforms: [.iOS(.v15)],
products: [
.library(
name: "Coordinator",
targets: ["Coordinator"]),
.library(
name: "ExerciseCounter",
targets: ["ExerciseCounter"]),
.library(
name: "Main",
targets: ["Main"]),
.library(
name: "Root",
targets: ["Root"]),
],
dependencies: [
.package(path: "../Domain")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "Coordinator",
dependencies: [
"Main",
"Root",
"ExerciseCounter",
.product(name: "Data", package: "Data")
]
)
.target(
name: "Main",
dependencies: [
"Main",
"Root",
"ExerciseCounter",
.product(name: "Data", package: "Data")
]
)

]
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//

import UIKit
import Shared
import Domain

final class LoginCoordinator: LoginCoordinatorProtocol {
var navigationController: UINavigationController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import UIKit
import SwiftUI
import Shared
import Domain

final class MainCoordinator: MainCoordinatorProtocol, CoordinatorFinishDelegate {
var finishDelegate: CoordinatorFinishDelegate?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
//

import Foundation
import Shared

protocol ExerciseCounterCoordinatorProtocol: Coordinator { }
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
//

import UIKit
import Shared

protocol LoginCoordinatorProtocol: Coordinator { }
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Foundation
import Shared

protocol MainCoordinatorProtocol: Coordinator {
func presentExerciseCounter(routine: [Int])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import UIKit
import Shared

protocol RootCoordinatorProtocol: Coordinator {
func openMainCoordinator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import UIKit
import Shared

final class RootCoordinator: RootCoordinatorProtocol {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//

import UIKit
import Shared

protocol ExerciseCounterRoutingLogic {
func dismiss()
Expand Down
Loading
Loading