parent
7481637fbb
commit
6d5257e1c0
21
SodaLive/Resources/Assets.xcassets/btn_audition_notification_normal.imageset/Contents.json
vendored
Normal file
21
SodaLive/Resources/Assets.xcassets/btn_audition_notification_normal.imageset/Contents.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "btn_audition_notification_normal.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 5.7 KiB |
21
SodaLive/Resources/Assets.xcassets/btn_audition_notification_selected.imageset/Contents.json
vendored
Normal file
21
SodaLive/Resources/Assets.xcassets/btn_audition_notification_selected.imageset/Contents.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "btn_audition_notification_selected.png",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
|
@ -10,11 +10,17 @@ import SwiftUI
|
||||||
struct AuditionView: View {
|
struct AuditionView: View {
|
||||||
|
|
||||||
@StateObject var viewModel = AuditionViewModel()
|
@StateObject var viewModel = AuditionViewModel()
|
||||||
|
@AppStorage("isAuditionNotification") private var isAuditionNotification: Bool = UserDefaults.bool(forKey: .isAuditionNotification)
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
BaseView(isLoading: $viewModel.isLoading) {
|
BaseView(isLoading: $viewModel.isLoading) {
|
||||||
VStack(spacing: 0) {
|
VStack(spacing: 0) {
|
||||||
HomeNavigationBar(title: "오디션") {}
|
HomeNavigationBar(title: "오디션") {
|
||||||
|
Image(isAuditionNotification ? "btn_audition_notification_selected" : "btn_audition_notification_normal")
|
||||||
|
.onTapGesture {
|
||||||
|
viewModel.updateNotificationSettings()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ScrollView(.vertical, showsIndicators: false) {
|
ScrollView(.vertical, showsIndicators: false) {
|
||||||
LazyVStack(alignment: .leading, spacing: 25) {
|
LazyVStack(alignment: .leading, spacing: 25) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import Combine
|
||||||
final class AuditionViewModel: ObservableObject {
|
final class AuditionViewModel: ObservableObject {
|
||||||
|
|
||||||
private let repository = AuditionRepository()
|
private let repository = AuditionRepository()
|
||||||
|
private let userRepository = UserRepository()
|
||||||
private var subscription = Set<AnyCancellable>()
|
private var subscription = Set<AnyCancellable>()
|
||||||
|
|
||||||
@Published var errorMessage = ""
|
@Published var errorMessage = ""
|
||||||
|
@ -80,4 +81,30 @@ final class AuditionViewModel: ObservableObject {
|
||||||
.store(in: &subscription)
|
.store(in: &subscription)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func updateNotificationSettings() {
|
||||||
|
let isAuditionNotification = UserDefaults.bool(forKey: .isAuditionNotification)
|
||||||
|
|
||||||
|
userRepository.updateNotificationSettings(audition: !isAuditionNotification)
|
||||||
|
.sink { result in
|
||||||
|
switch result {
|
||||||
|
case .finished:
|
||||||
|
DEBUG_LOG("finish")
|
||||||
|
case .failure(let error):
|
||||||
|
ERROR_LOG(error.localizedDescription)
|
||||||
|
}
|
||||||
|
} receiveValue: { response in
|
||||||
|
let responseData = response.data
|
||||||
|
|
||||||
|
do {
|
||||||
|
let jsonDecoder = JSONDecoder()
|
||||||
|
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||||
|
|
||||||
|
if decoded.success {
|
||||||
|
UserDefaults.set(!isAuditionNotification, forKey: .isAuditionNotification)
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
.store(in: &subscription)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ enum UserDefaultsKey: String, CaseIterable {
|
||||||
case notShowingEventPopupId
|
case notShowingEventPopupId
|
||||||
case isAdultContentVisible
|
case isAdultContentVisible
|
||||||
case contentPreference
|
case contentPreference
|
||||||
|
case isAuditionNotification
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UserDefaults {
|
extension UserDefaults {
|
||||||
|
|
|
@ -92,6 +92,7 @@ final class HomeViewModel: ObservableObject {
|
||||||
UserDefaults.set(data.can, forKey: .can)
|
UserDefaults.set(data.can, forKey: .can)
|
||||||
UserDefaults.set(data.isAuth, forKey: .auth)
|
UserDefaults.set(data.isAuth, forKey: .auth)
|
||||||
UserDefaults.set(data.role.rawValue, forKey: .role)
|
UserDefaults.set(data.role.rawValue, forKey: .role)
|
||||||
|
UserDefaults.set(data.auditionNotice ?? false, forKey: .isAuditionNotification)
|
||||||
if data.followingChannelLiveNotice == nil && data.followingChannelUploadContentNotice == nil && data.messageNotice == nil {
|
if data.followingChannelLiveNotice == nil && data.followingChannelUploadContentNotice == nil && data.messageNotice == nil {
|
||||||
AppState.shared.isShowNotificationSettingsDialog = true
|
AppState.shared.isShowNotificationSettingsDialog = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,5 @@ struct GetMemberInfoResponse: Decodable {
|
||||||
let messageNotice: Bool?
|
let messageNotice: Bool?
|
||||||
let followingChannelLiveNotice: Bool?
|
let followingChannelLiveNotice: Bool?
|
||||||
let followingChannelUploadContentNotice: Bool?
|
let followingChannelUploadContentNotice: Bool?
|
||||||
|
let auditionNotice: Bool?
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,5 @@ struct UpdateNotificationSettingRequest: Encodable {
|
||||||
var live: Bool? = nil
|
var live: Bool? = nil
|
||||||
var uploadContent: Bool? = nil
|
var uploadContent: Bool? = nil
|
||||||
var message: Bool? = nil
|
var message: Bool? = nil
|
||||||
|
var audition: Bool? = nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,13 +41,14 @@ final class UserRepository {
|
||||||
return api.requestPublisher(.getMemberInfo)
|
return api.requestPublisher(.getMemberInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateNotificationSettings(live: Bool? = nil, uploadContent: Bool? = nil, message: Bool? = nil) -> AnyPublisher<Response, MoyaError> {
|
func updateNotificationSettings(live: Bool? = nil, uploadContent: Bool? = nil, message: Bool? = nil, audition: Bool? = nil) -> AnyPublisher<Response, MoyaError> {
|
||||||
return api.requestPublisher(
|
return api.requestPublisher(
|
||||||
.notification(
|
.notification(
|
||||||
request: UpdateNotificationSettingRequest(
|
request: UpdateNotificationSettingRequest(
|
||||||
live: live,
|
live: live,
|
||||||
uploadContent: uploadContent,
|
uploadContent: uploadContent,
|
||||||
message: message
|
message: message,
|
||||||
|
audition: audition
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue