Skip to content

Commit

Permalink
[iOS]Feat: UpNext을 빈 배열로 시작할 때 player 상태 #345
Browse files Browse the repository at this point in the history
- 플레이어 안열림
- user interaction disable 시킴
  • Loading branch information
Sueaty committed Dec 8, 2020
1 parent d3ae1c1 commit 6998d1b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
4 changes: 3 additions & 1 deletion MiniVibe/MiniVibe/MainTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions MiniVibe/MiniVibe/Models/NowPlaying.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ class NowPlaying: ObservableObject {
@Published var isPlayerPresented: Bool = false
@Published var upNext = [Track]()
}


// 비어있다면? 기본 값을 보여주어야 하지 않을까
39 changes: 27 additions & 12 deletions MiniVibe/MiniVibe/Views/Common/PlayerPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
}
}
}
Expand Down

0 comments on commit 6998d1b

Please sign in to comment.