2020-02-19 23:00:23 +00:00
|
|
|
//
|
|
|
|
// PlaylistInputList.swift
|
2022-08-07 13:31:15 +01:00
|
|
|
// Mixonomer
|
2020-02-19 23:00:23 +00:00
|
|
|
//
|
|
|
|
// Created by Andy Pack on 19/02/2020.
|
|
|
|
// Copyright © 2020 Sarsoo. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
|
2020-03-07 18:51:52 +00:00
|
|
|
struct Name: Identifiable, Hashable {
|
2020-02-19 23:00:23 +00:00
|
|
|
var id = UUID()
|
|
|
|
var name: String
|
|
|
|
}
|
|
|
|
|
2022-08-13 22:07:59 +01:00
|
|
|
enum PlaylistInputType {
|
|
|
|
case MixonomerPlaylists
|
|
|
|
case SpotifyPlaylists
|
|
|
|
}
|
|
|
|
|
2020-02-19 23:00:23 +00:00
|
|
|
struct PlaylistInputList: View {
|
|
|
|
|
2020-03-20 00:08:18 +00:00
|
|
|
@Binding var names: [String]
|
2020-02-19 23:00:23 +00:00
|
|
|
var nameType: String
|
2022-08-13 22:07:59 +01:00
|
|
|
var type: PlaylistInputType
|
2020-02-19 23:00:23 +00:00
|
|
|
|
2022-08-13 22:07:59 +01:00
|
|
|
init(names: Binding<[String]>, nameType: String, type: PlaylistInputType){
|
2020-02-19 23:00:23 +00:00
|
|
|
self.nameType = nameType
|
2020-03-20 00:08:18 +00:00
|
|
|
self._names = names
|
2022-08-13 22:07:59 +01:00
|
|
|
self.type = type
|
2020-02-19 23:00:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var body: some View {
|
2020-03-07 18:51:52 +00:00
|
|
|
List{
|
|
|
|
Section(header: Image(systemName: "music.note")){ // Weird? added empty header as list renders with space for header then jumps up, not nice
|
|
|
|
if self.names.count > 0 {
|
|
|
|
ForEach(self.names, id: \.self){ name in
|
|
|
|
Text(name)
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
HStack {
|
|
|
|
Text("No Playlists")
|
|
|
|
.multilineTextAlignment(.center)
|
|
|
|
Spacer()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-02-19 23:00:23 +00:00
|
|
|
}
|
2020-03-07 18:51:52 +00:00
|
|
|
// .id(UUID())
|
|
|
|
.navigationBarTitle(nameType)
|
2022-08-13 22:07:59 +01:00
|
|
|
// .navigationBarItems(trailing:
|
|
|
|
// Button(
|
|
|
|
// action: {
|
|
|
|
//
|
|
|
|
// },
|
|
|
|
// label: { Image(systemName: "plus.circle") }
|
|
|
|
// )
|
|
|
|
// )
|
2020-02-19 23:00:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct PlaylistInputList_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
2020-03-20 00:08:18 +00:00
|
|
|
PlaylistInputList(names: .constant([
|
2020-02-19 23:00:23 +00:00
|
|
|
"name"
|
2022-08-13 22:07:59 +01:00
|
|
|
]), nameType: "Spotify Playlists", type: .MixonomerPlaylists)
|
2020-02-19 23:00:23 +00:00
|
|
|
}
|
|
|
|
}
|