Skip to content
This repository was archived by the owner on Aug 18, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion brain-marks/Categories/Views/CategoryList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,55 @@ struct CategoryList: View {
viewModel.getCategories()
}
.accentColor(.black)
.sheet(isPresented:$showAddURLView) {
.sheet(isPresented:$showAddURLView) {
AddURLView(categories: viewModel.categories)
}
}
}

struct NewCategorySheetView: View {
@Environment(\.presentationMode) var presentationMode
@State var newCategory = ""

var body: some View {
NavigationView {
VStack {
TextField("Enter name of new category", text: $newCategory)
.foregroundColor(.gray)


Spacer()

HStack(spacing: 25) {
Button {
presentationMode.wrappedValue.dismiss()
} label: {
Text("Cancel")
.frame(width: 150, height: 50)
.foregroundColor(.white)
.background(Color(UIColor(named: "twitter")!))
.font(.system(size: 20, weight: .semibold, design: .default))
.cornerRadius(10)
}

Button {
presentationMode.wrappedValue.dismiss()
DataStoreManger.shared.createCategory(
category: AWSCategory(name: newCategory,
imageName: "swift"))
} label: {
Text("Create")
.frame(width: 150, height: 50)
.foregroundColor(.white)
.background(Color(UIColor(named: "twitter")!))
.font(.system(size: 20, weight: .semibold, design: .default))
.cornerRadius(10)
}
}
.padding(20)
}
.navigationBarTitle("New Category")
.sheet(isPresented:$showAddURLView) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this shouldn't be here. There is a separate file called NewCategorySheetView. It's located at: brain-marks/Categories/Views

Do you has this file?

AddURLView(categories: viewModel.categories)
}
}
Expand Down
18 changes: 18 additions & 0 deletions brain-marks/Tweets/Views/TweetList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}

}
}