메인 - 회원정보 가져오기, 푸시토큰 업데이트, 이벤트 팝업 추가
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
//
|
||||
// NotificationSettingsDialog.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/11.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct NotificationSettingsDialog: View {
|
||||
|
||||
@StateObject var viewModel = NotificationSettingsDialogViewModel()
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { geo in
|
||||
ZStack {
|
||||
Color.black
|
||||
.opacity(0.5)
|
||||
.frame(width: geo.size.width, height: geo.size.height)
|
||||
|
||||
VStack(spacing: 0) {
|
||||
HStack(spacing: 0) {
|
||||
Text("라이브 알림")
|
||||
.font(.custom(Font.bold.rawValue, size: 15))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(viewModel.live ? "btn_toggle_on_big" : "btn_toggle_off_big")
|
||||
.resizable()
|
||||
.frame(width: 44, height: 27)
|
||||
.onTapGesture {
|
||||
viewModel.live.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle()
|
||||
.frame(height: 1)
|
||||
.foregroundColor(Color(hex: "909090"))
|
||||
.padding(.vertical, 13)
|
||||
|
||||
HStack(spacing: 0) {
|
||||
Text("콘텐츠 업로드 알림")
|
||||
.font(.custom(Font.bold.rawValue, size: 15))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(viewModel.uploadContent ? "btn_toggle_on_big" : "btn_toggle_off_big")
|
||||
.resizable()
|
||||
.frame(width: 44, height: 27)
|
||||
.onTapGesture {
|
||||
viewModel.uploadContent.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle()
|
||||
.frame(height: 1)
|
||||
.foregroundColor(Color(hex: "909090"))
|
||||
.padding(.vertical, 13)
|
||||
|
||||
HStack(spacing: 0) {
|
||||
Text("메시지 알림")
|
||||
.font(.custom(Font.bold.rawValue, size: 15))
|
||||
.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()
|
||||
}
|
||||
}
|
||||
|
||||
Text("확인")
|
||||
.font(.custom(Font.bold.rawValue, size: 15.3))
|
||||
.foregroundColor(Color(hex: "ffffff"))
|
||||
.padding(.vertical, 16)
|
||||
.frame(width: (geo.size.width - 66.7) * 2 / 3)
|
||||
.background(Color(hex: "9970ff"))
|
||||
.cornerRadius(8)
|
||||
.padding(.top, 33.3)
|
||||
.onTapGesture {
|
||||
viewModel.submit()
|
||||
}
|
||||
}
|
||||
.padding(26.7)
|
||||
.frame(width: geo.size.width - 26.7, alignment: .center)
|
||||
.background(Color(hex: "222222"))
|
||||
.cornerRadius(10)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct NotificationSettingsDialog_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
NotificationSettingsDialog()
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// NotificationSettingsDialogViewModel.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 2023/08/11.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Combine
|
||||
|
||||
final class NotificationSettingsDialogViewModel: ObservableObject {
|
||||
|
||||
private let userRepository = UserRepository()
|
||||
private var subscription = Set<AnyCancellable>()
|
||||
|
||||
@Published var live = true
|
||||
@Published var uploadContent = true
|
||||
@Published var message = true
|
||||
|
||||
func submit() {
|
||||
userRepository
|
||||
.updateNotificationSettings(live: live, uploadContent: uploadContent, message: message)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
DEBUG_LOG("finish")
|
||||
case .failure(let error):
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
}
|
||||
} receiveValue: { _ in
|
||||
AppState.shared.isShowNotificationSettingsDialog = false
|
||||
}
|
||||
.store(in: &subscription)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user