// // NotificationSettingsView.swift // SodaLive // // Created by klaus on 2023/08/10. // import SwiftUI struct NotificationSettingsView: View { @StateObject var viewModel = NotificationSettingsViewModel() var body: some View { BaseView(isLoading: $viewModel.isLoading) { VStack(spacing: 0) { DetailNavigationBar(title: "알림 설정") ScrollView(.vertical, showsIndicators: false) { VStack(spacing: 0) { HStack(spacing: 0) { Text("라이브 알림") .appFont(size: 15, weight: .bold) .foregroundColor(Color(hex: "eeeeee")) Spacer() Image(viewModel.followingChannelLive ? "btn_toggle_on_big" : "btn_toggle_off_big") .resizable() .frame(width: 44, height: 27) .onTapGesture { viewModel.followingChannelLive.toggle() } } .frame(height: 50) Rectangle() .frame(height: 1) .foregroundColor(Color(hex: "909090").opacity(0.3)) HStack(spacing: 0) { Text("콘텐츠 업로드 알림") .appFont(size: 15, weight: .bold) .foregroundColor(Color(hex: "eeeeee")) Spacer() Image(viewModel.followingChannelUploadContent ? "btn_toggle_on_big" : "btn_toggle_off_big") .resizable() .frame(width: 44, height: 27) .onTapGesture { viewModel.followingChannelUploadContent.toggle() } } .frame(height: 50) Rectangle() .frame(height: 1) .foregroundColor(Color(hex: "909090").opacity(0.3)) HStack(spacing: 0) { Text("메시지 알림") .appFont(size: 15, weight: .bold) .foregroundColor(Color(hex: "eeeeee")) Spacer() Image(viewModel.message ? "btn_toggle_on_big" : "btn_toggle_off_big") .resizable() .frame(width: 44, height: 27) .onTapGesture { viewModel.message.toggle() } } .frame(height: 50) } .padding(.vertical, 6.7) .padding(.horizontal, 13.3) .background(Color(hex: "222222")) .cornerRadius(10) .padding(.top, 26.7) .padding(.horizontal, 13.3) } } .onAppear { viewModel.getMemberInfo() } } .sodaToast(isPresented: $viewModel.isShowPopup, message: viewModel.errorMessage, autohideIn: 2) } } struct NotificationSettingsView_Previews: PreviewProvider { static var previews: some View { NotificationSettingsView() } } struct NotificationReceiveSettingsView: View { @StateObject var viewModel = NotificationReceiveSettingsViewModel() @State private var isInitialized = false @State private var isShowFollowNotifyDialog = false @State private var creatorId = 0 @State private var selectedItemIndex = -1 var body: some View { BaseView(isLoading: $viewModel.isLoading) { VStack(spacing: 0) { DetailNavigationBar(title: "알림 수신 설정") ScrollView(.vertical, showsIndicators: false) { VStack(alignment: .leading, spacing: 0) { Text("서비스 알림") .appFont(size: 16.7, weight: .bold) .foregroundColor(Color(hex: "eeeeee")) .padding(.top, 26.7) .padding(.horizontal, 13.3) VStack(spacing: 0) { NotificationReceiveServiceRowView( title: "라이브 알림", isOn: viewModel.followingChannelLive, onTapToggle: { viewModel.followingChannelLive.toggle() } ) Rectangle() .frame(height: 1) .foregroundColor(Color(hex: "909090").opacity(0.3)) NotificationReceiveServiceRowView( title: "콘텐츠 업로드 알림", isOn: viewModel.followingChannelUploadContent, onTapToggle: { viewModel.followingChannelUploadContent.toggle() } ) Rectangle() .frame(height: 1) .foregroundColor(Color(hex: "909090").opacity(0.3)) NotificationReceiveServiceRowView( title: "메시지 알림", isOn: viewModel.message, onTapToggle: { viewModel.message.toggle() } ) } .padding(.vertical, 6.7) .padding(.horizontal, 13.3) .background(Color(hex: "222222")) .cornerRadius(10) .padding(.top, 13.3) .padding(.horizontal, 13.3) Text("팔로잉 채널") .appFont(size: 16.7, weight: .bold) .foregroundColor(Color(hex: "eeeeee")) .padding(.top, 26.7) .padding(.horizontal, 13.3) HStack(spacing: 0) { Text("총") .appFont(size: 13.3, weight: .medium) .foregroundColor(Color.grayee) Text(" \(viewModel.totalCount) ") .appFont(size: 13.3, weight: .medium) .foregroundColor(Color.mainRed3) Text("명") .appFont(size: 13.3, weight: .medium) .foregroundColor(Color.grayee) Spacer() } .padding(.top, 13.3) .padding(.horizontal, 13.3) if viewModel.totalCount > 0 { VStack(spacing: 13.3) { ForEach(0.. Void var body: some View { HStack(spacing: 0) { Text(title) .appFont(size: 15, weight: .bold) .foregroundColor(Color(hex: "eeeeee")) Spacer() Image(isOn ? "btn_toggle_on_big" : "btn_toggle_off_big") .resizable() .frame(width: 44, height: 27) .onTapGesture { onTapToggle() } } .frame(height: 50) } }