Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/suyeon'
Browse files Browse the repository at this point in the history
Conflicts:
	KkuMulKum.xcodeproj/project.pbxproj
	KkuMulKum/Source/Onboarding/Profile/ViewModel/ProfileSetupViewModel.swift
  • Loading branch information
hooni0918 committed Jul 18, 2024
2 parents 20a423d + 470d850 commit f9eaa39
Show file tree
Hide file tree
Showing 30 changed files with 545 additions and 287 deletions.
16 changes: 8 additions & 8 deletions KkuMulKum.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
785AE1D12C3B07A600677CA0 /* PrivacyInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 785AE1D02C3B07A600677CA0 /* PrivacyInfo.plist */; };
789196362C492F8600FF8CDF /* AuthTargetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 789196352C492F8600FF8CDF /* AuthTargetType.swift */; };
789196382C49697B00FF8CDF /* AuthError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 789196372C49697B00FF8CDF /* AuthError.swift */; };
789196342C486F6B00FF8CDF /* KeychainAccessible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 789196332C486F6B00FF8CDF /* KeychainAccessible.swift */; };
789873322C3D1A7B00435E96 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7898732F2C3D1A7B00435E96 /* LoginViewController.swift */; };
789873332C3D1A7B00435E96 /* LoginViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 789873302C3D1A7B00435E96 /* LoginViewModel.swift */; };
789873342C3D1A7B00435E96 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 789873312C3D1A7B00435E96 /* LoginView.swift */; };
Expand All @@ -66,7 +67,6 @@
78B928782C29402E006D9942 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 78B928762C29402E006D9942 /* LaunchScreen.storyboard */; };
78BD61202C43F557005752FD /* SwiftKeychainWrapper in Frameworks */ = {isa = PBXBuildFile; productRef = 78BD611F2C43F557005752FD /* SwiftKeychainWrapper */; };
78BD612B2C4550A6005752FD /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78BD612A2C4550A6005752FD /* Bundle.swift */; };
78BD612F2C4561B9005752FD /* KeychainAccessible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78BD612E2C4561B9005752FD /* KeychainAccessible.swift */; };
78BD61342C45B4A7005752FD /* AuthService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78BD61332C45B4A7005752FD /* AuthService.swift */; };
78BD61382C463C8C005752FD /* NicknameModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78BD61372C463C8C005752FD /* NicknameModel.swift */; };
A39F2B192C47BF83008DA5F5 /* SetReadyCompletedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A39F2B182C47BF83008DA5F5 /* SetReadyCompletedView.swift */; };
Expand Down Expand Up @@ -241,6 +241,7 @@
785AE1D02C3B07A600677CA0 /* PrivacyInfo.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = PrivacyInfo.plist; sourceTree = "<group>"; };
789196352C492F8600FF8CDF /* AuthTargetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthTargetType.swift; sourceTree = "<group>"; };
789196372C49697B00FF8CDF /* AuthError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthError.swift; sourceTree = "<group>"; };
789196332C486F6B00FF8CDF /* KeychainAccessible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainAccessible.swift; sourceTree = "<group>"; };
7898732F2C3D1A7B00435E96 /* LoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = "<group>"; };
789873302C3D1A7B00435E96 /* LoginViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginViewModel.swift; sourceTree = "<group>"; };
789873312C3D1A7B00435E96 /* LoginView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginView.swift; sourceTree = "<group>"; };
Expand All @@ -260,7 +261,6 @@
78B928772C29402E006D9942 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
78B928792C29402E006D9942 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
78BD612A2C4550A6005752FD /* Bundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Bundle.swift; sourceTree = "<group>"; };
78BD612E2C4561B9005752FD /* KeychainAccessible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainAccessible.swift; sourceTree = "<group>"; };
78BD61332C45B4A7005752FD /* AuthService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthService.swift; sourceTree = "<group>"; };
78BD61372C463C8C005752FD /* NicknameModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NicknameModel.swift; sourceTree = "<group>"; };
A39F2B182C47BF83008DA5F5 /* SetReadyCompletedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetReadyCompletedView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -568,19 +568,19 @@
78AED1322C3D9514000AD80A /* Nickname */ = {
isa = PBXGroup;
children = (
782B40802C3E48BD008B0CA7 /* ViewModel */,
78AED1382C3D98DB000AD80A /* ViewController */,
78AED1352C3D98C1000AD80A /* NicknameView */,
782B40802C3E48BD008B0CA7 /* ViewModel */,
78AED1352C3D98C1000AD80A /* View */,
);
path = Nickname;
sourceTree = "<group>";
};
78AED1352C3D98C1000AD80A /* NicknameView */ = {
78AED1352C3D98C1000AD80A /* View */ = {
isa = PBXGroup;
children = (
78AED1362C3D98D1000AD80A /* NicknameView.swift */,
);
path = NicknameView;
path = View;
sourceTree = "<group>";
};
78AED1382C3D98DB000AD80A /* ViewController */ = {
Expand Down Expand Up @@ -630,8 +630,8 @@
78BD612D2C456162005752FD /* KeyChain */ = {
isa = PBXGroup;
children = (
78BD612E2C4561B9005752FD /* KeychainAccessible.swift */,
789D73A62C46AF4900C7077D /* KeychainService.swift */,
789196332C486F6B00FF8CDF /* KeychainAccessible.swift */,
);
path = KeyChain;
sourceTree = "<group>";
Expand Down Expand Up @@ -1805,7 +1805,6 @@
DE6D4D0F2C3F14D80005584B /* MeetingInfoService.swift in Sources */,
DDE7D2C32C470A58005A921F /* ProfileTargetType.swift in Sources */,
DD3F9DCC2C485614008E1FF7 /* HomeServiceType.swift in Sources */,
78BD612F2C4561B9005752FD /* KeychainAccessible.swift in Sources */,
DD39768A2C41C2AD00E2A4C4 /* HomeViewController.swift in Sources */,
DED5DBF42C34539A006ECE7E /* BaseTableViewCell.swift in Sources */,
DDE7D2CA2C47EE81005A921F /* PromiseTargetType.swift in Sources */,
Expand Down Expand Up @@ -1855,6 +1854,7 @@
DE0137D32C43C5E50088C777 /* MyPageView.swift in Sources */,
DE558C592C45954B008DAC4A /* SelectMemberViewController.swift in Sources */,
DD4909962C440CDC003ED304 /* ArriveView.swift in Sources */,
789196342C486F6B00FF8CDF /* KeychainAccessible.swift in Sources */,
DD86266A2C4606A300E4F980 /* ReadyStatusService.swift in Sources */,
DE254AB02C31195B00A4015E /* NSAttributedString+.swift in Sources */,
DD43937B2C412F4500EC1799 /* CreateMeetingViewController.swift in Sources */,
Expand Down
4 changes: 4 additions & 0 deletions KkuMulKum/Network/DTO/Model/Utils/PlaceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import Foundation
/// 네이버 지역 검색 API (Response)
struct PlaceModel: ResponseModelType {
let places: [Place]

enum CodingKeys: String, CodingKey {
case places = "locations"
}
}

struct Place: Codable {
Expand Down
2 changes: 1 addition & 1 deletion KkuMulKum/Network/Service/HomeService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class HomeService {
self.provider = provider
}

func request<T: Decodable>(
func request<T: ResponseModelType>(
with request: HomeTargetType
) async throws -> ResponseBodyDTO<T>? {
return try await withCheckedThrowingContinuation { continuation in
Expand Down
2 changes: 1 addition & 1 deletion KkuMulKum/Network/Service/MeetingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class MeetingService {
self.provider = provider
}

func request<T: Decodable>(
func request<T: ResponseModelType>(
with request: MeetingTargetType
) async throws -> ResponseBodyDTO<T>? {
return try await withCheckedThrowingContinuation { continuation in
Expand Down
3 changes: 1 addition & 2 deletions KkuMulKum/Network/Service/PromiseService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class PromiseService {
self.provider = provider
}

func request<T: Decodable>(
func request<T: ResponseModelType>(
with request: PromiseTargetType
) async throws -> ResponseBodyDTO<T>? {
return try await withCheckedThrowingContinuation { continuation in
Expand All @@ -38,5 +38,4 @@ final class PromiseService {
}
}
}

}
2 changes: 1 addition & 1 deletion KkuMulKum/Network/Service/UtilService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class UtilService {
self.provider = provider
}

func request<T: Decodable>(
func request<T: ResponseModelType>(
with request: UtilTargetType
) async throws -> ResponseBodyDTO<T>? {
return try await withCheckedThrowingContinuation { continuation in
Expand Down
11 changes: 7 additions & 4 deletions KkuMulKum/Network/TargetType/UtilTargetType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import Moya

enum UtilTargetType {
case searchPlaceList(keyword: String)
case searchPlaceList(query: String)
}

extension UtilTargetType: TargetType {
Expand All @@ -25,8 +25,8 @@ extension UtilTargetType: TargetType {

var path: String {
switch self {
case .searchPlaceList(let keyword):
return "/api/v1/locations?q=\(keyword)"
case .searchPlaceList:
return "/api/v1/locations"
}
}

Expand All @@ -35,7 +35,10 @@ extension UtilTargetType: TargetType {
}

var task: Moya.Task {
.requestPlain
switch self {
case .searchPlaceList(let query):
return .requestParameters(parameters: ["q": query], encoding: URLEncoding.queryString)
}
}

var headers: [String : String]? {
Expand Down
2 changes: 0 additions & 2 deletions KkuMulKum/Resource/KeyChain/KeychainAccessible.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class DefaultKeychainAccessible: KeychainAccessible {
return keychain.set(value, forKey: key, withAccessibility: .afterFirstUnlockThisDeviceOnly)
}



func getExpiresIn(_ Key: String) -> Int? {
return keychain.integer(forKey: Key)
}
Expand Down
10 changes: 8 additions & 2 deletions KkuMulKum/Source/AddPromise/ServiceType/FindPlaceService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
import Foundation

protocol FindPlaceServiceType {
func fetchPlaceList(with input: String) -> ResponseBodyDTO<PlaceModel>
func fetchPlaceList(with input: String) async throws -> ResponseBodyDTO<PlaceModel>?
}

extension UtilService: FindPlaceServiceType {
func fetchPlaceList(with input: String) async throws-> ResponseBodyDTO<PlaceModel>? {
return try await request(with: .searchPlaceList(query: input))
}
}

final class MockFindPlaceService: FindPlaceServiceType {
func fetchPlaceList(with input: String) -> ResponseBodyDTO<PlaceModel> {
func fetchPlaceList(with input: String) async throws -> ResponseBodyDTO<PlaceModel>? {
let mockData: PlaceModel = PlaceModel(
places: [
Place(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
import Foundation

protocol SelectMemeberServiceType {
func fetchMeetingMemberList(with meetingID: Int) -> ResponseBodyDTO<MeetingMembersModel>
func fetchMeetingMemberList(
with meetingID: Int
) async throws -> ResponseBodyDTO<MeetingMembersModel>?
}

extension MeetingService: SelectMemeberServiceType {}

final class MockSelectMemberService: SelectMemeberServiceType {
func fetchMeetingMemberList(with meetingID: Int) -> ResponseBodyDTO<MeetingMembersModel> {
func fetchMeetingMemberList(
with meetingID: Int
) async throws -> ResponseBodyDTO<MeetingMembersModel>? {
let mockData = MeetingMembersModel(
memberCount: 14,
members: [
Expand Down
29 changes: 26 additions & 3 deletions KkuMulKum/Source/AddPromise/ServiceType/SelectPenaltyService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,37 @@ protocol SelectPenaltyServiceType {
func requestAddingNewPromise(
with requestModel: AddPromiseRequestModel,
meetingID: Int
) -> ResponseBodyDTO<AddPromiseResponseModel>
) async throws -> ResponseBodyDTO<AddPromiseResponseModel>?
}

extension PromiseService: SelectPenaltyServiceType {
func requestAddingNewPromise(
with requestModel: AddPromiseRequestModel,
meetingID: Int
) async throws -> ResponseBodyDTO<AddPromiseResponseModel>? {
return try await request(
with: .addPromise(
meetingID: meetingID,
request: requestModel
)
)
}
}

final class MockSelectPenaltyService: SelectPenaltyServiceType {
func requestAddingNewPromise(
with requestModel: AddPromiseRequestModel,
meetingID: Int
) -> ResponseBodyDTO<AddPromiseResponseModel> {
return ResponseBodyDTO<AddPromiseResponseModel>(success: true, data: nil, error: nil)
) async throws -> ResponseBodyDTO<AddPromiseResponseModel>? {
let mockData = AddPromiseResponseModel(
promiseID: 1,
placeName: "홍대입구",
address: "주소",
roadAddress: "도로명주소",
time: "",
dressUpLevel: "",
penalty: ""
)
return ResponseBodyDTO<AddPromiseResponseModel>(success: true, data: mockData, error: nil)
}
}
2 changes: 1 addition & 1 deletion KkuMulKum/Source/AddPromise/View/FindPlaceView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class FindPlaceView: BaseView {
}

extension FindPlaceView {
var placeTextFieldDidChange: Observable<String?> { placeTextField.rx.text.asObservable() }
var placeTextFieldDidChange: Observable<String> { placeTextField.rx.text.orEmpty.asObservable() }
var confirmButtonDidTap: Observable<Void> { confirmButton.rx.tap.asObservable() }

func configureTextField(flag: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ final class AddPromiseViewController: BaseViewController {
.subscribe(with: self) { owner, _ in
let viewController = FindPlaceViewController(
viewModel: FindPlaceViewModel(
service: MockFindPlaceService()
service: UtilService()
)
)
viewController.delegate = owner
Expand Down
33 changes: 22 additions & 11 deletions KkuMulKum/Source/AddPromise/ViewModel/FindPlaceViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class FindPlaceViewModel {

extension FindPlaceViewModel: ViewModelType {
struct Input {
let textFieldDidChange: Observable<String?>
let textFieldDidChange: Observable<String>
let textFieldEndEditing: PublishRelay<Void>
let cellIsSelected: PublishRelay<Place?>
let confirmButtonDidTap: Observable<Void>
Expand All @@ -43,17 +43,9 @@ extension FindPlaceViewModel: ViewModelType {

input.textFieldEndEditing
.withLatestFrom(input.textFieldDidChange)
.map { [weak self] text -> [Place] in
guard let text,
!text.isEmpty,
let responseBodyDTO = self?.service.fetchPlaceList(with: text),
let data = responseBodyDTO.data
else {
return []
}
return data.places
.subscribe(with: self) { owner, text in
owner.fetchPlaceList(with: text)
}
.bind(to: placeListRelay)
.disposed(by: disposeBag)

let placeList = placeListRelay
Expand Down Expand Up @@ -85,3 +77,22 @@ extension FindPlaceViewModel: ViewModelType {
return output
}
}

private extension FindPlaceViewModel {
func fetchPlaceList(with input: String) {
Task {
do {
guard let responseBody = try await self.service.fetchPlaceList(with: input),
responseBody.success,
let places = responseBody.data?.places
else {
placeListRelay.accept([])
return
}
placeListRelay.accept(places)
} catch {
print(">>> \(error.localizedDescription) : \(#function)")
}
}
}
}
28 changes: 21 additions & 7 deletions KkuMulKum/Source/AddPromise/ViewModel/SelectMemberViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,9 @@ extension SelectMemberViewModel: ViewModelType {

func transform(input: Input, disposeBag: DisposeBag) -> Output {
input.viewDidLoad
.map { [weak self] _ -> [Member] in
guard let self else { return [] }
let responseBodyDTO = service.fetchMeetingMemberList(with: meetingID)
guard let data = responseBodyDTO.data else { return [] }
return data.members
.subscribe(with: self) { owner, _ in
owner.fetchMeetingMembers()
}
.bind(to: memberListRelay)
.disposed(by: disposeBag)

input.memberSelected
Expand All @@ -69,7 +65,7 @@ extension SelectMemberViewModel: ViewModelType {
owner.selectedMemberListRelay.accept(selectedMembers)
}
.disposed(by: disposeBag)

input.memberDeselected
.subscribe(with: self) { owner, member in
var selectedMembers = owner.selectedMemberListRelay.value
Expand All @@ -91,3 +87,21 @@ extension SelectMemberViewModel: ViewModelType {
return output
}
}

private extension SelectMemberViewModel {
func fetchMeetingMembers() {
Task {
do {
guard let responseBody = try await service.fetchMeetingMemberList(with: meetingID),
responseBody.success
else {
memberListRelay.accept([])
return
}
memberListRelay.accept(responseBody.data?.members ?? [])
} catch {
print(">>> \(error.localizedDescription) : \(#function)")
}
}
}
}
Loading

0 comments on commit f9eaa39

Please sign in to comment.