// // ContentSettingsView.swift // SodaLive // // Created by klaus on 10/10/24. // import SwiftUI struct ContentSettingsView: View { @StateObject var viewModel = ContentSettingsViewModel() @ObservedObject private var appState = AppState.shared var body: some View { BaseView(isLoading: $viewModel.isLoading) { ZStack { Color.black.ignoresSafeArea() VStack(spacing: 0) { DetailNavigationBar(title: "콘텐츠 보기 설정") { if AppState.shared.isRestartApp { AppState.shared.setAppStep(step: .splash) } else { AppState.shared.back() } } ScrollView(.vertical) { VStack(spacing: 0) { HStack(spacing: 0) { Text("민감한 콘텐츠 보기") .appFont(size: 15, weight: .bold) .foregroundColor(Color(hex: "eeeeee")) Spacer() Image(viewModel.isAdultContentVisible ? "btn_toggle_on_big" : "btn_toggle_off_big") .resizable() .frame(width: 44, height: 27) .onTapGesture { viewModel.handleAdultContentToggleTap() } } .frame(height: 50) if viewModel.isAdultContentVisible { Rectangle() .frame(height: 1) .foregroundColor(Color.gray90.opacity(0.3)) HStack(spacing: 0) { HStack(spacing: 13.3) { Image( viewModel.adultContentPreference == .ALL ? "btn_radio_select_selected" : "btn_radio_select_normal" ) .resizable() .frame(width: 20, height: 20) Text("전체") .appFont(size: 13.3, weight: .medium) .foregroundColor(Color.grayee) } .contentShape(Rectangle()) .onTapGesture { viewModel.adultContentPreference = .ALL } Spacer() HStack(spacing: 13.3) { Image( viewModel.adultContentPreference == .MALE ? "btn_radio_select_selected" : "btn_radio_select_normal" ) .resizable() .frame(width: 20, height: 20) Text("남성향") .appFont(size: 13.3, weight: .medium) .foregroundColor(Color.grayee) } .contentShape(Rectangle()) .onTapGesture { viewModel.adultContentPreference = .MALE } Spacer() HStack(spacing: 13.3) { Image( viewModel.adultContentPreference == .FEMALE ? "btn_radio_select_selected" : "btn_radio_select_normal" ) .resizable() .frame(width: 20, height: 20) Text("여성향") .appFont(size: 13.3, weight: .medium) .foregroundColor(Color.grayee) } .contentShape(Rectangle()) .onTapGesture { viewModel.adultContentPreference = .FEMALE } Spacer() } .frame(height: 50) } } .padding(.vertical, 6.7) .padding(.horizontal, 13.3) .background(Color.gray22) .cornerRadius(10) .padding(.top, 13.3) .padding(.horizontal, 13.3) } } if viewModel.isShowAdultContentAgeCheckDialog { SodaDialog( title: I18n.Settings.adultContentAgeCheckTitle, desc: I18n.Settings.adultContentAgeCheckDesc, confirmButtonTitle: I18n.Common.yes, confirmButtonAction: { viewModel.confirmAdultContentAgeCheck() }, cancelButtonTitle: I18n.Common.no, cancelButtonAction: { viewModel.cancelAdultContentAgeCheck() } ) } } } .sodaToast(isPresented: $viewModel.isShowPopup, message: viewModel.errorMessage, autohideIn: 2) .onAppear { if let pendingGuideMessage = appState.consumePendingContentSettingsGuideMessage() { viewModel.errorMessage = pendingGuideMessage viewModel.isShowPopup = true } } } } #Preview { ContentSettingsView() }