feat(notification): 알림 수신 설정 페이지와 이동 경로를 추가한다
This commit is contained in:
@@ -113,3 +113,219 @@ struct NotificationSettingsView_Previews: PreviewProvider {
|
||||
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..<viewModel.creatorList.count, id: \.self) { index in
|
||||
let creator = viewModel.creatorList[index]
|
||||
|
||||
FollowCreatorItemView(
|
||||
creator: creator,
|
||||
onClickFollow: {
|
||||
viewModel.creatorFollow(creatorId: $0, index: index)
|
||||
},
|
||||
showCreatorFollowNotifyDialog: {
|
||||
creatorId = $0
|
||||
selectedItemIndex = index
|
||||
isShowFollowNotifyDialog = true
|
||||
}
|
||||
)
|
||||
.padding(.horizontal, 20)
|
||||
.onTapGesture {
|
||||
AppState.shared
|
||||
.setAppStep(step: .creatorDetail(userId: creator.creatorId))
|
||||
}
|
||||
.onAppear {
|
||||
if index == viewModel.creatorList.count - 1 {
|
||||
viewModel.getFollowedCreatorAllList()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 13.3)
|
||||
} else {
|
||||
Text("팔로우 중인 채널이 없습니다.")
|
||||
.appFont(size: 13.3, weight: .medium)
|
||||
.foregroundColor(Color.grayee)
|
||||
.padding(.top, 13.3)
|
||||
.padding(.horizontal, 20)
|
||||
}
|
||||
}
|
||||
.padding(.bottom, 20)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
if !isInitialized {
|
||||
viewModel.initialize()
|
||||
isInitialized = true
|
||||
}
|
||||
}
|
||||
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .top, autohideIn: 2) {
|
||||
GeometryReader { geo in
|
||||
HStack {
|
||||
Spacer()
|
||||
Text(viewModel.errorMessage)
|
||||
.padding(.vertical, 13.3)
|
||||
.padding(.horizontal, 6.7)
|
||||
.frame(width: geo.size.width - 66.7, alignment: .center)
|
||||
.appFont(size: 12, weight: .medium)
|
||||
.background(Color(hex: "3bb9f1"))
|
||||
.foregroundColor(Color.white)
|
||||
.multilineTextAlignment(.leading)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.cornerRadius(20)
|
||||
.padding(.top, 66.7)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if isShowFollowNotifyDialog {
|
||||
CreatorFollowNotifyDialog(
|
||||
isShowing: $isShowFollowNotifyDialog,
|
||||
onClickNotifyAll: {
|
||||
viewModel.creatorFollow(
|
||||
creatorId: creatorId,
|
||||
index: selectedItemIndex,
|
||||
follow: true,
|
||||
notify: true
|
||||
)
|
||||
creatorId = 0
|
||||
selectedItemIndex = -1
|
||||
},
|
||||
onClickNotifyNone: {
|
||||
viewModel.creatorFollow(
|
||||
creatorId: creatorId,
|
||||
index: selectedItemIndex,
|
||||
follow: true,
|
||||
notify: false
|
||||
)
|
||||
creatorId = 0
|
||||
selectedItemIndex = -1
|
||||
},
|
||||
onClickUnFollow: {
|
||||
viewModel.creatorFollow(
|
||||
creatorId: creatorId,
|
||||
index: selectedItemIndex,
|
||||
follow: false,
|
||||
notify: false
|
||||
)
|
||||
creatorId = 0
|
||||
selectedItemIndex = -1
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct NotificationReceiveServiceRowView: View {
|
||||
|
||||
let title: String
|
||||
let isOn: Bool
|
||||
let onTapToggle: () -> 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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user