-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/#172 검색로직 수정 #177
Merged
+741
−228
Merged
Feat/#172 검색로직 수정 #177
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7bc8559
feat: #172 검색 API 불러오기 로직 추가
hooni0918 93d6fef
feat: #172 카메라 시점 고정
hooni0918 2a0a6c8
feat: #172 카메라 시점 고정
hooni0918 00680d7
feat: #172 마커 되돌리기 수정
hooni0918 173a39d
feat: #172 바텀시트 분리
hooni0918 3f57ab4
feat: #172 API까지는 불러옴
hooni0918 3e60757
feat: #172 actor 분기시 짝수번째에만 호출
hooni0918 913844d
feat: #172 로직 완성
hooni0918 18d49a4
feat: 검색 바텀시트 연결
hooni0918 15910c5
feat: label 수정
hooni0918 1dd96e1
feat: #172 로직 재수정
hooni0918 b65889f
feat: #172 unknown 키워드 삭제
hooni0918 3eb5e2f
feat: #172 coordinateSpace 삭제
hooni0918 eb6ff6b
fix: #172 코리반영
hooni0918 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
Spoony-iOS/Spoony-iOS/Network/Model/SearchLocationResponse.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// SearchLocationResponse.swift | ||
// Spoony-iOS | ||
// | ||
// Created by 이지훈 on 1/30/25. | ||
// | ||
|
||
import Foundation | ||
|
||
struct SearchLocationResponse: Codable { | ||
let success: Bool | ||
let data: SearchLocationData? | ||
let error: String? | ||
} | ||
|
||
struct SearchLocationData: Codable { | ||
let zzimCardResponses: [SearchLocationResult] | ||
} | ||
|
||
struct SearchLocationResult: Codable, Identifiable { | ||
var id = UUID() | ||
let locationId: Int | ||
let placeId: Int? | ||
let title: String | ||
let address: String | ||
let postTitle: String? | ||
let photoUrl: String? | ||
let latitude: Double? | ||
let longitude: Double? | ||
let categoryColorResponse: SearchCategoryColorResponse? | ||
} | ||
|
||
struct SearchCategoryColorResponse: Codable { | ||
let categoryId: Int | ||
let categoryName: String | ||
let iconUrl: String | ||
let iconTextColor: String | ||
let iconBackgroundColor: String | ||
} | ||
|
||
extension SearchLocationResponse { | ||
func toEntity() -> [SearchLocationResult] { | ||
return data?.zzimCardResponses ?? [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// SearchResult.swift | ||
// Spoony-iOS | ||
// | ||
// Created by 이지훈 on 1/16/25. | ||
// | ||
|
||
import Foundation | ||
|
||
struct SearchResult: Identifiable, Equatable { | ||
let id = UUID() | ||
let title: String | ||
let locationId: Int | ||
let address: String | ||
} | ||
|
||
extension PickListCardResponse { | ||
func toSearchLocationResult() -> SearchLocationResult { | ||
return SearchLocationResult( | ||
locationId: self.placeId, | ||
placeId: self.placeId, | ||
title: self.placeName, | ||
address: self.placeAddress, | ||
postTitle: self.postTitle, | ||
photoUrl: self.photoUrl, | ||
latitude: self.latitude, | ||
longitude: self.longitude, | ||
categoryColorResponse: self.categoryColorResponse.toSearchCategoryColorResponse() | ||
) | ||
} | ||
} | ||
|
||
extension BottomSheetCategoryColorResponse { | ||
func toSearchCategoryColorResponse() -> SearchCategoryColorResponse { | ||
return SearchCategoryColorResponse( | ||
categoryId: self.categoryId, | ||
categoryName: self.categoryName, | ||
iconUrl: self.iconUrl, | ||
iconTextColor: self.iconTextColor, | ||
iconBackgroundColor: self.iconBackgroundColor | ||
) | ||
} | ||
} | ||
|
||
extension SearchLocationResult { | ||
func toPickListCardResponse() -> PickListCardResponse { | ||
return PickListCardResponse( | ||
placeId: self.placeId ?? 0, | ||
placeName: self.title, | ||
placeAddress: self.address, | ||
postTitle: self.postTitle ?? "", | ||
photoUrl: self.photoUrl ?? "", | ||
latitude: self.latitude ?? 0.0, | ||
longitude: self.longitude ?? 0.0, | ||
categoryColorResponse: self.categoryColorResponse?.toBottomSheetCategoryColorResponse() ?? | ||
BottomSheetCategoryColorResponse(categoryId: 0, categoryName: "", iconUrl: "", iconTextColor: "", iconBackgroundColor: "") | ||
) | ||
} | ||
} | ||
|
||
extension SearchCategoryColorResponse { | ||
func toBottomSheetCategoryColorResponse() -> BottomSheetCategoryColorResponse { | ||
return BottomSheetCategoryColorResponse( | ||
categoryId: self.categoryId, | ||
categoryName: self.categoryName, | ||
iconUrl: self.iconUrl, | ||
iconTextColor: self.iconTextColor, | ||
iconBackgroundColor: self.iconBackgroundColor | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ protocol HomeServiceType { | |
func fetchPickList(userId: Int) async throws -> ResturantpickListResponse | ||
func fetchSpoonCount(userId: Int) async throws -> Int | ||
func fetchFocusedPlace(userId: Int, placeId: Int) async throws -> MapFocusResponse | ||
func fetchLocationList(userId: Int, locationId: Int) async throws -> ResturantpickListResponse | ||
} | ||
|
||
final class DefaultHomeService: HomeServiceType { | ||
|
@@ -83,4 +84,25 @@ final class DefaultHomeService: HomeServiceType { | |
} | ||
} | ||
} | ||
|
||
func fetchLocationList(userId: Int, locationId: Int) async throws -> ResturantpickListResponse { | ||
return try await withCheckedThrowingContinuation { continuation in | ||
provider.request(.getLocationList(userId: userId, locationId: locationId)) { result in | ||
switch result { | ||
case .success(let response): | ||
do { | ||
let responseDto = try response.map(BaseResponse<ResturantpickListResponse>.self) | ||
guard let data = responseDto.data else { | ||
throw NSError(domain: "HomeService", code: -1, userInfo: [NSLocalizedDescriptionKey: "No data available"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이건 무슨 에러 인가요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fetchLocation 에 대한 기본 에러타입 지정을 안해서 기본 NSError로 전부 빼놓았습니다 (fatalerror같은종류,,) |
||
} | ||
continuation.resume(returning: data) | ||
} catch { | ||
continuation.resume(throwing: error) | ||
} | ||
case .failure(let error): | ||
continuation.resume(throwing: error) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
Spoony-iOS/Spoony-iOS/Resource/Components/BottomSheet/Plain/BottomSheetItem.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// | ||
// BottomSheetItem.swift | ||
// Spoony-iOS | ||
// | ||
// Created by 이지훈 on 1/30/25. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct BottomSheetListItem: View { | ||
let pickCard: PickListCardResponse | ||
|
||
var body: some View { | ||
HStack(spacing: 12) { | ||
VStack(alignment: .leading, spacing: 8) { | ||
HStack(spacing: 8) { | ||
Text(pickCard.placeName) | ||
.customFont(.body1b) | ||
.lineLimit(1) | ||
.truncationMode(.tail) | ||
|
||
// 카테고리 칩 | ||
HStack(spacing: 4) { | ||
// 카테고리 아이콘 | ||
AsyncImage(url: URL(string: pickCard.categoryColorResponse.iconUrl)) { phase in | ||
switch phase { | ||
case .success(let image): | ||
image | ||
.resizable() | ||
.scaledToFit() | ||
.frame(width: 16.adjusted, height: 16.adjustedH) | ||
default: | ||
Color.clear | ||
.frame(width: 16.adjusted, height: 16.adjustedH) | ||
} | ||
} | ||
|
||
Text(pickCard.categoryColorResponse.categoryName) | ||
.customFont(.caption1m) | ||
.lineLimit(1) | ||
} | ||
.padding(.horizontal, 8) | ||
.padding(.vertical, 4) | ||
.background(Color(hex: pickCard.categoryColorResponse.iconBackgroundColor)) | ||
.foregroundColor(Color(hex: pickCard.categoryColorResponse.iconTextColor)) | ||
.cornerRadius(12) | ||
} | ||
|
||
Text(pickCard.placeAddress) | ||
.customFont(.caption1m) | ||
.foregroundColor(.gray600) | ||
.lineLimit(1) | ||
.truncationMode(.tail) | ||
|
||
Text(pickCard.postTitle) | ||
.customFont(.caption1m) | ||
.foregroundColor(.spoonBlack) | ||
.lineLimit(1) | ||
.truncationMode(.tail) | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
.padding(12) | ||
.background(.white) | ||
.cornerRadius(8) | ||
.overlay( | ||
RoundedRectangle(cornerRadius: 8) | ||
.stroke(Color(.gray0), lineWidth: 1) | ||
) | ||
.shadow( | ||
color: Color(.gray0), | ||
radius: 16, | ||
x: 0, | ||
y: 2 | ||
) | ||
} | ||
// 이미지 | ||
AsyncImage(url: URL(string: pickCard.photoUrl)) { phase in | ||
switch phase { | ||
case .success(let image): | ||
image | ||
.resizable() | ||
.scaledToFill() | ||
case .failure: | ||
defaultPlaceholder | ||
case .empty: | ||
defaultPlaceholder | ||
default: | ||
defaultPlaceholder | ||
} | ||
} | ||
.frame(width: 98.adjusted, height: 98.adjusted) | ||
.clipShape(RoundedRectangle(cornerRadius: 8)) | ||
.layoutPriority(0) | ||
} | ||
.padding(.horizontal, 16) | ||
.frame(height: 120.adjusted) | ||
} | ||
|
||
private var defaultPlaceholder: some View { | ||
RoundedRectangle(cornerRadius: 8) | ||
.fill(Color.gray.opacity(0.1)) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
placeId가 고유한 값이 아닌가요?
고유한 값이라면 나머지 값들도 비교하는 이유가 있을까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
지금은 수정이 되었는데 해당 코드 작성시에 해당 placeID 와 식당 정보들이 매핑이 이상하게 내려오고 있었습니다.
현재는 수정되어있으니 placeID가 유일한 코드가 맞아요!