Compare commits
No commits in common. "41b7247a44342c7cc6cd9ada54e62ac460954a48" and "68675ebfe841a44f9acae7cbeb4a60542fedf2dc" have entirely different histories.
41b7247a44
...
68675ebfe8
|
@ -31,14 +31,6 @@ struct ContentRankingAllView: View {
|
||||||
.background(Color(hex: "222222"))
|
.background(Color(hex: "222222"))
|
||||||
.padding(.top, 13.3)
|
.padding(.top, 13.3)
|
||||||
|
|
||||||
ContentMainRankingSortView(
|
|
||||||
sorts: viewModel.contentRankingSortList,
|
|
||||||
selectSort: { viewModel.selectedContentRankingSort = $0 },
|
|
||||||
selectedSort: $viewModel.selectedContentRankingSort
|
|
||||||
)
|
|
||||||
.frame(width: screenSize().width - 26.7)
|
|
||||||
.padding(.vertical, 16.7)
|
|
||||||
|
|
||||||
ScrollView(.vertical, showsIndicators: false) {
|
ScrollView(.vertical, showsIndicators: false) {
|
||||||
VStack(spacing: 20) {
|
VStack(spacing: 20) {
|
||||||
ForEach(0..<viewModel.contentRankingItemList.count, id: \.self) { index in
|
ForEach(0..<viewModel.contentRankingItemList.count, id: \.self) { index in
|
||||||
|
@ -149,7 +141,6 @@ struct ContentRankingAllView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
viewModel.getContentRankingSortType()
|
|
||||||
viewModel.getContentRanking()
|
viewModel.getContentRanking()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,15 +19,6 @@ final class ContentRankingAllViewModel: ObservableObject {
|
||||||
|
|
||||||
@Published var dateString = ""
|
@Published var dateString = ""
|
||||||
@Published var contentRankingItemList = [GetAudioContentRankingItem]()
|
@Published var contentRankingItemList = [GetAudioContentRankingItem]()
|
||||||
@Published var contentRankingSortList = [String]()
|
|
||||||
|
|
||||||
@Published var selectedContentRankingSort = "매출" {
|
|
||||||
didSet {
|
|
||||||
page = 1
|
|
||||||
isLast = false
|
|
||||||
getContentRanking()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var page = 1
|
var page = 1
|
||||||
var isLast = false
|
var isLast = false
|
||||||
|
@ -37,7 +28,7 @@ final class ContentRankingAllViewModel: ObservableObject {
|
||||||
if (!isLast && !isLoading && page <= 5) {
|
if (!isLast && !isLoading && page <= 5) {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
|
|
||||||
repository.getContentRanking(page: page, size: pageSize, sortType: selectedContentRankingSort)
|
repository.getContentRanking(page: page, size: pageSize)
|
||||||
.sink { result in
|
.sink { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .finished:
|
case .finished:
|
||||||
|
@ -85,40 +76,4 @@ final class ContentRankingAllViewModel: ObservableObject {
|
||||||
.store(in: &subscription)
|
.store(in: &subscription)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getContentRankingSortType() {
|
|
||||||
repository.getContentRankingSortType()
|
|
||||||
.sink { result in
|
|
||||||
switch result {
|
|
||||||
case .finished:
|
|
||||||
DEBUG_LOG("finish")
|
|
||||||
case .failure(let error):
|
|
||||||
ERROR_LOG(error.localizedDescription)
|
|
||||||
}
|
|
||||||
} receiveValue: { [unowned self] response in
|
|
||||||
let responseData = response.data
|
|
||||||
|
|
||||||
do {
|
|
||||||
let jsonDecoder = JSONDecoder()
|
|
||||||
let decoded = try jsonDecoder.decode(ApiResponse<[String]>.self, from: responseData)
|
|
||||||
|
|
||||||
if let data = decoded.data, decoded.success {
|
|
||||||
self.contentRankingSortList.removeAll()
|
|
||||||
self.contentRankingSortList.append(contentsOf: data)
|
|
||||||
} else {
|
|
||||||
if let message = decoded.message {
|
|
||||||
self.errorMessage = message
|
|
||||||
} else {
|
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
|
||||||
}
|
|
||||||
|
|
||||||
self.isShowPopup = true
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
|
||||||
self.isShowPopup = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.store(in: &subscription)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,7 @@ enum ContentApi {
|
||||||
case getNewContentThemeList
|
case getNewContentThemeList
|
||||||
case getNewContentAllOfTheme(theme: String, page: Int, size: Int)
|
case getNewContentAllOfTheme(theme: String, page: Int, size: Int)
|
||||||
case getAudioContentListByCurationId(curationId: Int, page: Int, size: Int, sort: ContentCurationViewModel.Sort)
|
case getAudioContentListByCurationId(curationId: Int, page: Int, size: Int, sort: ContentCurationViewModel.Sort)
|
||||||
case getContentRanking(page: Int, size: Int, sortType: String)
|
case getContentRanking(page: Int, size: Int)
|
||||||
case getContentRankingSortType
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension ContentApi: TargetType {
|
extension ContentApi: TargetType {
|
||||||
|
@ -102,9 +101,6 @@ extension ContentApi: TargetType {
|
||||||
|
|
||||||
case .getContentRanking:
|
case .getContentRanking:
|
||||||
return "/audio-content/ranking"
|
return "/audio-content/ranking"
|
||||||
|
|
||||||
case .getContentRankingSortType:
|
|
||||||
return "/audio-content/ranking-sort-type"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,8 +108,7 @@ extension ContentApi: TargetType {
|
||||||
switch self {
|
switch self {
|
||||||
case .getAudioContentList, .getAudioContentDetail, .getOrderList, .getAudioContentThemeList,
|
case .getAudioContentList, .getAudioContentDetail, .getOrderList, .getAudioContentThemeList,
|
||||||
.getAudioContentCommentList, .getAudioContentCommentReplyList, .getMain, .getNewContentOfTheme,
|
.getAudioContentCommentList, .getAudioContentCommentReplyList, .getMain, .getNewContentOfTheme,
|
||||||
.getNewContentThemeList, .getNewContentAllOfTheme, .getAudioContentListByCurationId, .getContentRanking,
|
.getNewContentThemeList, .getNewContentAllOfTheme, .getAudioContentListByCurationId, .getContentRanking:
|
||||||
.getContentRankingSortType:
|
|
||||||
return .get
|
return .get
|
||||||
|
|
||||||
case .likeContent, .modifyAudioContent, .modifyComment:
|
case .likeContent, .modifyAudioContent, .modifyComment:
|
||||||
|
@ -225,17 +220,13 @@ extension ContentApi: TargetType {
|
||||||
|
|
||||||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
||||||
|
|
||||||
case .getContentRanking(let page, let size, let sortType):
|
case .getContentRanking(let page, let size):
|
||||||
let parameters = [
|
let parameters = [
|
||||||
"page": page - 1,
|
"page": page - 1,
|
||||||
"size": size,
|
"size": size,
|
||||||
"sort-type": sortType
|
|
||||||
] as [String : Any]
|
] as [String : Any]
|
||||||
|
|
||||||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
||||||
|
|
||||||
case .getContentRankingSortType:
|
|
||||||
return .requestPlain
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,11 +93,7 @@ final class ContentRepository {
|
||||||
return api.requestPublisher(.getAudioContentListByCurationId(curationId: curationId, page: page, size: size, sort: sort))
|
return api.requestPublisher(.getAudioContentListByCurationId(curationId: curationId, page: page, size: size, sort: sort))
|
||||||
}
|
}
|
||||||
|
|
||||||
func getContentRankingSortType() -> AnyPublisher<Response, MoyaError> {
|
func getContentRanking(page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
|
||||||
return api.requestPublisher(.getContentRankingSortType)
|
return api.requestPublisher(.getContentRanking(page: page, size: size))
|
||||||
}
|
|
||||||
|
|
||||||
func getContentRanking(page: Int, size: Int, sortType: String = "매출") -> AnyPublisher<Response, MoyaError> {
|
|
||||||
return api.requestPublisher(.getContentRanking(page: page, size: size, sortType: sortType))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,11 +305,6 @@ final class ContentDetailViewModel: ObservableObject {
|
||||||
} else {
|
} else {
|
||||||
if let message = decoded.message {
|
if let message = decoded.message {
|
||||||
self.errorMessage = message
|
self.errorMessage = message
|
||||||
if message.contains("캔이 부족합니다") {
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
|
||||||
AppState.shared.setAppStep(step: .canCharge(refresh: {}, afterCompletionToGoBack: true))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ struct LiveRoomDonationDialogView: View {
|
||||||
Image("ic_forward")
|
Image("ic_forward")
|
||||||
}
|
}
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
AppState.shared.setAppStep(step: .canCharge(refresh: {}, afterCompletionToGoBack: true))
|
AppState.shared.setAppStep(step: .canCharge(refresh: {}))
|
||||||
self.isShowing = false
|
self.isShowing = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
//
|
|
||||||
// ContentMainRankingSortView.swift
|
|
||||||
// SodaLive
|
|
||||||
//
|
|
||||||
// Created by klaus on 2023/11/03.
|
|
||||||
//
|
|
||||||
|
|
||||||
import SwiftUI
|
|
||||||
|
|
||||||
struct ContentMainRankingSortView: View {
|
|
||||||
let sorts: [String]
|
|
||||||
let selectSort: (String) -> Void
|
|
||||||
|
|
||||||
@Binding var selectedSort: String
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
|
||||||
HStack(alignment: .top, spacing: 8) {
|
|
||||||
ForEach(0..<sorts.count, id: \.self) { index in
|
|
||||||
let sort = sorts[index]
|
|
||||||
Text(sort)
|
|
||||||
.font(.custom(Font.medium.rawValue, size: 14.7))
|
|
||||||
.foregroundColor(Color(hex: selectedSort == sort ? "9970ff" : "777777"))
|
|
||||||
.padding(.horizontal, 13.3)
|
|
||||||
.padding(.vertical, 9.3)
|
|
||||||
.border(
|
|
||||||
Color(hex: selectedSort == sort ? "9970ff" : "eeeeee"),
|
|
||||||
width: 0.5
|
|
||||||
)
|
|
||||||
.cornerRadius(16.7)
|
|
||||||
.overlay(
|
|
||||||
RoundedRectangle(cornerRadius: CGFloat(16.7))
|
|
||||||
.stroke(lineWidth: 0.5)
|
|
||||||
.foregroundColor(Color(hex: selectedSort == sort ? "9970ff" : "eeeeee"))
|
|
||||||
)
|
|
||||||
.onTapGesture {
|
|
||||||
if selectedSort != sort {
|
|
||||||
selectSort(sort)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ContentMainRankingSortView_Previews: PreviewProvider {
|
|
||||||
static var previews: some View {
|
|
||||||
ContentMainRankingSortView(
|
|
||||||
sorts: ["전체", "테마1", "테마2"],
|
|
||||||
selectSort: { _ in },
|
|
||||||
selectedSort: .constant("전체")
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -10,12 +10,8 @@ import Kingfisher
|
||||||
|
|
||||||
struct ContentMainRankingView: View {
|
struct ContentMainRankingView: View {
|
||||||
|
|
||||||
let sorts: [String]
|
|
||||||
let item: GetAudioContentRanking
|
let item: GetAudioContentRanking
|
||||||
|
|
||||||
let selectSort: (String) -> Void
|
|
||||||
@Binding var selectedSort: String
|
|
||||||
|
|
||||||
let rows = [
|
let rows = [
|
||||||
GridItem(.fixed(60), alignment: .leading),
|
GridItem(.fixed(60), alignment: .leading),
|
||||||
GridItem(.fixed(60), alignment: .leading),
|
GridItem(.fixed(60), alignment: .leading),
|
||||||
|
@ -51,9 +47,6 @@ struct ContentMainRankingView: View {
|
||||||
.background(Color(hex: "222222"))
|
.background(Color(hex: "222222"))
|
||||||
.padding(.top, 13.3)
|
.padding(.top, 13.3)
|
||||||
|
|
||||||
ContentMainRankingSortView(sorts: sorts, selectSort: selectSort, selectedSort: $selectedSort)
|
|
||||||
.padding(.vertical, 16.7)
|
|
||||||
|
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
LazyHGrid(rows: rows, spacing: 13.3) {
|
LazyHGrid(rows: rows, spacing: 13.3) {
|
||||||
ForEach(0..<item.items.count, id: \.self) { index in
|
ForEach(0..<item.items.count, id: \.self) { index in
|
||||||
|
@ -99,7 +92,6 @@ struct ContentMainRankingView: View {
|
||||||
struct ContentMainRankingView_Previews: PreviewProvider {
|
struct ContentMainRankingView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
ContentMainRankingView(
|
ContentMainRankingView(
|
||||||
sorts: ["매출", "후원", "댓글"],
|
|
||||||
item: GetAudioContentRanking(
|
item: GetAudioContentRanking(
|
||||||
startDate: "2023년 10월 2일",
|
startDate: "2023년 10월 2일",
|
||||||
endDate: "10월 9일",
|
endDate: "10월 9일",
|
||||||
|
@ -145,9 +137,7 @@ struct ContentMainRankingView_Previews: PreviewProvider {
|
||||||
creatorNickname: "ㄹㄴ어ㅏㅣㅇㄴ런아ㅣ"
|
creatorNickname: "ㄹㄴ어ㅏㅣㅇㄴ런아ㅣ"
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
),
|
)
|
||||||
selectSort: { _ in },
|
|
||||||
selectedSort: .constant("매출")
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,15 +56,9 @@ struct ContentMainView: View {
|
||||||
.padding(.horizontal, 13.3)
|
.padding(.horizontal, 13.3)
|
||||||
|
|
||||||
if let contentRanking = viewModel.contentRanking {
|
if let contentRanking = viewModel.contentRanking {
|
||||||
ContentMainRankingView(
|
ContentMainRankingView(item: contentRanking)
|
||||||
sorts: viewModel.contentRankingSortList,
|
|
||||||
item: contentRanking,
|
|
||||||
selectSort: { viewModel.selectedContentRankingSort = $0 },
|
|
||||||
selectedSort: $viewModel.selectedContentRankingSort
|
|
||||||
)
|
|
||||||
.padding(.top, 40)
|
.padding(.top, 40)
|
||||||
.padding(.horizontal, 13.3)
|
.padding(.horizontal, 13.3)
|
||||||
.animation(nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if viewModel.curationList.count > 0 {
|
if viewModel.curationList.count > 0 {
|
||||||
|
|
|
@ -24,7 +24,6 @@ final class ContentMainViewModel: ObservableObject {
|
||||||
@Published var orderList = [GetAudioContentMainItem]()
|
@Published var orderList = [GetAudioContentMainItem]()
|
||||||
@Published var themeList = [String]()
|
@Published var themeList = [String]()
|
||||||
@Published var curationList = [GetAudioContentCurationResponse]()
|
@Published var curationList = [GetAudioContentCurationResponse]()
|
||||||
@Published var contentRankingSortList = [String]()
|
|
||||||
@Published var contentRanking: GetAudioContentRanking? = nil
|
@Published var contentRanking: GetAudioContentRanking? = nil
|
||||||
|
|
||||||
@Published var selectedTheme = "전체" {
|
@Published var selectedTheme = "전체" {
|
||||||
|
@ -33,12 +32,6 @@ final class ContentMainViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Published var selectedContentRankingSort = "매출" {
|
|
||||||
didSet {
|
|
||||||
getContentRanking()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getMain() {
|
func getMain() {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
|
|
||||||
|
@ -66,7 +59,6 @@ final class ContentMainViewModel: ObservableObject {
|
||||||
self.orderList.removeAll()
|
self.orderList.removeAll()
|
||||||
self.curationList.removeAll()
|
self.curationList.removeAll()
|
||||||
self.themeList.removeAll()
|
self.themeList.removeAll()
|
||||||
self.contentRankingSortList.removeAll()
|
|
||||||
|
|
||||||
self.newContentUploadCreatorList.append(contentsOf: data.newContentUploadCreatorList)
|
self.newContentUploadCreatorList.append(contentsOf: data.newContentUploadCreatorList)
|
||||||
self.newContentList.append(contentsOf: data.newContentList)
|
self.newContentList.append(contentsOf: data.newContentList)
|
||||||
|
@ -74,7 +66,6 @@ final class ContentMainViewModel: ObservableObject {
|
||||||
self.orderList.append(contentsOf: data.orderList)
|
self.orderList.append(contentsOf: data.orderList)
|
||||||
self.curationList.append(contentsOf: data.curationList)
|
self.curationList.append(contentsOf: data.curationList)
|
||||||
self.contentRanking = data.contentRanking
|
self.contentRanking = data.contentRanking
|
||||||
self.contentRankingSortList.append(contentsOf: data.contentRankingSortTypeList)
|
|
||||||
|
|
||||||
self.themeList.append("전체")
|
self.themeList.append("전체")
|
||||||
self.themeList.append(contentsOf: data.themeList)
|
self.themeList.append(contentsOf: data.themeList)
|
||||||
|
@ -133,42 +124,4 @@ final class ContentMainViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
.store(in: &subscription)
|
.store(in: &subscription)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getContentRanking() {
|
|
||||||
isLoading = true
|
|
||||||
|
|
||||||
repository.getContentRanking(page: 1, size: 12, sortType: selectedContentRankingSort)
|
|
||||||
.sink { result in
|
|
||||||
switch result {
|
|
||||||
case .finished:
|
|
||||||
DEBUG_LOG("finish")
|
|
||||||
case .failure(let error):
|
|
||||||
ERROR_LOG(error.localizedDescription)
|
|
||||||
}
|
|
||||||
} receiveValue: { [unowned self] response in
|
|
||||||
self.isLoading = false
|
|
||||||
let responseData = response.data
|
|
||||||
|
|
||||||
do {
|
|
||||||
let jsonDecoder = JSONDecoder()
|
|
||||||
let decoded = try jsonDecoder.decode(ApiResponse<GetAudioContentRanking>.self, from: responseData)
|
|
||||||
|
|
||||||
if let data = decoded.data, decoded.success {
|
|
||||||
self.contentRanking = data
|
|
||||||
} else {
|
|
||||||
if let message = decoded.message {
|
|
||||||
self.errorMessage = message
|
|
||||||
} else {
|
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
|
||||||
}
|
|
||||||
|
|
||||||
self.isShowPopup = true
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
|
||||||
self.isShowPopup = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.store(in: &subscription)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ struct GetAudioContentMainResponse: Decodable {
|
||||||
let themeList: [String]
|
let themeList: [String]
|
||||||
let newContentList: [GetAudioContentMainItem]
|
let newContentList: [GetAudioContentMainItem]
|
||||||
let curationList: [GetAudioContentCurationResponse]
|
let curationList: [GetAudioContentCurationResponse]
|
||||||
let contentRankingSortTypeList: [String]
|
|
||||||
let contentRanking: GetAudioContentRanking
|
let contentRanking: GetAudioContentRanking
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct CanPgPaymentView: View {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color.black.ignoresSafeArea()
|
Color.black.ignoresSafeArea()
|
||||||
|
|
||||||
if viewModel.isShowPaymentView {
|
if viewModel.isShowPamentView {
|
||||||
BootpayUI(payload: viewModel.payload, requestType: BootpayRequest.TYPE_PAYMENT)
|
BootpayUI(payload: viewModel.payload, requestType: BootpayRequest.TYPE_PAYMENT)
|
||||||
.onConfirm {
|
.onConfirm {
|
||||||
DEBUG_LOG("onConfirm: \($0)")
|
DEBUG_LOG("onConfirm: \($0)")
|
||||||
|
@ -38,31 +38,28 @@ struct CanPgPaymentView: View {
|
||||||
}
|
}
|
||||||
.onError {
|
.onError {
|
||||||
DEBUG_LOG("onError: \($0)")
|
DEBUG_LOG("onError: \($0)")
|
||||||
viewModel.isShowPaymentView = false
|
viewModel.isShowPamentView = false
|
||||||
viewModel.errorMessage = "결제 중 오류가 발생했습니다."
|
viewModel.errorMessage = "결제 중 오류가 발생했습니다."
|
||||||
viewModel.isShowPopup = true
|
viewModel.isShowPopup = true
|
||||||
}
|
}
|
||||||
.onDone {
|
.onDone {
|
||||||
DEBUG_LOG("onDone: \($0)")
|
DEBUG_LOG("onDone: \($0)")
|
||||||
viewModel.verifyPayment($0) {
|
viewModel.verifyPayment($0) {
|
||||||
let can = UserDefaults.int(forKey: .can)
|
|
||||||
UserDefaults.set(can + canResponse.can + canResponse.rewardCan, forKey: .can)
|
|
||||||
|
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
|
||||||
if afterCompletionToGoBack {
|
if afterCompletionToGoBack {
|
||||||
AppState.shared.back()
|
AppState.shared.back()
|
||||||
AppState.shared.back()
|
|
||||||
} else {
|
} else {
|
||||||
AppState.shared.setAppStep(step: .canStatus(refresh: refresh))
|
AppState.shared.setAppStep(step: .canStatus(refresh: refresh))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
let can = UserDefaults.int(forKey: .can)
|
||||||
|
UserDefaults.set(can + canResponse.can + canResponse.rewardCan, forKey: .can)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onClose {
|
.onClose {
|
||||||
DEBUG_LOG("onClose")
|
DEBUG_LOG("onClose")
|
||||||
viewModel.isShowPaymentView = false
|
viewModel.isShowPamentView = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GeometryReader { proxy in
|
GeometryReader { proxy in
|
||||||
|
@ -282,7 +279,7 @@ struct CanPgPaymentView: View {
|
||||||
viewModel.payload.price = Double(canResponse.price)
|
viewModel.payload.price = Double(canResponse.price)
|
||||||
viewModel.payload.taxFree = 0
|
viewModel.payload.taxFree = 0
|
||||||
|
|
||||||
viewModel.isShowPaymentView = true
|
viewModel.isShowPamentView = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class CanPgPaymentViewModel: ObservableObject {
|
||||||
@Published var isShowPopup = false
|
@Published var isShowPopup = false
|
||||||
@Published var isLoading = false
|
@Published var isLoading = false
|
||||||
|
|
||||||
@Published var isShowPaymentView = false
|
@Published var isShowPamentView = false
|
||||||
@Published var paymentMethod: PaymentMethod? = nil
|
@Published var paymentMethod: PaymentMethod? = nil
|
||||||
|
|
||||||
let payload = Payload()
|
let payload = Payload()
|
||||||
|
@ -99,9 +99,6 @@ final class CanPgPaymentViewModel: ObservableObject {
|
||||||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||||
|
|
||||||
if decoded.success {
|
if decoded.success {
|
||||||
self.errorMessage = "캔이 충전되었습니다"
|
|
||||||
self.isShowPopup = true
|
|
||||||
|
|
||||||
onSuccess()
|
onSuccess()
|
||||||
} else {
|
} else {
|
||||||
if let message = decoded.message {
|
if let message = decoded.message {
|
||||||
|
|
Loading…
Reference in New Issue