Skip to content

Instantly share code, notes, and snippets.

@markvanwijnen
Created March 21, 2021 16:38
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/6f85e587e13d3a93d8a30f34253284ae to your computer and use it in GitHub Desktop.
Save markvanwijnen/6f85e587e13d3a93d8a30f34253284ae to your computer and use it in GitHub Desktop.
import SwiftUI
import Combine
struct ContentView: View {
@EnvironmentObject var twitterAPI: TwitterAPI
var body: some View {
VStack {
if let screenName = twitterAPI.user?.screenName {
Text("Welcome").font(.largeTitle)
Text(screenName).font(.largeTitle)
} else {
Button("Signin with Twitter", action: {
twitterAPI.authorize()
})
}
}
.sheet(isPresented: $twitterAPI.authorizationSheetIsPresented) {
SafariView(url: $twitterAPI.authorizationURL)
}
}
}
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