2020-02-21 01:24:09 +00:00
|
|
|
//
|
|
|
|
// SettingsList.swift
|
2022-08-07 13:31:15 +01:00
|
|
|
// Mixonomer
|
2020-02-21 01:24:09 +00:00
|
|
|
//
|
|
|
|
// Created by Andy Pack on 20/02/2020.
|
|
|
|
// Copyright © 2020 Sarsoo. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import SwiftUI
|
|
|
|
import KeychainAccess
|
|
|
|
|
|
|
|
struct SettingsList: View {
|
2020-03-03 00:04:20 +00:00
|
|
|
|
2020-04-25 15:44:54 +01:00
|
|
|
@EnvironmentObject var liveUser: LiveUser
|
|
|
|
|
2022-08-11 20:53:09 +01:00
|
|
|
@State private var deleteAlertShowing = false
|
|
|
|
|
2020-02-21 01:24:09 +00:00
|
|
|
var body: some View {
|
2022-12-09 08:51:42 +00:00
|
|
|
NavigationView {
|
2020-04-26 00:11:07 +01:00
|
|
|
List{
|
|
|
|
Section {
|
|
|
|
Button(action: {
|
2022-08-07 19:34:14 +01:00
|
|
|
if let url = URL(string: "https://mixonomer.sarsoo.xyz") {
|
2020-04-26 00:11:07 +01:00
|
|
|
UIApplication.shared.open(url)
|
|
|
|
}
|
|
|
|
}) {
|
|
|
|
Text("Launch Web Version")
|
2020-03-08 00:47:35 +00:00
|
|
|
}
|
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")
|
|
|
|
}
|
2020-04-26 00:11:07 +01:00
|
|
|
Button(action: {
|
2022-08-11 20:53:09 +01:00
|
|
|
self.liveUser.logout()
|
2020-04-26 00:11:07 +01:00
|
|
|
}) {
|
|
|
|
Text("Log out")
|
2020-03-08 00:47:35 +00:00
|
|
|
}
|
2020-03-03 00:04:20 +00:00
|
|
|
}
|
2022-08-15 19:24:56 +01:00
|
|
|
|
2022-11-19 12:28:33 +00:00
|
|
|
Section(header: Text("Integrations")) {
|
2022-12-09 08:51:42 +00:00
|
|
|
Toggle(isOn: self.$liveUser.user.spotify_linked) {
|
2022-11-19 12:28:33 +00:00
|
|
|
Text("Spotify Link")
|
2022-08-15 19:24:56 +01:00
|
|
|
}
|
2022-08-16 18:01:17 +01:00
|
|
|
.disabled(true)
|
2022-11-19 12:28:33 +00:00
|
|
|
|
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-15 19:24:56 +01:00
|
|
|
|
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-11-19 12:28:33 +00:00
|
|
|
|
2022-08-11 20:53:09 +01:00
|
|
|
let api = UserApi.deleteUser
|
|
|
|
RequestBuilder.buildRequest(apiRequest: api).responseJSON{ response in
|
2022-11-19 12:28:33 +00:00
|
|
|
|
2022-08-13 22:07:59 +01:00
|
|
|
if self.liveUser.check_network_response(response: response) {
|
2022-11-19 12:28:33 +00:00
|
|
|
|
2022-08-11 20:53:09 +01:00
|
|
|
self.liveUser.logout()
|
|
|
|
}
|
|
|
|
else {
|
2022-11-19 12:28:33 +00:00
|
|
|
|
2022-08-11 20:53:09 +01:00
|
|
|
}
|
|
|
|
}
|
2022-11-19 12:28:33 +00:00
|
|
|
|
2022-08-11 20:53:09 +01:00
|
|
|
}
|
|
|
|
}, message: {
|
|
|
|
Text("This is irreversible, are you sure you want to delete your account?")
|
|
|
|
})
|
|
|
|
}
|
2020-04-26 00:11:07 +01:00
|
|
|
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") {
|
2020-04-26 00:11:07 +01:00
|
|
|
UIApplication.shared.open(url)
|
|
|
|
}
|
|
|
|
}) {
|
|
|
|
Text("Server Source")
|
2020-03-08 00:47:35 +00:00
|
|
|
}
|
2020-04-26 00:11:07 +01:00
|
|
|
Button(action: {
|
2022-08-07 13:31:15 +01:00
|
|
|
if let url = URL(string: "https://github.com/sarsoo/Mixonomer-ios") {
|
2020-04-26 00:11:07 +01:00
|
|
|
UIApplication.shared.open(url)
|
|
|
|
}
|
|
|
|
}) {
|
|
|
|
Text("iOS Source")
|
2020-03-08 00:47:35 +00:00
|
|
|
}
|
2020-02-21 01:24:09 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-26 00:11:07 +01:00
|
|
|
.listStyle(GroupedListStyle())
|
2022-08-11 20:53:09 +01:00
|
|
|
.navigationBarTitle(Text("Settings ⚡️"))
|
2020-03-03 00:04:20 +00:00
|
|
|
}
|
2020-02-21 01:24:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SettingsList_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
SettingsList()
|
2022-12-09 08:51:42 +00:00
|
|
|
.environmentObject(LiveUser.get_preview_user())
|
2020-02-21 01:24:09 +00:00
|
|
|
}
|
|
|
|
}
|