Last active
March 8, 2021 18:50
-
-
Save markvanwijnen/61fc33527097600a16b1266e589928b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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