snapshot current state before gitea sync
This commit is contained in:
@@ -8,25 +8,43 @@
|
||||
import SwiftUI
|
||||
|
||||
struct CourseCatalogView: View {
|
||||
func parse() -> [Course] {
|
||||
|
||||
var courses: [Course] {
|
||||
let url = Bundle.main.url(forResource: "courses", withExtension: "json")!
|
||||
let data = try! Data(contentsOf: url)
|
||||
let decoder = JSONDecoder()
|
||||
let products = try? decoder.decode([Course].self, from: data)
|
||||
return products!
|
||||
var courses = try? decoder.decode([Course].self, from: data)
|
||||
|
||||
courses?.sort(by: { $0.name < $1.name })
|
||||
return courses!
|
||||
}
|
||||
|
||||
@State var searchText = ""
|
||||
|
||||
var searchResults: [Course] {
|
||||
if searchText.isEmpty {
|
||||
return courses
|
||||
} else {
|
||||
return courses.filter { $0.name.contains(searchText) }
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
NavigationView {
|
||||
List{
|
||||
ForEach(parse(), id: \.self) { item in
|
||||
VStack(alignment: .leading, spacing: 0){
|
||||
Text("name:\(item.name)")
|
||||
Text("\(item.description)")
|
||||
List {
|
||||
ForEach(searchResults, id: \.self) { item in
|
||||
|
||||
NavigationLink(destination: CourseDetailsView(item)) {
|
||||
VStack(alignment: .leading) {
|
||||
Text(item.name)
|
||||
Text(item.type)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(Color.gray)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.searchable(text: $searchText)
|
||||
.navigationBarTitle("Courses")
|
||||
}
|
||||
}
|
||||
@@ -34,6 +52,8 @@ struct CourseCatalogView: View {
|
||||
|
||||
struct CourseCatalogView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
CourseCatalogView().preferredColorScheme(.dark)
|
||||
Group {
|
||||
CourseCatalogView().preferredColorScheme(.dark)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
32
StudyStructure/CourseDetailsView.swift
Normal file
32
StudyStructure/CourseDetailsView.swift
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// CourseDetailsView.swift
|
||||
// CourseDetailsView
|
||||
//
|
||||
// Created by Felix Förtsch on 01.08.21.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct CourseDetailsView: View {
|
||||
|
||||
init(_ course: Course) {
|
||||
self.course = course
|
||||
}
|
||||
|
||||
let course: Course
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text(course.id)
|
||||
Text(course.name)
|
||||
Text(course.description)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//struct CourseDetailsView_Previews: PreviewProvider {
|
||||
// static var previews: some View {
|
||||
// CourseDetailsView()
|
||||
// }
|
||||
//}
|
||||
@@ -15,21 +15,22 @@ struct Course: Codable, Hashable {
|
||||
var cp: Int
|
||||
}
|
||||
|
||||
struct SlotTypes: Codable {
|
||||
var cp: Int
|
||||
var amount: Int
|
||||
var type: String
|
||||
}
|
||||
|
||||
struct Curriculum : Codable {
|
||||
let id: Int
|
||||
let name: String
|
||||
let cp: Int
|
||||
let publishedDate: Date
|
||||
var slotTypes: [SlotTypes]
|
||||
}
|
||||
|
||||
struct School: Codable {
|
||||
var name: String
|
||||
var curriculums: [Curriculum]
|
||||
|
||||
struct Curriculum : Codable {
|
||||
let id: Int
|
||||
let name: String
|
||||
let cp: Int
|
||||
let publishedDate: Date
|
||||
var slotTypes: [SlotTypes]
|
||||
|
||||
struct SlotTypes: Codable {
|
||||
var cp: Int
|
||||
var amount: Int
|
||||
var type: String
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -394,7 +394,7 @@
|
||||
{
|
||||
"id": "10-202-2225",
|
||||
"name": "Zeichnen von Graphen",
|
||||
"type": "",
|
||||
"type": "Vertiefungsmodul",
|
||||
"cp": 10,
|
||||
"description": "",
|
||||
"duration": 1
|
||||
|
||||
Reference in New Issue
Block a user