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

ProductInfo ๋ฐ์ดํ„ฐ๐Ÿ”„๋ทฐ ๋ฐ”์ธ๋”ฉ #53

Merged
merged 13 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit Hold shift + click to select a range
5cfa4df
๐Ÿ—๏ธ ProductInfoDetailView UI ์ฝ”๋“œ ๊ด€๋ จ ๊ตฌ์กฐํ™”
eung7 Feb 24, 2024
7623a05
๐Ÿ—๏ธ ProductInfoLineGraphView UI ์ฝ”๋“œ ๊ด€๋ จ ๊ตฌ์กฐํ™”
eung7 Feb 24, 2024
c97f09e
โœจ ProductInfoDetailView ํŽธ์˜์  ๋กœ๊ณ  Image ๋ฐ์ดํ„ฐ ๋ฐ”์ธ๋”ฉ
eung7 Feb 24, 2024
5ad2e54
๐Ÿ—๏ธ ProductInfoLineGraphView UI ์ฝ”๋“œ ๊ด€๋ จ ๊ตฌ์กฐํ™”
eung7 Feb 24, 2024
63e56fb
๐ŸŒฑ DetailProduct๋กœ ๋„ค์ด๋ฐ ๋ณ€๊ฒฝ ๋ฐ ViewModel ์ œ๋„ค๋ฆญ ์ถ”๊ฐ€
eung7 Feb 24, 2024
11a6f66
๐Ÿ’„ ProductInfoLineGraph ๋Œ€ํญ ์ˆ˜์ •
eung7 Feb 24, 2024
ca7a76f
Merge branch 'main' into feature/productinfo/48
WhiteHyun Feb 25, 2024
ff9704b
Merge branch 'main' into feature/productinfo/48
eung7 Feb 26, 2024
b2e67c0
๐ŸŒฑ Json ๋‚ ์งœ ํƒ€์ž… ๋ณ€๊ฒฝ ๋ฐ ๊ด€๋ จ๋œ ์ฝ”๋“œ ์ˆ˜์ •
eung7 Feb 26, 2024
72da250
Merge branch 'feature/productinfo/48' of https://github.com/PyeonHaenโ€ฆ
eung7 Feb 26, 2024
fd5efa8
๐ŸŽจ `updateSymbolLocations`๋กœ ๋„ค์ด๋ฐ ๋ณ€๊ฒฝ
eung7 Feb 26, 2024
64ffacb
๐ŸŽจ `updateSymbolLocations`๋กœ ๋„ค์ด๋ฐ ๋ณ€๊ฒฝ
eung7 Feb 26, 2024
1226b36
๐Ÿ”ฅ LineGraphPanelView ๋ถˆํ•„์š”ํ•œ ์ฝ”๋“œ ์‚ญ์ œ
eung7 Feb 26, 2024
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
17 changes: 9 additions & 8 deletions APIService/Sources/ProductInfoAPI/ProductInfoService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import Network
// MARK: - ProductInfoServiceRepresentable

public protocol ProductInfoServiceRepresentable {
func fetchProduct() async throws -> ProductDetail
func fetchProductPrice() async throws -> [ProductDetail]
func fetchProduct() async throws -> DetailProduct
func fetchProductPrice() async throws -> [DetailProduct]
}

