Compare commits

...

9 Commits

Author SHA1 Message Date
Yu Sung 50e5f526a3 라이브 탭
- 추천라이브 캡슐 색상 변경
2024-09-24 14:01:30 +09:00
Yu Sung bc970f56c8 콘텐츠 상세
- 시간표시 슬라이더 색상변경
2024-09-24 13:58:55 +09:00
Yu Sung cba7a1c3ba 콘텐츠 업로드
- 미리듣기 최소시간 15초로 변경
2024-09-24 13:49:29 +09:00
Yu Sung 0de6111487 라이브 비밀후원
- 방장인 경우 비밀후원도 후원 총액에 반영되도록 수정
2024-09-24 12:14:59 +09:00
Yu Sung 6c8f3eb8bb 팔로잉/팔로워 리스트 - 팔로우와 알림설정
- 팔로잉 상태에서 알림 켜기/끄기 상태 추가
2024-09-23 17:54:35 +09:00
Yu Sung 31696ce7da 알림설정 화면이 닫힐 때 creatorId가 0으로 설정되면서 팔로잉과 알림설정이 되지 않는 버그 수정 2024-09-23 17:18:04 +09:00
Yu Sung 842cbc3073 시리즈 상세 - 크리에이터 팔로우와 알림설정
- 팔로잉 상태에서 알림 켜기/끄기 상태 추가
2024-09-23 16:57:22 +09:00
Yu Sung ed4729ac11 콘텐츠 상세 - 크리에이터 팔로우와 알림설정
- 팔로잉 상태에서 알림 켜기/끄기 상태 추가
2024-09-23 16:39:18 +09:00
Yu Sung d3ab1507a4 크리에이터 채널 - 팔로우와 알림설정
- 팔로잉 상태에서 알림 켜기/끄기 상태 추가
2024-09-23 15:19:15 +09:00
37 changed files with 489 additions and 140 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View 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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View 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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 502 B

View File

@ -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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 793 B

View File

@ -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
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -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))

View File

@ -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
}

View File

@ -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,10 +29,15 @@ struct ContentDetailCreatorProfileView: View {
Spacer()
if creator.creatorId != UserDefaults.int(forKey: .userId) {
Image(creator.isFollowing ? "btn_following_big" : "btn_follow_big")
Image(creator.isFollow ?
creator.isNotify ?
"btn_following_big" :
"btn_following_no_alarm_big" :
"btn_follow_big"
)
.onTapGesture {
if creator.isFollowing {
onClickUnFollow(creator.creatorId)
showCreatorFollowNotifyDialog(creator.creatorId)
} else {
onClickFollow(creator.creatorId)
}

View File

@ -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

View File

@ -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,

View File

@ -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:

View File

@ -55,4 +55,6 @@ struct AudioContentCreator: Decodable {
let nickname: String
let profileImageUrl: String
let isFollowing: Bool
let isFollow: Bool
let isNotify: Bool
}

View File

@ -34,4 +34,5 @@ struct GetSeriesDetailCreator: Decodable {
let nickname: String
let profileImage: String
let isFollow: Bool
let isNotify: Bool
}

View File

@ -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,10 +125,17 @@ struct SeriesDetailView: View {
Spacer()
if seriesDetail.creator.creatorId != UserDefaults.int(forKey: .userId) {
Image(viewModel.isFollow ? "btn_following_big" : "btn_follow_big")
Image(
viewModel.isFollow ?
viewModel.isNotify ?
"btn_following_big" :
"btn_following_no_alarm_big" :
"btn_follow_big"
)
.onTapGesture {
if viewModel.isFollow {
viewModel.unFollow(seriesDetail.creator.creatorId)
creatorId = seriesDetail.creator.creatorId
isShowFollowNotifyDialog = true
} else {
viewModel.follow(seriesDetail.creator.creatorId)
}
@ -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
}
)
}
}
}
}

View File

@ -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

View File

@ -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: {}
)
}

View File

@ -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,11 +29,16 @@ struct FollowerListItemView: View {
Spacer()
if let isFollow = item.isFollow {
Image(isFollow ? "btn_following_big" : "btn_follow_big")
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 ?
creatorUnFollow(item.userId) :
showCreatorFollowNotifyDialog(item.userId) :
creatorFollow(item.userId)
}
}
@ -59,7 +64,7 @@ struct FollowerListItemView_Previews: PreviewProvider {
isFollow: false
),
creatorFollow: { _ in },
creatorUnFollow: { _ in }
showCreatorFollowNotifyDialog: { _ in }
)
}
}

View File

@ -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)

View File

@ -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

View File

@ -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?
}

View File

@ -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
}

View File

@ -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: {
}
}

View File

@ -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,

View File

@ -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:

View File

@ -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")
Image(
creator.isFollow ?
creator.isNotify ?
"btn_following_big" :
"btn_following_no_alarm_big" :
"btn_follow_big"
)
.onTapGesture {
if isFollow {
onClickUnFollow(creator.creatorId)
if creator.isFollow {
showCreatorFollowNotifyDialog(creator.creatorId)
} else {
onClickFollow(creator.creatorId)
}
isFollow = !isFollow
}
}
Rectangle()
.foregroundColor(Color(hex: "595959"))
.foregroundColor(Color.gray59)
.frame(height: 0.5)
}
.onAppear {
isFollow = creator.isFollow
}
}
}

View File

@ -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
}
)
}
}
}
}

View File

@ -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)
} 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계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
}
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)
self.isShowPopup = true
}
} catch {
self.errorMessage = "다시 시도해 주세요.\n계속 같은 문제가 발생할 경우 고객센터로 문의 주시기 바랍니다."
self.isShowPopup = true
}
}
} receiveValue: { _ in }
.store(in: &subscription)
}
}

View File

@ -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
}

View File

@ -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

View File

@ -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 {

View File

@ -9,4 +9,6 @@ import Foundation
struct CreatorFollowRequest: Encodable {
let creatorId: Int
var isNotify: Bool = true
var isActive: Bool = true
}

View File

@ -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> {