-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [WEAV-74] Drop Down View 생성 * [WEAV-74] 드롭다운, 회사 리스트 API 연결 * [WEAV-74] 없는 회사 선택 기능 구현 * [WEAV-74] 같은 회사 매칭 여부 선택 뷰 구현 * [WEAV-74] debug 전용 인증 건너뛰기 구현 * [WEAV-74] 회사 검색 뷰 로직 테스트코드 작성 * [CICD] Unit test Generate swift added. * [WEAV-74] 회사 리스트 드롭다운 페이지네이션
- Loading branch information
1 parent
fae7192
commit b39e340
Showing
18 changed files
with
931 additions
and
15 deletions.
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
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
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
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
19 changes: 19 additions & 0 deletions
19
Projects/Core/Model/Sources/Network/CompanySearchResponse.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,19 @@ | ||
// | ||
// CompanySearchResponse.swift | ||
// CommonKit | ||
// | ||
// Created by 김지수 on 10/9/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct CompanySearchResponse { | ||
public let id: String | ||
public let name: String | ||
|
||
public init(id: String, name: String) { | ||
self.id = id | ||
self.name = name | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
Projects/Core/NetworkKit/Sources/CompanyService/CompanyService.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 @@ | ||
// | ||
// CompanyService.swift | ||
// CommonKit | ||
// | ||
// Created by 김지수 on 10/9/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import OpenapiGenerated | ||
import Model | ||
|
||
//MARK: - Service Protocol | ||
public protocol CompanyServiceProtocol { | ||
func requestSearchCompany( | ||
keyword: String, | ||
next: String? | ||
) async throws -> ([CompanySearchResponse], String?) | ||
} | ||
|
||
//MARK: - Service | ||
public final class CompanyService { | ||
public static var shared = CompanyService() | ||
private init() {} | ||
} | ||
|
||
extension CompanyService: CompanyServiceProtocol { | ||
public func requestSearchCompany( | ||
keyword: String, | ||
next: String? = nil | ||
) async throws -> ([CompanySearchResponse], String?) { | ||
let response = try await client.searchCompanies( | ||
query: .init(name: keyword, next: next) | ||
).ok.body.json | ||
|
||
let result = response.companies.map { | ||
CompanySearchResponse( | ||
id: $0.id, | ||
name: $0.name | ||
) | ||
} | ||
let next = response.next | ||
return (result, next) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Projects/Core/NetworkKit/Sources/CompanyService/CompanyServiceMock.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,34 @@ | ||
// | ||
// CompanyServiceMock.swift | ||
// CommonKit | ||
// | ||
// Created by 김지수 on 10/10/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Model | ||
|
||
//MARK: - Service | ||
public final class CompanyServiceMock: CompanyServiceProtocol { | ||
|
||
public init() {} | ||
|
||
public func requestSearchCompany(keyword: String, next: String?) async throws -> ([Model.CompanySearchResponse], String?) { | ||
return ([ | ||
.init(id: "0", name: "현대글로비스"), | ||
.init(id: "1", name: "현대자동차"), | ||
.init(id: "2", name: "기아자동차"), | ||
.init(id: "3", name: "채널톡"), | ||
.init(id: "4", name: "닥터다이어리"), | ||
.init(id: "5", name: "컬쳐커넥션"), | ||
.init(id: "6", name: "엄청좋은회사"), | ||
.init(id: "7", name: "로지텍"), | ||
.init(id: "8", name: "스탠리"), | ||
.init(id: "9", name: "스타벅스"), | ||
.init(id: "10", name: "호날두주식회사"), | ||
.init(id: "11", name: "애플"), | ||
.init(id: "12", name: "엔비디아"), | ||
], nil) | ||
} | ||
} |
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
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
123 changes: 123 additions & 0 deletions
123
Projects/DesignSystem/DesignCore/Sources/DropDown/DropDownView.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,123 @@ | ||
// | ||
// DropDownView.swift | ||
// DesignCore | ||
// | ||
// Created by 김지수 on 10/9/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
public protocol DropDownFetchable: Hashable, Equatable { | ||
var id: String { get } | ||
var name: String { get } | ||
} | ||
|
||
public struct DropDownPicker<Content: View>: View { | ||
|
||
@FocusState var showDropDown: Bool | ||
|
||
var tapHandler: ((Int) -> Void)? | ||
var content: () -> Content | ||
|
||
var dataSources: [any DropDownFetchable] | ||
let itemSize: CGFloat = 56 | ||
|
||
var nextPageHandler: (() -> Void)? | ||
var needCallNextPage = false | ||
|
||
var frameHeight: CGFloat { | ||
if !showDropDown { | ||
return 0 | ||
} | ||
|
||
if dataSources.count > 3 { | ||
return itemSize * 3 + itemSize * 0.5 | ||
} | ||
|
||
return itemSize * CGFloat(dataSources.count) | ||
} | ||
|
||
var frameOffset: CGFloat { | ||
if !showDropDown { | ||
return 0 | ||
} | ||
|
||
if dataSources.count > 3 { | ||
return 140 | ||
} | ||
|
||
return 125 - 28 * CGFloat(3 - dataSources.count) | ||
} | ||
|
||
public init( | ||
dataSources: [any DropDownFetchable], | ||
showDropDown: FocusState<Bool>, | ||
needCallNextPage: Bool = false, | ||
@ViewBuilder content: @escaping () -> Content, | ||
tapHandler: ((Int) -> Void)? = nil, | ||
nextPageHandler: (() -> Void)? = nil | ||
) { | ||
self.dataSources = dataSources | ||
self.content = content | ||
self.tapHandler = tapHandler | ||
self._showDropDown = showDropDown | ||
self.nextPageHandler = nextPageHandler | ||
self.needCallNextPage = needCallNextPage | ||
} | ||
|
||
public var body: some View { | ||
VStack { | ||
ZStack { | ||
ZStack { | ||
RoundedRectangle(cornerRadius: 24) | ||
.foregroundStyle(.white) // | ||
ScrollView { | ||
LazyVStack(alignment: .leading, spacing: 0) { | ||
ForEach(0 ..< dataSources.count, id: \.self) { index in | ||
let item = dataSources[index] | ||
Button(action: { | ||
tapHandler?(index) | ||
withAnimation { | ||
showDropDown.toggle() | ||
} | ||
}, label: { | ||
HStack(spacing: 16) { | ||
Text(item.name) | ||
.typography(.regular_14) | ||
.multilineTextAlignment(.leading) | ||
Spacer() | ||
} | ||
.foregroundStyle(DesignCore.Colors.grey500) | ||
.frame(height: itemSize) | ||
.padding(.horizontal, 16) | ||
.background(.white) | ||
}) | ||
} | ||
} | ||
.frame(maxWidth: .infinity, alignment: .leading) | ||
if needCallNextPage { | ||
ProgressView() | ||
.padding(.bottom, 10) | ||
.onAppear { | ||
nextPageHandler?() | ||
} | ||
} | ||
} | ||
} | ||
.clipShape( | ||
RoundedRectangle(cornerRadius: 24) | ||
|
||
) | ||
.shadow(.default) | ||
.animation(.easeInOut(duration: 0.2), value: frameOffset) | ||
.frame(height: frameHeight) | ||
.offset(y: frameOffset) | ||
|
||
content() | ||
} | ||
.frame(height: 50) | ||
} | ||
.zIndex(999) | ||
} | ||
} |
Oops, something went wrong.