@@ -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+
74100struct ToastView : View {
75101 let message : String
76102 @Binding var isShowing : Bool
0 commit comments