Skip to content

Commit c6f0624

Browse files
authored
Merge pull request #27 from MarketPlace-O2O-Platform/Design#26/MyPageCouponCell
[Refactor] 받은 쿠폰함의 쿠폰 디자인 변경
2 parents 08f6f6b + b1bec5c commit c6f0624

11 files changed

Lines changed: 134 additions & 88 deletions

File tree

MarketPlace/API/Service/NetworkService.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ protocol NetworkServiceProtocol {
2121
final class NetworkService: NetworkServiceProtocol {
2222
func request<T: Decodable>(_ endpoint: Endpoint) async -> NetworkResult<T> {
2323
var request = endpoint.urlRequest
24-
print(request.url)
2524

2625
if let token = KeychainManager.getToken() {
2726
request.addValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "쿠폰.png",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"author" : "xcode",
19+
"version" : 1
20+
}
21+
}
9.18 KB
Loading

MarketPlace/Service/MarketService.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ final class MarketService: MarketServiceProtocol {
9898
return await networkService.request(
9999
MarketEndpoint.postMarketRequest(name: name, address: address)
100100
)
101+
}
101102

102103
// MARK: - 주소별 매장 조회 API
103104
func fetchMarketsWithAddress(lastPageIndex: Int?, category: String?, pageSize: Int?) async -> NetworkResult<APIResDto<MarketResDto<MarketModel>>> {

MarketPlace/View/Main/Components/ImageTextOverlay.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct ImageTextOverlay: View {
1919
ForEach(texts.indices, id: \.self) { index in
2020
Text(texts[index])
2121
.foregroundColor(Color.white)
22-
.pretendardFont(size: index == 0 || index == 2 ? 18 : 26, weight: index == 1 ? .heavy : .bold)
22+
.pretendardFont(size: index == 0 || index == 2 ? 18 : 26, weight: .semibold)
2323
.lineLimit(index == 1 ? 2 : 1)
2424
.lineSpacing(index == 0 || index == 1 ? 33.8 : 3.12)
2525
.padding(.leading, 5)

MarketPlace/View/Main/Components/MarketCouponListView.swift

Lines changed: 62 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ struct MarketCouponListView: View {
77
@Binding private var selectedCouponId: Int
88
@Binding private var showToast: Bool
99
@Binding private var toastMessage: String
10-
10+
11+
@State private var currentIndex: Int = 0
12+
1113
private let marketId: Int
12-
14+
1315
init(
1416
coupons: Binding<[CouponValidModel]>,
1517
isPopupVisible: Binding<Bool>,
@@ -27,50 +29,74 @@ struct MarketCouponListView: View {
2729
}
2830

2931
var body: some View {
30-
ZStack {
31-
ScrollView(.horizontal, showsIndicators: false) {
32-
HStack(spacing: 8) {
33-
ForEach($coupons) { $coupon in
32+
VStack(alignment: .leading, spacing: 10) {
33+
TabView(selection: $currentIndex) {
34+
ForEach(Array($coupons.enumerated()), id: \.element.id) { index, $coupon in
35+
ZStack(alignment: .leading) {
3436
Image("couponDetail")
3537
.resizable()
3638
.aspectRatio(contentMode: .fill)
3739
.frame(height: 93)
38-
.overlay(alignment: .leading) {
39-
VStack(alignment: .leading, spacing: 5) {
40-
Text(coupon.couponName)
41-
.pretendardFont(size: 16, weight: .semibold)
42-
.foregroundColor(.white)
43-
.lineLimit(2)
44-
.multilineTextAlignment(.leading)
45-
.frame(maxWidth: 200, alignment: .leading)
46-
47-
Text(coupon.deadLine.toKoreanDateFormat())
48-
.pretendardFont(size: 14, weight: .regular)
49-
.foregroundColor(.white)
50-
}
51-
.padding(.leading, 25)
52-
.padding(.vertical, 5)
53-
.opacity(coupon.isAvailable ? 1.0 : 0.5)
54-
.onTapGesture {
55-
if coupon.isAvailable && !coupon.isMemberIssued {
56-
selectedCouponId = coupon.id
57-
isPopupVisible = true
58-
} else if coupon.isMemberIssued {
59-
toastMessage = "이미 발급 완료된 쿠폰입니다"
60-
showToast = true
61-
} else if !coupon.isAvailable {
62-
toastMessage = "기한이 만료되었습니다"
63-
showToast = true
64-
}
65-
}
66-
}
40+
41+
VStack(alignment: .leading, spacing: 5) {
42+
Text(coupon.couponName)
43+
.pretendardFont(size: 16, weight: .semibold)
44+
.foregroundColor(.white)
45+
.lineLimit(2)
46+
.multilineTextAlignment(.leading)
47+
.frame(maxWidth: 200, alignment: .leading)
48+
49+
Text(coupon.deadLine.toKoreanDateFormat())
50+
.pretendardFont(size: 14, weight: .regular)
51+
.foregroundColor(.white)
52+
}
53+
.padding(.leading, 25)
54+
.padding(.vertical, 5)
55+
.opacity(coupon.isAvailable ? 1.0 : 0.5)
56+
}
57+
.padding(.horizontal, 16)
58+
.tag(index)
59+
.onTapGesture {
60+
if coupon.isAvailable && !coupon.isMemberIssued {
61+
selectedCouponId = coupon.id
62+
isPopupVisible = true
63+
} else if coupon.isMemberIssued {
64+
toastMessage = "이미 발급 완료된 쿠폰입니다"
65+
showToast = true
66+
} else if !coupon.isAvailable {
67+
toastMessage = "기한이 만료되었습니다"
68+
showToast = true
69+
}
6770
}
68-
}.padding(.horizontal, 16)
71+
}
72+
}
73+
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
74+
.frame(height: 110)
75+
76+
HStack {
77+
Spacer()
78+
HStack(spacing: 6) {
79+
ForEach(0..<coupons.count, id: \.self) { i in
80+
Circle()
81+
.fill(i == currentIndex ? Color.primary : Color.secondary.opacity(0.4))
82+
.frame(width: 5, height: 5)
83+
}
84+
}
85+
Spacer()
6986
}
87+
88+
Text(coupons.indices.contains(currentIndex) ? "\(coupons[currentIndex].couponDescription)\n쿠폰 다운로드 시점으로부터 3일 이내로 미사용 시 소멸 예정" : "")
89+
.pretendardFont(size: 13, weight: .regular)
90+
.foregroundColor(.gray)
91+
.padding(.top, 10)
92+
.padding(.leading, 20)
93+
.animation(.easeInOut, value: currentIndex)
7094
}
7195
}
7296
}
7397

98+
99+
74100
struct ToastView: View {
75101
let message: String
76102
@Binding var isShowing: Bool

MarketPlace/View/Main/View/MarketDetailView.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,6 @@ struct MarketDetailView: View {
7979
.pretendardFont(size: 13, weight: .semibold)
8080
.padding(.leading, 16)
8181
}
82-
83-
Text(shop.description)
84-
.pretendardFont(size: 13, weight: .regular)
85-
.foregroundColor(.gray)
86-
.padding(.leading, 16)
8782
}
8883
.zIndex(10)
8984

MarketPlace/View/MyPage/Components/MyCouponCell.swift

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,64 @@ struct MyCouponCell: View {
55
var onTap: () -> Void
66

77
var body: some View {
8-
Image(viewModel.couponStatus==CouponStatus.issued ? "myCoupon_canuse" : "myCoupon_used")
8+
Image("myCoupon")
99
.resizable()
1010
.scaledToFit()
11-
.frame(width: 335, height: 102)
11+
.frame(width: 335)
1212
.overlay {
13-
HStack(spacing: 0) {
14-
ShimmeringAsyncImage(
15-
url: URL(
16-
string: URLManager.shared.baseStringURL + "image/" + viewModel.coupon.thumbnail
17-
),
18-
cornerRadius: 0,
19-
width: 102,
20-
height: 102
21-
)
22-
23-
VStack(alignment: .leading, spacing: 4) {
24-
Text(viewModel.coupon.couponName)
25-
.pretendardFont(size: 18, weight: .medium)
26-
.font(.headline)
27-
.lineLimit(1)
28-
.foregroundColor(Color(hex: "#121212"))
29-
30-
Text(viewModel.coupon.description)
31-
.pretendardFont(size: 15, weight: .semibold)
32-
.lineLimit(1)
33-
.foregroundColor(Color(red: 0.07, green: 0.07, blue: 0.07))
13+
VStack(alignment: .leading) {
14+
HStack(alignment: .top, spacing: 12) {
15+
ShimmeringAsyncImage(
16+
url: URL(
17+
string: URLManager.shared.baseStringURL + "image/" + viewModel.coupon.thumbnail
18+
),
19+
cornerRadius: 4,
20+
width: 60,
21+
height: 65
22+
)
3423

35-
Text(viewModel.formattedDeadline)
36-
.pretendardFont(size: 13, weight: .regular)
37-
.foregroundColor(Color(red: 0.33, green: 0.33, blue: 0.33))
24+
VStack(alignment: .leading, spacing: 7) {
25+
Text("하노이키친 인천대점")
26+
.pretendardFont(size: 14, weight: .regular)
27+
.lineLimit(1)
28+
.foregroundStyle(Color(hex: "#727272"))
29+
30+
Text(viewModel.coupon.couponName)
31+
.pretendardFont(size: 24, weight: .medium)
32+
.lineLimit(1)
33+
.foregroundStyle(Color(hex: "#303030"))
34+
}.padding(.top, 5)
3835
}
39-
.padding(.horizontal, 12)
40-
.frame(width: 165, alignment: .leading)
41-
42-
Spacer()
36+
.padding(.top, 10)
37+
.padding(.horizontal, 20)
4338

4439
Button(action: {
4540
if viewModel.canUse {
4641
onTap()
4742
}
48-
}) {
43+
}, label: {
4944
Text(viewModel.couponStatusText)
50-
.pretendardFont(size: 13, weight: .bold)
51-
.foregroundStyle(Color.white)
52-
}.disabled(!viewModel.canUse)
45+
.foregroundStyle(viewModel.couponStatus==CouponStatus.issued ? .white : Color(hex: "#727272"))
46+
.pretendardFont(size: 14, weight: .semibold)
47+
.padding(.vertical, 15)
48+
.frame(maxWidth: .infinity)
49+
.background(
50+
RoundedRectangle(cornerRadius: 4)
51+
.fill(viewModel.couponStatus==CouponStatus.issued ? Color(hex: "#303030") : Color(hex: "#E0E0E0"))
52+
)
53+
})
54+
.padding(.horizontal ,20)
55+
.disabled(!viewModel.canUse)
5356

54-
Spacer()
57+
Button(action: {
58+
59+
}, label: {
60+
Text("쿠러미 카카오채널로 영수증 전송")
61+
.pretendardFont(size: 14, weight: .regular)
62+
.foregroundStyle(Color(hex: "#727272"))
63+
})
64+
.padding(.leading, 20)
65+
.padding(.top, 20)
5566
}
5667
}
5768
}

MarketPlace/View/MyPage/View/MyCouponView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ struct MyCouponView: View {
3939
}
4040
}
4141
.frame(maxWidth: .infinity)
42-
.padding(.top, 20)
42+
.padding(.vertical, 20)
4343
}
44-
.background(Color.white)
44+
.background(Color(hex: "#FAFAFA"))
4545
}
4646

4747
if showingPopup {

MarketPlace/View/MyPage/View/MyPageView.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Foundation
22
import SwiftUI
33

44
struct MyPageView: View {
5-
@State private var selectedCategory: Int = 0
65
@StateObject private var viewModel = MyPageViewModel()
76
@EnvironmentObject var loginVM: LoginViewModel
87

@@ -23,7 +22,6 @@ struct MyPageView: View {
2322
.padding(.horizontal, 20)
2423
.padding(.bottom, 8)
2524

26-
CircleCategoryTabView(selectedTab: $selectedCategory)
2725
FavoriteShopListView(favoriteMarkets: $viewModel.favoriteMarkets)
2826
}
2927
.background(Color.white)
@@ -33,11 +31,6 @@ struct MyPageView: View {
3331
await viewModel.fetchMemberInfo()
3432
}
3533
}
36-
.onChange(of: selectedCategory) {
37-
Task{
38-
await viewModel.fetchFavoriteMarket(lastModifiedAt: nil, pageSize: nil)
39-
}
40-
}
4134
.overlay {
4235
CustomAlertView(isPresented: $showLogoutAlert, title: "로그아웃 하시겠습니까?", buttonTitle: "로그아웃") {
4336
loginVM.logout()

0 commit comments

Comments
 (0)