From 6998d1b421491a09618cc17bb8d8a25078386857 Mon Sep 17 00:00:00 2001 From: Sue Cho Date: Wed, 9 Dec 2020 00:47:54 +0900 Subject: [PATCH] =?UTF-8?q?[iOS]Feat:=20UpNext=EC=9D=84=20=EB=B9=88=20?= =?UTF-8?q?=EB=B0=B0=EC=97=B4=EB=A1=9C=20=EC=8B=9C=EC=9E=91=ED=95=A0=20?= =?UTF-8?q?=EB=95=8C=20player=20=EC=83=81=ED=83=9C=20#345?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 플레이어 안열림 - user interaction disable 시킴 --- MiniVibe/MiniVibe/MainTab.swift | 4 +- MiniVibe/MiniVibe/Models/NowPlaying.swift | 3 ++ .../MiniVibe/Views/Common/PlayerPreview.swift | 39 +++++++++++++------ 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/MiniVibe/MiniVibe/MainTab.swift b/MiniVibe/MiniVibe/MainTab.swift index 7b31f00e..a23cd88e 100644 --- a/MiniVibe/MiniVibe/MainTab.swift +++ b/MiniVibe/MiniVibe/MainTab.swift @@ -53,7 +53,9 @@ struct MainTab: View { title: "Dynamite", artist: "방탄소년단") .onTapGesture { - nowPlaying.isPlayerPresented.toggle() + if !nowPlaying.upNext.isEmpty { + nowPlaying.isPlayerPresented.toggle() + } } .sheet(isPresented: $nowPlaying.isPlayerPresented) { PlayerView(title: "Dynamite", diff --git a/MiniVibe/MiniVibe/Models/NowPlaying.swift b/MiniVibe/MiniVibe/Models/NowPlaying.swift index ca6d66be..cc15f3ae 100644 --- a/MiniVibe/MiniVibe/Models/NowPlaying.swift +++ b/MiniVibe/MiniVibe/Models/NowPlaying.swift @@ -12,3 +12,6 @@ class NowPlaying: ObservableObject { @Published var isPlayerPresented: Bool = false @Published var upNext = [Track]() } + + +// 비어있다면? 기본 값을 보여주어야 하지 않을까 diff --git a/MiniVibe/MiniVibe/Views/Common/PlayerPreview.swift b/MiniVibe/MiniVibe/Views/Common/PlayerPreview.swift index 74aabdb4..20bf1990 100644 --- a/MiniVibe/MiniVibe/Views/Common/PlayerPreview.swift +++ b/MiniVibe/MiniVibe/Views/Common/PlayerPreview.swift @@ -10,21 +10,22 @@ import SwiftUI struct PlayerPreview: View { @EnvironmentObject private var nowPlaying: NowPlaying let coordinate: CGRect - let title: String - let artist: String + let title: String // 얘네도 실제로 값 받기 시작하면 + let artist: String // 바뀌겠지 private let height: CGFloat = 50 private let edgeInset = EdgeInsets(top: 5, leading: 10, bottom: 5, trailing: 10) var body: some View { VStack { HStack { - albumInfo + playingTrackInfo() Spacer() - - controlIcons + + previewControlIcons() + //controlIcons .font(.system(size: 20)) - .foregroundColor(.black) + //.foregroundColor(.black) } .frame(height: height) .padding(edgeInset) @@ -37,9 +38,15 @@ struct PlayerPreview: View { } - @ViewBuilder - var albumInfo: some View { - Image("album") + @ViewBuilder private func playingTrackInfo() -> some View { + var image: UIImage = UIImage(named: "placeholder") ?? UIImage() + var title: String = "What's on today?" + var artist: String = "Tap the play button" + if !nowPlaying.upNext.isEmpty { + // 현재 재생 곡에 해당하는 image, title, subtitle + } + + Image(uiImage: image) .resizable() .aspectRatio(1, contentMode: .fit) .frame(height: height) @@ -53,26 +60,34 @@ struct PlayerPreview: View { .foregroundColor(.secondary) } } - - var controlIcons: some View { - HStack(spacing: 20) { + + private func previewControlIcons() -> some View { + var emptyUpNext: Bool = nowPlaying.upNext.isEmpty + var iconColor: Color = emptyUpNext ? Color.secondary : Color.black + + return HStack(spacing: 20) { Button { nowPlaying.isPlaying.toggle() } label: { nowPlaying.isPlaying ? Image(systemName: "pause.fill") : Image(systemName: "play.fill") } + .foregroundColor(.black) Button { } label: { Image(systemName: "forward.fill") } + .disabled(emptyUpNext) + .foregroundColor(iconColor) Button { } label: { Image(systemName: "music.note.list") } + .disabled(emptyUpNext) + .foregroundColor(iconColor) } } }