Created
March 21, 2021 16:38
-
-
Save markvanwijnen/6f85e587e13d3a93d8a30f34253284ae 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 | |
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