From 522a17706348f021334972a971122264ef2f0a24 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Tue, 10 Jun 2025 21:28:11 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=BF=A0=ED=8F=B0=20=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=20=ED=9B=84=20=EB=A7=88=EC=9D=B4=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EA=B0=80=20=EC=83=88=EB=A1=9C=EA=B3=A0=EC=B9=A8=20=EB=90=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SodaLive/Sources/App/AppStep.swift | 2 +- SodaLive/Sources/ContentView.swift | 4 ++-- SodaLive/Sources/MyPage/Can/Coupon/CanCouponView.swift | 8 +++++--- .../Sources/MyPage/Can/Coupon/CanCouponViewModel.swift | 3 ++- SodaLive/Sources/MyPage/MyPageView.swift | 4 +++- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/SodaLive/Sources/App/AppStep.swift b/SodaLive/Sources/App/AppStep.swift index 41a1ee7..a244b16 100644 --- a/SodaLive/Sources/App/AppStep.swift +++ b/SodaLive/Sources/App/AppStep.swift @@ -122,7 +122,7 @@ enum AppStep { case creatorCommunityModify(postId: Int, onSuccess: () -> Void) - case canCoupon + case canCoupon(refresh: () -> Void) case contentAllByTheme(themeId: Int) diff --git a/SodaLive/Sources/ContentView.swift b/SodaLive/Sources/ContentView.swift index d0034df..da90bbb 100644 --- a/SodaLive/Sources/ContentView.swift +++ b/SodaLive/Sources/ContentView.swift @@ -185,8 +185,8 @@ struct ContentView: View { case .creatorCommunityModify(let postId, let onSuccess): CreatorCommunityModifyView(postId: postId, onSuccess: onSuccess) - case .canCoupon: - CanCouponView() + case .canCoupon(let refresh): + CanCouponView(refresh: refresh) case .contentAllByTheme(let themeId): ContentAllByThemeView(themeId: themeId) diff --git a/SodaLive/Sources/MyPage/Can/Coupon/CanCouponView.swift b/SodaLive/Sources/MyPage/Can/Coupon/CanCouponView.swift index 2a1602e..1711152 100644 --- a/SodaLive/Sources/MyPage/Can/Coupon/CanCouponView.swift +++ b/SodaLive/Sources/MyPage/Can/Coupon/CanCouponView.swift @@ -11,6 +11,8 @@ struct CanCouponView: View { @StateObject var viewModel = CanCouponViewModel() + let refresh: () -> Void + var body: some View { BaseView(isLoading: $viewModel.isLoading) { GeometryReader { proxy in @@ -52,7 +54,7 @@ struct CanCouponView: View { .cornerRadius(10) .padding(.top, 21.3) .onTapGesture { - viewModel.useCoupon() + viewModel.useCoupon { refresh() } } VStack(alignment: .leading, spacing: 0) { @@ -116,7 +118,7 @@ struct CanCouponView: View { .padding(.horizontal, 6.7) .frame(width: geo.size.width - 66.7, alignment: .center) .font(.custom(Font.medium.rawValue, size: 12)) - .background(Color(hex: "9970ff")) + .background(Color.button) .foregroundColor(Color.white) .multilineTextAlignment(.leading) .fixedSize(horizontal: false, vertical: true) @@ -133,6 +135,6 @@ struct CanCouponView: View { struct CanCouponView_Previews: PreviewProvider { static var previews: some View { - CanCouponView() + CanCouponView(refresh: {}) } } diff --git a/SodaLive/Sources/MyPage/Can/Coupon/CanCouponViewModel.swift b/SodaLive/Sources/MyPage/Can/Coupon/CanCouponViewModel.swift index 8a3b4a0..42d1904 100644 --- a/SodaLive/Sources/MyPage/Can/Coupon/CanCouponViewModel.swift +++ b/SodaLive/Sources/MyPage/Can/Coupon/CanCouponViewModel.swift @@ -19,7 +19,7 @@ final class CanCouponViewModel: ObservableObject { @Published var couponNumber = "" - func useCoupon() { + func useCoupon(onComplete: @escaping () -> Void) { if !isLoading { isLoading = true repository.useCanCoupon(couponNumber: couponNumber) @@ -46,6 +46,7 @@ final class CanCouponViewModel: ObservableObject { } DispatchQueue.main.asyncAfter(deadline: .now() + 1) { + onComplete() AppState.shared.back() } } else { diff --git a/SodaLive/Sources/MyPage/MyPageView.swift b/SodaLive/Sources/MyPage/MyPageView.swift index 4f6f310..a8c5eeb 100644 --- a/SodaLive/Sources/MyPage/MyPageView.swift +++ b/SodaLive/Sources/MyPage/MyPageView.swift @@ -157,7 +157,9 @@ struct MyPageView: View { .frame(width: screenSize().width - 26.7) .padding(.top, 13.3) .onTapGesture { - AppState.shared.setAppStep(step: .canCoupon) + AppState.shared.setAppStep(step: .canCoupon(refresh: { + viewModel.getMypage() + })) } }