From 5da6d7e164872fa53dc70f14248e316ed4c71ad1 Mon Sep 17 00:00:00 2001 From: GeonWoo Date: Sun, 10 Mar 2024 14:40:38 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20delegate=20swiftUI?= =?UTF-8?q?=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FunchApp/Application/Dependency.swift | 5 +++ FunchApp/Application/FunchApp.swift | 9 ++-- .../HomeScene/HomePresentation.swift | 45 ++++++++++++++++++- .../Presentation/HomeScene/HomeView.swift | 32 +------------ .../HomeScene/HomeViewBuilder.swift | 6 +-- .../HomeScene/HomeViewModel.swift | 9 +++- .../ProfileScene/ProfileView.swift | 1 - .../ProfileScene/ProfileViewBuilder.swift | 27 ++++++++--- .../ProfileScene/ProfileViewModel.swift | 8 ++-- 9 files changed, 90 insertions(+), 52 deletions(-) diff --git a/FunchApp/Application/Dependency.swift b/FunchApp/Application/Dependency.swift index 321a267..f040f3c 100644 --- a/FunchApp/Application/Dependency.swift +++ b/FunchApp/Application/Dependency.swift @@ -18,6 +18,11 @@ final class DIContainer: ObservableObject { let subwayStationRepository: SubwayStationRepository } + struct Delegate { + +// var ProfileViewDelegate: ProfileViewDelegate = ProfileDelegate + } + private(set) var dependency: Dependency private(set) var openUrl: OpenURLProtocol diff --git a/FunchApp/Application/FunchApp.swift b/FunchApp/Application/FunchApp.swift index f14b9ba..164650f 100644 --- a/FunchApp/Application/FunchApp.swift +++ b/FunchApp/Application/FunchApp.swift @@ -34,16 +34,15 @@ struct FunchApp: App { } .overlay { if isSplashing { - withAnimation(.easeOut) { - SplashViewBuilder().body - } - + SplashViewBuilder().body } } } .onAppear { DispatchQueue.main.asyncAfter(deadline: .now() + 1.35) { - isSplashing.toggle() + withAnimation(.easeInOut) { + isSplashing.toggle() + } } } .environmentObject(container) diff --git a/FunchApp/Presentation/HomeScene/HomePresentation.swift b/FunchApp/Presentation/HomeScene/HomePresentation.swift index e670cb3..6d1f025 100644 --- a/FunchApp/Presentation/HomeScene/HomePresentation.swift +++ b/FunchApp/Presentation/HomeScene/HomePresentation.swift @@ -5,7 +5,7 @@ // Created by Geon Woo lee on 2/22/24. // -import Foundation +import SwiftUI enum HomePresentation: Hashable, Identifiable { var id: Int { hashValue } @@ -16,3 +16,46 @@ enum HomePresentation: Hashable, Identifiable { case easterEgg case multiProfile } + +struct HomePresentationView: View { + @EnvironmentObject var container: DIContainer + @State var presentation: HomePresentation + var viewModel: HomeViewModel + + var body: some View { + switch presentation { + case .profile: + NavigationStack { + ProfileViewBuilder( + container, + delegate: viewModel + ).body + } +// .onDisappear { +// viewModel.send(action: .load) +// } + case let .matchResult(matchingInfo): + NavigationStack { + MatchResultViewBuilder( + container, + matchingInfo: matchingInfo + ).body + } + case .mbtiCollection: + NavigationStack { + MBTIBoardViewBuilder(container).body + } + case .easterEgg: + NavigationStack { + EasterEggViewBuilder(container).body + } + case .multiProfile: + NavigationStack { + MultiProfileListViewBuilder(container).body + } +// .onDisappear { +// viewModel.send(action: .load) +// } + } + } +} diff --git a/FunchApp/Presentation/HomeScene/HomeView.swift b/FunchApp/Presentation/HomeScene/HomeView.swift index 133bb8b..3931a54 100644 --- a/FunchApp/Presentation/HomeScene/HomeView.swift +++ b/FunchApp/Presentation/HomeScene/HomeView.swift @@ -102,37 +102,7 @@ struct HomeView: View { hideKeyboard() } .fullScreenCover(item: $viewModel.presentation) { presentation in - switch presentation { - case .profile: - NavigationStack { - ProfileViewBuilder(container).body - } - .onDisappear { - viewModel.send(action: .load) - } - case let .matchResult(matchingInfo): - NavigationStack { - MatchResultViewBuilder( - container, - matchingInfo: matchingInfo - ).body - } - case .mbtiCollection: - NavigationStack { - MBTIBoardViewBuilder(container).body - } - case .easterEgg: - NavigationStack { - EasterEggViewBuilder(container).body - } - case .multiProfile: - NavigationStack { - MultiProfileListViewBuilder(container).body - } - .onDisappear { - viewModel.send(action: .load) - } - } + HomePresentationView(presentation: presentation, viewModel: self.viewModel) } .toolbar { ToolbarItemGroup(placement: .topBarTrailing) { diff --git a/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift b/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift index 6614633..46b83e4 100644 --- a/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift +++ b/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift @@ -7,17 +7,17 @@ import SwiftUI -final class HomeViewBuilder { +final class HomeViewBuilder{ private var container: DIContainer init(_ container: DIContainer) { self.container = container + } var body: some View { - let viewModel = makeViewModel() - let view = HomeView(viewModel: viewModel) + let view = HomeView(viewModel: self.makeViewModel()) return view } diff --git a/FunchApp/Presentation/HomeScene/HomeViewModel.swift b/FunchApp/Presentation/HomeScene/HomeViewModel.swift index 41ae31a..9407fae 100644 --- a/FunchApp/Presentation/HomeScene/HomeViewModel.swift +++ b/FunchApp/Presentation/HomeScene/HomeViewModel.swift @@ -59,6 +59,7 @@ final class HomeViewModel: ObservableObject { private var useCase: UseCase private var container: DIContainer + private var cancellables = Set() struct UseCase { let fetchProfile: DefaultFetchProfileUseCase @@ -71,8 +72,6 @@ final class HomeViewModel: ObservableObject { self.container = container } - var cancellables = Set() - func send(action: Action) { switch action { case .load: @@ -168,3 +167,9 @@ final class HomeViewModel: ObservableObject { }.store(in: &cancellables) } } + +extension HomeViewModel: ProfileViewDelegate { + func delete(profile: Profile) { + self.send(action: .load) + } +} diff --git a/FunchApp/Presentation/ProfileScene/ProfileView.swift b/FunchApp/Presentation/ProfileScene/ProfileView.swift index 4c0e508..495c339 100644 --- a/FunchApp/Presentation/ProfileScene/ProfileView.swift +++ b/FunchApp/Presentation/ProfileScene/ProfileView.swift @@ -128,7 +128,6 @@ struct ProfileView: View { .toolbarBackground(Color.gray900, for: .navigationBar) } - private func profileView(_ profile: Profile) -> some View { VStack(alignment: .leading, spacing: 0) { Text(profile.userCode) diff --git a/FunchApp/Presentation/ProfileScene/ProfileViewBuilder.swift b/FunchApp/Presentation/ProfileScene/ProfileViewBuilder.swift index c05fb6d..38c2fb1 100644 --- a/FunchApp/Presentation/ProfileScene/ProfileViewBuilder.swift +++ b/FunchApp/Presentation/ProfileScene/ProfileViewBuilder.swift @@ -6,22 +6,37 @@ // import SwiftUI +import Combine + +protocol ProfileViewDelegate: AnyObject { + func delete(profile: Profile) +} struct ProfileViewBuilder { private var container: DIContainer + private var viewModel: ProfileViewModel + private var delegate: ProfileViewDelegate - init(_ container: DIContainer) { + init( + _ container: DIContainer, + delegate: ProfileViewDelegate + ) { self.container = container - } - - var body: some View { + self.delegate = delegate + let useCase = DefaultDeleteProfileUseCase(profileRepository: container.dependency.profileRepository) - let viewModel = ProfileViewModel( + + self.viewModel = .init( container: container, - useCase: useCase + useCase: useCase, + delegate: delegate ) + } + + var body: some View { let view = ProfileView(viewModel: viewModel) + return view } } diff --git a/FunchApp/Presentation/ProfileScene/ProfileViewModel.swift b/FunchApp/Presentation/ProfileScene/ProfileViewModel.swift index d62914a..da89cf4 100644 --- a/FunchApp/Presentation/ProfileScene/ProfileViewModel.swift +++ b/FunchApp/Presentation/ProfileScene/ProfileViewModel.swift @@ -39,15 +39,18 @@ final class ProfileViewModel: ObservableObject { private var useCase: DeleteProfileUseCase private var container: DIContainer + weak var delegate: ProfileViewDelegate? private var cancellables = Set() init( container: DIContainer, - useCase: DeleteProfileUseCase + useCase: DeleteProfileUseCase, + delegate: ProfileViewDelegate ) { self.container = container self.useCase = useCase + self.delegate = delegate } func send(action: Action) { @@ -64,7 +67,6 @@ final class ProfileViewModel: ObservableObject { case .deleteProfile: guard let userId = profile?.userId else { return } - useCase.execute(requestId: userId) .sink { _ in @@ -79,8 +81,8 @@ final class ProfileViewModel: ObservableObject { self.presentation = .onboarding } else { self.presentation = .home + delegate?.delete(profile: profile) } - } .store(in: &cancellables) From 49e969f2faf364f14366d63d9fae4c9145a91216 Mon Sep 17 00:00:00 2001 From: GeonWoo Date: Sun, 10 Mar 2024 15:47:07 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20delegate=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HomeScene/HomePresentation.swift | 5 ++++- .../HomeScene/HomeViewBuilder.swift | 3 ++- .../HomeScene/HomeViewModel.swift | 6 ++++++ .../MultiProfileListView.swift | 5 ++++- .../MultiProfileListViewBuilder.swift | 16 ++++++++++++--- .../MultiProfileListViewModel.swift | 20 +++++++++++++++++-- 6 files changed, 47 insertions(+), 8 deletions(-) diff --git a/FunchApp/Presentation/HomeScene/HomePresentation.swift b/FunchApp/Presentation/HomeScene/HomePresentation.swift index 6d1f025..61ace2a 100644 --- a/FunchApp/Presentation/HomeScene/HomePresentation.swift +++ b/FunchApp/Presentation/HomeScene/HomePresentation.swift @@ -51,7 +51,10 @@ struct HomePresentationView: View { } case .multiProfile: NavigationStack { - MultiProfileListViewBuilder(container).body + MultiProfileListViewBuilder( + container, + delegate: viewModel + ).body } // .onDisappear { // viewModel.send(action: .load) diff --git a/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift b/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift index 46b83e4..425c277 100644 --- a/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift +++ b/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift @@ -17,7 +17,8 @@ final class HomeViewBuilder{ } var body: some View { - let view = HomeView(viewModel: self.makeViewModel()) + let viewModel = makeViewModel() + let view = HomeView(viewModel: viewModel) return view } diff --git a/FunchApp/Presentation/HomeScene/HomeViewModel.swift b/FunchApp/Presentation/HomeScene/HomeViewModel.swift index 9407fae..438f4aa 100644 --- a/FunchApp/Presentation/HomeScene/HomeViewModel.swift +++ b/FunchApp/Presentation/HomeScene/HomeViewModel.swift @@ -173,3 +173,9 @@ extension HomeViewModel: ProfileViewDelegate { self.send(action: .load) } } + +extension HomeViewModel: MultiProfileListDelegate { + func change(profile: Profile) { + self.send(action: .load) + } +} diff --git a/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift b/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift index 0fe9c84..b577d6c 100644 --- a/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift +++ b/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift @@ -82,12 +82,15 @@ struct MultiProfileListView: View { break } } + .onReceive(viewModel.$dismiss) { isDismiss in + if isDismiss { dismiss() } + } .toolbarBackground(Color.gray900, for: .navigationBar) .toolbarBackground(.visible, for: .navigationBar) .toolbar { ToolbarItem(placement: .topBarLeading) { Button { - dismiss() + viewModel.send(action: .dismiss) } label: { Image(.iconX) } diff --git a/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewBuilder.swift b/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewBuilder.swift index 63fee06..294ae66 100644 --- a/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewBuilder.swift +++ b/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewBuilder.swift @@ -7,16 +7,26 @@ import SwiftUI -final class MultiProfileListViewBuilder { +struct MultiProfileListViewBuilder { private var container: DIContainer + private var viewModel: MultiProfileListViewModel + private var delegate: MultiProfileListDelegate - init(_ container: DIContainer) { + init( + _ container: DIContainer, + delegate: MultiProfileListDelegate + ) { self.container = container + self.delegate = delegate + + self.viewModel = .init( + container: container, + delegate: delegate + ) } var body: some View { - let viewModel = MultiProfileListViewModel(container: container) let view = MultiProfileListView(viewModel: viewModel) return view diff --git a/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewModel.swift b/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewModel.swift index 4a05e10..bc5e173 100644 --- a/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewModel.swift +++ b/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewModel.swift @@ -7,12 +7,17 @@ import SwiftUI +protocol MultiProfileListDelegate: AnyObject { + func change(profile: Profile) +} + final class MultiProfileListViewModel: ObservableObject { enum Action { case load case selection(Profile) case presentation(MultiProfileListPresentation) + case dismiss } @Published var presentation: MultiProfileListPresentation? @@ -20,11 +25,17 @@ final class MultiProfileListViewModel: ObservableObject { @Published var profiles: [Profile] = [.empty, .testableValue] /// 유저가 선택한 프로필 @Published var selection: Profile? + @Published var dismiss: Bool = false private var container: DIContainer - - init(container: DIContainer) { + weak var delegate: MultiProfileListDelegate? + + init( + container: DIContainer, + delegate: MultiProfileListDelegate + ) { self.container = container + self.delegate = delegate } func send(action: Action) { @@ -42,6 +53,11 @@ final class MultiProfileListViewModel: ObservableObject { case let .presentation(presentation): self.presentation = presentation + + case .dismiss: + guard let profile = self.selection else { return } + delegate?.change(profile: profile) + dismiss = true } } } From 3847d057aa4293a720c5731426404e3870e7dc2d Mon Sep 17 00:00:00 2001 From: GeonWoo Date: Sun, 10 Mar 2024 16:06:29 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20present=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HomeScene/HomePresentation.swift | 7 +------ .../MultiProfileListPresentation.swift | 17 ++++++++++++++-- .../MultiProfileListView.swift | 20 +------------------ 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/FunchApp/Presentation/HomeScene/HomePresentation.swift b/FunchApp/Presentation/HomeScene/HomePresentation.swift index 61ace2a..b79887d 100644 --- a/FunchApp/Presentation/HomeScene/HomePresentation.swift +++ b/FunchApp/Presentation/HomeScene/HomePresentation.swift @@ -20,6 +20,7 @@ enum HomePresentation: Hashable, Identifiable { struct HomePresentationView: View { @EnvironmentObject var container: DIContainer @State var presentation: HomePresentation + var viewModel: HomeViewModel var body: some View { @@ -31,9 +32,6 @@ struct HomePresentationView: View { delegate: viewModel ).body } -// .onDisappear { -// viewModel.send(action: .load) -// } case let .matchResult(matchingInfo): NavigationStack { MatchResultViewBuilder( @@ -56,9 +54,6 @@ struct HomePresentationView: View { delegate: viewModel ).body } -// .onDisappear { -// viewModel.send(action: .load) -// } } } } diff --git a/FunchApp/Presentation/MultiProfileScene/MultiProfileListPresentation.swift b/FunchApp/Presentation/MultiProfileScene/MultiProfileListPresentation.swift index a1ae584..d46768e 100644 --- a/FunchApp/Presentation/MultiProfileScene/MultiProfileListPresentation.swift +++ b/FunchApp/Presentation/MultiProfileScene/MultiProfileListPresentation.swift @@ -5,11 +5,24 @@ // Created by Geon Woo lee on 3/2/24. // -import Foundation +import SwiftUI enum MultiProfileListPresentation: Hashable, Identifiable { var id: Int { hashValue } case create - case home +} + +struct MultiProfileListPresentationView: View { + @EnvironmentObject var container: DIContainer + @State var presentation: MultiProfileListPresentation + + var body: some View { + switch presentation { + case .create: + NavigationStack { + ProfileEditorViewBuilder(container).body + } + } + } } diff --git a/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift b/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift index b577d6c..f6bc759 100644 --- a/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift +++ b/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift @@ -62,25 +62,7 @@ struct MultiProfileListView: View { viewModel.send(action: .load) } .fullScreenCover(item: $viewModel.presentation) { presentation in - switch presentation { - case .create: - NavigationStack { - ProfileEditorViewBuilder(container).body - } - .onDisappear { - viewModel.send(action: .load) - } - case .home: - EmptyView() - } - } - .onReceive(viewModel.$presentation) { - switch $0 { - case .home: - container.paths.removeAll() - default: - break - } + MultiProfileListPresentationView(presentation: presentation) } .onReceive(viewModel.$dismiss) { isDismiss in if isDismiss { dismiss() } From bfb53e75591d07bd301b822bf019985ed6d3835b Mon Sep 17 00:00:00 2001 From: GeonWoo Date: Sun, 10 Mar 2024 16:20:37 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20delegate=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FunchApp.xcodeproj/project.pbxproj | 8 ++++++++ .../Presentation/EasterEggScene/EasterEggView.swift | 5 ++--- FunchApp/Presentation/HomeScene/HomeView.swift | 3 --- .../Presentation/MBTIBoardScene/MBTIBoardView.swift | 4 +--- .../MatchResultScene/MatchResultView.swift | 5 ++--- .../MultiProfileScene/MultiProfileListDelegate.swift | 12 ++++++++++++ .../MultiProfileScene/MultiProfileListView.swift | 5 +---- .../MultiProfileListViewModel.swift | 4 ---- .../ProfileEditorScene/ProfileEditorView.swift | 3 +-- .../ProfileEditorScene/ProfileEditorViewModel.swift | 1 - FunchApp/Presentation/ProfileScene/ProfileView.swift | 5 ++--- .../ProfileScene/ProfileViewBuilder.swift | 4 ---- .../ProfileScene/ProfileViewDelegate.swift | 10 ++++++++++ 13 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 FunchApp/Presentation/MultiProfileScene/MultiProfileListDelegate.swift create mode 100644 FunchApp/Presentation/ProfileScene/ProfileViewDelegate.swift diff --git a/FunchApp.xcodeproj/project.pbxproj b/FunchApp.xcodeproj/project.pbxproj index 4cefa4f..d8152b2 100644 --- a/FunchApp.xcodeproj/project.pbxproj +++ b/FunchApp.xcodeproj/project.pbxproj @@ -120,6 +120,8 @@ 1ACE49802B5BA46600024336 /* ProfileRepositoryImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ACE497F2B5BA46600024336 /* ProfileRepositoryImpl.swift */; }; 1ACE49862B5BAB5F00024336 /* DefaultFunchButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ACE49852B5BAB5F00024336 /* DefaultFunchButtonStyle.swift */; }; 1ACE498D2B5C111500024336 /* ChipView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ACE498C2B5C111500024336 /* ChipView.swift */; }; + 1AFB7D9C2B9D9387007E4D2F /* MultiProfileListDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AFB7D9B2B9D9387007E4D2F /* MultiProfileListDelegate.swift */; }; + 1AFB7D9E2B9D9481007E4D2F /* ProfileViewDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1AFB7D9D2B9D9481007E4D2F /* ProfileViewDelegate.swift */; }; 3E1E73EF2B7071030082386A /* SubwayStationRepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E1E73EE2B7071030082386A /* SubwayStationRepositoryTests.swift */; }; 3E1E73F12B70B3570082386A /* ChipButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E1E73F02B70B3570082386A /* ChipButton.swift */; }; 3E1E73F32B713B3A0082386A /* String+.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E1E73F22B713B3A0082386A /* String+.swift */; }; @@ -257,6 +259,8 @@ 1ACE497F2B5BA46600024336 /* ProfileRepositoryImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileRepositoryImpl.swift; sourceTree = ""; }; 1ACE49852B5BAB5F00024336 /* DefaultFunchButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFunchButtonStyle.swift; sourceTree = ""; }; 1ACE498C2B5C111500024336 /* ChipView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipView.swift; sourceTree = ""; }; + 1AFB7D9B2B9D9387007E4D2F /* MultiProfileListDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiProfileListDelegate.swift; sourceTree = ""; }; + 1AFB7D9D2B9D9481007E4D2F /* ProfileViewDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileViewDelegate.swift; sourceTree = ""; }; 3E1E73EE2B7071030082386A /* SubwayStationRepositoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubwayStationRepositoryTests.swift; sourceTree = ""; }; 3E1E73F02B70B3570082386A /* ChipButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipButton.swift; sourceTree = ""; }; 3E1E73F22B713B3A0082386A /* String+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+.swift"; sourceTree = ""; }; @@ -488,6 +492,7 @@ 1AC7812D2B91E6CC00E298E3 /* MultiProfileScene */ = { isa = PBXGroup; children = ( + 1AFB7D9B2B9D9387007E4D2F /* MultiProfileListDelegate.swift */, 1AC781362B923EEA00E298E3 /* MultiProfileListViewBuilder.swift */, 1AC7812B2B91E6C900E298E3 /* MultiProfileListView.swift */, 1AC781342B923EC800E298E3 /* MultiProfileListViewModel.swift */, @@ -596,6 +601,7 @@ 1ACE495E2B5B9EFF00024336 /* ProfileScene */ = { isa = PBXGroup; children = ( + 1AFB7D9D2B9D9481007E4D2F /* ProfileViewDelegate.swift */, 1A83F0302B80E6CB00E6EC89 /* ProfileViewBuilder.swift */, 1A83F0322B80E6E000E6EC89 /* ProfileViewModel.swift */, 1ACE49552B5B9E9300024336 /* ProfileView.swift */, @@ -1037,6 +1043,7 @@ 1A83F0382B80E8E200E6EC89 /* SplashViewBuilder.swift in Sources */, 1A44AAAC2B67EFCD006D8894 /* CreateProfile.Req.swift in Sources */, 1A8F13092B8B7DAB001E0237 /* LinkStringSet.swift in Sources */, + 1AFB7D9E2B9D9481007E4D2F /* ProfileViewDelegate.swift in Sources */, 1AC781202B90E81500E298E3 /* RepositoryError.swift in Sources */, 1A8F12F12B87A33C001E0237 /* MBTIBoardUseCase.swift in Sources */, 1A7B069E2B5D702D0024356C /* APIEnvironment.swift in Sources */, @@ -1053,6 +1060,7 @@ 1A83F02C2B80E1BD00E6EC89 /* HomeViewModel.swift in Sources */, 3EA875682B86492B00713C64 /* DeleteProfile.Res.swift in Sources */, 1A7B06A22B5D8C710024356C /* MatchingInfo.swift in Sources */, + 1AFB7D9C2B9D9387007E4D2F /* MultiProfileListDelegate.swift in Sources */, 1ACE497D2B5BA3B600024336 /* CreateProfile.Res.swift in Sources */, 1A83F02E2B80E26B00E6EC89 /* MatchResultViewBuilder.swift in Sources */, 1A8F12EA2B8784B8001E0237 /* ProfileEditorPresentation.swift in Sources */, diff --git a/FunchApp/Presentation/EasterEggScene/EasterEggView.swift b/FunchApp/Presentation/EasterEggScene/EasterEggView.swift index 718afd9..79f3617 100644 --- a/FunchApp/Presentation/EasterEggScene/EasterEggView.swift +++ b/FunchApp/Presentation/EasterEggScene/EasterEggView.swift @@ -8,11 +8,10 @@ import SwiftUI struct EasterEggView: View { - - @Environment(\.dismiss) var dismiss - @StateObject var viewModel: EasterEggViewModel + @Environment(\.dismiss) var dismiss + var body: some View { ZStack { Color.gray900 diff --git a/FunchApp/Presentation/HomeScene/HomeView.swift b/FunchApp/Presentation/HomeScene/HomeView.swift index 3931a54..f9882f2 100644 --- a/FunchApp/Presentation/HomeScene/HomeView.swift +++ b/FunchApp/Presentation/HomeScene/HomeView.swift @@ -8,9 +8,6 @@ import SwiftUI struct HomeView: View { - - @EnvironmentObject var container: DIContainer - @StateObject var viewModel: HomeViewModel var body: some View { diff --git a/FunchApp/Presentation/MBTIBoardScene/MBTIBoardView.swift b/FunchApp/Presentation/MBTIBoardScene/MBTIBoardView.swift index be7c23a..eb177c7 100644 --- a/FunchApp/Presentation/MBTIBoardScene/MBTIBoardView.swift +++ b/FunchApp/Presentation/MBTIBoardScene/MBTIBoardView.swift @@ -8,10 +8,8 @@ import SwiftUI struct MBTIBoardView: View { - - @Environment(\.dismiss) var dismiss - @StateObject var viewModel: MBTIBoardViewModel + @Environment(\.dismiss) var dismiss var body: some View { ZStack { diff --git a/FunchApp/Presentation/MatchResultScene/MatchResultView.swift b/FunchApp/Presentation/MatchResultScene/MatchResultView.swift index b34d2b4..8a47927 100644 --- a/FunchApp/Presentation/MatchResultScene/MatchResultView.swift +++ b/FunchApp/Presentation/MatchResultScene/MatchResultView.swift @@ -9,12 +9,11 @@ import SwiftUI import SwiftUIPager struct MatchResultView: View { - - @Environment(\.dismiss) var dismiss - @StateObject var viewModel: MatchResultViewModel @StateObject var page: Page = .first() + @Environment(\.dismiss) var dismiss + var viewSize: CGSize = UIScreen.main.bounds.size var body: some View { diff --git a/FunchApp/Presentation/MultiProfileScene/MultiProfileListDelegate.swift b/FunchApp/Presentation/MultiProfileScene/MultiProfileListDelegate.swift new file mode 100644 index 0000000..845fe15 --- /dev/null +++ b/FunchApp/Presentation/MultiProfileScene/MultiProfileListDelegate.swift @@ -0,0 +1,12 @@ +// +// MultiProfileListDelegate.swift +// FunchApp +// +// Created by Geon Woo lee on 3/10/24. +// + +import Foundation + +protocol MultiProfileListDelegate: AnyObject { + func change(profile: Profile) +} diff --git a/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift b/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift index f6bc759..6004595 100644 --- a/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift +++ b/FunchApp/Presentation/MultiProfileScene/MultiProfileListView.swift @@ -8,13 +8,10 @@ import SwiftUI struct MultiProfileListView: View { + @StateObject var viewModel: MultiProfileListViewModel @Environment(\.dismiss) var dismiss - @EnvironmentObject var container: DIContainer - - @StateObject var viewModel: MultiProfileListViewModel - var body: some View { ZStack { Color.gray900 diff --git a/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewModel.swift b/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewModel.swift index bc5e173..e655fe9 100644 --- a/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewModel.swift +++ b/FunchApp/Presentation/MultiProfileScene/MultiProfileListViewModel.swift @@ -7,10 +7,6 @@ import SwiftUI -protocol MultiProfileListDelegate: AnyObject { - func change(profile: Profile) -} - final class MultiProfileListViewModel: ObservableObject { enum Action { diff --git a/FunchApp/Presentation/ProfileEditorScene/ProfileEditorView.swift b/FunchApp/Presentation/ProfileEditorScene/ProfileEditorView.swift index e2a0203..907a1e7 100644 --- a/FunchApp/Presentation/ProfileEditorScene/ProfileEditorView.swift +++ b/FunchApp/Presentation/ProfileEditorScene/ProfileEditorView.swift @@ -8,11 +8,10 @@ import SwiftUI struct ProfileEditorView: View { + @StateObject var viewModel: ProfileEditorViewModel @Environment(\.dismiss) var dismiss - @StateObject var viewModel: ProfileEditorViewModel - var body: some View { ZStack { Color.gray900 diff --git a/FunchApp/Presentation/ProfileEditorScene/ProfileEditorViewModel.swift b/FunchApp/Presentation/ProfileEditorScene/ProfileEditorViewModel.swift index b5647c8..456c1fd 100644 --- a/FunchApp/Presentation/ProfileEditorScene/ProfileEditorViewModel.swift +++ b/FunchApp/Presentation/ProfileEditorScene/ProfileEditorViewModel.swift @@ -162,7 +162,6 @@ final class ProfileEditorViewModel: ObservableObject { } } - extension ProfileEditorViewModel { private func makeCreateUserQuery() -> CreateUserQuery { let major = majors.map { major in diff --git a/FunchApp/Presentation/ProfileScene/ProfileView.swift b/FunchApp/Presentation/ProfileScene/ProfileView.swift index 495c339..1670086 100644 --- a/FunchApp/Presentation/ProfileScene/ProfileView.swift +++ b/FunchApp/Presentation/ProfileScene/ProfileView.swift @@ -8,12 +8,11 @@ import SwiftUI struct ProfileView: View { - - @Environment(\.dismiss) var dismiss - @StateObject var viewModel: ProfileViewModel @EnvironmentObject var diContainer: DIContainer + @Environment(\.dismiss) var dismiss + var body: some View { ZStack { Color.gray900 diff --git a/FunchApp/Presentation/ProfileScene/ProfileViewBuilder.swift b/FunchApp/Presentation/ProfileScene/ProfileViewBuilder.swift index 38c2fb1..56b0b32 100644 --- a/FunchApp/Presentation/ProfileScene/ProfileViewBuilder.swift +++ b/FunchApp/Presentation/ProfileScene/ProfileViewBuilder.swift @@ -8,10 +8,6 @@ import SwiftUI import Combine -protocol ProfileViewDelegate: AnyObject { - func delete(profile: Profile) -} - struct ProfileViewBuilder { private var container: DIContainer diff --git a/FunchApp/Presentation/ProfileScene/ProfileViewDelegate.swift b/FunchApp/Presentation/ProfileScene/ProfileViewDelegate.swift new file mode 100644 index 0000000..4d372da --- /dev/null +++ b/FunchApp/Presentation/ProfileScene/ProfileViewDelegate.swift @@ -0,0 +1,10 @@ +// +// ProfileViewDelegate.swift +// FunchApp +// +// Created by Geon Woo lee on 3/10/24. +// + +protocol ProfileViewDelegate: AnyObject { + func delete(profile: Profile) +} From 522f8ae4763c3672ffac60dfbe41c98b12fb6f3f Mon Sep 17 00:00:00 2001 From: GeonWoo Date: Wed, 13 Mar 2024 01:22:00 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[=EC=88=98=EC=A0=95]=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=BB=A8=EB=B2=A4=EC=85=98=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FunchApp/Presentation/HomeScene/HomeViewBuilder.swift | 1 - .../MultiProfileScene/MultiProfileListDelegate.swift | 1 + FunchApp/Presentation/ProfileScene/ProfileViewDelegate.swift | 1 + FunchApp/Presentation/ProfileScene/ProfileViewModel.swift | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) diff --git a/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift b/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift index 425c277..6c0f6e2 100644 --- a/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift +++ b/FunchApp/Presentation/HomeScene/HomeViewBuilder.swift @@ -13,7 +13,6 @@ final class HomeViewBuilder{ init(_ container: DIContainer) { self.container = container - } var body: some View { diff --git a/FunchApp/Presentation/MultiProfileScene/MultiProfileListDelegate.swift b/FunchApp/Presentation/MultiProfileScene/MultiProfileListDelegate.swift index 845fe15..3364b4c 100644 --- a/FunchApp/Presentation/MultiProfileScene/MultiProfileListDelegate.swift +++ b/FunchApp/Presentation/MultiProfileScene/MultiProfileListDelegate.swift @@ -8,5 +8,6 @@ import Foundation protocol MultiProfileListDelegate: AnyObject { + /// 프로필 변경 func change(profile: Profile) } diff --git a/FunchApp/Presentation/ProfileScene/ProfileViewDelegate.swift b/FunchApp/Presentation/ProfileScene/ProfileViewDelegate.swift index 4d372da..98ae683 100644 --- a/FunchApp/Presentation/ProfileScene/ProfileViewDelegate.swift +++ b/FunchApp/Presentation/ProfileScene/ProfileViewDelegate.swift @@ -6,5 +6,6 @@ // protocol ProfileViewDelegate: AnyObject { + /// 프로필 삭제시 호출 func delete(profile: Profile) } diff --git a/FunchApp/Presentation/ProfileScene/ProfileViewModel.swift b/FunchApp/Presentation/ProfileScene/ProfileViewModel.swift index da89cf4..8641ea1 100644 --- a/FunchApp/Presentation/ProfileScene/ProfileViewModel.swift +++ b/FunchApp/Presentation/ProfileScene/ProfileViewModel.swift @@ -97,6 +97,7 @@ final class ProfileViewModel: ObservableObject { case let .alert(type): showsAlert = true alertMessage = type + } }