From 6d3929a173e07970e6057b5a54e57974c65d0dba Mon Sep 17 00:00:00 2001 From: aj Date: Sat, 25 Apr 2020 15:44:54 +0100 Subject: [PATCH] SwiftUI login screen with router view, updated tag icon --- Music Tools.xcodeproj/project.pbxproj | 28 +-- Music Tools/Application/Main.storyboard | 179 ------------------ Music Tools/Application/SceneDelegate.swift | 13 +- Music Tools/Controller/LoginController.swift | 96 ---------- Music Tools/Info.plist | 3 +- Music Tools/Model/LiveUser.swift | 10 +- Music Tools/Router.swift | 30 +++ .../{RootView.swift => AppSkeleton.swift} | 11 +- Music Tools/Views/LoginScreen.swift | 17 +- Music Tools/Views/Playlist/PlaylistView.swift | 1 - Music Tools/Views/Settings/SettingsList.swift | 5 + 11 files changed, 73 insertions(+), 320 deletions(-) delete mode 100644 Music Tools/Application/Main.storyboard delete mode 100644 Music Tools/Controller/LoginController.swift create mode 100644 Music Tools/Router.swift rename Music Tools/Views/{RootView.swift => AppSkeleton.swift} (97%) diff --git a/Music Tools.xcodeproj/project.pbxproj b/Music Tools.xcodeproj/project.pbxproj index f369bbf..be7a74b 100644 --- a/Music Tools.xcodeproj/project.pbxproj +++ b/Music Tools.xcodeproj/project.pbxproj @@ -11,16 +11,15 @@ E906F7F724143AA7004E1E31 /* SwiftUICharts in Frameworks */ = {isa = PBXBuildFile; productRef = E906F7F624143AA7004E1E31 /* SwiftUICharts */; }; E92F94822401412100B6B721 /* SwiftUIRefresh in Frameworks */ = {isa = PBXBuildFile; productRef = E92F94812401412100B6B721 /* SwiftUIRefresh */; }; E934AC99240DD0E4009869F4 /* AddTagSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = E934AC98240DD0E4009869F4 /* AddTagSheet.swift */; }; + E971F8B9245462D500B543B6 /* Router.swift in Sources */ = {isa = PBXBuildFile; fileRef = E971F8B8245462D500B543B6 /* Router.swift */; }; E97AF45623FC4E7800635494 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = E97AF45523FC4E7800635494 /* User.swift */; }; E97AF45923FC50EC00635494 /* SwiftyJSON in Frameworks */ = {isa = PBXBuildFile; productRef = E97AF45823FC50EC00635494 /* SwiftyJSON */; }; E97AF45B23FC748D00635494 /* UserApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = E97AF45A23FC748D00635494 /* UserApi.swift */; }; E97AF45E23FC83AF00635494 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = E97AF45D23FC83AF00635494 /* KeychainAccess */; }; E97AF46023FC85D600635494 /* PlaylistApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = E97AF45F23FC85D600635494 /* PlaylistApi.swift */; }; - E97AF46223FC89CC00635494 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E97AF46123FC89CB00635494 /* Main.storyboard */; }; E97AF46423FD4EEF00635494 /* LiveUser.swift in Sources */ = {isa = PBXBuildFile; fileRef = E97AF46323FD4EEF00635494 /* LiveUser.swift */; }; E97AF46723FD650800635494 /* AddPlaylistSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = E97AF46623FD650800635494 /* AddPlaylistSheet.swift */; }; E97AF46923FD9E1B00635494 /* PlaylistInputList.swift in Sources */ = {isa = PBXBuildFile; fileRef = E97AF46823FD9E1B00635494 /* PlaylistInputList.swift */; }; - E97AF46C23FDA90900635494 /* LoginController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E97AF46B23FDA90900635494 /* LoginController.swift */; }; E98254BD23F9B7A90056D9D3 /* Playlist.swift in Sources */ = {isa = PBXBuildFile; fileRef = E98254BC23F9B7A90056D9D3 /* Playlist.swift */; }; E98254C223F9FFF90056D9D3 /* PlaylistView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E98254C123F9FFF90056D9D3 /* PlaylistView.swift */; }; E98254CA23FA26600056D9D3 /* PlaylistRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = E98254C923FA26600056D9D3 /* PlaylistRow.swift */; }; @@ -35,7 +34,7 @@ E9E30C3323FF255C00574EEF /* SettingsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9E30C3223FF255C00574EEF /* SettingsList.swift */; }; E9EA690B23F9A5430012C3E8 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9EA690A23F9A5430012C3E8 /* AppDelegate.swift */; }; E9EA690D23F9A5430012C3E8 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9EA690C23F9A5430012C3E8 /* SceneDelegate.swift */; }; - E9EA690F23F9A5430012C3E8 /* RootView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9EA690E23F9A5430012C3E8 /* RootView.swift */; }; + E9EA690F23F9A5430012C3E8 /* AppSkeleton.swift in Sources */ = {isa = PBXBuildFile; fileRef = E9EA690E23F9A5430012C3E8 /* AppSkeleton.swift */; }; E9EA691123F9A54A0012C3E8 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E9EA691023F9A54A0012C3E8 /* Assets.xcassets */; }; E9EA691423F9A54B0012C3E8 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E9EA691323F9A54B0012C3E8 /* Preview Assets.xcassets */; }; E9EA691723F9A54B0012C3E8 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E9EA691523F9A54B0012C3E8 /* LaunchScreen.storyboard */; }; @@ -63,14 +62,13 @@ /* Begin PBXFileReference section */ E906F7F32414019C004E1E31 /* NetworkPersister.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkPersister.swift; sourceTree = ""; }; E934AC98240DD0E4009869F4 /* AddTagSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTagSheet.swift; sourceTree = ""; }; + E971F8B8245462D500B543B6 /* Router.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Router.swift; sourceTree = ""; }; E97AF45523FC4E7800635494 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = ""; }; E97AF45A23FC748D00635494 /* UserApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserApi.swift; sourceTree = ""; }; E97AF45F23FC85D600635494 /* PlaylistApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaylistApi.swift; sourceTree = ""; }; - E97AF46123FC89CB00635494 /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; E97AF46323FD4EEF00635494 /* LiveUser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiveUser.swift; sourceTree = ""; }; E97AF46623FD650800635494 /* AddPlaylistSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddPlaylistSheet.swift; sourceTree = ""; }; E97AF46823FD9E1B00635494 /* PlaylistInputList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaylistInputList.swift; sourceTree = ""; }; - E97AF46B23FDA90900635494 /* LoginController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginController.swift; sourceTree = ""; }; E98254BC23F9B7A90056D9D3 /* Playlist.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Playlist.swift; sourceTree = ""; }; E98254C123F9FFF90056D9D3 /* PlaylistView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaylistView.swift; sourceTree = ""; }; E98254C923FA26600056D9D3 /* PlaylistRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaylistRow.swift; sourceTree = ""; }; @@ -85,7 +83,7 @@ E9EA690723F9A5430012C3E8 /* Music Tools.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Music Tools.app"; sourceTree = BUILT_PRODUCTS_DIR; }; E9EA690A23F9A5430012C3E8 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; E9EA690C23F9A5430012C3E8 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - E9EA690E23F9A5430012C3E8 /* RootView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootView.swift; sourceTree = ""; }; + E9EA690E23F9A5430012C3E8 /* AppSkeleton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSkeleton.swift; sourceTree = ""; }; E9EA691023F9A54A0012C3E8 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; E9EA691323F9A54B0012C3E8 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; E9EA691623F9A54B0012C3E8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; @@ -128,14 +126,6 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - E97AF46A23FDA8ED00635494 /* Controller */ = { - isa = PBXGroup; - children = ( - E97AF46B23FDA90900635494 /* LoginController.swift */, - ); - path = Controller; - sourceTree = ""; - }; E98254BE23F9BD540056D9D3 /* Model */ = { isa = PBXGroup; children = ( @@ -165,7 +155,7 @@ E9E30C3423FF256100574EEF /* Settings */, E9E30C2F23FEACF700574EEF /* Tag */, E9E30C2E23FEACDE00574EEF /* Playlist */, - E9EA690E23F9A5430012C3E8 /* RootView.swift */, + E9EA690E23F9A5430012C3E8 /* AppSkeleton.swift */, E98254CF23FB00B60056D9D3 /* LoginScreen.swift */, ); path = Views; @@ -177,7 +167,6 @@ E9EA691523F9A54B0012C3E8 /* LaunchScreen.storyboard */, E9EA690A23F9A5430012C3E8 /* AppDelegate.swift */, E9EA690C23F9A5430012C3E8 /* SceneDelegate.swift */, - E97AF46123FC89CB00635494 /* Main.storyboard */, ); path = Application; sourceTree = ""; @@ -237,12 +226,12 @@ children = ( E98254C623FA25280056D9D3 /* Application */, E9EA691023F9A54A0012C3E8 /* Assets.xcassets */, - E97AF46A23FDA8ED00635494 /* Controller */, E9EA691823F9A54B0012C3E8 /* Info.plist */, E98254BE23F9BD540056D9D3 /* Model */, E98254BF23F9BE040056D9D3 /* Network */, E9EA691223F9A54B0012C3E8 /* Preview Content */, E98254C023F9FFDD0056D9D3 /* Views */, + E971F8B8245462D500B543B6 /* Router.swift */, ); path = "Music Tools"; sourceTree = ""; @@ -394,7 +383,6 @@ E9EA691723F9A54B0012C3E8 /* LaunchScreen.storyboard in Resources */, E9EA691423F9A54B0012C3E8 /* Preview Assets.xcassets in Resources */, E9EA691123F9A54A0012C3E8 /* Assets.xcassets in Resources */, - E97AF46223FC89CC00635494 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -430,11 +418,11 @@ E9EA690D23F9A5430012C3E8 /* SceneDelegate.swift in Sources */, E98254DB23FB64740056D9D3 /* Network.swift in Sources */, E9E30C2A23FEAA3A00574EEF /* TagRow.swift in Sources */, - E97AF46C23FDA90900635494 /* LoginController.swift in Sources */, E97AF46023FC85D600635494 /* PlaylistApi.swift in Sources */, - E9EA690F23F9A5430012C3E8 /* RootView.swift in Sources */, + E9EA690F23F9A5430012C3E8 /* AppSkeleton.swift in Sources */, E98254BD23F9B7A90056D9D3 /* Playlist.swift in Sources */, E97AF46723FD650800635494 /* AddPlaylistSheet.swift in Sources */, + E971F8B9245462D500B543B6 /* Router.swift in Sources */, E98254C223F9FFF90056D9D3 /* PlaylistView.swift in Sources */, E97AF46423FD4EEF00635494 /* LiveUser.swift in Sources */, E97AF45623FC4E7800635494 /* User.swift in Sources */, diff --git a/Music Tools/Application/Main.storyboard b/Music Tools/Application/Main.storyboard deleted file mode 100644 index 44c9c72..0000000 --- a/Music Tools/Application/Main.storyboard +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Music Tools/Application/SceneDelegate.swift b/Music Tools/Application/SceneDelegate.swift index 627d7d1..68997fc 100644 --- a/Music Tools/Application/SceneDelegate.swift +++ b/Music Tools/Application/SceneDelegate.swift @@ -20,7 +20,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). // Create the SwiftUI view that provides the window contents. - let contentView = RootView() + let contentView = Router() let keychain = Keychain(service: "xyz.sarsoo.music.login") @@ -28,17 +28,10 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { if let windowScene = scene as? UIWindowScene { let window = UIWindow(windowScene: windowScene) - var controller: UIViewController - if keychain["username"] != nil && keychain["password"] != nil { - let liveUser = LiveUser(playlists: [], tags: [], username: keychain["username"]!).loadUserDefaults() - controller = UIHostingController(rootView: contentView.environmentObject(liveUser)) - } else { - let storyboard = UIStoryboard(name: "Main", bundle: nil) - controller = storyboard.instantiateInitialViewController()! - } + let liveUser = LiveUser(playlists: [], tags: [], username: keychain["username"] ?? "", loggedIn: false).loadUserDefaults() - window.rootViewController = controller + window.rootViewController = UIHostingController(rootView: contentView.environmentObject(liveUser)) // window.rootViewController = UIHostingController(rootView: contentView.environmentObject(liveUser)) // window.rootViewController = LoginController() self.window = window diff --git a/Music Tools/Controller/LoginController.swift b/Music Tools/Controller/LoginController.swift deleted file mode 100644 index 38a0e3c..0000000 --- a/Music Tools/Controller/LoginController.swift +++ /dev/null @@ -1,96 +0,0 @@ -// -// LoginController.swift -// Music Tools -// -// Created by Ellie McCarthy on 19/02/2020. -// Copyright © 2020 Sarsoo. All rights reserved. -// - -import UIKit -import SwiftUI -import KeychainAccess - -class LoginController: UIViewController, UITextFieldDelegate { - - // MARK: Properties - - @IBOutlet weak var usernameField: UITextField! - @IBOutlet weak var passwordField: UITextField! - @IBOutlet weak var goButton: UIButton! - - - override func viewDidLoad() { - super.viewDidLoad() - - // Do any additional setup after loading the view. - } - - // MARK: Actions - @IBSegueAction func returnUIView(_ coder: NSCoder) -> UIViewController? { - // TODO add right username - let liveUser = LiveUser(playlists: [], tags: [], username: "") - return UIHostingController(coder: coder, rootView: RootView().environmentObject(liveUser)) - } - - var isLoggedIn: Bool? = nil { - didSet { - if self.isLoggedIn == true { - self.performSegue(withIdentifier: "loginToMain", sender: self) - } else if self.isLoggedIn == false { - debugPrint("false logged in") - self.isLoggedIn = nil - } else { - debugPrint("nil state") - } - } - } - - @IBAction func doLogin(_ sender: Any) { - - let keychain = Keychain(service: "xyz.sarsoo.music.login") - keychain["username"] = usernameField.text - keychain["password"] = passwordField.text - - let api = UserApi.getUser - RequestBuilder.buildRequest(apiRequest: api).responseJSON{ response in - - switch response.result { - case .success: - self.isLoggedIn = true - break - case .failure(let error): - debugPrint("error: \(error)") - self.isLoggedIn = false - do { - try keychain.remove("username") - try keychain.remove("password") - } catch let error { - debugPrint("Could not clear keychain, \(error)") - } - break - } - } - } - - // block initial segue from button presson - override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool { return false } - - // MARK: UITextFieldDelegate - - func textFieldShouldReturn(_ textField: UITextField) -> Bool { - textField.resignFirstResponder() - return true - } - - - /* - // MARK: - Navigation - - // In a storyboard-based application, you will often want to do a little preparation before navigation - override func prepare(for segue: UIStoryboardSegue, sender: Any?) { - // Get the new view controller using segue.destination. - // Pass the selected object to the new view controller. - } - */ - -} diff --git a/Music Tools/Info.plist b/Music Tools/Info.plist index 5cf13e5..d9d3b42 100644 --- a/Music Tools/Info.plist +++ b/Music Tools/Info.plist @@ -39,8 +39,6 @@ UILaunchStoryboardName LaunchScreen - UIMainStoryboardFile - Main UIRequiredDeviceCapabilities armv7 @@ -60,6 +58,7 @@ UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + UIInterfaceOrientationPortraitUpsideDown UISupportedInterfaceOrientations~ipad diff --git a/Music Tools/Model/LiveUser.swift b/Music Tools/Model/LiveUser.swift index c76aec1..dbf6f0b 100644 --- a/Music Tools/Model/LiveUser.swift +++ b/Music Tools/Model/LiveUser.swift @@ -16,13 +16,20 @@ class LiveUser: ObservableObject { @Published var tags: [Tag] @Published var username: String + @Published var loggedIn: Bool { + didSet { + UserDefaults.standard.set(loggedIn, forKey: "loggedIn") + } + } + @Published var isRefreshingPlaylists = false @Published var isRefreshingTags = false - init(playlists: [Playlist], tags: [Tag], username: String) { + init(playlists: [Playlist], tags: [Tag], username: String, loggedIn: Bool) { self.playlists = playlists self.tags = tags self.username = username + self.loggedIn = loggedIn } func updatePlaylist(playlistIn: Playlist) { @@ -98,6 +105,7 @@ class LiveUser: ObservableObject { let _strPlaylists = defaults.string(forKey: "playlists") let _strTags = defaults.string(forKey: "tags") + loggedIn = defaults.bool(forKey: "loggedIn") do { if let _strPlaylists = _strPlaylists { diff --git a/Music Tools/Router.swift b/Music Tools/Router.swift new file mode 100644 index 0000000..baef478 --- /dev/null +++ b/Music Tools/Router.swift @@ -0,0 +1,30 @@ +// +// Router.swift +// Music Tools +// +// Created by Andy Pack on 25/04/2020. +// Copyright © 2020 Sarsoo. All rights reserved. +// + +import SwiftUI + +struct Router: View { + + @EnvironmentObject var liveUser: LiveUser + + @ViewBuilder + var body: some View { + if liveUser.loggedIn { + AppSkeleton() + } + else { + LoginScreen() + } + } +} + +struct Router_Previews: PreviewProvider { + static var previews: some View { + Router() + } +} diff --git a/Music Tools/Views/RootView.swift b/Music Tools/Views/AppSkeleton.swift similarity index 97% rename from Music Tools/Views/RootView.swift rename to Music Tools/Views/AppSkeleton.swift index a81cca6..de5278b 100644 --- a/Music Tools/Views/RootView.swift +++ b/Music Tools/Views/AppSkeleton.swift @@ -1,5 +1,5 @@ // -// RootView.swift +// AppSkeleton.swift // Music Tools // // Created by Andy Pack on 16/02/2020. @@ -11,16 +11,15 @@ import SwiftUIRefresh import Alamofire import SwiftyJSON -struct RootView: View { +struct AppSkeleton: View { @EnvironmentObject var liveUser: LiveUser @State private var selection = 0 // Tab view selection - @State private var showAdd = false // State for showing add modal view var body: some View { - TabView { + TabView { // PLAYLISTS NavigationView { @@ -114,7 +113,7 @@ struct RootView: View { } .tabItem { VStack { - Image(systemName: "sum") + Image(systemName: "tag") Text("Tags") } } @@ -144,6 +143,6 @@ struct RootView: View { struct RootView_Previews: PreviewProvider { static var previews: some View { - RootView() + AppSkeleton() } } diff --git a/Music Tools/Views/LoginScreen.swift b/Music Tools/Views/LoginScreen.swift index 25b3664..aa9b97f 100644 --- a/Music Tools/Views/LoginScreen.swift +++ b/Music Tools/Views/LoginScreen.swift @@ -9,9 +9,15 @@ import SwiftUI struct LoginScreen: View { + + @EnvironmentObject var liveUser: LiveUser + + @State private var username: String = "" + @State private var password: String = "" + var body: some View { VStack { - Image("Logo") + Image("MusicToolsLogo") .resizable() .frame(width: 200.0, height: 200.0, alignment: .trailing) .cornerRadius(18) @@ -19,12 +25,13 @@ struct LoginScreen: View { .padding(.bottom, 20) Text("Sarsoo Music Tools") .font(.largeTitle) - TextField("Username", text: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Value@*/.constant("")/*@END_MENU_TOKEN@*/) - SecureField("Password", text: /*@START_MENU_TOKEN@*/ /*@PLACEHOLDER=Value@*/.constant("Apple")/*@END_MENU_TOKEN@*/) + TextField("Username", text: $username) + SecureField("Password", text: $password) HStack { - Button(action: /*@START_MENU_TOKEN@*/{}/*@END_MENU_TOKEN@*/) { + Button(action: { + self.liveUser.loggedIn = true + }) { Text("Log In") - } .padding(.trailing, 20.0) Button(action: /*@START_MENU_TOKEN@*/{}/*@END_MENU_TOKEN@*/) { diff --git a/Music Tools/Views/Playlist/PlaylistView.swift b/Music Tools/Views/Playlist/PlaylistView.swift index f121a53..17bce93 100644 --- a/Music Tools/Views/Playlist/PlaylistView.swift +++ b/Music Tools/Views/Playlist/PlaylistView.swift @@ -23,7 +23,6 @@ struct PlaylistView: View { @State private var chart_limit: Int = 0 @State private var showingSheet = false - @State private var isRefreshing = false var chartStyle: ChartStyle { diff --git a/Music Tools/Views/Settings/SettingsList.swift b/Music Tools/Views/Settings/SettingsList.swift index f33c329..6644876 100644 --- a/Music Tools/Views/Settings/SettingsList.swift +++ b/Music Tools/Views/Settings/SettingsList.swift @@ -11,6 +11,8 @@ import KeychainAccess struct SettingsList: View { + @EnvironmentObject var liveUser: LiveUser + init(){ UITableView.appearance().tableFooterView = UIView() } @@ -31,6 +33,9 @@ struct SettingsList: View { do { try keychain.remove("username") try keychain.remove("password") + + self.liveUser.loggedIn = false + } catch let error { debugPrint("Could not clear keychain, \(error)") }