feat: 쿠폰 등록 후 마이페이지가 새로고침 되도록 수정
This commit is contained in:
@@ -122,7 +122,7 @@ enum AppStep {
|
|||||||
|
|
||||||
case creatorCommunityModify(postId: Int, onSuccess: () -> Void)
|
case creatorCommunityModify(postId: Int, onSuccess: () -> Void)
|
||||||
|
|
||||||
case canCoupon
|
case canCoupon(refresh: () -> Void)
|
||||||
|
|
||||||
case contentAllByTheme(themeId: Int)
|
case contentAllByTheme(themeId: Int)
|
||||||
|
|
||||||
|
|||||||
@@ -185,8 +185,8 @@ struct ContentView: View {
|
|||||||
case .creatorCommunityModify(let postId, let onSuccess):
|
case .creatorCommunityModify(let postId, let onSuccess):
|
||||||
CreatorCommunityModifyView(postId: postId, onSuccess: onSuccess)
|
CreatorCommunityModifyView(postId: postId, onSuccess: onSuccess)
|
||||||
|
|
||||||
case .canCoupon:
|
case .canCoupon(let refresh):
|
||||||
CanCouponView()
|
CanCouponView(refresh: refresh)
|
||||||
|
|
||||||
case .contentAllByTheme(let themeId):
|
case .contentAllByTheme(let themeId):
|
||||||
ContentAllByThemeView(themeId: themeId)
|
ContentAllByThemeView(themeId: themeId)
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ struct CanCouponView: View {
|
|||||||
|
|
||||||
@StateObject var viewModel = CanCouponViewModel()
|
@StateObject var viewModel = CanCouponViewModel()
|
||||||
|
|
||||||
|
let refresh: () -> Void
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
BaseView(isLoading: $viewModel.isLoading) {
|
BaseView(isLoading: $viewModel.isLoading) {
|
||||||
GeometryReader { proxy in
|
GeometryReader { proxy in
|
||||||
@@ -52,7 +54,7 @@ struct CanCouponView: View {
|
|||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
.padding(.top, 21.3)
|
.padding(.top, 21.3)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
viewModel.useCoupon()
|
viewModel.useCoupon { refresh() }
|
||||||
}
|
}
|
||||||
|
|
||||||
VStack(alignment: .leading, spacing: 0) {
|
VStack(alignment: .leading, spacing: 0) {
|
||||||
@@ -116,7 +118,7 @@ struct CanCouponView: View {
|
|||||||
.padding(.horizontal, 6.7)
|
.padding(.horizontal, 6.7)
|
||||||
.frame(width: geo.size.width - 66.7, alignment: .center)
|
.frame(width: geo.size.width - 66.7, alignment: .center)
|
||||||
.font(.custom(Font.medium.rawValue, size: 12))
|
.font(.custom(Font.medium.rawValue, size: 12))
|
||||||
.background(Color(hex: "9970ff"))
|
.background(Color.button)
|
||||||
.foregroundColor(Color.white)
|
.foregroundColor(Color.white)
|
||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
@@ -133,6 +135,6 @@ struct CanCouponView: View {
|
|||||||
|
|
||||||
struct CanCouponView_Previews: PreviewProvider {
|
struct CanCouponView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
CanCouponView()
|
CanCouponView(refresh: {})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ final class CanCouponViewModel: ObservableObject {
|
|||||||
|
|
||||||
@Published var couponNumber = ""
|
@Published var couponNumber = ""
|
||||||
|
|
||||||
func useCoupon() {
|
func useCoupon(onComplete: @escaping () -> Void) {
|
||||||
if !isLoading {
|
if !isLoading {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
repository.useCanCoupon(couponNumber: couponNumber)
|
repository.useCanCoupon(couponNumber: couponNumber)
|
||||||
@@ -46,6 +46,7 @@ final class CanCouponViewModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||||
|
onComplete()
|
||||||
AppState.shared.back()
|
AppState.shared.back()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -157,7 +157,9 @@ struct MyPageView: View {
|
|||||||
.frame(width: screenSize().width - 26.7)
|
.frame(width: screenSize().width - 26.7)
|
||||||
.padding(.top, 13.3)
|
.padding(.top, 13.3)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
AppState.shared.setAppStep(step: .canCoupon)
|
AppState.shared.setAppStep(step: .canCoupon(refresh: {
|
||||||
|
viewModel.getMypage()
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user