Skip to content
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

프로모션 눌렀을 때 UI 변경 / + 인코딩 이슈 해결 / DesignSystem의 primary 색상명 변경 #80

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Core/Sources/Network/NetworkProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public struct NetworkProvider: Networking {
case let .query(data):
var components = URLComponents(string: url.absoluteString)
components?.queryItems = data.toDictionary.map { URLQueryItem(name: $0, value: "\($1)") }
request.url = components?.url
request.url = URL(string: components?.url?.absoluteString.replacingOccurrences(of: "+", with: "%2B") ?? "")
}
} catch {
throw NetworkError.encodeError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,63 +17,68 @@ struct HomeProductDetailSelectionView<ViewModel>: View where ViewModel: HomeView

var body: some View {
HStack {
Button {
convenienceStoreModalPresented = true
} label: {
Group {
convenienceImageView()
.resizable()
.scaledToFit()
Image.chevronDown
.renderingMode(.template)
.foregroundStyle(.gray300)
.accessibilityHidden(true)
}
}
.accessibilityHint("더블 탭하여 편의점을 선택하세요")
.sheet(isPresented: $convenienceStoreModalPresented) {
ConvenienceSelectBottomSheetView<ViewModel>()
.presentationDetents([.height(Metrics.convenienceBottomSheetHeight)])
.presentationCornerRadius(20)
.presentationBackground(.regularMaterial)
}

convenienceStoreButton
Spacer()
promotionButton
}
.frame(height: Metrics.height)
}

Button {
promotionModalPresented = true
} label: {
HStack(spacing: Metrics.buttonSpacing) {
Text(verbatim: "All")
.font(.title2)
Image.arrowTriangleDownFill
.renderingMode(.template)
}
.frame(height: Metrics.textHeight)
.foregroundStyle(.gray400)
.padding(
.init(
top: Metrics.promotionButtonPaddingTop,
leading: Metrics.promotionButtonPaddingLeading,
bottom: Metrics.promotionButtonPaddingBottom,
trailing: Metrics.promotionButtonPaddingTrailing
)
)
}
.accessibilityHint("더블 탭하여 할인 조건을 선택하세요")
.overlay {
RoundedRectangle(cornerRadius: Metrics.promotionButtonCornerRadius)
.stroke()
.foregroundStyle(.gray400)
private var convenienceStoreButton: some View {
Button {
convenienceStoreModalPresented = true
} label: {
Group {
convenienceImageView()
.resizable()
.scaledToFit()
Image.chevronDown
.renderingMode(.template)
.foregroundStyle(.gray300)
.accessibilityHidden(true)
}
.sheet(isPresented: $promotionModalPresented) {
PromotionSelectBottomSheetView<ViewModel>()
.presentationDetents([.height(Metrics.promotionBottomSheetHeight)])
.presentationCornerRadius(20)
.presentationBackground(.regularMaterial)
}
.accessibilityHint("더블 탭하여 편의점을 선택하세요")
.sheet(isPresented: $convenienceStoreModalPresented) {
ConvenienceSelectBottomSheetView<ViewModel>()
.bottomSheetPresentation(height: Metrics.convenienceBottomSheetHeight)
}
}

private var promotionButton: some View {
Button {
promotionModalPresented = true
} label: {
HStack(spacing: Metrics.buttonSpacing) {
Text(verbatim: viewModel.state.productConfiguration.promotion.rawValue)
.font(.title2)
Image.arrowTriangleDownFill
.renderingMode(.template)
}
.frame(height: Metrics.textHeight)
.foregroundStyle(viewModel.state.productConfiguration.promotion == .allItems ? .gray400 : .white)
.padding(
.init(
top: Metrics.promotionButtonPaddingTop,
leading: Metrics.promotionButtonPaddingLeading,
bottom: Metrics.promotionButtonPaddingBottom,
trailing: Metrics.promotionButtonPaddingTrailing
)
)
}
.accessibilityHint("더블 탭하여 할인 조건을 선택하세요")
.background(
RoundedRectangle(cornerRadius: Metrics.promotionButtonCornerRadius)
.fill(viewModel.state.productConfiguration.promotion == .allItems ? .clear : .pyeonHaengPrimary)
)
.overlay {
RoundedRectangle(cornerRadius: Metrics.promotionButtonCornerRadius)
.stroke(viewModel.state.productConfiguration.promotion == .allItems ? .gray400 : .clear)
}
.sheet(isPresented: $promotionModalPresented) {
PromotionSelectBottomSheetView<ViewModel>()
.bottomSheetPresentation(height: Metrics.promotionBottomSheetHeight)
}
.frame(height: Metrics.height)
}

private func convenienceImageView() -> Image {
Expand All @@ -92,6 +97,14 @@ struct HomeProductDetailSelectionView<ViewModel>: View where ViewModel: HomeView
}
}

extension View {
func bottomSheetPresentation(height: CGFloat) -> some View {
presentationDetents([.height(height)])
.presentationCornerRadius(20)
.presentationBackground(.regularMaterial)
}
}

// MARK: - Metrics

private enum Metrics {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private extension HomeProductSorterView {
var string = AttributedString(localized: "총 \(viewModel.state.totalCount)개의 상품이 있어요!")

if let range = string.range(of: "\(viewModel.state.totalCount.formatted())") {
string[range].foregroundColor = .green500
string[range].foregroundColor = .pyeonHaengPrimary
}

return string
Expand All @@ -61,7 +61,7 @@ private extension HomeProductSorterView {
.gray200
case .ascending,
.descending:
.green500
.pyeonHaengPrimary
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ public extension ShapeStyle where Self == Color {

// Semantic Colors

static var primary: Color { .green500 }
static var pyeonHaengPrimary: Color { .green500 }
}