Skip to content

Commit

Permalink
refactor: 컴포넌트 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
lina0322 committed Jun 29, 2024
1 parent c04962a commit 86d2701
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 25 deletions.
16 changes: 10 additions & 6 deletions Projects/Features/Search/Sources/View/FakeSearchBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ struct FakeSearchBar: View {
}

var body: some View {
fakeTextField
.frame(maxWidth: .infinity)
.frame(height: 44)
.background(Color.Background.assistive)
.clipShape(RoundedRectangle(cornerRadius: 10))
.padding(.horizontal, 20)
.padding(.vertical, 16)
}

private var fakeTextField: some View {
HStack(spacing: 12) {
ResourceKitAsset.Icon.search.swiftUIImage

Expand All @@ -26,11 +36,5 @@ struct FakeSearchBar: View {
Spacer()
}
.padding(.horizontal, 16)
.frame(maxWidth: .infinity)
.frame(height: 44)
.background(Color.Background.assistive)
.clipShape(RoundedRectangle(cornerRadius: 10))
.padding(.horizontal, 20)
.padding(.vertical, 16)
}
}
34 changes: 21 additions & 13 deletions Projects/Features/Search/Sources/View/HotKeywordImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,11 @@ struct HotKeywordImageView: View, HorizontalMimItemViewProtocol {

var body: some View {
ZStack {
KFImage(URL(string: hotKeyword.imageUrlString))
.resizable()
.loadDiskFileSynchronously()
.cacheMemoryOnly()
.frame(width: 90, height: 90)
.aspectRatio(contentMode: .fit)
imageView

Color.black.opacity(0.4)

Text(hotKeyword.title)
.font(Font.Body.Large.semiBold)
.foregroundColor(Color.Text.inverse)
.lineLimit(2)
.multilineTextAlignment(.center)
.padding(.horizontal, 16)
.frame(width: 90, height: 90)
keywordView
}
.overlay(
RoundedRectangle(cornerRadius: 10)
Expand All @@ -46,4 +35,23 @@ struct HotKeywordImageView: View, HorizontalMimItemViewProtocol {
)
.clipShape(RoundedRectangle(cornerRadius: 10))
}

private var imageView: some View {
KFImage(URL(string: hotKeyword.imageUrlString))
.resizable()
.loadDiskFileSynchronously()
.cacheMemoryOnly()
.frame(width: 90, height: 90)
.aspectRatio(contentMode: .fit)
}

private var keywordView: some View {
Text(hotKeyword.title)
.font(Font.Body.Large.semiBold)
.foregroundColor(Color.Text.inverse)
.lineLimit(2)
.multilineTextAlignment(.center)
.padding(.horizontal, 16)
.frame(width: 90, height: 90)
}
}
16 changes: 10 additions & 6 deletions Projects/Features/Search/Sources/View/SearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ public struct SearchView: View {

public var body: some View {
VStack(spacing: 0) {
Button {
isPresenting = true
} label: {
FakeSearchBar(placeHolder: "🚧 검색은 오픈 준비 중!")
}
.buttonStyle(PlainButtonStyle())
fakeSearchBar

ScrollView {
VStack(spacing: 0) {
Expand All @@ -47,6 +42,15 @@ public struct SearchView: View {
)
}

private var fakeSearchBar: some View {
Button {
isPresenting = true
} label: {
FakeSearchBar(placeHolder: "🚧 검색은 오픈 준비 중!")
}
.buttonStyle(PlainButtonStyle())
}

private var currentHotKeywords: some View {
VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 8) {
Expand Down

0 comments on commit 86d2701

Please sign in to comment.