ElliotableSwiftUI
ElliotableSwiftUI 是一个用于生成大学 课程表 的简单库。
如果您只添加一门课程,课程时间将自动计算并被添加到课程表。
作者信息
iOS 开发的课程表库
作者:Denny.K (Taein Kim) / 韩国首尔
邮箱:[email protected]
博客:https://terry-some.tistory.com/
安装
Cocoapods (建设中)
Elliotable 通过 CocoaPods 提供使用,安装时只需在您的 Podfile 中添加以下行:
pod 'ElliotableSwiftUI'
使用方法
课程项结构
courseId : The identifier of the course
courseName : The name of the course
roomName : The name of the lecture room
professor : Professor Name
courseDay : Weekday of the course
startTime : Start time of course (String type - format : "HH:mm")
endTime : End time of course (String type - format : "HH:mm")
backgroundColor : backgroud color of each course item
(Optional) textColor: Course Item Text Color
生成 Swift UI 视图
您可以通过添加关于时间表样式的属性来生成时间表视图。
下面的源代码显示了生成时间表视图的几个示例。
struct ContentView: View {
var body: some View {
generateTimetableView()
}
private func generateTimetableView() -> ElliotableView {
let courseList = [
ElliottEvent(courseId: "111", courseName: "TEST1", roomName: "ROOM1", professor: "PROF1", courseDay: .monday, startTime: "09:00", endTime: "10:15", backgroundColor: .systemBlue),
ElliottEvent(courseId: "222", courseName: "TEST2", roomName: "ROOM2", professor: "PROF1", courseDay: .tuesday, startTime: "13:30", endTime: "14:45", backgroundColor: .orange),
ElliottEvent(courseId: "333", courseName: "TEST3", roomName: "ROOM3", professor: "PROF1", courseDay: .thursday, startTime: "19:00", endTime: "20:45", backgroundColor: UIColor(displayP3Red: 0, green: 1.0, blue: 1.0, alpha: 0.5)),
ElliottEvent(courseId: "444", courseName: "TEST4", roomName: "ROOM4", professor: "PROF4", courseDay: .tuesday, startTime: "14:30", endTime: "18:00", backgroundColor: UIColor(displayP3Red: 1.0, green: 1.0, blue: 0, alpha: 0.5))]
let daySymbols = ["월", "화", "수", "목", "금", "토", "일"]
let elliotableView = ElliotableView()
elliotableView.courseList(list: courseList)
elliotableView.dayCount(count: 5)
elliotableView.daySymbols(symbols: daySymbols)
elliotableView.borderColor(color: Color(.sRGB, red: 0.7, green: 0.7, blue: 0.7, opacity: 1))
elliotableView.headerFont(font: .system(size: 14, weight: .bold))
elliotableView.symbolBackgroundColor(color: Color(.sRGB, red: 0.97, green: 0.97, blue: 0.97, opacity: 1))
elliotableView.timeHeaderTextColor(color: Color(.sRGB, red: 0.6, green: 0.6, blue: 0.6, opacity: 1))
return elliotableView
}
}
(建设中)