-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
161 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// DataLink.swift | ||
// SwiftPamphletApp | ||
// | ||
// Created by Ming Dai on 2024/3/7. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct DataLink: Identifiable { | ||
let id = UUID() | ||
let title: String | ||
let imageName: String | ||
var children: [DataLink]? | ||
|
||
@ViewBuilder | ||
static func viewToShow(for title: String?) -> some View { | ||
switch title { | ||
case "资料整理": | ||
DataSortingListView() | ||
case "库动态": | ||
ExploreRepoListView(showAsGroup: false) | ||
case "开发者": | ||
ActiveDeveloperListView(vm: IssueVM(repoName: SPC.pamphletIssueRepoName, issueNumber: 30)) | ||
case "探索库": | ||
ExploreRepoListView(showAsGroup: true) | ||
case "库存档": | ||
ExploreRepoListView(showAsGroup: true, isArchive: true) | ||
case "语法速查": | ||
IssuesListFromCustomView(vm: IssueVM(guideName: "guide-syntax")) | ||
case "特性": | ||
IssuesListFromCustomView(vm: IssueVM(guideName:"guide-features")) | ||
case "专题": | ||
IssuesListFromCustomView(vm: IssueVM(guideName:"guide-subject")) | ||
case "SwiftUI": | ||
IssuesListFromCustomView(vm: IssueVM(guideName:"lib-SwiftUI")) | ||
case "Combine": | ||
IssuesListFromCustomView(vm: IssueVM(guideName:"lib-Combine")) | ||
case "Concurrency": | ||
IssuesListFromCustomView(vm: IssueVM(guideName:"lib-Concurrency")) | ||
default: | ||
// 默认是语法速查 | ||
IssuesListFromCustomView(vm: IssueVM(guideName: "guide-syntax")) | ||
} | ||
} | ||
} | ||
|
||
extension DataLink { | ||
static var dataLinks = [ | ||
DataLink(title: "动态", imageName: "", children: [ | ||
DataLink(title: "资料整理", imageName: "p11") | ||
]), | ||
DataLink(title: "Github", imageName: "", children: [ | ||
// DataLink(title: "库动态", imageName: "p6"), | ||
// DataLink(title: "开发者", imageName: "p5"), | ||
DataLink(title: "探索库", imageName: "p24"), | ||
DataLink(title: "库存档", imageName: "p25") | ||
]), | ||
DataLink(title: "Swift指南", imageName: "", children: [ | ||
DataLink(title: "语法速查", imageName: "p23"), | ||
DataLink(title: "特性", imageName: "p10"), | ||
DataLink(title: "专题", imageName: "p12") | ||
]), | ||
DataLink(title: "库使用指南", imageName: "", children: [ | ||
DataLink(title: "SwiftUI", imageName: "p3"), | ||
DataLink(title: "Combine", imageName: "p19"), | ||
DataLink(title: "Concurrency", imageName: "p1") | ||
]) | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// MainView.swift | ||
// SwiftPamphletApp | ||
// | ||
// Created by Ming Dai on 2024/3/7. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct HomeView: View { | ||
@StateObject var appVM = AppVM() | ||
@State private var selectedDataLinkString: String? | ||
|
||
var body: some View { | ||
NavigationSplitView { | ||
SidebarView(selectedDataLinkString: $selectedDataLinkString) | ||
} detail: { | ||
DataLink.viewToShow(for: selectedDataLinkString) | ||
} | ||
.environmentObject(appVM) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// SidebarView.swift | ||
// SwiftPamphletApp | ||
// | ||
// Created by Ming Dai on 2024/3/7. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SidebarView: View { | ||
@Binding var selectedDataLinkString: String? | ||
|
||
var body: some View { | ||
// List(DataLink.dataLinks, children: \.children, selection: $selectedDataLinkString) { link in | ||
// SideBarLabel(title: link.title, imageName: link.imageName) | ||
// .tag(link.title) | ||
// } | ||
List(selection: $selectedDataLinkString, content: { | ||
ForEach(DataLink.dataLinks) { link in | ||
Section { | ||
OutlineGroup(link.children ?? [], children: \.children) { i in | ||
SideBarLabel(title: i.title, imageName: i.imageName) | ||
.tag(i.title) | ||
} | ||
} header: { | ||
Label(link.title, systemImage: "") | ||
} | ||
} | ||
}) | ||
.frame(minWidth: 200) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters