diff --git a/brain-marks/Categories/Views/CategoryList.swift b/brain-marks/Categories/Views/CategoryList.swift index fc73ed6..715aaa7 100644 --- a/brain-marks/Categories/Views/CategoryList.swift +++ b/brain-marks/Categories/Views/CategoryList.swift @@ -48,9 +48,9 @@ struct CategoryList: View { viewModel.getCategories() } .accentColor(.black) - .sheet(isPresented:$showAddURLView) { - AddURLView(categories: viewModel.categories) - } + .sheet(isPresented:$showAddURLView) { + AddURLView(categories: viewModel.categories) + } } } diff --git a/brain-marks/Tweets/Views/TweetList.swift b/brain-marks/Tweets/Views/TweetList.swift index fd088a8..a7d4b49 100644 --- a/brain-marks/Tweets/Views/TweetList.swift +++ b/brain-marks/Tweets/Views/TweetList.swift @@ -17,6 +17,11 @@ struct TweetList: View { List(viewModel.tweets) { tweet in TweetCard(tweet: tweet) + .onTapGesture { + print("opening twitter for \(tweet.tweetID)\(tweet.authorUsername)") + self.openTwitter(tweetID: tweet.tweetID, authorUsername: tweet.authorUsername!) + } + } .toolbar { ToolbarItem(placement: .principal) { @@ -35,4 +40,17 @@ struct TweetList: View { Spacer() } + func openTwitter(tweetID:String, authorUsername:String){ + let appURL = NSURL(string: "twitter://home")! + let webURL = NSURL(string: "https://twitter.com/\(authorUsername)/status/\(tweetID)?s=21")! + + let application = UIApplication.shared + + if application.canOpenURL(appURL as URL) { + application.open(appURL as URL) + } else { + application.open(webURL as URL) + } + + } }