Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign Story Row #239

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 8 additions & 4 deletions ios/HackerNews.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
C3AC6AD42CB6E806006BD22D /* HackerNewsPreviewTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3AC6AD32CB6E7FD006BD22D /* HackerNewsPreviewTest.swift */; };
C3AC6AD62CB6E81B006BD22D /* HackerNewsSnapshotTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3AC6AD52CB6E816006BD22D /* HackerNewsSnapshotTest.swift */; };
C3AC6AD92CB6E8F7006BD22D /* SnapshottingTests in Frameworks */ = {isa = PBXBuildFile; productRef = C3AC6AD82CB6E8F7006BD22D /* SnapshottingTests */; };
EC072CAA2CEF02A500D00B8D /* StoryRowV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC072CA92CEF02A500D00B8D /* StoryRowV2.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -192,6 +193,7 @@
C3AC6AD32CB6E7FD006BD22D /* HackerNewsPreviewTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HackerNewsPreviewTest.swift; sourceTree = "<group>"; };
C3AC6AD52CB6E816006BD22D /* HackerNewsSnapshotTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HackerNewsSnapshotTest.swift; sourceTree = "<group>"; };
C3AC6AD72CB6E854006BD22D /* HackerNews.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = HackerNews.xctestplan; sourceTree = "<group>"; };
EC072CA92CEF02A500D00B8D /* StoryRowV2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryRowV2.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -235,6 +237,7 @@
A413E8582A8D868500C0F867 /* ThemedButtonStyle.swift */,
A434C2DF2A8E75960002F488 /* WebView.swift */,
A47309B52AA7D1F600201376 /* CommentRow.swift */,
EC072CA92CEF02A500D00B8D /* StoryRowV2.swift */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -689,6 +692,7 @@
A42705AB2A4296BA0057E439 /* PostListScreen.swift in Sources */,
A40DC1FA2C20D8B60055B920 /* Previews.swift in Sources */,
A427057F2A4293B10057E439 /* ContentView.swift in Sources */,
EC072CAA2CEF02A500D00B8D /* StoryRowV2.swift in Sources */,
1DF162032A436E7B001A3F76 /* DateUtils.swift in Sources */,
A413E8572A8C40E800C0F867 /* Extensions.swift in Sources */,
A42705A92A4294EB0057E439 /* LoginScreen.swift in Sources */,
Expand Down Expand Up @@ -868,7 +872,7 @@
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"HackerNews/Preview Content\"";
DEVELOPMENT_TEAM = 62J2XHNK9T;
DEVELOPMENT_TEAM = LSPBG7SYXK;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
Expand All @@ -890,7 +894,7 @@
MARKETING_VERSION = 3.4;
OTHER_LDFLAGS = "-fprofile-instr-generate";
OTHER_SWIFT_FLAGS = "-profile-generate -profile-coverage-mapping";
PRODUCT_BUNDLE_IDENTIFIER = "com.emerge.hn.Hacker-News";
PRODUCT_BUNDLE_IDENTIFIER = com.emergetools.hackernews;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
Expand All @@ -911,7 +915,7 @@
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "\"HackerNews/Preview Content\"";
DEVELOPMENT_TEAM = 62J2XHNK9T;
DEVELOPMENT_TEAM = LSPBG7SYXK;
"ENABLE_HARDENED_RUNTIME[sdk=macosx*]" = YES;
ENABLE_PREVIEWS = YES;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
Expand All @@ -931,7 +935,7 @@
);
LIBRARY_SEARCH_PATHS = "\"$(PROJECT_DIR)/Frameworks/Reaper.xcframework\"";
MARKETING_VERSION = 3.4;
PRODUCT_BUNDLE_IDENTIFIER = "com.emerge.hn.Hacker-News";
PRODUCT_BUNDLE_IDENTIFIER = com.emergetools.hackernews;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "261ff378e7b15ed930e88adbf89034cf9764a714ee554702b7a367bba1734bed",
"originHash" : "24bebf1b8a7941b76197956b51b5401cff81714df8139818d77c9821c372f77b",
"pins" : [
{
"identity" : "accessibilitysnapshot",
Expand Down
38 changes: 38 additions & 0 deletions ios/HackerNews/Assets.xcassets/Color.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFE"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFE"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
20 changes: 20 additions & 0 deletions ios/HackerNews/Assets.xcassets/HNRed.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x6F",
"green" : "0x47",
"red" : "0xEF"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
60 changes: 60 additions & 0 deletions ios/HackerNews/Components/StoryRowV2.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// StoryRowV2.swift
// HackerNews
//
// Created by Rikin Marfatia on 11/20/24.
//

import SwiftUI

struct StoryRowV2: View {
@ObservedObject var model: AppViewModel
let story: Story

var body: some View {
VStack(alignment: .leading, spacing: 8) {
let author = story.by!
Text("@\(author)")
.foregroundColor(.hnOrange)
.fontWeight(/*@START_MENU_TOKEN@*/.bold/*@END_MENU_TOKEN@*/)
Text(story.title)
.font(.headline)
HStack(spacing: 16) {
HStack(spacing: 4) {
Image(systemName: "arrow.up")
.foregroundColor(.green)
Text("\(story.score)")
}
HStack(spacing: 4) {
Image(systemName: "clock")
.foregroundColor(.purple)
Text(story.displayableDate)
}
Spacer()
// 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)")
}
}
.buttonStyle(.bordered)
.buttonBorderShape(ButtonBorderShape.capsule)
}
}
}
}

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)
}
}
}
38 changes: 20 additions & 18 deletions ios/HackerNews/Screens/PostListScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,26 @@ struct PostListScreen: View {
.scaleEffect(2)
case .loaded(let stories):
List(stories, id: \.id) { story in
let navigationValue: AppViewModel.AppNavigation = {
if let url = story.makeUrl() {
return AppViewModel.AppNavigation.webLink(url: url, title: story.title)
} else {
return AppViewModel.AppNavigation.storyComments(story: story)
}
}()
NavigationLink(
value: navigationValue,
label: {
StoryRow(
appState: appState,
story: story,
index: stories.firstIndex(where: { $0.id == story.id })!
)
}
)
.listRowBackground(Color.clear)
let navigationValue: AppViewModel.AppNavigation = {
if let url = story.makeUrl() {
return AppViewModel.AppNavigation.webLink(url: url, title: story.title)
} else {
return AppViewModel.AppNavigation.storyComments(story: story)
}
}()

StoryRowV2(
model: appState,
story: story
)
.background(
NavigationLink(
value: navigationValue,
label: {}
)
.opacity(0.0)
)
.listRowBackground(Color.clear)
}
.listStyle(.plain)
}
Expand Down
9 changes: 9 additions & 0 deletions ios/HackerNews/Screens/StoryRow.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// StoryRow.swift
// HackerNews
//
// Created by Rikin Marfatia on 11/20/24.
//

import SwiftUI

7 changes: 4 additions & 3 deletions ios/HackerNews/Utils/Colors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import Foundation
import SwiftUI

struct HNColors {
static let orange = Color("HNOrange")
static let background = Color("Background")
static let commentBackground = Color("CommentBackground")
static let orange = Color("HNOrange")
static let background = Color("Background")
static let commentBackground = Color("CommentBackground")
static let red = Color("HNRed")
}
Loading