// MARK: - ProductInfoService
Expand All @@ -31,30 +31,31 @@ public struct ProductInfoService {
// MARK: ProductInfoServiceRepresentable

extension ProductInfoService: ProductInfoServiceRepresentable {
public func fetchProduct() async throws -> ProductDetail {
public func fetchProduct() async throws -> DetailProduct {
let response: ProductDetailResponse = try await network.request(
with: ProductInfoEndPoint.fetchProduct(productID)
)
return ProductDetail(dto: response)
return DetailProduct(dto: response)
}

public func fetchProductPrice() async throws -> [ProductDetail] {
public func fetchProductPrice() async throws -> [DetailProduct] {
let response: [ProductDetailResponse] = try await network.request(
with: ProductInfoEndPoint.fetchPrices(productID)
)
return response.map(ProductDetail.init(dto:))
return response.map(DetailProduct.init(dto:))
}
}

private extension ProductDetail {
private extension DetailProduct {
init(dto: ProductDetailResponse) {
self.init(
id: dto.id,
imageURL: dto.img,
price: dto.price,
name: dto.name,
promotion: dto.tag,
convenienceStore: dto.store
convenienceStore: dto.store,
date: dto.date
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ struct ProductDetailResponse: Decodable {
let store: ConvenienceStore
let tag: Promotion
let proinfo: Int
let date: String
let id: Int
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"name": "ํž›๋”ํ‹ฐ)์Šˆํผ๋ง์ฐจ์ดˆ์ฝ”์ฝ˜150ML",
"img": "https://image.woodongs.com/imgsvr/item/GD_8809490180818_002.jpg",
"price": 2500,
"price": 2400,
"store": "GS25",
"tag": "2+1",
"proinfo": 0,
Expand All @@ -12,7 +12,7 @@
{
"name": "ํž›๋”ํ‹ฐ)์Šˆํผ๋ง์ฐจ์ดˆ์ฝ”์ฝ˜150ML",
"img": "http://gs25appimg.gsretail.com/imgsvr/item/GD_8809490180818_001.jpg",
"price": 2500,
"price": 2100,
"store": "GS25",
"tag": "2+1",
"proinfo": 0,
Expand All @@ -32,7 +32,7 @@
{
"name": "ํž›๋”ํ‹ฐ)์Šˆํผ๋ง์ฐจ์ดˆ์ฝ”์ฝ˜150ML",
"img": "http://gs25appimg.gsretail.com/imgsvr/item/GD_8809490180818_001.jpg",
"price": 2500,
"price": 2600,
"store": "GS25",
"tag": "2+1",
"proinfo": 0,
Expand All @@ -42,7 +42,7 @@
{
"name": "ํž›๋”ํ‹ฐ)์Šˆํผ๋ง์ฐจ์ดˆ์ฝ”์ฝ˜150ML",
"img": "http://gs25appimg.gsretail.com/imgsvr/item/GD_8809490180818_001.jpg",
"price": 2500,
"price": 3000,
"store": "GS25",
"tag": "2+1",
"proinfo": 0,
Expand All @@ -52,7 +52,7 @@
{
"name": "ํž›๋”ํ‹ฐ)์Šˆํผ๋ง์ฐจ์ดˆ์ฝ”์ฝ˜150ML",
"img": "http://gs25appimg.gsretail.com/imgsvr/item/GD_8809490180818_001.jpg",
"price": 2500,
"price": 2900,
"store": "GS25",
"tag": "2+1",
"proinfo": 0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ProductDetail.swift
// DetailProduct.swift
//
//
// Created by ๊น€์‘์ฒ  on 2/6/24.
Expand All @@ -8,7 +8,7 @@
import Foundation

/// ํŽธ์˜์  ํ–‰์‚ฌ ์ œํ’ˆ์— ๋Œ€ํ•œ Entity Model์ž…๋‹ˆ๋‹ค.
public struct ProductDetail: Identifiable {
public struct DetailProduct: Identifiable, Equatable {
/// ์ œํ’ˆ ๊ณ ์œ  Identifier
public let id: Int

Expand All @@ -27,6 +27,9 @@ public struct ProductDetail: Identifiable {
/// ํŽธ์˜์ 
public let convenienceStore: ConvenienceStore

/// ๋‚ ์งœ
public let date: String

// TODO: ์นดํ…Œ๊ณ ๋ฆฌ ์ƒ์ˆ˜ ์ถ”๊ฐ€ํ•˜๊ธฐ

public init(
Expand All @@ -35,13 +38,25 @@ public struct ProductDetail: Identifiable {
price: Int,
name: String,
promotion: Promotion,
convenienceStore: ConvenienceStore
convenienceStore: ConvenienceStore,
date: String
) {
self.id = id
self.imageURL = imageURL
self.price = price
self.name = name
self.promotion = promotion
self.convenienceStore = convenienceStore
self.date = date
}

public init() {
id = 0
imageURL = nil
price = 0
name = ""
promotion = .buyOneGetOneFree
convenienceStore = ._7Eleven
date = ""
}
}
7 changes: 4 additions & 3 deletions PyeonHaeng-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
E57F2AA42B7717EA00E12B3D /* ProductInfoAPI in Frameworks */ = {isa = PBXBuildFile; productRef = E57F2AA32B7717EA00E12B3D /* ProductInfoAPI */; settings = {ATTRIBUTES = (Required, ); }; };
E57F2AA62B7717EA00E12B3D /* ProductInfoAPISupport in Frameworks */ = {isa = PBXBuildFile; productRef = E57F2AA52B7717EA00E12B3D /* ProductInfoAPISupport */; };
E57F2AA82B774CA700E12B3D /* ProductInfoDependency.swift in Sources */ = {isa = PBXBuildFile; fileRef = E57F2AA72B774CA700E12B3D /* ProductInfoDependency.swift */; };
E5F2EC402B637D4A00EE0838 /* ProductInfoHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5F2EC3F2B637D4A00EE0838 /* ProductInfoHeader.swift */; };
E5F2EC402B637D4A00EE0838 /* ProductInfoDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5F2EC3F2B637D4A00EE0838 /* ProductInfoDetailView.swift */; };
E5F2EC432B648F5B00EE0838 /* Int+.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5F2EC422B648F5B00EE0838 /* Int+.swift */; };
E5F2EC452B64926100EE0838 /* PromotionTagView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5F2EC442B64926100EE0838 /* PromotionTagView.swift */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -106,7 +106,7 @@
E50584522B763C8C002FDACF /* ProductInfoViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductInfoViewModel.swift; sourceTree = "<group>"; };
E5462C652B65677B00E9FDF2 /* PromotionTag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromotionTag.swift; sourceTree = "<group>"; };
E57F2AA72B774CA700E12B3D /* ProductInfoDependency.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductInfoDependency.swift; sourceTree = "<group>"; };
E5F2EC3F2B637D4A00EE0838 /* ProductInfoHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductInfoHeader.swift; sourceTree = "<group>"; };
E5F2EC3F2B637D4A00EE0838 /* ProductInfoDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductInfoDetailView.swift; sourceTree = "<group>"; };
E5F2EC422B648F5B00EE0838 /* Int+.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Int+.swift"; sourceTree = "<group>"; };
E5F2EC442B64926100EE0838 /* PromotionTagView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromotionTagView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -236,7 +236,7 @@
E57F2AA72B774CA700E12B3D /* ProductInfoDependency.swift */,
BA28F18A2B6155BD0052855E /* ProductInfoView.swift */,
E50584522B763C8C002FDACF /* ProductInfoViewModel.swift */,
E5F2EC3F2B637D4A00EE0838 /* ProductInfoHeader.swift */,
E5F2EC3F2B637D4A00EE0838 /* ProductInfoDetailView.swift */,
E50176252B6A204F0098D1BE /* ProductInfoLineGraphView.swift */,
);
path = ProductInfoScene;
Expand Down Expand Up @@ -515,6 +515,7 @@
buildActionMask = 2147483647;
files = (
BAE159DA2B65FC35002DCF94 /* HomeProductListView.swift in Sources */,
E5F2EC402B637D4A00EE0838 /* ProductInfoDetailView.swift in Sources */,
E5F2EC402B637D4A00EE0838 /* ProductInfoHeader.swift in Sources */,
BA402F7E2B85E31800E86AAD /* ConvenienceSelectBottomSheetView.swift in Sources */,
BA28F1852B6155810052855E /* OnboardingView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//
// ProductInfoDetailView.swift
// PyeonHaeng-iOS
//
// Created by ๊น€์‘์ฒ  on 2024/1/26.
//

import DesignSystem
import Entity
import SwiftUI

// MARK: - ProductInfoDetailView

struct ProductInfoDetailView<ViewModel>: View where ViewModel: ProductInfoViewModelRepresentable {
@EnvironmentObject private var viewModel: ViewModel

var body: some View {
VStack(spacing: 8.0) {
ImageView(product: viewModel.state.product)
DetailView(product: viewModel.state.product)
}
.padding(.bottom, 16.0)
}
}

// MARK: - ImageView

private struct ImageView: View {
let product: DetailProduct

var body: some View {
AsyncImage(url: product.imageURL) { image in
image
.resizable()
.scaledToFit()
} placeholder: {
// TODO: ํŽธํ–‰ ๊ธฐ๋ณธ ์ด๋ฏธ์ง€ ์ถ”๊ฐ€
ProgressView()
}
.frame(maxWidth: .infinity, maxHeight: Metrics.imageHeight)
.padding(.top, Metrics.imagePaddingTop)
.padding(.bottom, Metrics.imagePaddingBottom)
}
}

// MARK: - DetailView

private struct DetailView: View {
let product: DetailProduct

var body: some View {
Text(product.name)
.font(.h3)
.foregroundStyle(Color.gray900)
.frame(maxWidth: .infinity, alignment: .leading)
HStack(alignment: .bottom) {
VStack(alignment: .leading, spacing: .zero) {
Text("ํ–‰์‚ฌ ์ง„ํ–‰ ํŽธ์˜์ ")
.font(.c2)
.padding(.top, Metrics.textPaddingTop)
image(for: product.convenienceStore)
.padding(.top, Metrics.convenienceStoreLogoPaddingTop)
}
Spacer()
HStack(spacing: Metrics.horizontalSpacing) {
PromotionTagView(promotionTag: promotionTag(for: product.promotion))
Text("๊ฐœ๋‹น")
.font(.c1)
Text("\(Int(product.price / 2).formatted())์›")
.font(.h2)
.frame(maxHeight: 38.0)
}
}
.foregroundStyle(Color.gray900)
}

func promotionTag(for promotion: Promotion) -> PromotionTag {
switch promotion {
case .allItems:
.none
case .buyOneGetOneFree:
.onePlus
case .buyTwoGetOneFree:
.twoPlus
}
}

func image(for convenienceStore: ConvenienceStore) -> Image {
switch convenienceStore {
case .cu: .cu
case .gs25: .gs25
case ._7Eleven: ._7Eleven
case .emart24: .emart24
case .ministop: .ministop
}
}
}

// MARK: - Metrics

private enum Metrics {
static let imageHeight: CGFloat = 257.0
static let imagePaddingTop: CGFloat = 44.0
static let imagePaddingBottom: CGFloat = 40.0

static let textPaddingTop: CGFloat = 16.0
static let convenienceStoreLogoPaddingTop: CGFloat = 2.0
static let horizontalSpacing: CGFloat = 8.0
}

This file was deleted.

Loading