mirror of
https://github.com/XcodesOrg/XcodesApp.git
synced 2026-03-25 08:55:46 +00:00
43 lines
1.4 KiB
Swift
43 lines
1.4 KiB
Swift
import AppleAPI
|
|
import Preferences
|
|
import SwiftUI
|
|
|
|
extension Preferences.PaneIdentifier {
|
|
static let general = Self("general")
|
|
}
|
|
|
|
struct GeneralPreferencePane: View {
|
|
@EnvironmentObject var appState: AppState
|
|
|
|
var body: some View {
|
|
Preferences.Container(contentWidth: 400.0) {
|
|
Preferences.Section(title: "Apple ID") {
|
|
VStack(alignment: .leading) {
|
|
if appState.authenticationState == .authenticated {
|
|
Text(Current.defaults.string(forKey: "username") ?? "-")
|
|
Button("Sign Out", action: appState.signOut)
|
|
} else {
|
|
Button("Sign In", action: { self.appState.presentingSignInAlert = true })
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.sheet(isPresented: $appState.presentingSignInAlert) {
|
|
SignInCredentialsView(isPresented: $appState.presentingSignInAlert)
|
|
.environmentObject(appState)
|
|
}
|
|
}
|
|
}
|
|
.padding(.trailing)
|
|
}
|
|
}
|
|
|
|
struct GeneralPreferencePane_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
Group {
|
|
GeneralPreferencePane()
|
|
.environmentObject(AppState())
|
|
}
|
|
}
|
|
}
|