Skip to content

Commit

Permalink
feat: make Timetable struct encodable
Browse files Browse the repository at this point in the history
  • Loading branch information
s8ngyu committed Aug 17, 2023
1 parent dd52d4e commit 3e9bd66
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 65 deletions.
75 changes: 75 additions & 0 deletions ios/OTLWidgets/OTLAPI.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
// OTLAPI.swift
// OTLWidgetsExtension
//
// Created by Soongyu Kwon on 17/08/2023.
// Copyright © 2023 The Chromium Authors. All rights reserved.
//

import Foundation

struct Timetable: Encodable, Decodable, Hashable {
let id: Int
let lectures: [Lecture]
}

struct Lecture: Encodable, Decodable, Hashable {
let id: Int
let title: String
let title_en: String
let course: Int
let old_code: String
let class_no: String
let year: Int
let semester: Int
let code: String
let department: Int
let department_code: String
let department_name: String
let department_name_en: String
let type: String
let type_en: String
let limit: Int
let num_people: Int
let is_english: Bool
let credit: Int
let credit_au: Int
let common_title: String
let common_title_en: String
let class_title: String
let class_title_en: String
let review_total_weight: Double
let grade: Double
let speech: Double
let professors: [Professor]
let classtimes: [Classtime]
let examtimes: [Examtime]
}

struct Professor: Encodable, Decodable, Hashable {
let name: String
let name_en: String
let professor_id: Int
let review_total_weight: Double
}

struct Classtime: Encodable, Decodable, Hashable {
let building_code: String
let classroom: String
let classroom_en: String
let classroom_short: String
let classroom_short_en: String
let room_name: String
let day: Int
let begin: Int
let end: Int
}

struct Examtime: Encodable, Decodable, Hashable {
let str: String
let str_en: String
let day: Int
let begin: Int
let end: Int
}

65 changes: 0 additions & 65 deletions ios/OTLWidgets/WidgetBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,71 +9,6 @@
import Foundation
import SwiftUI

struct Timetable: Decodable, Hashable {
let id: Int
let lectures: [Lecture]
}

struct Lecture: Decodable, Hashable {
let id: Int
let title: String
let title_en: String
let course: Int
let old_code: String
let class_no: String
let year: Int
let semester: Int
let code: String
let department: Int
let department_code: String
let department_name: String
let department_name_en: String
let type: String
let type_en: String
let limit: Int
let num_people: Int
let is_english: Bool
let credit: Int
let credit_au: Int
let common_title: String
let common_title_en: String
let class_title: String
let class_title_en: String
let review_total_weight: Double
let grade: Double
let speech: Double
let professors: [Professor]
let classtimes: [Classtime]
let examtimes: [Examtime]
}

struct Professor: Decodable, Hashable {
let name: String
let name_en: String
let professor_id: Int
let review_total_weight: Double
}

struct Classtime: Decodable, Hashable {
let building_code: String
let classroom: String
let classroom_en: String
let classroom_short: String
let classroom_short_en: String
let room_name: String
let day: Int
let begin: Int
let end: Int
}

struct Examtime: Decodable, Hashable {
let str: String
let str_en: String
let day: Int
let begin: Int
let end: Int
}

struct VerticalLine: Shape {
func path(in rect: CGRect) -> Path {
var path = Path()
Expand Down

0 comments on commit 3e9bd66

Please sign in to comment.