Compare commits
9 Commits
f444f0bfb0
...
50e5f526a3
Author | SHA1 | Date |
---|---|---|
![]() |
50e5f526a3 | |
![]() |
bc970f56c8 | |
![]() |
cba7a1c3ba | |
![]() |
0de6111487 | |
![]() |
6c8f3eb8bb | |
![]() |
31696ce7da | |
![]() |
842cbc3073 | |
![]() |
ed4729ac11 | |
![]() |
d3ab1507a4 |
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.6 KiB |
21
SodaLive/Resources/Assets.xcassets/btn_following_no_alarm_big.imageset/Contents.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "btn_following_no_alarm_big.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 5.1 KiB |
21
SodaLive/Resources/Assets.xcassets/ic_avatar_unfollow.imageset/Contents.json
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "ic_avatar_unfollow.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
SodaLive/Resources/Assets.xcassets/ic_avatar_unfollow.imageset/ic_avatar_unfollow.png
vendored
Normal file
After Width: | Height: | Size: 502 B |
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "ic_notify_all.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
SodaLive/Resources/Assets.xcassets/ic_notify_all.imageset/ic_notify_all.png
vendored
Normal file
After Width: | Height: | Size: 793 B |
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "ic_notify_none.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
BIN
SodaLive/Resources/Assets.xcassets/ic_notify_none.imageset/ic_notify_none.png
vendored
Normal file
After Width: | Height: | Size: 1.2 KiB |
|
@ -356,7 +356,7 @@ struct ContentCreateView: View {
|
|||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
Text("미리듣기 시간을 직접 설정하지 않으면 콘텐츠 앞부분 30초가 자동으로 설정됩니다. 미리듣기의 시간제한은 없습니다.")
|
||||
Text("미리듣기 시간을 직접 설정하지 않으면 콘텐츠 앞부분 15초가 자동으로 설정됩니다. 미리듣기의 시간제한은 없습니다.")
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color(hex: "777777"))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
@ -387,7 +387,7 @@ struct ContentCreateView: View {
|
|||
.foregroundColor(Color(hex: "d2d2d2"))
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
TextField("00:00:30", text: $viewModel.previewEndTime)
|
||||
TextField("00:00:15", text: $viewModel.previewEndTime)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.font(.custom(Font.bold.rawValue, size: 14.6))
|
||||
|
|
|
@ -306,8 +306,8 @@ final class ContentCreateViewModel: ObservableObject {
|
|||
}
|
||||
|
||||
let timeDifference = timeDifference(startTime: previewStartTime, endTime: previewEndTime)
|
||||
if timeDifference < 30.0 {
|
||||
errorMessage = "미리 듣기의 최소 시간은 30초 입니다"
|
||||
if timeDifference < 15.0 {
|
||||
errorMessage = "미리 듣기의 최소 시간은 15초 입니다"
|
||||
isShowPopup = true
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ struct ContentDetailCreatorProfileView: View {
|
|||
|
||||
let creator: AudioContentCreator
|
||||
let onClickFollow: (Int) -> Void
|
||||
let onClickUnFollow: (Int) -> Void
|
||||
let showCreatorFollowNotifyDialog: (Int) -> Void
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
|
@ -29,14 +29,19 @@ struct ContentDetailCreatorProfileView: View {
|
|||
Spacer()
|
||||
|
||||
if creator.creatorId != UserDefaults.int(forKey: .userId) {
|
||||
Image(creator.isFollowing ? "btn_following_big" : "btn_follow_big")
|
||||
.onTapGesture {
|
||||
if creator.isFollowing {
|
||||
onClickUnFollow(creator.creatorId)
|
||||
} else {
|
||||
onClickFollow(creator.creatorId)
|
||||
}
|
||||
Image(creator.isFollow ?
|
||||
creator.isNotify ?
|
||||
"btn_following_big" :
|
||||
"btn_following_no_alarm_big" :
|
||||
"btn_follow_big"
|
||||
)
|
||||
.onTapGesture {
|
||||
if creator.isFollowing {
|
||||
showCreatorFollowNotifyDialog(creator.creatorId)
|
||||
} else {
|
||||
onClickFollow(creator.creatorId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,10 +91,10 @@ struct ContentDetailPlayView: View {
|
|||
.valueSliderStyle(
|
||||
HorizontalValueSliderStyle(
|
||||
track: HorizontalValueTrack(
|
||||
view: Rectangle().foregroundColor(Color(hex: "9970ff")),
|
||||
view: Rectangle().foregroundColor(Color.button),
|
||||
mask: Rectangle()
|
||||
)
|
||||
.background(Rectangle().foregroundColor(Color(hex: "979797").opacity(0.3)))
|
||||
.background(Rectangle().foregroundColor(Color.gray97.opacity(0.3)))
|
||||
.frame(height: 5.3),
|
||||
thumbSize: CGSizeZero,
|
||||
options: .interactiveTrack
|
||||
|
|
|
@ -19,6 +19,8 @@ struct ContentDetailView: View {
|
|||
@State private var isShowOrderView = false
|
||||
@State private var isShowOrderConfirmView = false
|
||||
@State private var isShowCommentListView = false
|
||||
@State private var isShowFollowNotifyDialog: Bool = false
|
||||
@State private var creatorId: Int = 0
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { proxy in
|
||||
|
@ -55,8 +57,11 @@ struct ContentDetailView: View {
|
|||
if let audioContent = viewModel.audioContent {
|
||||
ContentDetailCreatorProfileView(
|
||||
creator: audioContent.creator,
|
||||
onClickFollow: { viewModel.creatorFollow(userId: $0) },
|
||||
onClickUnFollow: { viewModel.creatorUnFollow(userId: $0) }
|
||||
onClickFollow: { viewModel.creatorFollow(creatorId: $0) },
|
||||
showCreatorFollowNotifyDialog: {
|
||||
creatorId = $0
|
||||
isShowFollowNotifyDialog = true
|
||||
}
|
||||
)
|
||||
.padding(.horizontal, 13.3)
|
||||
.padding(.top, 5.3)
|
||||
|
@ -347,6 +352,24 @@ struct ContentDetailView: View {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
if isShowFollowNotifyDialog {
|
||||
CreatorFollowNotifyDialog(
|
||||
isShowing: $isShowFollowNotifyDialog,
|
||||
onClickNotifyAll: {
|
||||
viewModel.creatorFollow(creatorId: creatorId, follow: true, notify: true)
|
||||
creatorId = 0
|
||||
},
|
||||
onClickNotifyNone: {
|
||||
viewModel.creatorFollow(creatorId: creatorId, follow: true, notify: false)
|
||||
creatorId = 0
|
||||
},
|
||||
onClickUnFollow: {
|
||||
viewModel.creatorFollow(creatorId: creatorId, follow: false, notify: false)
|
||||
creatorId = 0
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
.sheet(
|
||||
isPresented: $viewModel.isShowShareView,
|
||||
|
|
|
@ -87,10 +87,10 @@ final class ContentDetailViewModel: ObservableObject {
|
|||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func creatorFollow(userId: Int) {
|
||||
func creatorFollow(creatorId: Int, follow: Bool = true, notify: Bool = true) {
|
||||
isLoading = true
|
||||
|
||||
userRepository.creatorFollow(creatorId: userId)
|
||||
userRepository.creatorFollow(creatorId: creatorId, follow: follow, notify: notify)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
|
|
|
@ -55,4 +55,6 @@ struct AudioContentCreator: Decodable {
|
|||
let nickname: String
|
||||
let profileImageUrl: String
|
||||
let isFollowing: Bool
|
||||
let isFollow: Bool
|
||||
let isNotify: Bool
|
||||
}
|
||||
|
|
|
@ -34,4 +34,5 @@ struct GetSeriesDetailCreator: Decodable {
|
|||
let nickname: String
|
||||
let profileImage: String
|
||||
let isFollow: Bool
|
||||
let isNotify: Bool
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ struct SeriesDetailView: View {
|
|||
|
||||
let seriesId: Int
|
||||
|
||||
@State private var isShowFollowNotifyDialog: Bool = false
|
||||
@State private var creatorId: Int = 0
|
||||
|
||||
var body: some View {
|
||||
BaseView(isLoading: $viewModel.isLoading) {
|
||||
ZStack(alignment: .top) {
|
||||
|
@ -122,14 +125,21 @@ struct SeriesDetailView: View {
|
|||
Spacer()
|
||||
|
||||
if seriesDetail.creator.creatorId != UserDefaults.int(forKey: .userId) {
|
||||
Image(viewModel.isFollow ? "btn_following_big" : "btn_follow_big")
|
||||
.onTapGesture {
|
||||
if viewModel.isFollow {
|
||||
viewModel.unFollow(seriesDetail.creator.creatorId)
|
||||
} else {
|
||||
viewModel.follow(seriesDetail.creator.creatorId)
|
||||
}
|
||||
Image(
|
||||
viewModel.isFollow ?
|
||||
viewModel.isNotify ?
|
||||
"btn_following_big" :
|
||||
"btn_following_no_alarm_big" :
|
||||
"btn_follow_big"
|
||||
)
|
||||
.onTapGesture {
|
||||
if viewModel.isFollow {
|
||||
creatorId = seriesDetail.creator.creatorId
|
||||
isShowFollowNotifyDialog = true
|
||||
} else {
|
||||
viewModel.follow(seriesDetail.creator.creatorId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 16)
|
||||
|
@ -183,6 +193,24 @@ struct SeriesDetailView: View {
|
|||
.background(Color.gray11)
|
||||
}
|
||||
}
|
||||
|
||||
if isShowFollowNotifyDialog {
|
||||
CreatorFollowNotifyDialog(
|
||||
isShowing: $isShowFollowNotifyDialog,
|
||||
onClickNotifyAll: {
|
||||
viewModel.follow(creatorId, follow: true, notify: true)
|
||||
creatorId = 0
|
||||
},
|
||||
onClickNotifyNone: {
|
||||
viewModel.follow(creatorId, follow: true, notify: false)
|
||||
creatorId = 0
|
||||
},
|
||||
onClickUnFollow: {
|
||||
viewModel.follow(creatorId, follow: false, notify: false)
|
||||
creatorId = 0
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ final class SeriesDetailViewModel: ObservableObject {
|
|||
@Published var isShowPopup = false
|
||||
|
||||
@Published var isFollow: Bool = false
|
||||
@Published var isNotify: Bool = false
|
||||
@Published var seriesDetail: GetSeriesDetailResponse? = nil
|
||||
|
||||
var seriesId: Int = 0
|
||||
|
@ -44,6 +45,7 @@ final class SeriesDetailViewModel: ObservableObject {
|
|||
if let data = decoded.data, decoded.success {
|
||||
self.seriesDetail = data
|
||||
self.isFollow = data.creator.isFollow
|
||||
self.isNotify = data.creator.isNotify
|
||||
} else {
|
||||
if let message = decoded.message {
|
||||
self.errorMessage = message
|
||||
|
@ -63,10 +65,10 @@ final class SeriesDetailViewModel: ObservableObject {
|
|||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func follow(_ creatorId: Int) {
|
||||
func follow(_ creatorId: Int, follow: Bool = true, notify: Bool = true) {
|
||||
isLoading = true
|
||||
|
||||
userRepository.creatorFollow(creatorId: creatorId)
|
||||
userRepository.creatorFollow(creatorId: creatorId, follow: follow, notify: notify)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
|
@ -83,7 +85,8 @@ final class SeriesDetailViewModel: ObservableObject {
|
|||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||
|
||||
if decoded.success {
|
||||
self.isFollow = !self.isFollow
|
||||
self.isFollow = follow
|
||||
self.isNotify = notify
|
||||
} else {
|
||||
if let message = decoded.message {
|
||||
self.errorMessage = message
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
//
|
||||
// CreatorFollowNotifyDialog.swift
|
||||
// SodaLive
|
||||
//
|
||||
// Created by klaus on 9/23/24.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct CreatorFollowNotifyDialog: View {
|
||||
|
||||
@Binding var isShowing: Bool
|
||||
let onClickNotifyAll: () -> Void
|
||||
let onClickNotifyNone: () -> Void
|
||||
let onClickUnFollow: () -> Void
|
||||
|
||||
@State private var isShow: Bool = false
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Color.black.opacity(0.7).ignoresSafeArea()
|
||||
.onTapGesture {
|
||||
isShowing = false
|
||||
}
|
||||
|
||||
VStack(spacing: 0) {
|
||||
Spacer()
|
||||
|
||||
if isShow {
|
||||
VStack(alignment: .leading, spacing: 24) {
|
||||
Text("알림")
|
||||
.font(.custom(Font.bold.rawValue, size: 18.3))
|
||||
.foregroundColor(Color.grayee)
|
||||
|
||||
CreatorFollowNotifyItem(
|
||||
image: "ic_notify_all",
|
||||
title: "전체",
|
||||
onTapGesture: {
|
||||
isShowing = false
|
||||
onClickNotifyAll()
|
||||
}
|
||||
)
|
||||
CreatorFollowNotifyItem(
|
||||
image: "ic_notify_none",
|
||||
title: "없음",
|
||||
onTapGesture: {
|
||||
isShowing = false
|
||||
onClickNotifyNone()
|
||||
}
|
||||
)
|
||||
CreatorFollowNotifyItem(
|
||||
image: "ic_avatar_unfollow",
|
||||
title: "팔로우 취소",
|
||||
onTapGesture: {
|
||||
isShowing = false
|
||||
onClickUnFollow()
|
||||
}
|
||||
)
|
||||
}
|
||||
.frame(maxWidth:.infinity)
|
||||
.padding(.horizontal, 16)
|
||||
.padding(.top, 16)
|
||||
.padding(.bottom, 32)
|
||||
.background(Color.gray22)
|
||||
.cornerRadius(10, corners: [.topLeft, .topRight])
|
||||
.transition(.move(edge: .bottom))
|
||||
.animation(.easeInOut(duration: 0.5), value: isShow)
|
||||
}
|
||||
}
|
||||
.ignoresSafeArea()
|
||||
}
|
||||
.onAppear {
|
||||
withAnimation {
|
||||
isShow = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct CreatorFollowNotifyItem: View {
|
||||
|
||||
let image: String
|
||||
let title: String
|
||||
let onTapGesture: () -> Void
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 16) {
|
||||
Image(image)
|
||||
|
||||
Text(title)
|
||||
.font(.custom(Font.medium.rawValue, size: 13.3))
|
||||
.foregroundColor(Color.grayee)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture(perform: onTapGesture)
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
CreatorFollowNotifyDialog(
|
||||
isShowing: .constant(true),
|
||||
onClickNotifyAll: {},
|
||||
onClickNotifyNone: {},
|
||||
onClickUnFollow: {}
|
||||
)
|
||||
}
|
|
@ -12,7 +12,7 @@ struct FollowerListItemView: View {
|
|||
|
||||
let item: GetFollowerListResponseItem
|
||||
let creatorFollow: (Int) -> Void
|
||||
let creatorUnFollow: (Int) -> Void
|
||||
let showCreatorFollowNotifyDialog: (Int) -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 13.3) {
|
||||
|
@ -29,13 +29,18 @@ struct FollowerListItemView: View {
|
|||
|
||||
Spacer()
|
||||
|
||||
if let isFollow = item.isFollow {
|
||||
Image(isFollow ? "btn_following_big" : "btn_follow_big")
|
||||
.onTapGesture {
|
||||
isFollow ?
|
||||
creatorUnFollow(item.userId) :
|
||||
creatorFollow(item.userId)
|
||||
}
|
||||
if let isFollow = item.isFollow, let isNotify = item.isNotify {
|
||||
Image(isFollow ?
|
||||
isNotify ?
|
||||
"btn_following_big" :
|
||||
"btn_following_no_alarm_big" :
|
||||
"btn_follow_big"
|
||||
)
|
||||
.onTapGesture {
|
||||
isFollow ?
|
||||
showCreatorFollowNotifyDialog(item.userId) :
|
||||
creatorFollow(item.userId)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.top, 13.3)
|
||||
|
@ -59,7 +64,7 @@ struct FollowerListItemView_Previews: PreviewProvider {
|
|||
isFollow: false
|
||||
),
|
||||
creatorFollow: { _ in },
|
||||
creatorUnFollow: { _ in }
|
||||
showCreatorFollowNotifyDialog: { _ in }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,10 @@ struct FollowerListView: View {
|
|||
let userId: Int
|
||||
@StateObject var viewModel = FollowerListViewModel()
|
||||
|
||||
@State private var isShowFollowNotifyDialog: Bool = false
|
||||
@State private var creatorId: Int = 0
|
||||
@State private var selectedItemIndex: Int = 0
|
||||
|
||||
var body: some View {
|
||||
BaseView(isLoading: $viewModel.isLoading) {
|
||||
VStack(spacing: 0) {
|
||||
|
@ -20,11 +24,11 @@ struct FollowerListView: View {
|
|||
HStack(spacing: 4) {
|
||||
Text("전체")
|
||||
.font(.custom(Font.bold.rawValue, size: 18.3))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
.foregroundColor(Color.grayee)
|
||||
|
||||
Text("\(viewModel.totalCount)")
|
||||
.font(.custom(Font.medium.rawValue, size: 18.3))
|
||||
.foregroundColor(Color(hex: "9970ff"))
|
||||
.foregroundColor(Color.button)
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
@ -38,10 +42,12 @@ struct FollowerListView: View {
|
|||
FollowerListItemView(
|
||||
item: item,
|
||||
creatorFollow: {
|
||||
viewModel.creatorFollow(userId: $0)
|
||||
viewModel.creatorFollow(creatorId: $0, index: index)
|
||||
},
|
||||
creatorUnFollow: {
|
||||
viewModel.creatorUnFollow(userId: $0)
|
||||
showCreatorFollowNotifyDialog: {
|
||||
creatorId = $0
|
||||
selectedItemIndex = index
|
||||
isShowFollowNotifyDialog = true
|
||||
}
|
||||
)
|
||||
.onAppear {
|
||||
|
@ -55,6 +61,42 @@ struct FollowerListView: View {
|
|||
.padding(.bottom, 20)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
.popup(isPresented: $viewModel.isShowPopup, type: .toast, position: .bottom, autohideIn: 2) {
|
||||
HStack {
|
||||
|
@ -63,7 +105,7 @@ struct FollowerListView: View {
|
|||
.padding(.vertical, 13.3)
|
||||
.frame(width: screenSize().width - 66.7, alignment: .center)
|
||||
.font(.custom(Font.medium.rawValue, size: 12))
|
||||
.background(Color(hex: "9970ff"))
|
||||
.background(Color.button)
|
||||
.foregroundColor(Color.white)
|
||||
.multilineTextAlignment(.leading)
|
||||
.cornerRadius(20)
|
||||
|
|
|
@ -76,10 +76,10 @@ final class FollowerListViewModel: ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
func creatorFollow(userId: Int) {
|
||||
func creatorFollow(creatorId: Int, index: Int, follow: Bool = true, notify: Bool = true) {
|
||||
isLoading = true
|
||||
|
||||
userRepository.creatorFollow(creatorId: userId)
|
||||
userRepository.creatorFollow(creatorId: creatorId, follow: follow, notify: notify)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
|
@ -96,53 +96,11 @@ final class FollowerListViewModel: ObservableObject {
|
|||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||
|
||||
if decoded.success {
|
||||
self.isLast = false
|
||||
self.page = 1
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
self.getFollowerList()
|
||||
}
|
||||
} else {
|
||||
if let message = decoded.message {
|
||||
self.errorMessage = message
|
||||
} else {
|
||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||
}
|
||||
|
||||
self.isShowPopup = true
|
||||
}
|
||||
} catch {
|
||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||
self.isShowPopup = true
|
||||
}
|
||||
}
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func creatorUnFollow(userId: Int) {
|
||||
isLoading = true
|
||||
|
||||
userRepository.creatorUnFollow(creatorId: userId)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
DEBUG_LOG("finish")
|
||||
case .failure(let error):
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
}
|
||||
} receiveValue: { [unowned self] response in
|
||||
self.isLoading = false
|
||||
let responseData = response.data
|
||||
|
||||
do {
|
||||
let jsonDecoder = JSONDecoder()
|
||||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||
|
||||
if decoded.success {
|
||||
self.isLast = false
|
||||
self.page = 1
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
self.getFollowerList()
|
||||
}
|
||||
var follower = self.followerListItems[index]
|
||||
follower.isFollow = follow
|
||||
follower.isNotify = notify
|
||||
self.followerListItems.remove(at: index)
|
||||
self.followerListItems.insert(follower, at: index)
|
||||
} else {
|
||||
if let message = decoded.message {
|
||||
self.errorMessage = message
|
||||
|
|
|
@ -16,5 +16,6 @@ struct GetFollowerListResponseItem: Decodable {
|
|||
let userId: Int
|
||||
let profileImage: String
|
||||
let nickname: String
|
||||
let isFollow: Bool?
|
||||
var isFollow: Bool?
|
||||
var isNotify: Bool?
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ struct CreatorResponse: Decodable {
|
|||
let youtubeUrl: String?
|
||||
let websiteUrl: String?
|
||||
let blogUrl: String?
|
||||
let isFollow: Bool
|
||||
let isNotify: Bool
|
||||
let isNotification: Bool
|
||||
let notificationRecipientCount: Int
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ struct UserProfileCreatorView: View {
|
|||
let creator: CreatorResponse
|
||||
|
||||
let creatorFollow: () -> Void
|
||||
let creatorUnFollow: () -> Void
|
||||
let showCreatorFollowNotifyDialog: () -> Void
|
||||
let shareChannel: () -> Void
|
||||
|
||||
var body: some View {
|
||||
|
@ -57,12 +57,16 @@ struct UserProfileCreatorView: View {
|
|||
}
|
||||
} else {
|
||||
VStack(alignment: .leading, spacing: 9.3) {
|
||||
Image(creator.isNotification ? "btn_following_big" : "btn_follow_big")
|
||||
Image(
|
||||
creator.isFollow ?
|
||||
creator.isNotify ? "btn_following_big": "btn_following_no_alarm_big"
|
||||
: "btn_follow_big"
|
||||
)
|
||||
.resizable()
|
||||
.frame(width: 83.3, height: 26.7)
|
||||
.onTapGesture {
|
||||
if creator.isNotification {
|
||||
creatorUnFollow()
|
||||
if creator.isFollow {
|
||||
showCreatorFollowNotifyDialog()
|
||||
} else {
|
||||
creatorFollow()
|
||||
}
|
||||
|
@ -143,11 +147,13 @@ struct UserProfileCreatorView_Previews: PreviewProvider {
|
|||
youtubeUrl: Optional("https://www.youtube.com/watch?v=3x2tfZnfLRo"),
|
||||
websiteUrl: Optional("https://instagram.com/dear.zia"),
|
||||
blogUrl: Optional("dear.zia"),
|
||||
isFollow: false,
|
||||
isNotify: false,
|
||||
isNotification: false,
|
||||
notificationRecipientCount: 2
|
||||
)
|
||||
) {
|
||||
} creatorUnFollow: {
|
||||
} showCreatorFollowNotifyDialog: {
|
||||
} shareChannel: {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ struct UserProfileView: View {
|
|||
|
||||
@State private var memberId: Int = 0
|
||||
@State private var isShowMemberProfilePopup: Bool = false
|
||||
@State private var isShowFollowNotifyDialog: Bool = false
|
||||
|
||||
var body: some View {
|
||||
GeometryReader { proxy in
|
||||
|
@ -52,8 +53,8 @@ struct UserProfileView: View {
|
|||
UserProfileCreatorView(
|
||||
creator: creatorProfile.creator) {
|
||||
viewModel.creatorFollow()
|
||||
} creatorUnFollow: {
|
||||
viewModel.creatorUnFollow()
|
||||
} showCreatorFollowNotifyDialog: {
|
||||
isShowFollowNotifyDialog = true
|
||||
} shareChannel: {
|
||||
viewModel.shareChannel(userId: userId)
|
||||
}
|
||||
|
@ -323,6 +324,21 @@ struct UserProfileView: View {
|
|||
MemberProfileDialog(isShowing: $isShowMemberProfilePopup, memberId: memberId)
|
||||
}
|
||||
}
|
||||
|
||||
if isShowFollowNotifyDialog {
|
||||
CreatorFollowNotifyDialog(
|
||||
isShowing: $isShowFollowNotifyDialog,
|
||||
onClickNotifyAll: {
|
||||
viewModel.creatorFollow(follow: true, notify: true)
|
||||
},
|
||||
onClickNotifyNone: {
|
||||
viewModel.creatorFollow(follow: true, notify: false)
|
||||
},
|
||||
onClickUnFollow: {
|
||||
viewModel.creatorFollow(follow: false, notify: false)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
.sheet(
|
||||
isPresented: $viewModel.isShowShareView,
|
||||
|
|
|
@ -282,11 +282,11 @@ final class UserProfileViewModel: ObservableObject {
|
|||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func creatorFollow() {
|
||||
func creatorFollow(follow: Bool = true, notify: Bool = true) {
|
||||
if let creator = creatorProfile {
|
||||
isLoading = true
|
||||
|
||||
userRepository.creatorFollow(creatorId: creator.creator.creatorId)
|
||||
userRepository.creatorFollow(creatorId: creator.creator.creatorId, follow: follow, notify: notify)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
|
|
|
@ -12,9 +12,7 @@ struct FollowCreatorItemView: View {
|
|||
|
||||
let creator: GetCreatorFollowingAllListItem
|
||||
let onClickFollow: (Int) -> Void
|
||||
let onClickUnFollow: (Int) -> Void
|
||||
|
||||
@State private var isFollow = true
|
||||
let showCreatorFollowNotifyDialog: (Int) -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 13.3) {
|
||||
|
@ -26,29 +24,30 @@ struct FollowCreatorItemView: View {
|
|||
|
||||
Text(creator.nickname)
|
||||
.font(.custom(Font.bold.rawValue, size: 16.7))
|
||||
.foregroundColor(Color(hex: "eeeeee"))
|
||||
.foregroundColor(Color.grayee)
|
||||
.padding(.leading, 13.3)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(isFollow ? "btn_following_big" : "btn_follow_big")
|
||||
.onTapGesture {
|
||||
if isFollow {
|
||||
onClickUnFollow(creator.creatorId)
|
||||
} else {
|
||||
onClickFollow(creator.creatorId)
|
||||
}
|
||||
|
||||
isFollow = !isFollow
|
||||
Image(
|
||||
creator.isFollow ?
|
||||
creator.isNotify ?
|
||||
"btn_following_big" :
|
||||
"btn_following_no_alarm_big" :
|
||||
"btn_follow_big"
|
||||
)
|
||||
.onTapGesture {
|
||||
if creator.isFollow {
|
||||
showCreatorFollowNotifyDialog(creator.creatorId)
|
||||
} else {
|
||||
onClickFollow(creator.creatorId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle()
|
||||
.foregroundColor(Color(hex: "595959"))
|
||||
.foregroundColor(Color.gray59)
|
||||
.frame(height: 0.5)
|
||||
}
|
||||
.onAppear {
|
||||
isFollow = creator.isFollow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ struct FollowCreatorView: View {
|
|||
|
||||
@StateObject var viewModel = FollowCreatorViewModel()
|
||||
|
||||
@State private var isShowFollowNotifyDialog: Bool = false
|
||||
@State private var creatorId: Int = 0
|
||||
@State private var selectedItemIndex: Int = 0
|
||||
|
||||
var body: some View {
|
||||
BaseView(isLoading: $viewModel.isLoading) {
|
||||
VStack(spacing: 0) {
|
||||
|
@ -42,8 +46,14 @@ struct FollowCreatorView: View {
|
|||
|
||||
FollowCreatorItemView(
|
||||
creator: creator,
|
||||
onClickFollow: { viewModel.creatorFollow(userId: $0) },
|
||||
onClickUnFollow: { viewModel.creatorUnFollow(userId: $0) }
|
||||
onClickFollow: {
|
||||
viewModel.creatorFollow(creatorId: $0, index: index)
|
||||
},
|
||||
showCreatorFollowNotifyDialog: {
|
||||
creatorId = $0
|
||||
selectedItemIndex = index
|
||||
isShowFollowNotifyDialog = true
|
||||
}
|
||||
)
|
||||
.padding(.horizontal, 20)
|
||||
.onTapGesture {
|
||||
|
@ -84,6 +94,42 @@ struct FollowCreatorView: View {
|
|||
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
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,8 +80,9 @@ final class FollowCreatorViewModel: ObservableObject {
|
|||
}
|
||||
}
|
||||
|
||||
func creatorFollow(userId: Int) {
|
||||
userRepository.creatorFollow(creatorId: userId)
|
||||
func creatorFollow(creatorId: Int, index: Int, follow: Bool = true, notify: Bool = true) {
|
||||
isLoading = true
|
||||
userRepository.creatorFollow(creatorId: creatorId, follow: follow, notify: notify)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
|
@ -89,20 +90,34 @@ final class FollowCreatorViewModel: ObservableObject {
|
|||
case .failure(let error):
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
}
|
||||
} receiveValue: { _ in }
|
||||
.store(in: &subscription)
|
||||
}
|
||||
|
||||
func creatorUnFollow(userId: Int) {
|
||||
userRepository.creatorUnFollow(creatorId: userId)
|
||||
.sink { result in
|
||||
switch result {
|
||||
case .finished:
|
||||
DEBUG_LOG("finish")
|
||||
case .failure(let error):
|
||||
ERROR_LOG(error.localizedDescription)
|
||||
} receiveValue: { [unowned self] response in
|
||||
self.isLoading = false
|
||||
let responseData = response.data
|
||||
|
||||
do {
|
||||
let jsonDecoder = JSONDecoder()
|
||||
let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
|
||||
|
||||
if decoded.success {
|
||||
var creator = self.creatorList[index]
|
||||
creator.isFollow = follow
|
||||
creator.isNotify = notify
|
||||
self.creatorList.remove(at: index)
|
||||
self.creatorList.insert(creator, at: index)
|
||||
} else {
|
||||
if let message = decoded.message {
|
||||
self.errorMessage = message
|
||||
} else {
|
||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||
}
|
||||
|
||||
self.isShowPopup = true
|
||||
}
|
||||
} catch {
|
||||
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
|
||||
self.isShowPopup = true
|
||||
}
|
||||
} receiveValue: { _ in }
|
||||
}
|
||||
.store(in: &subscription)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,5 +16,6 @@ struct GetCreatorFollowingAllListItem: Decodable {
|
|||
let creatorId: Int
|
||||
let nickname: String
|
||||
let profileImageUrl: String
|
||||
let isFollow: Bool
|
||||
var isFollow: Bool
|
||||
var isNotify: Bool
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ struct SectionRecommendLiveView: View {
|
|||
HStack(spacing: 4) {
|
||||
ForEach(0..<items.count, id: \.self) { index in
|
||||
Capsule()
|
||||
.foregroundColor(index == currentIndex ? Color(hex: "3bb9f1") : Color(hex: "909090"))
|
||||
.foregroundColor(index == currentIndex ? Color.button : Color.gray90)
|
||||
.frame(
|
||||
width: index == currentIndex ? 18 : 6,
|
||||
height: 6
|
||||
|
|
|
@ -1958,6 +1958,8 @@ extension LiveRoomViewModel: AgoraRtmDelegate {
|
|||
)
|
||||
)
|
||||
|
||||
self.totalDonationCan += decoded.can
|
||||
|
||||
if let signature = decoded.signature {
|
||||
self.addSignature(signature: signature)
|
||||
} else if let imageUrl = decoded.signatureImageUrl {
|
||||
|
|
|
@ -9,4 +9,6 @@ import Foundation
|
|||
|
||||
struct CreatorFollowRequest: Encodable {
|
||||
let creatorId: Int
|
||||
var isNotify: Bool = true
|
||||
var isActive: Bool = true
|
||||
}
|
||||
|
|
|
@ -69,8 +69,8 @@ final class UserRepository {
|
|||
return api.requestPublisher(.updatePushToken(request: PushTokenUpdateRequest(pushToken: pushToken)))
|
||||
}
|
||||
|
||||
func creatorFollow(creatorId: Int) -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.creatorFollow(request: CreatorFollowRequest(creatorId: creatorId)))
|
||||
func creatorFollow(creatorId: Int, follow: Bool = true, notify: Bool = true) -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.creatorFollow(request: CreatorFollowRequest(creatorId: creatorId, isNotify: notify, isActive: follow)))
|
||||
}
|
||||
|
||||
func creatorUnFollow(creatorId: Int) -> AnyPublisher<Response, MoyaError> {
|
||||
|
|