mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-28 09:25:47 +00:00
Like xcodes, storing the username in defaults so we know which item to look up in the keychain later. This also fixes the Xcode list update logic to not only validate the session but login with saved credentials if it fails.
40 lines
1.3 KiB
Swift
40 lines
1.3 KiB
Swift
import AppleAPI
|
|
import SwiftUI
|
|
|
|
struct SettingsView: View {
|
|
@EnvironmentObject var appState: AppState
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading) {
|
|
GroupBox(label: Text("Apple ID")) {
|
|
VStack(alignment: .leading) {
|
|
if let username = Current.defaults.string(forKey: "username") {
|
|
Text(username)
|
|
Button("Sign Out", action: appState.logOut)
|
|
} else {
|
|
Button("Sign In", action: { self.appState.presentingSignInAlert = true })
|
|
.sheet(isPresented: $appState.presentingSignInAlert) {
|
|
SignInCredentialsView(isPresented: $appState.presentingSignInAlert)
|
|
.environmentObject(appState)
|
|
}
|
|
}
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
}
|
|
Spacer()
|
|
}
|
|
.padding()
|
|
.navigationTitle("Settings")
|
|
.frame(width: 300)
|
|
.frame(minHeight: 300)
|
|
}
|
|
}
|
|
|
|
struct SettingsView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
Group {
|
|
SettingsView()
|
|
.environmentObject(AppState())
|
|
}
|
|
}
|
|
}
|