2020-02-16 18:47:09 +00:00
|
|
|
//
|
2020-04-25 15:44:54 +01:00
|
|
|
// AppSkeleton.swift
|
2022-08-07 13:31:15 +01:00
|
|
|
// Mixonomer
|
2020-02-16 18:47:09 +00:00
|
|
|
//
|
|
|
|
// Created by Andy Pack on 16/02/2020.
|
|
|
|
// Copyright © 2020 Sarsoo. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
2020-02-18 01:44:30 +00:00
|
|
|
import Alamofire
|
2020-02-18 21:43:30 +00:00
|
|
|
import SwiftyJSON
|
2020-02-16 18:47:09 +00:00
|
|
|
|
2020-04-25 15:44:54 +01:00
|
|
|
struct AppSkeleton: View {
|
2020-02-19 23:00:23 +00:00
|
|
|
|
|
|
|
@EnvironmentObject var liveUser: LiveUser
|
|
|
|
|
2020-02-20 18:25:28 +00:00
|
|
|
@State private var selection = 0 // Tab view selection
|
2020-02-19 23:00:23 +00:00
|
|
|
|
2020-02-16 18:47:09 +00:00
|
|
|
var body: some View {
|
2020-04-25 15:44:54 +01:00
|
|
|
TabView {
|
2020-02-20 18:25:28 +00:00
|
|
|
|
2020-04-26 00:11:07 +01:00
|
|
|
PlaylistList()
|
|
|
|
.tabItem {
|
|
|
|
VStack {
|
|
|
|
Image(systemName: "music.note.list")
|
|
|
|
Text("Playlists")
|
2020-02-19 23:00:23 +00:00
|
|
|
}
|
2020-02-18 01:44:30 +00:00
|
|
|
}
|
2020-04-26 00:11:07 +01:00
|
|
|
.tag(0)
|
2020-02-20 18:25:28 +00:00
|
|
|
|
2022-08-14 13:14:21 +01:00
|
|
|
if liveUser.lastfm_connected() {
|
|
|
|
|
|
|
|
TagList()
|
|
|
|
.tabItem {
|
|
|
|
VStack {
|
|
|
|
Image(systemName: "tag")
|
|
|
|
Text("Tags")
|
2022-08-11 20:15:21 +01:00
|
|
|
}
|
2022-08-14 13:14:21 +01:00
|
|
|
}
|
|
|
|
.tag(1)
|
2022-08-11 20:15:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if let user = liveUser.user {
|
|
|
|
if user.type == .admin {
|
|
|
|
AdminList()
|
|
|
|
.tabItem( {
|
|
|
|
VStack {
|
|
|
|
Image(systemName: "person.badge.key.fill")
|
|
|
|
Text("Admin")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.tag(2)
|
2020-02-16 18:47:09 +00:00
|
|
|
}
|
2022-08-11 20:15:21 +01:00
|
|
|
}
|
2020-04-26 00:11:07 +01:00
|
|
|
|
|
|
|
SettingsList()
|
|
|
|
.tabItem {
|
|
|
|
VStack {
|
|
|
|
Image(systemName: "slider.horizontal.3")
|
|
|
|
Text("Settings")
|
2020-02-20 18:25:28 +00:00
|
|
|
}
|
2020-02-18 01:44:30 +00:00
|
|
|
}
|
2022-08-11 20:15:21 +01:00
|
|
|
.tag(3)
|
2020-02-20 18:25:28 +00:00
|
|
|
|
2020-02-18 01:44:30 +00:00
|
|
|
}.onAppear {
|
2020-02-22 13:28:15 +00:00
|
|
|
self.fetchAll()
|
2020-02-16 18:47:09 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-18 01:44:30 +00:00
|
|
|
|
2020-02-22 13:28:15 +00:00
|
|
|
private func fetchAll() {
|
2022-08-13 22:07:59 +01:00
|
|
|
self.liveUser.refresh_user()
|
|
|
|
self.liveUser.refresh_playlists()
|
|
|
|
self.liveUser.refresh_tags()
|
2020-02-18 01:44:30 +00:00
|
|
|
}
|
2020-02-16 18:47:09 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 02:21:49 +00:00
|
|
|
struct RootView_Previews: PreviewProvider {
|
2020-02-16 18:47:09 +00:00
|
|
|
static var previews: some View {
|
2020-04-25 15:44:54 +01:00
|
|
|
AppSkeleton()
|
2022-08-11 20:15:21 +01:00
|
|
|
.environmentObject(LiveUser(playlists: [], tags: [], username: "user", loggedIn: false))
|
2020-02-16 18:47:09 +00:00
|
|
|
}
|
|
|
|
}
|