Skip to content

Commit

Permalink
Wiring up Comment Button
Browse files Browse the repository at this point in the history
  • Loading branch information
Rahkeen committed Nov 22, 2024
1 parent eb5470c commit e801e77
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
35 changes: 20 additions & 15 deletions ios/HackerNews/Components/StoryRowV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,41 @@ struct StoryRowV2: View {
Text(story.title)
.font(.headline)
HStack(spacing: 16) {
HStack {
HStack(spacing: 4) {
Image(systemName: "arrow.up")
.foregroundColor(.green)
Text("\(story.score)")
}
HStack {
HStack(spacing: 4) {
Image(systemName: "clock")
.foregroundColor(.purple)
Text(story.displayableDate)
}
Spacer()
HStack {
Image(systemName: "bubble.right.fill")
.foregroundColor(.blue)
Text("\(story.commentCount)")
// Comment Button
Button(action: {
print("Pressed comment button for: \(story.id)")
model.navigationPath.append(
AppViewModel.AppNavigation.storyComments(story: story)
)
}) {
HStack(spacing: 4) {
Image(systemName: "message.fill")
Text("\(story.commentCount)")
}
}
.padding(8)
.background(.commentBackground)
.cornerRadius(.infinity)
.buttonStyle(.bordered)
.buttonBorderShape(ButtonBorderShape.capsule)
}
}
.padding()
}
}

struct StoryRowV2_Preview: PreviewProvider {
static var previews: some View {
let fakeStory = PreviewHelpers.makeFakeStory(index: 0, descendants: 3, kids: [1, 2, 3])
PreviewVariants {
StoryRowV2(model: AppViewModel(), story: fakeStory)
static var previews: some View {
let fakeStory = PreviewHelpers.makeFakeStory(index: 0, descendants: 3, kids: [1, 2, 3])
PreviewVariants {
StoryRowV2(model: AppViewModel(), story: fakeStory)
}
}
}
}
8 changes: 4 additions & 4 deletions ios/HackerNews/Screens/PostListScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ struct PostListScreen: View {
NavigationLink(
value: navigationValue,
label: {
StoryRowV2(
model: appState,
story: story
)
StoryRowV2(
model: appState,
story: story
)
}
)
.listRowBackground(Color.clear)
Expand Down

0 comments on commit e801e77

Please sign in to comment.