Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
JMM00 committed Jun 24, 2023
1 parent bc869af commit 51b876d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
17 changes: 17 additions & 0 deletions Halmap/Persistence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ struct PersistenceController {
}
}

func createCollectedSong(song: SongInfo, playListTitle: String?) -> CollectedSong {
let context = container.viewContext
let collectedSong = CollectedSong(context: context)
collectedSong.id = song.id
collectedSong.title = song.title
collectedSong.info = song.info
collectedSong.lyrics = song.lyrics
collectedSong.url = song.url
collectedSong.type = song.type
collectedSong.playListTitle = playListTitle
collectedSong.team = song.team
collectedSong.date = Date()

print("collectedSong", collectedSong, song.title)
return collectedSong
}

func deleteSongs(song: CollectedSong) {

container.viewContext.delete(song)
Expand Down
7 changes: 6 additions & 1 deletion Halmap/View/HalfSheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ struct HalfSheetView: View {
@ObservedObject var collectedSong: CollectedSong
@State var songData: Song
@State var song: CollectedSong = CollectedSong()

var team: String
@Binding var showSheet: Bool

// @Binding var showSheet: Bool
@Binding var collectedSongData: CollectedSong?


var body: some View {
VStack(spacing: 0) {
HStack(spacing: 16) {
Expand Down Expand Up @@ -43,7 +48,7 @@ struct HalfSheetView: View {
Spacer()
}
.onAppear() {
print("****\(songData)")
print("****\(collectedSongData?.title)")
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions Halmap/View/MainSongListTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ struct MainSongListTabView: View {
@Environment(\.dismiss) private var sheetDismiss
@Environment(\.dismiss) private var navigationLinkDismiss

let persistence = PersistenceController.shared
@State var temp: CollectedSong?

init() {
Color.setColor(selectedTeam)
}
Expand Down Expand Up @@ -105,13 +108,16 @@ struct MainSongListTabView: View {
isActivateNavigationLink = false
sheetDismiss()

temp = persistence.createCollectedSong(song: songInfo, playListTitle: "playList")


} label: {
Image(systemName: "ellipsis").foregroundColor(.customDarkGray)
}
.sheet(isPresented: $isShowingSheet) {
HalfSheet{
let collectedSong = CollectedSong(context: viewContext)
HalfSheetView(collectedSong: collectedSong, songData: music, team: selectedTeam, showSheet: $isShowingSheet)
HalfSheetView(collectedSong: collectedSong, songData: music, team: selectedTeam, showSheet: $isShowingSheet, collectedSongData: $temp)
}
}
}.frame(width: 20, height: 20)
Expand Down Expand Up @@ -188,14 +194,16 @@ struct MainSongListTabView: View {
isShowingSheet = true
isActivateNavigationLink = false
sheetDismiss()

temp = persistence.createCollectedSong(song: songInfo, playListTitle: "playList")

} label: {
Image(systemName: "ellipsis").foregroundColor(.customDarkGray)
}
.sheet(isPresented: $isShowingSheet) {
HalfSheet{
let collectedSong = CollectedSong(context: viewContext)
HalfSheetView(collectedSong: collectedSong, songData: music, team: selectedTeam, showSheet: $isShowingSheet)
HalfSheetView(collectedSong: collectedSong, songData: music, team: selectedTeam, showSheet: $isShowingSheet, collectedSongData: $temp)
}
}
}.frame(width: 20, height: 20)
Expand Down

0 comments on commit 51b876d

Please sign in to comment.