Files
sodalive-ios/SodaLive/Sources/Content/Main/V2/Free/All/ContentMainIntroduceCreatorAllView.swift

67 lines
2.5 KiB
Swift

//
// ContentMainIntroduceCreatorAllView.swift
// SodaLive
//
// Created by klaus on 2/22/25.
//
import SwiftUI
struct ContentMainIntroduceCreatorAllView: View {
@StateObject var viewModel = ContentMainIntroduceCreatorAllViewModel()
@State private var isInitialized = false
var body: some View {
Group {
BaseView(isLoading: $viewModel.isLoading) {
VStack(spacing: 13.3) {
DetailNavigationBar(title: "크리에이터 소개")
ScrollView(.vertical, showsIndicators: false) {
let horizontalPadding: CGFloat = 16
let gridSpacing: CGFloat = 16
let itemSize = (screenSize().width - (horizontalPadding * 2) - gridSpacing) / 2
LazyVGrid(
columns: Array(
repeating: GridItem(
.flexible(),
spacing: gridSpacing,
alignment: .topLeading
),
count: 2
),
alignment: .leading,
spacing: gridSpacing
) {
ForEach(0..<viewModel.introduceCreatorList.count, id: \.self) { index in
let item = viewModel.introduceCreatorList[index]
ContentNewAllItemView(width: itemSize, item: item)
.onAppear {
if index == viewModel.introduceCreatorList.count - 1 {
viewModel.getIntroduceCreatorList()
}
}
}
}
.padding(.horizontal, 13.3)
}
}
.onAppear {
if !isInitialized {
viewModel.getIntroduceCreatorList()
isInitialized = true
}
}
}
.navigationBarHidden(true)
.sodaToast(isPresented: $viewModel.isShowPopup, message: viewModel.errorMessage, autohideIn: 2)
}
}
}
#Preview {
ContentMainIntroduceCreatorAllView()
}