Skip to content

Commit 309b5d1

Browse files
committed
指南重构小实验
1 parent 1e5418f commit 309b5d1

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

SwiftPamphletApp.xcodeproj/project.pbxproj

+12
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
0871C6192BA040E5000B620D /* InfoRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0871C6182BA040E5000B620D /* InfoRowView.swift */; };
195195
0871C61B2BA04D23000B620D /* CategoryRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0871C61A2BA04D23000B620D /* CategoryRowView.swift */; };
196196
0871C61D2BA05F44000B620D /* InfosView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0871C61C2BA05F44000B620D /* InfosView.swift */; };
197+
0887A59A2BA28F6D00131359 /* CSGuideView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0887A5992BA28F6D00131359 /* CSGuideView.swift */; };
197198
088EE8F527BD24E000764525 /* PlayLinkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 088EE8F427BD24E000764525 /* PlayLinkView.swift */; };
198199
0896FB9027BA39B100676B7F /* PlayButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0896FB8F27BA39B100676B7F /* PlayButtonView.swift */; };
199200
0896FB9227BA486900676B7F /* 145.md in Resources */ = {isa = PBXBuildFile; fileRef = 0896FB9127BA486900676B7F /* 145.md */; };
@@ -458,6 +459,7 @@
458459
0871C61A2BA04D23000B620D /* CategoryRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoryRowView.swift; sourceTree = "<group>"; };
459460
0871C61C2BA05F44000B620D /* InfosView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfosView.swift; sourceTree = "<group>"; };
460461
0886702B27F804010001EA81 /* SwiftPamphletApp-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SwiftPamphletApp-Bridging-Header.h"; sourceTree = "<group>"; };
462+
0887A5992BA28F6D00131359 /* CSGuideView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CSGuideView.swift; sourceTree = "<group>"; };
461463
088EE8F427BD24E000764525 /* PlayLinkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayLinkView.swift; sourceTree = "<group>"; };
462464
0896FB8F27BA39B100676B7F /* PlayButtonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayButtonView.swift; sourceTree = "<group>"; };
463465
0896FB9127BA486900676B7F /* 145.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = 145.md; sourceTree = "<group>"; };
@@ -1086,6 +1088,7 @@
10861088
086A5F052744E88E00FECE02 /* SwiftPamphletApp */ = {
10871089
isa = PBXGroup;
10881090
children = (
1091+
0887A5982BA28F3600131359 /* Guide */,
10891092
08397E212B9EE83F00DFDD02 /* InfoOrganizer */,
10901093
08ED801A2B9D1EDA0069B7EC /* Setting */,
10911094
080124FD27EC62DC00E44222 /* SwiftPamphletAppDebug.entitlements */,
@@ -1202,6 +1205,14 @@
12021205
path = DB;
12031206
sourceTree = "<group>";
12041207
};
1208+
0887A5982BA28F3600131359 /* Guide */ = {
1209+
isa = PBXGroup;
1210+
children = (
1211+
0887A5992BA28F6D00131359 /* CSGuideView.swift */,
1212+
);
1213+
path = Guide;
1214+
sourceTree = "<group>";
1215+
};
12051216
0896FB9327BA60AA00676B7F /* Guide */ = {
12061217
isa = PBXGroup;
12071218
children = (
@@ -1674,6 +1685,7 @@
16741685
08448F0B2797F73200B61353 /* PlayArchitecture.swift in Sources */,
16751686
08038767276700F100519B15 /* CCYRESTfulAPI.swift in Sources */,
16761687
08522BD827CF344B005FF059 /* PlaySliderView.swift in Sources */,
1688+
0887A59A2BA28F6D00131359 /* CSGuideView.swift in Sources */,
16771689
086A5F362744ED9600FECE02 /* RepoView.swift in Sources */,
16781690
086A5F302744ED8600FECE02 /* IssuesListFromCustomView.swift in Sources */,
16791691
08C3BB7E27CE3EBD00ACF0FE /* PlayTabView.swift in Sources */,
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//
2+
// GuideView.swift
3+
// SwiftPamphletApp
4+
//
5+
// Created by Ming Dai on 2024/3/14.
6+
//
7+
8+
import SwiftUI
9+
10+
struct TestCSGuideView: View {
11+
var body: some View {
12+
CSGuideView(models: [
13+
Csgm(type: .text, text: "测试"),
14+
Csgm(type: .image, image: "p10"),
15+
Csgm(type: .imageWithText, text: "😂", image: "p12"),
16+
Csgm(type: .text, text: "测试2"),
17+
Csgm(type: .text, text: "测试3"),
18+
Csgm(type: .text, text: "测试4"),
19+
Csgm(type: .text, text: "测试5"),
20+
])
21+
}
22+
}
23+
24+
struct CSGuideView: View {
25+
@State var models: [Csgm]
26+
27+
var body: some View {
28+
ScrollView {
29+
ForEach(models) { model in
30+
if model.type == .text {
31+
Text(model.text)
32+
} else if model.type == .image {
33+
Image(model.image)
34+
} else if model.type == .imageWithText {
35+
VStack {
36+
Text(model.text)
37+
Image(model.image)
38+
}
39+
}
40+
}// end foreach
41+
}
42+
}
43+
}
44+
45+
struct Csgm:Identifiable {
46+
var id: UUID = UUID()
47+
var type: CSGType = .text
48+
var text: String = ""
49+
var image: String = ""
50+
var list: [String] = [String]()
51+
52+
enum CSGType {
53+
case text, image, imageWithText,list
54+
}
55+
}
56+

SwiftPamphletApp/SwiftPamphletAppApp.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ struct SwiftPamphletAppApp: App {
1717
var body: some Scene {
1818
WindowGroup {
1919
// SwiftPamphletApp() // 老版本
20-
HomeView() // 新版本
20+
// HomeView() // 新版本
21+
TestCSGuideView()
2122
.modelContainer(for: [IOInfo.self], isUndoEnabled: true)
23+
2224
}
2325
.windowToolbarStyle(UnifiedWindowToolbarStyle(showsTitle: true)) // 用来控制是否展示标题
2426
}

0 commit comments

Comments
 (0)