Skip to content

Commit 543ce75

Browse files
committed
Adding placeholders for other screens + bottom nav
1 parent d649f07 commit 543ce75

File tree

5 files changed

+105
-1
lines changed

5 files changed

+105
-1
lines changed

ios/HackerNews.xcodeproj/project.pbxproj

+12
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
C3AC6AD62CB6E81B006BD22D /* HackerNewsSnapshotTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3AC6AD52CB6E816006BD22D /* HackerNewsSnapshotTest.swift */; };
7272
C3AC6AD92CB6E8F7006BD22D /* SnapshottingTests in Frameworks */ = {isa = PBXBuildFile; productRef = C3AC6AD82CB6E8F7006BD22D /* SnapshottingTests */; };
7373
EC072CAA2CEF02A500D00B8D /* StoryRowV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC072CA92CEF02A500D00B8D /* StoryRowV2.swift */; };
74+
EC8BF4B02CF1030700EF4BA8 /* StoriesScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC8BF4AF2CF1030700EF4BA8 /* StoriesScreen.swift */; };
75+
EC8BF4B22CF1181800EF4BA8 /* BookmarksScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC8BF4B12CF1181800EF4BA8 /* BookmarksScreen.swift */; };
76+
EC8BF4B42CF1182400EF4BA8 /* SettingsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = EC8BF4B32CF1182400EF4BA8 /* SettingsScreen.swift */; };
7477
/* End PBXBuildFile section */
7578

7679
/* Begin PBXContainerItemProxy section */
@@ -194,6 +197,9 @@
194197
C3AC6AD52CB6E816006BD22D /* HackerNewsSnapshotTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HackerNewsSnapshotTest.swift; sourceTree = "<group>"; };
195198
C3AC6AD72CB6E854006BD22D /* HackerNews.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = HackerNews.xctestplan; sourceTree = "<group>"; };
196199
EC072CA92CEF02A500D00B8D /* StoryRowV2.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryRowV2.swift; sourceTree = "<group>"; };
200+
EC8BF4AF2CF1030700EF4BA8 /* StoriesScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoriesScreen.swift; sourceTree = "<group>"; };
201+
EC8BF4B12CF1181800EF4BA8 /* BookmarksScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksScreen.swift; sourceTree = "<group>"; };
202+
EC8BF4B32CF1182400EF4BA8 /* SettingsScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsScreen.swift; sourceTree = "<group>"; };
197203
/* End PBXFileReference section */
198204

199205
/* Begin PBXFrameworksBuildPhase section */
@@ -269,6 +275,9 @@
269275
A42705A82A4294EB0057E439 /* LoginScreen.swift */,
270276
A42705AA2A4296BA0057E439 /* PostListScreen.swift */,
271277
A48C0DE62A9818A50034CC0A /* StoryScreen.swift */,
278+
EC8BF4AF2CF1030700EF4BA8 /* StoriesScreen.swift */,
279+
EC8BF4B12CF1181800EF4BA8 /* BookmarksScreen.swift */,
280+
EC8BF4B32CF1182400EF4BA8 /* SettingsScreen.swift */,
272281
);
273282
path = Screens;
274283
sourceTree = "<group>";
@@ -701,8 +710,11 @@
701710
A434C2E02A8E75960002F488 /* WebView.swift in Sources */,
702711
A49933942AA28B5900DED8B1 /* StoryViewModel.swift in Sources */,
703712
A47309B62AA7D1F600201376 /* CommentRow.swift in Sources */,
713+
EC8BF4B02CF1030700EF4BA8 /* StoriesScreen.swift in Sources */,
704714
A49933952AA28B6500DED8B1 /* StoryScreen.swift in Sources */,
705715
A42705A72A42949D0057E439 /* AppViewModel.swift in Sources */,
716+
EC8BF4B42CF1182400EF4BA8 /* SettingsScreen.swift in Sources */,
717+
EC8BF4B22CF1181800EF4BA8 /* BookmarksScreen.swift in Sources */,
706718
A42705AD2A429D2E0057E439 /* HNApi.swift in Sources */,
707719
A423B0682BAE05FB00267DDB /* NetworkDebugger.swift in Sources */,
708720
);

ios/HackerNews/ContentView.swift

+17-1
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
}
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+
}
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+
}
+46
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)