diff --git a/Taxi/Taxi.xcodeproj/project.pbxproj b/Taxi/Taxi.xcodeproj/project.pbxproj index 2b27482a..cca59a71 100644 --- a/Taxi/Taxi.xcodeproj/project.pbxproj +++ b/Taxi/Taxi.xcodeproj/project.pbxproj @@ -64,6 +64,7 @@ 00F856A82844A985008E2E2F /* FirebaseFunctionsCombine-Community in Frameworks */ = {isa = PBXBuildFile; productRef = 00F856A72844A985008E2E2F /* FirebaseFunctionsCombine-Community */; }; 00F856AA2844A985008E2E2F /* FirebaseStorage in Frameworks */ = {isa = PBXBuildFile; productRef = 00F856A92844A985008E2E2F /* FirebaseStorage */; }; 00F856AC2844A985008E2E2F /* FirebaseStorageCombine-Community in Frameworks */ = {isa = PBXBuildFile; productRef = 00F856AB2844A985008E2E2F /* FirebaseStorageCombine-Community */; }; + 374E059E285A18EC00215533 /* MyPartyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 374E059D285A18EC00215533 /* MyPartyViewModel.swift */; }; 37D4D1F12856D285002E787B /* ChatRoomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37D4D1F02856D285002E787B /* ChatRoomView.swift */; }; 37F698852855FB910008C022 /* MyPartyView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37F698842855FB910008C022 /* MyPartyView.swift */; }; 50459E2F28542E4E00287371 /* PhotoPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50459E2E28542E4E00287371 /* PhotoPicker.swift */; }; @@ -154,6 +155,7 @@ 00F6B72628596EEF00DACA06 /* PatyListCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PatyListCell.swift; sourceTree = ""; }; 00F6B72E2859C00E00DACA06 /* AddTaxiPartyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTaxiPartyViewModel.swift; sourceTree = ""; }; 00F6B7302859C44D00DACA06 /* ChattingRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChattingRepository.swift; sourceTree = ""; }; + 374E059D285A18EC00215533 /* MyPartyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPartyViewModel.swift; sourceTree = ""; }; 37D4D1F02856D285002E787B /* ChatRoomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRoomView.swift; sourceTree = ""; }; 37F698842855FB910008C022 /* MyPartyView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPartyView.swift; sourceTree = ""; }; 50459E2E28542E4E00287371 /* PhotoPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoPicker.swift; sourceTree = ""; }; @@ -420,6 +422,7 @@ 50F8003A28586F9200FA1063 /* Authentication.swift */, 00F6B72E2859C00E00DACA06 /* AddTaxiPartyViewModel.swift */, 000C24FA2859E74E0054D679 /* ChattingViewModel.swift */, + 374E059D285A18EC00215533 /* MyPartyViewModel.swift */, ); path = ViewModel; sourceTree = ""; @@ -610,6 +613,7 @@ 00BC47472858CAF80055CB6A /* AddTaxiPartyUseCase.swift in Sources */, 00F6B7312859C44D00DACA06 /* ChattingRepository.swift in Sources */, 000E545A285321250085C39E /* JoinTaxiPartyUseCase.swift in Sources */, + 374E059E285A18EC00215533 /* MyPartyViewModel.swift in Sources */, 00D3AE72284F8467001E34A0 /* TaxiPartyRepository.swift in Sources */, 50459E332854701C00287371 /* ImageExtension.swift in Sources */, 00E8F1BB284B21FE00D68DF0 /* Message.swift in Sources */, diff --git a/Taxi/Taxi/Presenter/ViewModel/MyPartyViewModel.swift b/Taxi/Taxi/Presenter/ViewModel/MyPartyViewModel.swift new file mode 100644 index 00000000..160b6c23 --- /dev/null +++ b/Taxi/Taxi/Presenter/ViewModel/MyPartyViewModel.swift @@ -0,0 +1,35 @@ +// +// MyPartyViewModel.swift +// Taxi +// +// Created by 이윤영 on 2022/06/15. +// + +import Foundation + + final class MyPartyViewModel: ObservableObject { + @Published private (set) var myPartyList: [TaxiParty] = [] + private let myPartyUseCase: MyTaxiPartyUseCase = MyTaxiPartyUseCase() + + func getMyParties(user: User) { + myPartyUseCase.getMyTaxiParty(user, force: true) { [weak self] taxiParties, error in + guard let self = self, let taxiParties = taxiParties else { + print(error ?? "") + return + } + print("Get MyParties, taxiParties: \(taxiParties)") + self.myPartyList = taxiParties + } + } + + func leaveMyParty(user: User, party: TaxiParty) { + myPartyUseCase.leaveTaxiParty(party, user: user) { [weak self] error in + guard let self = self else { + print(error ?? "") + return + } + print("Leave Party, user:\(user.id), party:\(party.id)") + self.getMyParties(user: user) + } + } + }