Skip to content

Instantly share code, notes, and snippets.

@markvanwijnen
Last active March 8, 2021 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markvanwijnen/61fc33527097600a16b1266e589928b0 to your computer and use it in GitHub Desktop.
Save markvanwijnen/61fc33527097600a16b1266e589928b0 to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View {
@EnvironmentObject var twitterAPI: TwitterAPI // 1
var body: some View {
VStack {
if let screenName = twitterAPI.user?.screenName { // 2
Text("Welcome").font(.largeTitle)
Text(screenName).font(.largeTitle)
} else { // 3
Button("Signin with Twitter", action: {
twitterAPI.authorize()
})
}
}
.sheet(isPresented: $twitterAPI.authorizationSheetIsPresented) { // 4
SafariView(url: $twitterAPI.authorizationURL) // 5
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment