Skip to content

Commit

Permalink
clean old repo code
Browse files Browse the repository at this point in the history
  • Loading branch information
ming1016 committed Apr 9, 2024
1 parent 96ebc43 commit 22ba596
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 644 deletions.
8 changes: 0 additions & 8 deletions SwiftPamphletApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,10 @@
086A5F0E2744E89100FECE02 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 086A5F0D2744E89100FECE02 /* Preview Assets.xcassets */; };
086A5F2E2744ED8600FECE02 /* ActiveDeveloperListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F2A2744ED8600FECE02 /* ActiveDeveloperListView.swift */; };
086A5F302744ED8600FECE02 /* IssuesListFromCustomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F2C2744ED8600FECE02 /* IssuesListFromCustomView.swift */; };
086A5F352744ED9600FECE02 /* IssueView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F322744ED9600FECE02 /* IssueView.swift */; };
086A5F362744ED9600FECE02 /* RepoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F332744ED9600FECE02 /* RepoView.swift */; };
086A5F372744ED9600FECE02 /* UserView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F342744ED9600FECE02 /* UserView.swift */; };
086A5F3A2744EDA500FECE02 /* APIRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F382744EDA500FECE02 /* APIRequest.swift */; };
086A5F3B2744EDA500FECE02 /* GitHubAPIModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F392744EDA500FECE02 /* GitHubAPIModel.swift */; };
086A5F402744EDCE00FECE02 /* RepoVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F3D2744EDCE00FECE02 /* RepoVM.swift */; };
086A5F412744EDCE00FECE02 /* UserVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F3E2744EDCE00FECE02 /* UserVM.swift */; };
086A5F422744EDCE00FECE02 /* IssueVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F3F2744EDCE00FECE02 /* IssueVM.swift */; };
086A5F442744EE2800FECE02 /* SwiftPamphletAppConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F432744EE2800FECE02 /* SwiftPamphletAppConfig.swift */; };
Expand Down Expand Up @@ -444,12 +442,10 @@
086A5F0F2744E89100FECE02 /* SwiftPamphletApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SwiftPamphletApp.entitlements; sourceTree = "<group>"; };
086A5F2A2744ED8600FECE02 /* ActiveDeveloperListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActiveDeveloperListView.swift; sourceTree = "<group>"; };
086A5F2C2744ED8600FECE02 /* IssuesListFromCustomView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssuesListFromCustomView.swift; sourceTree = "<group>"; };
086A5F322744ED9600FECE02 /* IssueView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueView.swift; sourceTree = "<group>"; };
086A5F332744ED9600FECE02 /* RepoView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepoView.swift; sourceTree = "<group>"; };
086A5F342744ED9600FECE02 /* UserView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserView.swift; sourceTree = "<group>"; };
086A5F382744EDA500FECE02 /* APIRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = APIRequest.swift; sourceTree = "<group>"; };
086A5F392744EDA500FECE02 /* GitHubAPIModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitHubAPIModel.swift; sourceTree = "<group>"; };
086A5F3D2744EDCE00FECE02 /* RepoVM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepoVM.swift; sourceTree = "<group>"; };
086A5F3E2744EDCE00FECE02 /* UserVM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserVM.swift; sourceTree = "<group>"; };
086A5F3F2744EDCE00FECE02 /* IssueVM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueVM.swift; sourceTree = "<group>"; };
086A5F432744EE2800FECE02 /* SwiftPamphletAppConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftPamphletAppConfig.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1161,7 +1157,6 @@
086A5F1E2744ECA400FECE02 /* DetailView */ = {
isa = PBXGroup;
children = (
086A5F322744ED9600FECE02 /* IssueView.swift */,
086A5F332744ED9600FECE02 /* RepoView.swift */,
086A5F342744ED9600FECE02 /* UserView.swift */,
08448F4A279E872B00B61353 /* GuideView.swift */,
Expand Down Expand Up @@ -1189,7 +1184,6 @@
isa = PBXGroup;
children = (
086A5F3F2744EDCE00FECE02 /* IssueVM.swift */,
086A5F3D2744EDCE00FECE02 /* RepoVM.swift */,
086A5F3E2744EDCE00FECE02 /* UserVM.swift */,
);
path = VM;
Expand Down Expand Up @@ -1720,7 +1714,6 @@
08BE635027C4C0F2002BC6A8 /* PlayFormView.swift in Sources */,
08397E252B9EEE1300DFDD02 /* InfoListView.swift in Sources */,
08397E2F2B9F353B00DFDD02 /* CategoryListView.swift in Sources */,
086A5F402744EDCE00FECE02 /* RepoVM.swift in Sources */,
08BE636627C88750002BC6A8 /* PlayProgressView.swift in Sources */,
3AE0D59A2BAB0A0600D6D925 /* DeveloperListView.swift in Sources */,
084417772B99BA3F0049297D /* SidebarView.swift in Sources */,
Expand All @@ -1730,7 +1723,6 @@
08ED801C2B9D1EEC0069B7EC /* SettingView.swift in Sources */,
08CD61FE27758B8A008C0935 /* Lexer.swift in Sources */,
086A5F422744EDCE00FECE02 /* IssueVM.swift in Sources */,
086A5F352744ED9600FECE02 /* IssueView.swift in Sources */,
08522BF027CF9FFA005FF059 /* PlayAnimation.swift in Sources */,
08AEAEDD277EA64900B969E2 /* DBDevNoti.swift in Sources */,
08BE635E27C72F50002BC6A8 /* PlayNavigationView.swift in Sources */,
Expand Down
95 changes: 0 additions & 95 deletions SwiftPamphletApp/GitHubAPI/DetailView/IssueView.swift

This file was deleted.

139 changes: 2 additions & 137 deletions SwiftPamphletApp/GitHubAPI/DetailView/RepoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,127 +7,6 @@

import SwiftUI

struct RepoView: View {
enum EnterType {
case normal, readme
}
@Environment(AppVM.self) var appVM
@State var vm: RepoVM
@State private var tabSelct = 1
@State var type: EnterType = .normal
var isShowRepoCommitsLink = true
var isShowIssuesLink = true
var isCleanUnread = false
var isCleanExpUnread = false
@State private var expUnreadCount = 0

@State var isEnterFullScreen: Bool = false // 全屏控制

var body: some View {
HStack {
VStack(alignment: .leading, spacing: 10) {
HStack {
Text(vm.repo.name).font(.system(.largeTitle))
Text("(\(vm.repo.fullName))")
}
HStack {
Image(systemName: "star.fill").foregroundColor(.red)
Text("\(vm.repo.stargazersCount)")
Image(systemName: "tuningfork").foregroundColor(.cyan)
Text("\(vm.repo.forks)")
Text("议题 \(vm.repo.openIssues)")
Text("语言 \(vm.repo.language ?? "")")
ButtonGoGitHubWeb(url: vm.repo.htmlUrl ?? "https://github.com", text: "在 GitHub 上访问")
Button {
withAnimation {
isEnterFullScreen.toggle()
appVM.fullScreen(isEnter: isEnterFullScreen)
}
} label: {
Image(systemName: isEnterFullScreen == true ? "arrow.down.right.and.arrow.up.left" : "arrow.up.left.and.arrow.down.right")
}

}
if vm.repo.description != nil {
Text("简介:\(vm.repo.description ?? "")")
}

HStack {
Text("作者:")
NukeImage(width: 40, height: 40, url: vm.repo.owner.avatarUrl)
ButtonGoGitHubWeb(url: vm.repo.owner.login, text: vm.repo.owner.login, ignoreHost: true)
}
} // end VStack
Spacer()
}
.alert(vm.errMsg, isPresented: $vm.errHint, actions: {})
.frame(minWidth: SPC.detailMinWidth)

.padding(EdgeInsets(top: 20, leading: 10, bottom: 0, trailing: 10))
.onAppear {
if type == .readme {
vm.doing(.inInitJustRepo)
tabSelct = 4
} else {
vm.doing(.inInit)
}
}
.onDisappear {
appVM.expNotis[vm.repoName]?.unRead = 0
appVM.calculateExpCountNotis()
}
// end HStack

TabView(selection: $tabSelct) {
RepoCommitsView(commits: vm.commits, repo: vm.repo, isShowLink: isShowRepoCommitsLink, unReadCount: expUnreadCount)
.tabItem {
Text("新提交")
}
.onAppear(perform: {
vm.doing(.inCommit)
if isCleanExpUnread == true {
expUnreadCount = appVM.expNotis[vm.repoName]?.unRead ?? 0
vm.doing(.clearExpUnReadCommit)
appVM.expNotis[vm.repoName]?.unRead = SPC.unreadMagicNumber
appVM.calculateExpCountNotis()
}
})
.tag(1)


IssuesView(issues: vm.issues, repo: vm.repo, isShowLink: isShowIssuesLink)
.tabItem {
Text("议题列表")
}
.onAppear {
vm.doing(.inIssues)
}
.tag(2)

IssueEventsView(issueEvents: vm.issueEvents, repo: vm.repo, isShowLink: isShowIssuesLink)
.tabItem {
Text("议题事件")
}
.onAppear {
vm.doing(.inIssueEvents)
}
.tag(3)

ReadmeView(content: vm.readme.content.replacingOccurrences(of: "\n", with: ""))
.tabItem {
Text("README")
}
.onAppear {
vm.doing(.inReadme)
}
.tag(4)

} // end TabView
Spacer()
}

}

struct ReadmeView: View {
@Environment(\.colorScheme) private var colorScheme
var content: String
Expand All @@ -143,17 +22,10 @@ struct ReadmeView: View {
struct IssuesView: View {
var issues: [IssueModel]
var repo: RepoModel
var isShowLink = true
var body: some View {
List {
ForEach(issues) { issue in
if isShowLink == true {
NavigationLink(destination: IssueView(vm: IssueVM(repoName: repo.fullName, issueNumber: issue.number))) {
IssueLabelView(issue: issue)
}
} else {
IssueLabelView(issue: issue)
}
IssueLabelView(issue: issue)
} // end ForEach
} // end List
} // end body
Expand All @@ -162,17 +34,10 @@ struct IssuesView: View {
struct IssueEventsView: View {
var issueEvents: [IssueEventModel]
var repo: RepoModel
var isShowLink = true
var body: some View {
List {
ForEach(issueEvents) { issueEvent in
if isShowLink == true {
NavigationLink(destination: IssueView(vm: IssueVM(repoName: repo.fullName, issueNumber: issueEvent.issue.number))) {
IssueEventLabelView(issueEvent: issueEvent)
} // end NavigationLink
} else {
IssueEventLabelView(issueEvent: issueEvent)
}
IssueEventLabelView(issueEvent: issueEvent)
} // end ForEach
} // end List
} // end body
Expand Down
27 changes: 1 addition & 26 deletions SwiftPamphletApp/GitHubAPI/DetailView/UserView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,7 @@ struct UserEventView: View {
List {
ForEach(Array(events.enumerated()), id: \.0) { i, event in

if isShowUserEventLink == true {
NavigationLink {
UserEventLinkDestination(event: event)
} label: {
AUserEventLabel(
event: event,
isShowActor: isShowActor,
isUnRead: unReadCount > 0 && i < unReadCount
)
} // end NavigationLink
} else {
AUserEventLabel(event: event, isShowActor: isShowActor, isUnRead: unReadCount > 0 && i < unReadCount)
}
AUserEventLabel(event: event, isShowActor: isShowActor, isUnRead: unReadCount > 0 && i < unReadCount)
Divider()
} // end ForEach
}// end List
Expand All @@ -138,19 +126,6 @@ struct ListCommits: View {
}
}

struct UserEventLinkDestination: View {
var event: EventModel
var body: some View {
VStack {
if event.payload.issue?.number != nil {
IssueView(vm: IssueVM(repoName: event.repo.name, issueNumber: event.payload.issue?.number ?? 0))
} else {
RepoView(vm: RepoVM(repoName: event.repo.name), type: .readme, isShowRepoCommitsLink: false, isShowIssuesLink: false)
}
}
}
}

struct AUserEventLabel: View {
var event: EventModel
var isShowActor: Bool = false
Expand Down
4 changes: 2 additions & 2 deletions SwiftPamphletApp/GitHubAPI/Developer/EditDeveloper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ struct EditDeveloper: View {
}
.tag(1)

IssuesView(issues: repoVM.issues, repo: repoVM.repo, isShowLink: false)
IssuesView(issues: repoVM.issues, repo: repoVM.repo)
.tabItem {
Text("议题列表")
}
.tag(2)

IssueEventsView(issueEvents: repoVM.issuesEvents, repo: repoVM.repo, isShowLink: false)
IssueEventsView(issueEvents: repoVM.issuesEvents, repo: repoVM.repo)
.tabItem {
Text("议题事件")
}
Expand Down
Loading

0 comments on commit 22ba596

Please sign in to comment.