parent
d3ab1507a4
commit
ed4729ac11
|
@ -12,7 +12,7 @@ struct ContentDetailCreatorProfileView: View {
|
||||||
|
|
||||||
let creator: AudioContentCreator
|
let creator: AudioContentCreator
|
||||||
let onClickFollow: (Int) -> Void
|
let onClickFollow: (Int) -> Void
|
||||||
let onClickUnFollow: (Int) -> Void
|
let showCreatorFollowNotifyDialog: (Int) -> Void
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
HStack(spacing: 0) {
|
HStack(spacing: 0) {
|
||||||
|
@ -29,14 +29,19 @@ struct ContentDetailCreatorProfileView: View {
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
if creator.creatorId != UserDefaults.int(forKey: .userId) {
|
if creator.creatorId != UserDefaults.int(forKey: .userId) {
|
||||||
Image(creator.isFollowing ? "btn_following_big" : "btn_follow_big")
|
Image(creator.isFollow ?
|
||||||
.onTapGesture {
|
creator.isNotify ?
|
||||||
if creator.isFollowing {
|
"btn_following_big" :
|
||||||
onClickUnFollow(creator.creatorId)
|
"btn_following_no_alarm_big" :
|
||||||
} else {
|
"btn_follow_big"
|
||||||
onClickFollow(creator.creatorId)
|
)
|
||||||
}
|
.onTapGesture {
|
||||||
|
if creator.isFollowing {
|
||||||
|
showCreatorFollowNotifyDialog(creator.creatorId)
|
||||||
|
} else {
|
||||||
|
onClickFollow(creator.creatorId)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,15 @@ struct ContentDetailView: View {
|
||||||
@State private var isShowOrderView = false
|
@State private var isShowOrderView = false
|
||||||
@State private var isShowOrderConfirmView = false
|
@State private var isShowOrderConfirmView = false
|
||||||
@State private var isShowCommentListView = false
|
@State private var isShowCommentListView = false
|
||||||
|
@State private var isShowFollowNotifyDialog: Bool = false {
|
||||||
|
didSet {
|
||||||
|
if !isShowFollowNotifyDialog {
|
||||||
|
creatorId = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@State private var creatorId: Int = 0
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
GeometryReader { proxy in
|
GeometryReader { proxy in
|
||||||
|
@ -55,8 +64,11 @@ struct ContentDetailView: View {
|
||||||
if let audioContent = viewModel.audioContent {
|
if let audioContent = viewModel.audioContent {
|
||||||
ContentDetailCreatorProfileView(
|
ContentDetailCreatorProfileView(
|
||||||
creator: audioContent.creator,
|
creator: audioContent.creator,
|
||||||
onClickFollow: { viewModel.creatorFollow(userId: $0) },
|
onClickFollow: { viewModel.creatorFollow(creatorId: $0) },
|
||||||
onClickUnFollow: { viewModel.creatorUnFollow(userId: $0) }
|
showCreatorFollowNotifyDialog: {
|
||||||
|
creatorId = $0
|
||||||
|
isShowFollowNotifyDialog = true
|
||||||
|
}
|
||||||
)
|
)
|
||||||
.padding(.horizontal, 13.3)
|
.padding(.horizontal, 13.3)
|
||||||
.padding(.top, 5.3)
|
.padding(.top, 5.3)
|
||||||
|
@ -347,6 +359,21 @@ struct ContentDetailView: View {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isShowFollowNotifyDialog {
|
||||||
|
CreatorFollowNotifyDialog(
|
||||||
|
isShowing: $isShowFollowNotifyDialog,
|
||||||
|
onClickNotifyAll: {
|
||||||
|
viewModel.creatorFollow(creatorId: creatorId, follow: true, notify: true)
|
||||||
|
},
|
||||||
|
onClickNotifyNone: {
|
||||||
|
viewModel.creatorFollow(creatorId: creatorId, follow: true, notify: false)
|
||||||
|
},
|
||||||
|
onClickUnFollow: {
|
||||||
|
viewModel.creatorFollow(creatorId: creatorId, follow: false, notify: false)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.sheet(
|
.sheet(
|
||||||
isPresented: $viewModel.isShowShareView,
|
isPresented: $viewModel.isShowShareView,
|
||||||
|
|
|
@ -87,10 +87,10 @@ final class ContentDetailViewModel: ObservableObject {
|
||||||
.store(in: &subscription)
|
.store(in: &subscription)
|
||||||
}
|
}
|
||||||
|
|
||||||
func creatorFollow(userId: Int) {
|
func creatorFollow(creatorId: Int, follow: Bool = true, notify: Bool = true) {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
|
|
||||||
userRepository.creatorFollow(creatorId: userId)
|
userRepository.creatorFollow(creatorId: creatorId, follow: follow, notify: notify)
|
||||||
.sink { result in
|
.sink { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .finished:
|
case .finished:
|
||||||
|
|
|
@ -55,4 +55,6 @@ struct AudioContentCreator: Decodable {
|
||||||
let nickname: String
|
let nickname: String
|
||||||
let profileImageUrl: String
|
let profileImageUrl: String
|
||||||
let isFollowing: Bool
|
let isFollowing: Bool
|
||||||
|
let isFollow: Bool
|
||||||
|
let isNotify: Bool
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue