diff --git a/Projects/App/Project.swift b/Projects/App/Project.swift index 7b34db7f..19a94bd5 100644 --- a/Projects/App/Project.swift +++ b/Projects/App/Project.swift @@ -26,7 +26,7 @@ let project = Project( infoPlist: .extendingDefault( with: [ "CFBundleDisplayName": "도담도담", - "CFBundleShortVersionString": "3.3.1", + "CFBundleShortVersionString": "3.3.4", "CFBundleVersion": "1", "UISupportedInterfaceOrientations": ["UIInterfaceOrientationPortrait"], "UIMainStoryboardFile": "", diff --git a/Projects/Data/DataSource/Source/Bus/BusDataSource.swift b/Projects/Data/DataSource/Source/Bus/BusDataSource.swift index 367c0a72..22c0884d 100644 --- a/Projects/Data/DataSource/Source/Bus/BusDataSource.swift +++ b/Projects/Data/DataSource/Source/Bus/BusDataSource.swift @@ -25,15 +25,7 @@ public struct BusDataSource: DataSourceProtocol { return response.data } - public func postApplyBus(id: Int) async throws { - _ = try await remote.postApplyBus(id: id) - } - - public func patchAppliedBus(id: Int) async throws { - _ = try await remote.patchAppliedBus(id: id) - } - - public func deleteAppliedBus(id: Int) async throws { - _ = try await remote.deleteAppliedBus(id: id) + public func applyBus(id: Int) async throws { + _ = try await remote.applyBus(id: id) } } diff --git a/Projects/Data/Network/Source/Remote/Bus/BusRemote.swift b/Projects/Data/Network/Source/Remote/Bus/BusRemote.swift index afb57efc..3dc6ed37 100644 --- a/Projects/Data/Network/Source/Remote/Bus/BusRemote.swift +++ b/Projects/Data/Network/Source/Remote/Bus/BusRemote.swift @@ -21,15 +21,7 @@ public struct BusRemote: RemoteProtocol { try await self.request(target: .fetchAppliedBus, res: BusResponse?.self) } - public func postApplyBus(id: Int) async throws -> DefaultResponse { - try await self.request(target: .postApplyBus(id: id)) - } - - public func patchAppliedBus(id: Int) async throws -> DefaultResponse { - try await self.request(target: .patchAppliedBus(id: id)) - } - - public func deleteAppliedBus(id: Int) async throws -> DefaultResponse { - try await self.request(target: .deleteAppliedBus(id: id)) + public func applyBus(id: Int) async throws -> DefaultResponse { + try await self.request(target: .applyBus(id: id)) } } diff --git a/Projects/Data/Network/Source/Service/Bus/BusService.swift b/Projects/Data/Network/Source/Service/Bus/BusService.swift index 38f982d9..8b00ff7a 100644 --- a/Projects/Data/Network/Source/Service/Bus/BusService.swift +++ b/Projects/Data/Network/Source/Service/Bus/BusService.swift @@ -11,9 +11,7 @@ enum BusService: ServiceProtocol { case fetchAllBus case fetchAppliedBus - case postApplyBus(id: Int) - case patchAppliedBus(id: Int) - case deleteAppliedBus(id: Int) + case applyBus(id: Int) } extension BusService { @@ -26,9 +24,7 @@ extension BusService { switch self { case .fetchAllBus: "" case .fetchAppliedBus: "/apply" - case let .postApplyBus(id): "/apply/\(id)" - case let .patchAppliedBus(id): "/apply/\(id)" - case let .deleteAppliedBus(id): "/apply/\(id)" + case let .applyBus(id): "/apply/status/\(id)" } } @@ -36,9 +32,7 @@ extension BusService { switch self { case .fetchAllBus: .get case .fetchAppliedBus: .get - case .postApplyBus: .post - case .patchAppliedBus: .patch - case .deleteAppliedBus: .delete + case .applyBus: .patch } } @@ -48,11 +42,7 @@ extension BusService { .requestPlain case .fetchAppliedBus: .requestPlain - case .postApplyBus: - .requestPlain - case .patchAppliedBus: - .requestPlain - case .deleteAppliedBus: + case .applyBus: .requestPlain } } diff --git a/Projects/Data/Repository/Source/Bus/BusRepositoryImpl.swift b/Projects/Data/Repository/Source/Bus/BusRepositoryImpl.swift index bc92292c..35e56f22 100644 --- a/Projects/Data/Repository/Source/Bus/BusRepositoryImpl.swift +++ b/Projects/Data/Repository/Source/Bus/BusRepositoryImpl.swift @@ -24,15 +24,7 @@ public struct BusRepositoryImpl: BusRepository { try await dataSource.fetchAppliedBus() } - public func postApplyBus(id: Int) async throws { - try await dataSource.postApplyBus(id: id) - } - - public func patchAppliedBus(id: Int) async throws { - try await dataSource.patchAppliedBus(id: id) - } - - public func deleteAppliedBus(id: Int) async throws { - try await dataSource.deleteAppliedBus(id: id) + public func applyBus(id: Int) async throws { + try await dataSource.applyBus(id: id) } } diff --git a/Projects/Domain/Source/Repository/Bus/BusRepository.swift b/Projects/Domain/Source/Repository/Bus/BusRepository.swift index 09b5f7a7..6e3fa339 100644 --- a/Projects/Domain/Source/Repository/Bus/BusRepository.swift +++ b/Projects/Domain/Source/Repository/Bus/BusRepository.swift @@ -11,9 +11,5 @@ public protocol BusRepository: RepositoryProtocol { func fetchAppliedBus() async throws -> BusResponse? - func postApplyBus(id: Int) async throws - - func patchAppliedBus(id: Int) async throws - - func deleteAppliedBus(id: Int) async throws + func applyBus(id: Int) async throws } diff --git a/Projects/Feature/Source/Bus/Apply/BusApplyView.swift b/Projects/Feature/Source/Bus/Apply/BusApplyView.swift index b5ee1aec..955633bf 100644 --- a/Projects/Feature/Source/Bus/Apply/BusApplyView.swift +++ b/Projects/Feature/Source/Bus/Apply/BusApplyView.swift @@ -24,11 +24,9 @@ struct BusApplyView: View { id: \.self ) { bus in Button { - guard viewModel.selectedBus?.id ?? 0 != bus.id else { + if viewModel.selectedBus?.id == bus.id { viewModel.selectedBus = nil - return - } - withAnimation(.spring(duration: 0.25)) { + } else { viewModel.selectedBus = bus } } label: { @@ -52,8 +50,9 @@ struct BusApplyView: View { .padding([.bottom, .horizontal], 16) } .task { - await viewModel.fetchBuses() - await viewModel.fetchAppledBus() + async let fetchBuses: () = viewModel.fetchBuses() + async let fetchAppledBus: () = viewModel.fetchAppledBus() + _ = await [fetchBuses, fetchAppledBus] } .onChange(of: viewModel.showNotFoundBus) { if $0 { @@ -66,7 +65,9 @@ struct BusApplyView: View { } .onChange(of: viewModel.dialogMessage) { let dialog = Dialog(title: $0) - .primaryButton("확인") + .primaryButton("확인") { + flow.pop() + } self.dialog.present(dialog) } } diff --git a/Projects/Feature/Source/Bus/Apply/BusApplyViewModel.swift b/Projects/Feature/Source/Bus/Apply/BusApplyViewModel.swift index bffd694d..f88f6f95 100644 --- a/Projects/Feature/Source/Bus/Apply/BusApplyViewModel.swift +++ b/Projects/Feature/Source/Bus/Apply/BusApplyViewModel.swift @@ -30,7 +30,7 @@ class BusApplyViewModel: ObservableObject { showNotFoundBus = true } } catch { - print("\(#function)") + print(#function) print(error) } } @@ -41,72 +41,35 @@ class BusApplyViewModel: ObservableObject { appliedBus = try await busRepository.fetchAppliedBus() self.selectedBus = appliedBus } catch { - print("\(#function)") + print(#function) print(error) } } @MainActor func completeBus() async { - print("\(#function)") - defer { - Task { - await fetchBuses() - await fetchAppledBus() - } - } - guard let selectedBus else { - await deleteBus(id: appliedBus?.id ?? 0) - return - } - guard let appliedBus else { - await postBus(id: selectedBus.id) - return - } - guard selectedBus != appliedBus else { - await deleteBus(id: selectedBus.id) - return - } - guard selectedBus.applyCount < selectedBus.peopleLimit else { - dialogMessage = "버스가 만석이에요" - return + print(#function) + + if let selectedBus { + await self.applyBus(id: selectedBus.id) + } else if let appliedBus { + await self.applyBus(id: appliedBus.id) } - await patchBus(id: selectedBus.id) + + dialogMessage = "버스 신청에 성공했어요" + + async let fetchBuses: () = fetchBuses() + async let fetchAppledBus: () = fetchAppledBus() + _ = await [fetchBuses, fetchAppledBus] } @MainActor - private func postBus(id: Int) async { + private func applyBus(id: Int) async { do { - try await busRepository.postApplyBus(id: id) - self.appliedBus = selectedBus - dialogMessage = "버스 신청에 성공했어요" + try await busRepository.applyBus(id: id) } catch { dialogMessage = "버스 신청에 실패했어요" print(error) } } - - @MainActor - private func deleteBus(id: Int) async { - do { - try await busRepository.deleteAppliedBus(id: id) - self.appliedBus = nil - dialogMessage = "버스 삭제에 성공했어요" - } catch { - dialogMessage = "버스 삭제에 실패했어요" - print(error) - } - } - - @MainActor - private func patchBus(id: Int) async { - do { - try await busRepository.patchAppliedBus(id: id) - dialogMessage = "버스 변경에 성공했어요" - self.appliedBus = selectedBus - } catch { - dialogMessage = "버스 변경에 실패했어요" - print(error) - } - } } diff --git a/Projects/Feature/Source/Bus/Apply/Component/BusApplyCell.swift b/Projects/Feature/Source/Bus/Apply/Component/BusApplyCell.swift index f8e3b494..d7bc698e 100644 --- a/Projects/Feature/Source/Bus/Apply/Component/BusApplyCell.swift +++ b/Projects/Feature/Source/Bus/Apply/Component/BusApplyCell.swift @@ -29,11 +29,12 @@ struct BusApplyCell: View { if bus.id == selectedBus?.id ?? 0 { Image(icon: .checkmark) .resizable() - .frame(width: 32, height: 32) + .frame(width: 20, height: 20) .foreground(DodamColor.Primary.normal) } } .frame(height: 40) .padding(.horizontal, 8) + .animation(.spring(duration: 0.2), value: selectedBus) } } diff --git a/Projects/Feature/Source/Notice/Component/CategoryButton.swift b/Projects/Feature/Source/Notice/Component/CategoryButton.swift index f77b8aca..213a99e1 100644 --- a/Projects/Feature/Source/Notice/Component/CategoryButton.swift +++ b/Projects/Feature/Source/Notice/Component/CategoryButton.swift @@ -37,7 +37,7 @@ struct CategoryButton: View { .foreground(isSelected ? DodamColor.Static.white : DodamColor.Label.alternative) .background(isSelected ? DodamColor.Primary.normal : DodamColor.Background.normal) .cornerRadius(30) - .overlay{ + .overlay { if !isSelected { RoundedRectangle(cornerRadius: 30) .dodamStroke(DodamColor.Line.alternative, lineWidth: 1) diff --git a/Projects/Feature/Source/Out/OutApply/OutApplyView.swift b/Projects/Feature/Source/Out/OutApply/OutApplyView.swift index 2aac8d4d..4f2b9fa4 100644 --- a/Projects/Feature/Source/Out/OutApply/OutApplyView.swift +++ b/Projects/Feature/Source/Out/OutApply/OutApplyView.swift @@ -173,8 +173,5 @@ struct OutApplyView: View { .padding(.bottom, 8) .padding(.horizontal, 16) } - .task { - await viewModel.onAppear() - } } } diff --git a/Projects/Feature/Source/Out/OutApply/OutApplyViewModel.swift b/Projects/Feature/Source/Out/OutApply/OutApplyViewModel.swift index a708e947..dbeb4f45 100644 --- a/Projects/Feature/Source/Out/OutApply/OutApplyViewModel.swift +++ b/Projects/Feature/Source/Out/OutApply/OutApplyViewModel.swift @@ -15,20 +15,24 @@ class OutApplyViewModel: ObservableObject { // MARK: - State @Published var reasonText: String = "" @Published var dateAt: Date = Date() - @Published var startAt: Date = Date() - @Published var endAt: Date = Date() + @Published var startAt: Date = { + var components = DateComponents() + components.hour = 15 + components.minute = 50 + return Calendar.current.date(from: components)! + }() + @Published var endAt: Date = { + var components = DateComponents() + components.hour = 18 + components.minute = 20 + return Calendar.current.date(from: components)! + }() // MARK: - Repository @Inject var outGoingRepository: any OutGoingRepository @Inject var outSleepingRepository: any OutSleepingRepository // MARK: - Method - @MainActor - func onAppear() async { - startAt = Date() - endAt = startAt - } - @MainActor func postOutGoing(dinnerOrNot: Bool) async { do { diff --git a/Tuist/Package.resolved b/Tuist/Package.resolved index 5af71a69..f88fb8e9 100644 --- a/Tuist/Package.resolved +++ b/Tuist/Package.resolved @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Team-B1ND/dds-ios", "state" : { - "revision" : "a81902aa7680f1ed2392bee0999f588d3d1d4a8b", - "version" : "0.2.22" + "revision" : "fd07c7763938d95d03228d1ccb6a7cfc4cbe7c66", + "version" : "0.2.27" } }, { diff --git a/Tuist/Package.swift b/Tuist/Package.swift index e5603f80..8c606001 100644 --- a/Tuist/Package.swift +++ b/Tuist/Package.swift @@ -24,7 +24,7 @@ import PackageDescription let package = Package( name: "PackageName", dependencies: [ - .package(url: "https://github.com/Team-B1ND/dds-ios", exact: "0.2.22"), + .package(url: "https://github.com/Team-B1ND/dds-ios", exact: "0.2.27"), .package(url: "https://github.com/Moya/Moya", from: "15.0.0"), .package(url: "https://github.com/Swinject/Swinject.git", from: "2.8.0"), .package(url: "https://github.com/Mercen-Lee/FlowKit", branch: "main"),