Skip to content

Commit bcb9c96

Browse files
committed
Ready TestFlight for iOS
1 parent 8e91e3b commit bcb9c96

File tree

9 files changed

+107
-43
lines changed

9 files changed

+107
-43
lines changed

V2exOS.xcodeproj/project.pbxproj

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
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+
0D5555F92997B6B100A8B9FD /* ViewExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D5555F82997B6B100A8B9FD /* ViewExt.swift */; };
39+
0D5555FA2997B6B100A8B9FD /* ViewExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D5555F82997B6B100A8B9FD /* ViewExt.swift */; };
40+
0D5555FB2997B6B100A8B9FD /* ViewExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D5555F82997B6B100A8B9FD /* ViewExt.swift */; };
41+
0D5555FC2997C1C500A8B9FD /* CurrentUserStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0DA3F3A628A412FE00E7224D /* CurrentUserStore.swift */; };
42+
0D5555FF2997C1FF00A8B9FD /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = 0D5555FE2997C1FF00A8B9FD /* KeychainAccess */; };
3843
0D7EF06F299736C800E77A0C /* NodeListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D7EF06E299736C800E77A0C /* NodeListView.swift */; };
3944
0D8A2E6F2896AB49001B2769 /* CommentListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D8A2E6E2896AB49001B2769 /* CommentListView.swift */; };
4045
0D8A2E712896AE19001B2769 /* PreviewData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0D8A2E702896AE19001B2769 /* PreviewData.swift */; };
@@ -86,6 +91,7 @@
8691
0D34DF8E2942FED1000A0096 /* AppearanceConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppearanceConfig.swift; sourceTree = "<group>"; };
8792
0D40378B28E6E4EA00B1A341 /* SettingsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
8893
0D40378D28E6E4F500B1A341 /* ProxyHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProxyHelper.swift; sourceTree = "<group>"; };
94+
0D5555F82997B6B100A8B9FD /* ViewExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExt.swift; sourceTree = "<group>"; };
8995
0D7A1A5429880B8D00003696 /* Info_tv.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info_tv.plist; sourceTree = "<group>"; };
9096
0D7EF06E299736C800E77A0C /* NodeListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeListView.swift; sourceTree = "<group>"; };
9197
0D8A2E6E2896AB49001B2769 /* CommentListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommentListView.swift; sourceTree = "<group>"; };
@@ -127,6 +133,7 @@
127133
0D2334DF299697E000DF4B73 /* PagerTabStripView in Frameworks */,
128134
0D2334EA2996998500DF4B73 /* V2exAPI in Frameworks */,
129135
0D2334E62996998500DF4B73 /* MarkdownUI in Frameworks */,
136+
0D5555FF2997C1FF00A8B9FD /* KeychainAccess in Frameworks */,
130137
);
131138
runOnlyForDeploymentPostprocessing = 0;
132139
};
@@ -254,6 +261,7 @@
254261
0D40378D28E6E4F500B1A341 /* ProxyHelper.swift */,
255262
0D34DF8E2942FED1000A0096 /* AppearanceConfig.swift */,
256263
0DD2A4DC2987C57B0018C2CF /* Constants.swift */,
264+
0D5555F82997B6B100A8B9FD /* ViewExt.swift */,
257265
);
258266
path = Utils;
259267
sourceTree = "<group>";
@@ -358,6 +366,7 @@
358366
0D2334E52996998500DF4B73 /* MarkdownUI */,
359367
0D2334E72996998500DF4B73 /* Kingfisher */,
360368
0D2334E92996998500DF4B73 /* V2exAPI */,
369+
0D5555FE2997C1FF00A8B9FD /* KeychainAccess */,
361370
);
362371
productName = V2exOSiOS;
363372
productReference = 0D2334CE2996944500DF4B73 /* V2exOSiOS.app */;
@@ -484,6 +493,7 @@
484493
0D40378E28E6E4F500B1A341 /* ProxyHelper.swift in Sources */,
485494
0DF3301028A56A3600AEF312 /* StringExt.swift in Sources */,
486495
0D8A2E6F2896AB49001B2769 /* CommentListView.swift in Sources */,
496+
0D5555F92997B6B100A8B9FD /* ViewExt.swift in Sources */,
487497
0D40378C28E6E4EA00B1A341 /* SettingsView.swift in Sources */,
488498
);
489499
runOnlyForDeploymentPostprocessing = 0;
@@ -499,6 +509,8 @@
499509
0D2334EF29969A3B00DF4B73 /* TimeFormat.swift in Sources */,
500510
0D2334EB299699AB00DF4B73 /* TopicDetailView.swift in Sources */,
501511
0D2334EE299699DD00DF4B73 /* UserName.swift in Sources */,
512+
0D5555FB2997B6B100A8B9FD /* ViewExt.swift in Sources */,
513+
0D5555FC2997C1C500A8B9FD /* CurrentUserStore.swift in Sources */,
502514
0D2334F129969A6B00DF4B73 /* PreviewData.swift in Sources */,
503515
0D2334D12996944500DF4B73 /* V2exOSiOSApp.swift in Sources */,
504516
0D2334EC299699B000DF4B73 /* AppearanceConfig.swift in Sources */,
@@ -518,6 +530,7 @@
518530
0DA7FA862987A76B00374B3A /* UserName.swift in Sources */,
519531
0DA7FA67298799B300374B3A /* V2exOSTVApp.swift in Sources */,
520532
0DA7FA822987A6DB00374B3A /* CommentListView.swift in Sources */,
533+
0D5555FA2997B6B100A8B9FD /* ViewExt.swift in Sources */,
521534
0DA7FA7B29879CA500374B3A /* TimeFormat.swift in Sources */,
522535
0DA7FA872987A8C800374B3A /* TopicDetailView.swift in Sources */,
523536
0DA7FA852987A76500374B3A /* AppearanceConfig.swift in Sources */,
@@ -904,8 +917,8 @@
904917
isa = XCRemoteSwiftPackageReference;
905918
repositoryURL = "https://github.com/isaced/V2exAPI.git";
906919
requirement = {
907-
kind = upToNextMajorVersion;
908-
minimumVersion = 1.1.0;
920+
branch = main;
921+
kind = branch;
909922
};
910923
};
911924
0D2334DC2996972300DF4B73 /* XCRemoteSwiftPackageReference "PagerTabStripView" */ = {
@@ -968,6 +981,11 @@
968981
package = 0D12614828A94963009DBCE2 /* XCRemoteSwiftPackageReference "V2exAPI" */;
969982
productName = V2exAPI;
970983
};
984+
0D5555FE2997C1FF00A8B9FD /* KeychainAccess */ = {
985+
isa = XCSwiftPackageProductDependency;
986+
package = 0DA3F3A228A411ED00E7224D /* XCRemoteSwiftPackageReference "KeychainAccess" */;
987+
productName = KeychainAccess;
988+
};
971989
0D8F3352288D243A00C27AF1 /* MarkdownUI */ = {
972990
isa = XCSwiftPackageProductDependency;
973991
package = 0D8F3351288D243A00C27AF1 /* XCRemoteSwiftPackageReference "MarkdownUI" */;

V2exOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

V2exOS/Utils/ViewExt.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// ViewExt.swift
3+
// V2exOS
4+
//
5+
// Created by isaced on 2023/2/11.
6+
//
7+
8+
import SwiftUI
9+
10+
// === .onFirstAppear() ===
11+
12+
extension View {
13+
func onFirstAppear(perform: @escaping () -> Void) -> some View {
14+
modifier(OnFirstAppear(perform: perform))
15+
}
16+
}
17+
18+
private struct OnFirstAppear: ViewModifier {
19+
let perform: () -> Void
20+
21+
@State private var firstTime = true
22+
23+
func body(content: Content) -> some View {
24+
content.onAppear {
25+
if firstTime {
26+
firstTime = false
27+
perform()
28+
}
29+
}
30+
}
31+
}

V2exOS/Views/SidebarView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ struct SidebarView: View {
105105
searchText = ""
106106
}
107107
}
108-
.onAppear {
108+
.onFirstAppear {
109109
Task {
110110
self.nodeList = try await v2ex.nodesList()
111111
self.isLoading = false

V2exOS/Views/TopicDetail/TopicDetailView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ struct TopicDetailView: View {
2424
Text(topic.title ?? "" )
2525
.font(.title)
2626
.lineLimit(3)
27+
#if os(macOS)
28+
.foregroundColor(Color(.labelColor))
29+
#endif
30+
#if os(iOS)
31+
.foregroundColor(Color(.label))
32+
#endif
2733
#if os(tvOS)
2834
.focusable()
2935
#endif

V2exOS/Views/TopicList/TopicListView.swift

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import Kingfisher
1111

1212
struct TopicListView: View {
1313

14+
@EnvironmentObject private var currentUser: CurrentUserStore
15+
1416
var nodeName: String
1517

1618
@State var isLoading = true
@@ -21,38 +23,41 @@ struct TopicListView: View {
2123

2224
var body: some View {
2325
NavigationView{
24-
if isLoading {
25-
ProgressView()
26-
.frame(minWidth: 400)
27-
}else{
28-
List {
29-
if let topics = topics {
30-
ForEach(topics) { topic in
31-
TopicListCellView(topic: topic)
32-
}
33-
34-
if topics.count > 0 && nodeName != NodeNameAll && nodeName != NodeNameHot {
35-
HStack {
36-
Spacer()
37-
ProgressView()
38-
.onAppear {
39-
Task {
40-
await self.loadData(page: self.page + 1)
41-
}
26+
27+
List {
28+
if let topics = topics {
29+
ForEach(topics) { topic in
30+
TopicListCellView(topic: topic)
31+
}
32+
33+
if topics.count > 0 && nodeName != NodeNameAll && nodeName != NodeNameHot {
34+
HStack {
35+
Spacer()
36+
ProgressView()
37+
.onAppear {
38+
Task {
39+
await self.loadData(page: self.page + 1)
4240
}
43-
Spacer()
44-
}
41+
}
42+
Spacer()
4543
}
4644
}
47-
4845
}
49-
.listStyle(.inset)
50-
.frame(minWidth: 400, idealWidth: 500)
51-
.foregroundColor(.black)
5246
}
53-
}
54-
.task {
55-
await loadData()
47+
.overlay {
48+
if isLoading {
49+
ProgressView()
50+
}
51+
}
52+
.listStyle(.inset)
53+
.frame(minWidth: 400, idealWidth: 500)
54+
.foregroundColor(.black)
55+
.onFirstAppear {
56+
print("onFirstAppear....")
57+
Task {
58+
await loadData()
59+
}
60+
}
5661
}
5762
.navigationTitle(_node?.title ?? "V2exOS")
5863
#if os(iOS)
@@ -71,6 +76,8 @@ struct TopicListView: View {
7176
}
7277

7378
func loadData(page: Int = 1) async {
79+
print("TopcListView loadData... \(nodeName)")
80+
7481
if error != nil {
7582
return
7683
}
@@ -86,9 +93,12 @@ struct TopicListView: View {
8693
topics = try await v2ex.latestTopics()
8794
} else if nodeName == NodeNameHot {
8895
topics = try await v2ex.hotTopics()
89-
9096
} else {
91-
topics = try await v2ex.topics(nodeName: nodeName, page: page)?.result
97+
if currentUser.user == nil && (self.topics?.isEmpty ?? true) {
98+
topics = try await v2ex.topics(nodeName: nodeName)
99+
} else {
100+
topics = try await v2ex.topics(nodeName: nodeName, page: page)?.result
101+
}
92102
_node = try await v2ex.nodesShow(name: nodeName)
93103
}
94104

V2exOSTV/Views/TopicListView.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ struct TopicListView: View {
3333
ProgressView()
3434
}
3535
}
36-
.task {
37-
await loadData()
36+
.onFirstAppear {
37+
Task {
38+
await loadData()
39+
}
3840
}
3941
}
4042

V2exOSiOS/V2exOSiOSApp.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ struct V2exOSiOSApp: App {
2525
// }
2626
// }
2727
.environmentObject(SettingsConfig.shared)
28+
.environmentObject(CurrentUserStore.shared)
29+
2830
}
2931
}
3032
}

V2exOSiOS/Views/HomeView.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,10 @@ struct HomeView: View {
1313
let nodes = [
1414
["最热", NodeNameHot],
1515
["全部", NodeNameAll],
16-
["技术", "tech"],
17-
["创意", "creative"],
18-
["好玩", "play"],
19-
["Apple", "apple"],
16+
["分享创造", "create"],
17+
["分享发现", "share"],
2018
["酷工作", "jobs"],
21-
["交易", "deals"],
22-
["城市", "city"],
2319
["问与答", "qna"],
24-
["R2", "r2"],
2520
]
2621

2722
var body: some View {

0 commit comments

Comments
 (0)