diff --git a/SodaLive/Resources/Assets.xcassets/btn_radio_select_normal.imageset/btn_radio_select_normal.png b/SodaLive/Resources/Assets.xcassets/btn_radio_select_normal.imageset/btn_radio_select_normal.png index 40f508a..c27ca43 100644 Binary files a/SodaLive/Resources/Assets.xcassets/btn_radio_select_normal.imageset/btn_radio_select_normal.png and b/SodaLive/Resources/Assets.xcassets/btn_radio_select_normal.imageset/btn_radio_select_normal.png differ diff --git a/SodaLive/Resources/Assets.xcassets/btn_radio_select_selected.imageset/btn_radio_select_selected.png b/SodaLive/Resources/Assets.xcassets/btn_radio_select_selected.imageset/btn_radio_select_selected.png index 57f23d1..6f39bbc 100644 Binary files a/SodaLive/Resources/Assets.xcassets/btn_radio_select_selected.imageset/btn_radio_select_selected.png and b/SodaLive/Resources/Assets.xcassets/btn_radio_select_selected.imageset/btn_radio_select_selected.png differ diff --git a/SodaLive/Sources/App/AppState.swift b/SodaLive/Sources/App/AppState.swift index 5321177..b10c654 100644 --- a/SodaLive/Sources/App/AppState.swift +++ b/SodaLive/Sources/App/AppState.swift @@ -40,6 +40,8 @@ class AppState: ObservableObject { @Published var purchasedContentId = 0 @Published var purchasedContentOrderType = OrderType.KEEP + @Published var isChangeAdultContentVisible = false + func setAppStep(step: AppStep) { switch step { case .splash, .main: diff --git a/SodaLive/Sources/App/AppStep.swift b/SodaLive/Sources/App/AppStep.swift index 984b40c..352fc08 100644 --- a/SodaLive/Sources/App/AppStep.swift +++ b/SodaLive/Sources/App/AppStep.swift @@ -38,6 +38,8 @@ enum AppStep { case notificationSettings + case contentViewSettings + case signOut case canStatus(refresh: () -> Void) diff --git a/SodaLive/Sources/ContentView.swift b/SodaLive/Sources/ContentView.swift index f2b1e9a..a72f775 100644 --- a/SodaLive/Sources/ContentView.swift +++ b/SodaLive/Sources/ContentView.swift @@ -14,7 +14,11 @@ struct ContentView: View { ZStack { Color.black.ignoresSafeArea() - MainView() + if appState.isChangeAdultContentVisible { + EmptyView() + } else { + MainView() + } switch appState.appStep { case .splash: @@ -59,6 +63,9 @@ struct ContentView: View { case .notificationSettings: NotificationSettingsView() + case .contentViewSettings: + ContentSettingsView() + case .signOut: SignOutView() diff --git a/SodaLive/Sources/Extensions/UserDefaultsExtension.swift b/SodaLive/Sources/Extensions/UserDefaultsExtension.swift index 3570579..6545e6e 100644 --- a/SodaLive/Sources/Extensions/UserDefaultsExtension.swift +++ b/SodaLive/Sources/Extensions/UserDefaultsExtension.swift @@ -23,6 +23,8 @@ enum UserDefaultsKey: String, CaseIterable { case isFollowedChannel case isViewedOnboardingView case notShowingEventPopupId + case isAdultContentVisible + case contentPreference } extension UserDefaults { diff --git a/SodaLive/Sources/Settings/Content/ContentSettingsView.swift b/SodaLive/Sources/Settings/Content/ContentSettingsView.swift new file mode 100644 index 0000000..9ea9e7d --- /dev/null +++ b/SodaLive/Sources/Settings/Content/ContentSettingsView.swift @@ -0,0 +1,127 @@ +// +// ContentSettingsView.swift +// SodaLive +// +// Created by klaus on 10/10/24. +// + +import SwiftUI + +struct ContentSettingsView: View { + + @StateObject var viewModel = ContentSettingsViewModel() + + var body: some View { + ZStack { + Color.black.ignoresSafeArea() + + VStack(spacing: 0) { + DetailNavigationBar(title: "콘텐츠 보기 설정") { + if AppState.shared.isChangeAdultContentVisible { + AppState.shared.setAppStep(step: .splash) + } else { + AppState.shared.back() + } + } + + ScrollView(.vertical) { + VStack(spacing: 0) { + HStack(spacing: 0) { + Text("민감한 콘텐츠 보기") + .font(.custom(Font.bold.rawValue, size: 15)) + .foregroundColor(Color(hex: "eeeeee")) + + Spacer() + + Image(viewModel.isAdultContentVisible ? "btn_toggle_on_big" : "btn_toggle_off_big") + .resizable() + .frame(width: 44, height: 27) + .onTapGesture { + viewModel.isAdultContentVisible.toggle() + } + } + .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("전체") + .font(.custom(Font.medium.rawValue, size: 13.3)) + .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("남성향") + .font(.custom(Font.medium.rawValue, size: 13.3)) + .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("여성향") + .font(.custom(Font.medium.rawValue, size: 13.3)) + .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) + } + } + } + } +} + +#Preview { + ContentSettingsView() +} diff --git a/SodaLive/Sources/Settings/Content/ContentSettingsViewModel.swift b/SodaLive/Sources/Settings/Content/ContentSettingsViewModel.swift new file mode 100644 index 0000000..38888c4 --- /dev/null +++ b/SodaLive/Sources/Settings/Content/ContentSettingsViewModel.swift @@ -0,0 +1,33 @@ +// +// ContentSettingsViewModel.swift +// SodaLive +// +// Created by klaus on 10/10/24. +// + +import Foundation + +final class ContentSettingsViewModel: ObservableObject { + @Published var isAdultContentVisible = UserDefaults.bool(forKey: .isAdultContentVisible) { + didSet { + if oldValue != isAdultContentVisible { + UserDefaults.set(isAdultContentVisible, forKey: .isAdultContentVisible) + AppState.shared.isChangeAdultContentVisible = true + + if !isAdultContentVisible { + adultContentPreference = .ALL + UserDefaults.set(ContentType.ALL.rawValue, forKey: .contentPreference) + } + } + } + } + + @Published var adultContentPreference = ContentType(rawValue: UserDefaults.string(forKey: .contentPreference)) ?? ContentType.ALL { + didSet { + if oldValue != adultContentPreference { + UserDefaults.set(adultContentPreference.rawValue, forKey: .contentPreference) + AppState.shared.isChangeAdultContentVisible = true + } + } + } +} diff --git a/SodaLive/Sources/Settings/Content/ContentType.swift b/SodaLive/Sources/Settings/Content/ContentType.swift new file mode 100644 index 0000000..7873d5a --- /dev/null +++ b/SodaLive/Sources/Settings/Content/ContentType.swift @@ -0,0 +1,17 @@ +// +// ContentType.swift +// SodaLive +// +// Created by klaus on 10/10/24. +// + +enum ContentType: String, Codable { + // 전체 + case ALL + + // 남성향 + case MALE + + // 여성향 + case FEMALE +} diff --git a/SodaLive/Sources/Settings/SettingsView.swift b/SodaLive/Sources/Settings/SettingsView.swift index 8d336f0..0d52d49 100644 --- a/SodaLive/Sources/Settings/SettingsView.swift +++ b/SodaLive/Sources/Settings/SettingsView.swift @@ -89,6 +89,29 @@ struct SettingsView: View { .cornerRadius(6.7) .padding(.top, 26.7) + if UserDefaults.bool(forKey: .auth) { + HStack(spacing: 0) { + Text("콘텐츠 보기 설정") + .font(.custom(Font.bold.rawValue, size: 14.7)) + .foregroundColor(Color.grayee) + + Spacer() + + Image("ic_forward") + .resizable() + .frame(width: 20, height: 20) + } + .padding(.horizontal, 16.7) + .frame(width: cardWidth, height: 50) + .background(Color.gray22) + .cornerRadius(6.7) + .contentShape(Rectangle()) + .padding(.top, 13.3) + .onTapGesture { + AppState.shared.setAppStep(step: .contentViewSettings) + } + } + VStack(spacing: 0) { HStack(spacing: 0) { Text("이용약관") diff --git a/SodaLive/Sources/Splash/SplashView.swift b/SodaLive/Sources/Splash/SplashView.swift index a8796d3..e6456d7 100644 --- a/SodaLive/Sources/Splash/SplashView.swift +++ b/SodaLive/Sources/Splash/SplashView.swift @@ -58,6 +58,9 @@ struct SplashView: View { } } .onAppear { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { + AppState.shared.isChangeAdultContentVisible = false + } fetchLastestVersion() } }