Mixonomer-iOS/Mixonomer/Views/Settings/SettingsList.swift

132 lines
4.4 KiB
Swift
Raw Normal View History

//
// SettingsList.swift
2022-08-07 13:31:15 +01:00
// Mixonomer
//
// Created by Andy Pack on 20/02/2020.
// Copyright © 2020 Sarsoo. All rights reserved.
//
import SwiftUI
import KeychainAccess
struct SettingsList: View {
@EnvironmentObject var liveUser: LiveUser
2022-08-11 20:53:09 +01:00
@State private var deleteAlertShowing = false
var body: some View {
2022-12-09 08:51:42 +00:00
NavigationView {
List{
Section {
Button(action: {
2022-08-07 19:34:14 +01:00
if let url = URL(string: "https://mixonomer.sarsoo.xyz") {
UIApplication.shared.open(url)
}
}) {
Text("Launch Web Version")
}
2022-08-12 11:21:54 +01:00
Button(action: {
if let url = URL(string: "https://mixonomer.sarsoo.xyz/privacy") {
UIApplication.shared.open(url)
}
}) {
Text("Privacy Policy")
}
Button(action: {
2022-08-11 20:53:09 +01:00
self.liveUser.logout()
}) {
Text("Log out")
}
}
Section(header: Text("Integrations")) {
2022-12-09 08:51:42 +00:00
Toggle(isOn: self.$liveUser.user.spotify_linked) {
Text("Spotify Link")
}
2022-08-16 18:01:17 +01:00
.disabled(true)
2022-12-09 08:51:42 +00:00
NavigationLink("Last.fm") {
List{
TextField("Username", text: self.$liveUser.user.lastfm_username)
}
}
2022-08-16 18:01:17 +01:00
}
2022-12-09 08:51:42 +00:00
Section {
NavigationLink(destination: NotificationsControls()) {
HStack {
Text("Notifications")
}
}
}
2022-08-11 20:53:09 +01:00
Section {
Button(action: {
deleteAlertShowing = true
}) {
Text("Delete Account")
.foregroundColor(.red)
}
.alert("Delete Account", isPresented: $deleteAlertShowing, actions: {
Button("Delete", role: .destructive) {
2022-08-11 20:53:09 +01:00
let api = UserApi.deleteUser
RequestBuilder.buildRequest(apiRequest: api).responseJSON{ response in
if self.liveUser.check_network_response(response: response) {
2022-08-11 20:53:09 +01:00
self.liveUser.logout()
}
else {
2022-08-11 20:53:09 +01:00
}
}
2022-08-11 20:53:09 +01:00
}
}, message: {
Text("This is irreversible, are you sure you want to delete your account?")
})
}
Section(
header:
Text("Development"),
footer:
HStack{
Spacer()
Image("APFooter")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 100.0)
Spacer()
}
) {
Button(action: {
2022-08-07 13:31:15 +01:00
if let url = URL(string: "https://github.com/sarsoo/Mixonomer") {
UIApplication.shared.open(url)
}
}) {
Text("Server Source")
}
Button(action: {
2022-08-07 13:31:15 +01:00
if let url = URL(string: "https://github.com/sarsoo/Mixonomer-ios") {
UIApplication.shared.open(url)
}
}) {
Text("iOS Source")
}
}
}
.listStyle(GroupedListStyle())
2022-08-11 20:53:09 +01:00
.navigationBarTitle(Text("Settings ⚡️"))
}
}
}
struct SettingsList_Previews: PreviewProvider {
static var previews: some View {
SettingsList()
2022-12-09 08:51:42 +00:00
.environmentObject(LiveUser.get_preview_user())
}
}