Skip to content

Commit

Permalink
[Infra] API Call 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
jisu15-kim committed Nov 26, 2024
1 parent d72a713 commit 82c64aa
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@ import CommonKit
import CoreKit
import Model
import DesignCore
import NetworkKit

//MARK: - Intent
class EditDateProfileDistanceIntent {
private weak var model: EditDateProfileDistanceModelActionable?
private let input: DataModel
private let profileService: ProfileServiceProtocol

// MARK: Life cycle
init(
model: EditDateProfileDistanceModelActionable,
input: DataModel
input: DataModel,
service: ProfileServiceProtocol = ProfileService.shared
) {
self.input = input
self.model = model
self.profileService = service
model.setUserInfo(input.userInfo)
model.setDistanceType(input.userInfo.dreamPartner.distanceType)
}
Expand Down Expand Up @@ -70,7 +74,7 @@ extension EditDateProfileDistanceIntent: EditDateProfileDistanceIntent.Intentabl
}
}
func requestUpdatePartnerInfo(newUserInfo: UserInfo) async throws {

try await profileService.requestPutPartnerInfo(userInfo: newUserInfo)
}

// default
Expand Down
9 changes: 0 additions & 9 deletions Projects/Features/Home/Sources/HomeMain/HomeMainIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ extension HomeMainIntent: HomeMainIntent.Intentable {
model?.setSelectedTab(tab: tab)
}
func onAppear() {
Task {
if let userInfo = input.userInfo {
model?.setUserInfo(userInfo: userInfo)
} else {
let userInfo = try await authService.requestMyUserInfo()
AppCoordinator.shared.userInfo = userInfo
model?.setUserInfo(userInfo: userInfo)
}
}
}

func task() async {}
Expand Down
72 changes: 35 additions & 37 deletions Projects/Features/Home/Sources/HomeMain/HomeMainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,50 +35,48 @@ public struct HomeMainView: View {

public var body: some View {
VStack(spacing: 0) {
if let userInfo = state.userInfo {
// Tab
HStack(spacing: 30) {
ForEach(HomeMainTab.allCases, id: \.self) { tab in
Button(action: {
withAnimation {
intent.onTapTab(tab)
}
}) {
VStack(spacing: 0) {
let isSelected = tab == state.selectedTab
Circle()
.frame(width: 6, height: 6)
.foregroundStyle(isSelected ? DesignCore.Colors.grey500 : .clear)
Text(tab.title)
.typography(.en_medium_20)
.padding(.vertical, 12)
.foregroundColor(isSelected ? DesignCore.Colors.grey500 : DesignCore.Colors.grey500.opacity(0.2))
}
.padding(.top, 8)
// Tab
HStack(spacing: 30) {
ForEach(HomeMainTab.allCases, id: \.self) { tab in
Button(action: {
withAnimation {
intent.onTapTab(tab)
}
}) {
VStack(spacing: 0) {
let isSelected = tab == state.selectedTab
Circle()
.frame(width: 6, height: 6)
.foregroundStyle(isSelected ? DesignCore.Colors.grey500 : .clear)
Text(tab.title)
.typography(.en_medium_20)
.padding(.vertical, 12)
.foregroundColor(isSelected ? DesignCore.Colors.grey500 : DesignCore.Colors.grey500.opacity(0.2))
}
.padding(.top, 8)
}
}

// 탭 콘텐츠
TabView(selection: $container.model.selectedTab) {
// 첫 번째 탭 내용
VStack {
Text("첫 번째 탭")
Button {
intent.onTapNextButton()
} label: {
Text("토스트!")
}

}

// 탭 콘텐츠
TabView(selection: $container.model.selectedTab) {
// 첫 번째 탭 내용
VStack {
Text("첫 번째 탭")
Button {
intent.onTapNextButton()
} label: {
Text("토스트!")
}
.tag(HomeMainTab.home)

// 두 번째 탭 내용
ProfileView(userInfo: userInfo)
.tag(HomeMainTab.profile)
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
.tag(HomeMainTab.home)

// 두 번째 탭 내용
ProfileView()
.tag(HomeMainTab.profile)
}
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
}
.task {
await intent.task()
Expand Down
4 changes: 1 addition & 3 deletions Projects/Features/Home/Sources/Profile/ProfileIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ extension ProfileIntent {
func task() async
}

struct DataModel {
let userInfo: UserInfo
}
struct DataModel {}
}

//MARK: - Intentable
Expand Down
6 changes: 2 additions & 4 deletions Projects/Features/Home/Sources/Profile/ProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ public struct ProfileView: View {
GridItem(.flexible(), spacing: 16)
]

public init(userInfo: UserInfo) {
public init() {
let model = ProfileModel()
let intent = ProfileIntent(
model: model,
input: .init(
userInfo: userInfo
)
input: .init()
)
let container = MVIContainer(
intent: intent as ProfileIntent.Intentable,
Expand Down

0 comments on commit 82c64aa

Please sign in to comment.