diff --git a/SodaLive/Sources/Content/Main/V2/ContentMainViewV2.swift b/SodaLive/Sources/Content/Main/V2/ContentMainViewV2.swift index 499341e..8d5c7bd 100644 --- a/SodaLive/Sources/Content/Main/V2/ContentMainViewV2.swift +++ b/SodaLive/Sources/Content/Main/V2/ContentMainViewV2.swift @@ -6,6 +6,7 @@ // import SwiftUI +import Kingfisher enum ContentMainTab { case HOME @@ -24,7 +25,11 @@ struct TabItem { struct ContentMainViewV2: View { + @StateObject var contentPlayManager = ContentPlayManager.shared + @StateObject var contentPlayerPlayManager = ContentPlayerPlayManager.shared + @State private var selectedTab: ContentMainTab = .SERIES + @State private var isShowPlayer = false let tabItemList = [ TabItem(title: "홈", tab: .HOME), @@ -127,6 +132,120 @@ struct ContentMainViewV2: View { ContentMainTabFreeView() } } + + Spacer() + + if contentPlayerPlayManager.isShowingMiniPlayer { + HStack(spacing: 0) { + KFImage(URL(string: contentPlayerPlayManager.coverImageUrl)) + .cancelOnDisappear(true) + .downsampling( + size: CGSize( + width: 36.7, + height: 36.7 + ) + ) + .resizable() + .frame(width: 36.7, height: 36.7) + .cornerRadius(5.3) + + VStack(alignment: .leading, spacing: 2.3) { + Text(contentPlayerPlayManager.title) + .font(.custom(Font.medium.rawValue, size: 13)) + .foregroundColor(Color.grayee) + .lineLimit(2) + + Text(contentPlayerPlayManager.nickname) + .font(.custom(Font.medium.rawValue, size: 11)) + .foregroundColor(Color.grayd2) + } + .padding(.horizontal, 10.7) + + Spacer() + + Image(contentPlayerPlayManager.isPlaying ? "ic_noti_pause" : "btn_bar_play") + .resizable() + .frame(width: 25, height: 25) + .onTapGesture { + contentPlayerPlayManager.playOrPause() + } + + Image("ic_noti_stop") + .resizable() + .frame(width: 25, height: 25) + .padding(.leading, 16) + .onTapGesture { contentPlayerPlayManager.resetPlayer() } + } + .padding(.vertical, 10.7) + .padding(.horizontal, 13.3) + .background(Color.gray22) + .contentShape(Rectangle()) + .onTapGesture { + isShowPlayer = true + } + } + + if contentPlayManager.isShowingMiniPlayer { + HStack(spacing: 0) { + KFImage(URL(string: contentPlayManager.coverImage)) + .cancelOnDisappear(true) + .downsampling( + size: CGSize( + width: 36.7, + height: 36.7 + ) + ) + .resizable() + .frame(width: 36.7, height: 36.7) + .cornerRadius(5.3) + + VStack(alignment: .leading, spacing: 2.3) { + Text(contentPlayManager.title) + .font(.custom(Font.medium.rawValue, size: 13)) + .foregroundColor(Color.grayee) + .lineLimit(2) + + Text(contentPlayManager.nickname) + .font(.custom(Font.medium.rawValue, size: 11)) + .foregroundColor(Color.grayd2) + } + .padding(.horizontal, 10.7) + + Spacer() + + Image(contentPlayManager.isPlaying ? "ic_noti_pause" : "btn_bar_play") + .resizable() + .frame(width: 25, height: 25) + .onTapGesture { + if contentPlayManager.isPlaying { + contentPlayManager.pauseAudio() + } else { + contentPlayManager + .playAudio(contentId: contentPlayManager.contentId) + } + } + + Image("ic_noti_stop") + .resizable() + .frame(width: 25, height: 25) + .padding(.leading, 16) + .onTapGesture { contentPlayManager.stopAudio() } + } + .padding(.vertical, 10.7) + .padding(.horizontal, 13.3) + .background(Color.gray22) + .contentShape(Rectangle()) + .onTapGesture { + AppState.shared + .setAppStep( + step: .contentDetail(contentId: contentPlayManager.contentId) + ) + } + } + } + + if isShowPlayer { + ContentPlayerView(isShowing: $isShowPlayer, playlist: []) } } .navigationBarHidden(true)