Files
sodalive-ios/SodaLive/Sources/Notification/List/PushNotificationListView.swift

80 lines
2.9 KiB
Swift

import SwiftUI
struct PushNotificationListView: View {
@StateObject var viewModel = PushNotificationListViewModel()
@State private var isInitialized = false
var body: some View {
BaseView(isLoading: $viewModel.isLoading) {
VStack(alignment: .leading, spacing: 13.3) {
titleBar
ContentMainContentThemeView(
themeList: viewModel.categories,
selectTheme: {
viewModel.selectedCategory = $0
},
selectedTheme: $viewModel.selectedCategory
)
ScrollView(.vertical, showsIndicators: false) {
LazyVStack(spacing: 0) {
ForEach(0..<viewModel.items.count, id: \.self) { index in
let item = viewModel.items[index]
PushNotificationListItemView(item: item)
.contentShape(Rectangle())
.onTapGesture {
viewModel.onTapItem(item)
}
.onAppear {
if index == viewModel.items.count - 1 {
viewModel.getPushNotificationList()
}
}
}
if viewModel.items.isEmpty && !viewModel.isLoading {
VStack(spacing: 8) {
Image("ic_no_item")
.resizable()
.frame(width: 60, height: 60)
Text("알림이 없습니다.")
.appFont(size: 10.7, weight: .medium)
.foregroundColor(Color(hex: "bbbbbb"))
}
.frame(width: screenSize().width, height: screenSize().height / 2)
}
}
}
}
.onAppear {
if !isInitialized {
viewModel.initialize()
isInitialized = true
}
}
}
.sodaToast(isPresented: $viewModel.isShowPopup, message: viewModel.errorMessage, autohideIn: 2)
.navigationBarHidden(true)
}
private var titleBar: some View {
ZStack {
DetailNavigationBar(title: "알림")
HStack(spacing: 0) {
Spacer()
Image("ic_bell_settings")
.contentShape(Rectangle())
.onTapGesture {
AppState.shared.setAppStep(step: .notificationReceiveSettings)
}
}
.padding(.horizontal, 13.3)
.frame(height: 50)
}
}
}