Skip to content

Commit

Permalink
[iOS] Feat: 곡 추가되는 형식 변경 #348
Browse files Browse the repository at this point in the history
- 트랙 id의 배열 -> NowPlaying.UpNextTrack 구조체 배열
  • Loading branch information
Sueaty committed Dec 8, 2020
1 parent fa91b17 commit 24e6c47
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 8 additions & 3 deletions MiniVibe/MiniVibe/Models/NowPlaying.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
import Foundation

class NowPlaying: ObservableObject {
struct UpNextTrack {
let id: Int
let title: String
let artist: Artist
let imageUrl: String
}

@Published var isPlaying: Bool = false
@Published var isPlayerPresented: Bool = false
@Published var upNext = [Int]() // Track.id
@Published var upNext = [UpNextTrack]()
}

// 비어있다면? 기본 값을 보여주어야 하지 않을까
5 changes: 4 additions & 1 deletion MiniVibe/MiniVibe/Views/Common/TrackRows/TrackRowB.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ struct TrackRowB: View {
.foregroundColor(.secondary)
}
.onTapGesture {
nowPlaying.upNext.append(track.id)
nowPlaying.upNext.append(NowPlaying.UpNextTrack(id: track.id,
title: track.title,
artist: track.artist,
imageUrl: track.album.imageUrl))
}

Spacer()
Expand Down
5 changes: 4 additions & 1 deletion MiniVibe/MiniVibe/Views/Player/UpNextList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ struct UpNextList: View {

@State private var isAutoPlay: Bool = true
@State private var editMode = EditMode.active
@EnvironmentObject private var nowPlaying: NowPlaying


@State private var tracks: [Item] = (0..<20).map {
Item(title: "Track #\($0)")
}
Expand All @@ -44,7 +47,7 @@ struct UpNextList: View {

VStack(spacing: 0) {
List(selection: $selectedTracks) {
ForEach(tracks, id: \.self) { track in
ForEach(nowPlaying.upNext, id: \.id) { track in
Text(track.title)
}
.onMove(perform: onMove(source:destination:))
Expand Down

0 comments on commit 24e6c47

Please sign in to comment.