From ed4729ac11add2fea8820dda94ae1688149bb7a7 Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Mon, 23 Sep 2024 16:39:18 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20-=20=ED=81=AC=EB=A6=AC=EC=97=90=EC=9D=B4=ED=84=B0?= =?UTF-8?q?=20=ED=8C=94=EB=A1=9C=EC=9A=B0=EC=99=80=20=EC=95=8C=EB=A6=BC?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20-=20=ED=8C=94=EB=A1=9C=EC=9E=89=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=EC=97=90=EC=84=9C=20=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=EC=BC=9C=EA=B8=B0/=EB=81=84=EA=B8=B0=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContentDetailCreatorProfileView.swift | 21 ++++++++----- .../Content/Detail/ContentDetailView.swift | 31 +++++++++++++++++-- .../Detail/ContentDetailViewModel.swift | 4 +-- .../GetAudioContentDetailResponse.swift | 2 ++ 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/SodaLive/Sources/Content/Detail/ContentDetailCreatorProfileView.swift b/SodaLive/Sources/Content/Detail/ContentDetailCreatorProfileView.swift index 60922af..ff8f30c 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailCreatorProfileView.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailCreatorProfileView.swift @@ -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) } + } } } } diff --git a/SodaLive/Sources/Content/Detail/ContentDetailView.swift b/SodaLive/Sources/Content/Detail/ContentDetailView.swift index a6787de..c18c379 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailView.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailView.swift @@ -19,6 +19,15 @@ struct ContentDetailView: View { @State private var isShowOrderView = false @State private var isShowOrderConfirmView = 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 { GeometryReader { proxy in @@ -55,8 +64,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 +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( isPresented: $viewModel.isShowShareView, diff --git a/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift b/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift index 5ef8374..89f1fa8 100644 --- a/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift +++ b/SodaLive/Sources/Content/Detail/ContentDetailViewModel.swift @@ -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: diff --git a/SodaLive/Sources/Content/Detail/GetAudioContentDetailResponse.swift b/SodaLive/Sources/Content/Detail/GetAudioContentDetailResponse.swift index 7fe75f6..36c2e8a 100644 --- a/SodaLive/Sources/Content/Detail/GetAudioContentDetailResponse.swift +++ b/SodaLive/Sources/Content/Detail/GetAudioContentDetailResponse.swift @@ -55,4 +55,6 @@ struct AudioContentCreator: Decodable { let nickname: String let profileImageUrl: String let isFollowing: Bool + let isFollow: Bool + let isNotify: Bool }