Skip to content

Commit 74a1ec1

Browse files
committed
Adding placeholders for other screens + bottom nav
1 parent 63f05f4 commit 74a1ec1

File tree

5 files changed

+105
-1
lines changed

5 files changed

+105
-1
lines changed

ios/HackerNews.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
C3AC6AD62CB6E81B006BD22D /* HackerNewsSnapshotTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3AC6AD52CB6E816006BD22D /* HackerNewsSnapshotTest.swift */; };
4444
C3AC6AD92CB6E8F7006BD22D /* SnapshottingTests in Frameworks */ = {isa = PBXBuildFile; productRef = C3AC6AD82CB6E8F7006BD22D /* SnapshottingTests */; };
4545
EC072CAA2CEF02A500D00B8D /* StoryRowV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC072CA92CEF02A500D00B8D /* StoryRowV2.swift */; };
46+
EC8BF4B02CF1030700EF4BA8 /* StoriesScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC8BF4AF2CF1030700EF4BA8 /* StoriesScreen.swift */; };
47+
EC8BF4B22CF1181800EF4BA8 /* BookmarksScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC8BF4B12CF1181800EF4BA8 /* BookmarksScreen.swift */; };
48+
EC8BF4B42CF1182400EF4BA8 /* SettingsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC8BF4B32CF1182400EF4BA8 /* SettingsScreen.swift */; };
4649
/* End PBXBuildFile section */
4750

4851
/* Begin PBXContainerItemProxy section */
@@ -138,6 +141,9 @@
138141
C3AC6AD52CB6E816006BD22D /* HackerNewsSnapshotTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HackerNewsSnapshotTest.swift; sourceTree = "<group>"; };
139142
C3AC6AD72CB6E854006BD22D /* HackerNews.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = HackerNews.xctestplan; sourceTree = "<group>"; };
140143
EC072CA92CEF02A500D00B8D /* StoryRowV2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryRowV2.swift; sourceTree = "<group>"; };
144+
EC8BF4AF2CF1030700EF4BA8 /* StoriesScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoriesScreen.swift; sourceTree = "<group>"; };
145+
EC8BF4B12CF1181800EF4BA8 /* BookmarksScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksScreen.swift; sourceTree = "<group>"; };
146+
EC8BF4B32CF1182400EF4BA8 /* SettingsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsScreen.swift; sourceTree = "<group>"; };
141147
/* End PBXFileReference section */
142148

143149
/* Begin PBXFrameworksBuildPhase section */
@@ -213,6 +219,9 @@
213219
A42705A82A4294EB0057E439 /* LoginScreen.swift */,
214220
A42705AA2A4296BA0057E439 /* PostListScreen.swift */,
215221
A48C0DE62A9818A50034CC0A /* StoryScreen.swift */,
222+
EC8BF4AF2CF1030700EF4BA8 /* StoriesScreen.swift */,
223+
EC8BF4B12CF1181800EF4BA8 /* BookmarksScreen.swift */,
224+
EC8BF4B32CF1182400EF4BA8 /* SettingsScreen.swift */,
216225
);
217226
path = Screens;
218227
sourceTree = "<group>";
@@ -573,8 +582,11 @@
573582
A434C2E02A8E75960002F488 /* WebView.swift in Sources */,
574583
A49933942AA28B5900DED8B1 /* StoryViewModel.swift in Sources */,
575584
A47309B62AA7D1F600201376 /* CommentRow.swift in Sources */,
585+
EC8BF4B02CF1030700EF4BA8 /* StoriesScreen.swift in Sources */,
576586
A49933952AA28B6500DED8B1 /* StoryScreen.swift in Sources */,
577587
A42705A72A42949D0057E439 /* AppViewModel.swift in Sources */,
588+
EC8BF4B42CF1182400EF4BA8 /* SettingsScreen.swift in Sources */,
589+
EC8BF4B22CF1181800EF4BA8 /* BookmarksScreen.swift in Sources */,
578590
A42705AD2A429D2E0057E439 /* HNApi.swift in Sources */,
579591
A423B0682BAE05FB00267DDB /* NetworkDebugger.swift in Sources */,
580592
);

ios/HackerNews/ContentView.swift

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,23 @@ struct ContentView: View {
1414
var body: some View {
1515
switch appState.authState {
1616
case .loggedIn:
17-
PostListScreen(appState: appState)
17+
TabView {
18+
StoriesScreen(model: appState)
19+
.tabItem {
20+
Label("Feed", systemImage: "list.dash")
21+
}
22+
23+
BookmarksScreen()
24+
.tabItem {
25+
Label("Bookmarks", systemImage: "book.fill")
26+
}
27+
28+
SettingsScreen()
29+
.tabItem {
30+
Label("Settings", systemImage: "gear")
31+
}
32+
}
33+
.navigationTitle("Hacker News")
1834
case .loggedOut:
1935
LoginScreen(appState: appState)
2036
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// BookmarksScreen.swift
3+
// HackerNews
4+
//
5+
// Created by Rikin Marfatia on 11/22/24.
6+
//
7+
8+
import Foundation
9+
import SwiftUI
10+
11+
struct BookmarksScreen: View {
12+
var body: some View {
13+
Text("Hello Bookmarks")
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// SettingsScreen.swift
3+
// HackerNews
4+
//
5+
// Created by Rikin Marfatia on 11/22/24.
6+
//
7+
8+
import Foundation
9+
import SwiftUI
10+
11+
struct SettingsScreen: View {
12+
var body: some View {
13+
Text("Hello Settings")
14+
}
15+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// StoriesScreen.swift
3+
// HackerNews
4+
//
5+
// Created by Rikin Marfatia on 11/22/24.
6+
//
7+
8+
import Foundation
9+
import SwiftUI
10+
11+
struct StoriesScreen: View {
12+
@ObservedObject var model: AppViewModel
13+
14+
var body: some View {
15+
switch model.storiesState {
16+
case .notStarted, .loading:
17+
ProgressView()
18+
case .loaded(let stories):
19+
List(stories, id: \.id) { story in
20+
StoryRowV2(model: model, story: story)
21+
.background(
22+
NavigationLink(
23+
value: navigationForStory(story: story),
24+
label: {}
25+
)
26+
.opacity(0.0)
27+
)
28+
.listRowBackground(Color.clear)
29+
}
30+
.listStyle(.plain)
31+
}
32+
}
33+
34+
private func navigationForStory(story: Story) -> AppViewModel.AppNavigation {
35+
if let url = story.makeUrl() {
36+
return AppViewModel.AppNavigation.webLink(url: url, title: story.title)
37+
} else {
38+
return AppViewModel.AppNavigation.storyComments(story: story)
39+
}
40+
}
41+
}
42+
43+
44+
#Preview {
45+
StoriesScreen(model: AppViewModel())
46+
}

0 commit comments

Comments
 (0)