136 lines
5.4 KiB
Swift
136 lines
5.4 KiB
Swift
//
|
|
// PointStatusView.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 5/20/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct PointStatusView: View {
|
|
|
|
let refresh: () -> Void
|
|
|
|
@StateObject var viewModel = PointStatusViewModel()
|
|
|
|
var body: some View {
|
|
BaseView(isLoading: $viewModel.isLoading) {
|
|
GeometryReader { proxy in
|
|
VStack(spacing: 0) {
|
|
DetailNavigationBar(title: "포인트 내역") {
|
|
AppState.shared.setAppStep(step: .main)
|
|
}
|
|
|
|
ScrollView(.vertical, showsIndicators: false) {
|
|
VStack(spacing: 26.7) {
|
|
HStack(spacing: 6.7) {
|
|
Image("ic_point")
|
|
.resizable()
|
|
.frame(width: 26.7, height: 26.7)
|
|
|
|
Text("\(viewModel.totalCan)")
|
|
.font(.custom(Font.bold.rawValue, size: 18.3))
|
|
.foregroundColor(.grayee)
|
|
}
|
|
}
|
|
.padding(.vertical, 13.3)
|
|
.frame(maxWidth: .infinity)
|
|
.padding(.horizontal, 13.3)
|
|
.background(Color.gray22)
|
|
.cornerRadius(16.7)
|
|
.padding(.top, 13.3)
|
|
|
|
HStack(spacing: 0) {
|
|
VStack(spacing: 0) {
|
|
Spacer()
|
|
Text("받은내역")
|
|
.font(.custom(Font.medium.rawValue, size: 13.3))
|
|
.foregroundColor(viewModel.currentTab == .reward ? .grayee : .gray77)
|
|
Spacer()
|
|
Rectangle()
|
|
.frame(height: 1)
|
|
.foregroundColor(
|
|
.button
|
|
.opacity(viewModel.currentTab == .reward ? 1 : 0)
|
|
)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
.frame(height: 50)
|
|
.onTapGesture {
|
|
if viewModel.currentTab != .reward {
|
|
viewModel.currentTab = .reward
|
|
}
|
|
}
|
|
|
|
VStack(spacing: 0) {
|
|
Spacer()
|
|
Text("사용내역")
|
|
.font(.custom(Font.medium.rawValue, size: 13.3))
|
|
.foregroundColor(viewModel.currentTab == .use ? .grayee : .gray77)
|
|
Spacer()
|
|
Rectangle()
|
|
.frame(height: 1)
|
|
.foregroundColor(
|
|
.button
|
|
.opacity(viewModel.currentTab == .use ? 1 : 0)
|
|
)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
.frame(height: 50)
|
|
.onTapGesture {
|
|
if viewModel.currentTab != .use {
|
|
viewModel.currentTab = .use
|
|
}
|
|
}
|
|
}
|
|
.padding(.top, 13.3)
|
|
|
|
switch viewModel.currentTab {
|
|
case .reward:
|
|
PointRewardStatusView()
|
|
|
|
case .use:
|
|
PointUseStatusView()
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
|
|
if proxy.safeAreaInsets.bottom > 0 {
|
|
Rectangle()
|
|
.foregroundColor(.black)
|
|
.frame(width: proxy.size.width, height: 15.3)
|
|
}
|
|
}
|
|
.edgesIgnoringSafeArea(.bottom)
|
|
}
|
|
}
|
|
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .top, autohideIn: 2) {
|
|
GeometryReader { geo in
|
|
HStack {
|
|
Spacer()
|
|
Text(viewModel.errorMessage)
|
|
.padding(.vertical, 13.3)
|
|
.padding(.horizontal, 6.7)
|
|
.frame(width: geo.size.width - 66.7, alignment: .center)
|
|
.font(.custom(Font.medium.rawValue, size: 12))
|
|
.background(Color.button)
|
|
.foregroundColor(Color.white)
|
|
.multilineTextAlignment(.leading)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
.cornerRadius(20)
|
|
.padding(.top, 66.7)
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|
|
.onAppear {
|
|
viewModel.getPointStatus()
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
PointStatusView {}
|
|
}
|