Skip to content

Commit ba2b6df

Browse files
committed
clean code
1 parent 07254cd commit ba2b6df

File tree

10 files changed

+32
-34
lines changed

10 files changed

+32
-34
lines changed

SwiftPamphletApp.xcodeproj/project.pbxproj

+17-9
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,20 @@
991991
path = UseViewComponent;
992992
sourceTree = "<group>";
993993
};
994+
0846234D2BAC59AF003373D9 /* App */ = {
995+
isa = PBXGroup;
996+
children = (
997+
083554E227572BB60095E0EE /* AppVM.swift */,
998+
086A5F432744EE2800FECE02 /* SwiftPamphletAppConfig.swift */,
999+
086A5F062744E88E00FECE02 /* SwiftPamphletAppApp.swift */,
1000+
08AEAEF4277F0A1E00B969E2 /* SPSidebar.swift */,
1001+
08AEAEF0277F09D000B969E2 /* IntroView.swift */,
1002+
08AEAEF2277F09FA00B969E2 /* NavView.swift */,
1003+
084E1A6427B51EDB0072BBB6 /* AutoTask.swift */,
1004+
);
1005+
path = App;
1006+
sourceTree = "<group>";
1007+
};
9941008
084E1A6127B517990072BBB6 /* SwiftThoseThings */ = {
9951009
isa = PBXGroup;
9961010
children = (
@@ -1093,24 +1107,18 @@
10931107
086A5F052744E88E00FECE02 /* SwiftPamphletApp */ = {
10941108
isa = PBXGroup;
10951109
children = (
1110+
0846234D2BAC59AF003373D9 /* App */,
1111+
084417732B99B8EA0049297D /* HomeUI */,
10961112
0887A5982BA28F3600131359 /* Guide */,
10971113
08397E212B9EE83F00DFDD02 /* InfoOrganizer */,
1114+
086A5F252744ECD700FECE02 /* GitHubAPI */,
10981115
08ED801A2B9D1EDA0069B7EC /* Setting */,
10991116
080124FD27EC62DC00E44222 /* SwiftPamphletAppDebug.entitlements */,
11001117
08CD61FB27758B22008C0935 /* Core */,
11011118
080387652766FF3200519B15 /* Network */,
11021119
086A5F482744EF2B00FECE02 /* ViewComponet */,
11031120
08BE637A27CDD9E7002BC6A8 /* DataSorting */,
11041121
086A5F472744EF0800FECE02 /* Resource */,
1105-
086A5F252744ECD700FECE02 /* GitHubAPI */,
1106-
084417732B99B8EA0049297D /* HomeUI */,
1107-
083554E227572BB60095E0EE /* AppVM.swift */,
1108-
086A5F432744EE2800FECE02 /* SwiftPamphletAppConfig.swift */,
1109-
086A5F062744E88E00FECE02 /* SwiftPamphletAppApp.swift */,
1110-
08AEAEF4277F0A1E00B969E2 /* SPSidebar.swift */,
1111-
08AEAEF0277F09D000B969E2 /* IntroView.swift */,
1112-
08AEAEF2277F09FA00B969E2 /* NavView.swift */,
1113-
084E1A6427B51EDB0072BBB6 /* AutoTask.swift */,
11141122
086A5F0A2744E89100FECE02 /* Assets.xcassets */,
11151123
086A5F0F2744E89100FECE02 /* SwiftPamphletApp.entitlements */,
11161124
086A5F0C2744E89100FECE02 /* Preview Content */,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

SwiftPamphletApp/GitHubAPI/Developer/EditDeveloper.swift

+12-22
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ struct EditDeveloper: View {
1212
@Bindable var dev: DeveloperModel
1313
@State var vm: UserVM
1414
@State private var tabSelct = 1
15-
var isCleanUnread = false
16-
@State private var unReadCount = 0
17-
var isShowUserEventLink = true
1815

1916
var body: some View {
2017
TextField("请输入账号:", text: $dev.name)
@@ -73,7 +70,7 @@ struct EditDeveloper: View {
7370

7471
TabView(selection: $tabSelct) {
7572

76-
DeveloperEventView(events: vm.events, isShowUserEventLink: isShowUserEventLink, unReadCount: unReadCount)
73+
DeveloperEventView(events: vm.events)
7774
.tabItem {
7875
Image(systemName: "keyboard")
7976
Text("事件")
@@ -83,7 +80,7 @@ struct EditDeveloper: View {
8380
vm.doing(.inEvent)
8481
}
8582
.tag(1)
86-
DeveloperEventView(events: vm.receivedEvents, isShowActor: true, isShowUserEventLink: isShowUserEventLink)
83+
DeveloperEventView(events: vm.receivedEvents)
8784
.tabItem {
8885
Image(systemName: "keyboard.badge.ellipsis")
8986
Text("Ta 接收的事件")
@@ -100,26 +97,19 @@ struct EditDeveloper: View {
10097

10198
struct DeveloperEventView: View {
10299
var events: [EventModel]
103-
var isShowActor = false
104-
var isShowUserEventLink = true
105-
var unReadCount = 0
106100
var body: some View {
107101
List {
108102
ForEach(Array(events.enumerated()), id: \.0) { i, event in
109-
110-
if isShowUserEventLink == true {
111-
NavigationLink {
112-
UserEventLinkDestination(event: event)
113-
} label: {
114-
AUserEventLabel(
115-
event: event,
116-
isShowActor: isShowActor,
117-
isUnRead: unReadCount > 0 && i < unReadCount
118-
)
119-
} // end NavigationLink
120-
} else {
121-
AUserEventLabel(event: event, isShowActor: isShowActor, isUnRead: unReadCount > 0 && i < unReadCount)
122-
}
103+
104+
NavigationLink {
105+
UserEventLinkDestination(event: event)
106+
} label: {
107+
AUserEventLabel(
108+
event: event,
109+
isShowActor: false,
110+
isUnRead: false
111+
)
112+
} // end NavigationLink
123113
} // end ForEach
124114
}// end List
125115
.id(UUID()) // 优化 commits 有多个时数据变化可能影响的性能。这样做每次更新都产生新的视图,因此无法做动画效果。相当于 UITableView 上的 reloadData()

SwiftPamphletApp/InfoOrganizer/Info/InfoRowView.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ struct InfoRowView: View {
1818
var body: some View {
1919
VStack(alignment:.leading) {
2020
HStack {
21-
if info.category != nil {
22-
Text(info.category?.name ?? "")
23-
}
2421
if info.star == true {
2522
Image(systemName: "star.fill")
2623
}
24+
if info.category != nil {
25+
Text(info.category?.name ?? "")
26+
}
2727
Spacer()
2828
}
2929
.foregroundColor(light: .secondary, dark: .secondary)

0 commit comments

Comments
 (0)