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() + })) } }