Skip to content

Commit 8e91e3b

Browse files
committed
Add NodeList for iOS
1 parent e44143b commit 8e91e3b

File tree

7 files changed

+68
-3
lines changed

7 files changed

+68
-3
lines changed

V2exOS.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
0D34DF8F2942FED1000A0096 /* AppearanceConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D34DF8E2942FED1000A0096 /* AppearanceConfig.swift */; };
3636
0D40378C28E6E4EA00B1A341 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D40378B28E6E4EA00B1A341 /* SettingsView.swift */; };
3737
0D40378E28E6E4F500B1A341 /* ProxyHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D40378D28E6E4F500B1A341 /* ProxyHelper.swift */; };
38+
0D7EF06F299736C800E77A0C /* NodeListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D7EF06E299736C800E77A0C /* NodeListView.swift */; };
3839
0D8A2E6F2896AB49001B2769 /* CommentListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D8A2E6E2896AB49001B2769 /* CommentListView.swift */; };
3940
0D8A2E712896AE19001B2769 /* PreviewData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D8A2E702896AE19001B2769 /* PreviewData.swift */; };
4041
0D8F3350288D1F8800C27AF1 /* TopicListCellView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D8F334F288D1F8800C27AF1 /* TopicListCellView.swift */; };
@@ -86,6 +87,7 @@
8687
0D40378B28E6E4EA00B1A341 /* SettingsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
8788
0D40378D28E6E4F500B1A341 /* ProxyHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProxyHelper.swift; sourceTree = "<group>"; };
8889
0D7A1A5429880B8D00003696 /* Info_tv.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info_tv.plist; sourceTree = "<group>"; };
90+
0D7EF06E299736C800E77A0C /* NodeListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeListView.swift; sourceTree = "<group>"; };
8991
0D8A2E6E2896AB49001B2769 /* CommentListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentListView.swift; sourceTree = "<group>"; };
9092
0D8A2E702896AE19001B2769 /* PreviewData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewData.swift; sourceTree = "<group>"; };
9193
0D8F334F288D1F8800C27AF1 /* TopicListCellView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopicListCellView.swift; sourceTree = "<group>"; };
@@ -238,6 +240,7 @@
238240
isa = PBXGroup;
239241
children = (
240242
0D2334E12996990700DF4B73 /* HomeView.swift */,
243+
0D7EF06E299736C800E77A0C /* NodeListView.swift */,
241244
);
242245
path = Views;
243246
sourceTree = "<group>";
@@ -499,6 +502,7 @@
499502
0D2334F129969A6B00DF4B73 /* PreviewData.swift in Sources */,
500503
0D2334D12996944500DF4B73 /* V2exOSiOSApp.swift in Sources */,
501504
0D2334EC299699B000DF4B73 /* AppearanceConfig.swift in Sources */,
505+
0D7EF06F299736C800E77A0C /* NodeListView.swift in Sources */,
502506
0D2334E42996997000DF4B73 /* TopicListCellView.swift in Sources */,
503507
);
504508
runOnlyForDeploymentPostprocessing = 0;

V2exOS/Views/TopicDetail/CommentListView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ struct CommentListView: View {
2020
var body: some View {
2121
Label("\(commentCount ?? 0) 条回复", systemImage: "bubble.middle.bottom.fill")
2222
.foregroundColor(.secondary)
23+
#if os(iOS)
24+
.listRowSeparator(.hidden)
25+
#endif
2326
#if os(tvOS)
2427
.focusable()
2528
#endif

V2exOS/Views/TopicDetail/TopicDetailView.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,22 @@ struct TopicDetailView: View {
6868
.fixedSize(horizontal: false, vertical: true)
6969

7070
}
71-
71+
#if os(iOS)
72+
.listRowSeparator(.hidden)
73+
#endif
7274
Spacer()
7375

7476
CommentListView(commentCount: topic.replies, commentList: commentList)
7577

7678
if isCommentLoading {
77-
Spacer()
7879
HStack {
7980
Spacer()
8081
ProgressView()
8182
Spacer()
8283
}
84+
#if os(iOS)
85+
.listRowSeparator(.hidden)
86+
#endif
8387
}
8488
}
8589
#if os(iOS)

V2exOS/Views/TopicList/TopicListView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ struct TopicListView: View {
5555
await loadData()
5656
}
5757
.navigationTitle(_node?.title ?? "V2exOS")
58+
#if os(iOS)
59+
.navigationViewStyle(.stack)
60+
#endif
5861
#if os(macOS)
5962
.navigationSubtitle(_node?.header ?? "")
6063
#endif

V2exOSiOS/Info.plist

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
4-
<dict/>
4+
<dict>
5+
<key>ITSAppUsesNonExemptEncryption</key>
6+
<false/>
7+
</dict>
58
</plist>

V2exOSiOS/Views/HomeView.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ struct HomeView: View {
3737
TitleNavBarItem(title: title)
3838
}
3939
}
40+
41+
NodeListView()
42+
.pagerTabItem(tag: 9999) {
43+
TitleNavBarItem(title: "其他版块")
44+
}
4045
}
4146
.pagerTabStripViewStyle(.scrollableBarButton(tabItemSpacing: 20))
4247
.toolbar(.hidden, for: .automatic)

V2exOSiOS/Views/NodeListView.swift

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// NodeListView.swift
3+
// V2exOSiOS
4+
//
5+
// Created by isaced on 2023/2/11.
6+
//
7+
8+
import SwiftUI
9+
import V2exAPI
10+
11+
struct NodeListView: View {
12+
13+
@State var nodeList : [V2Node] = []
14+
@State var isLoading = true
15+
16+
var body: some View {
17+
List(nodeList) { node in
18+
NavigationLink(destination: TopicListView(nodeName: node.name)) {
19+
Text(node.title ?? "")
20+
}
21+
}
22+
.overlay {
23+
if isLoading {
24+
ProgressView()
25+
}
26+
}
27+
.task {
28+
self.isLoading = true
29+
do {
30+
self.nodeList = try await v2ex.nodesList() ?? []
31+
} catch {
32+
print(error)
33+
}
34+
self.isLoading = false
35+
}
36+
}
37+
}
38+
39+
struct NodeListView_Previews: PreviewProvider {
40+
static var previews: some View {
41+
NodeListView()
42+
}
43+
}

0 commit comments

Comments
 (0)