Swiftpack.co - jaeho0718/JHTimeTable as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by jaeho0718.
jaeho0718/JHTimeTable 1.0.4
Customizable School Timetable Library
โญ๏ธ 1
๐Ÿ•“ 4 days ago
iOS macOS watchOS
.package(url: "https://github.com/jaeho0718/JHTimeTable.git", from: "1.0.4")

JHTimeTable

SwiftUI Customizable School TimeTable Library

screenshot

์„ค์น˜

  • Swift Package Manager

์‚ฌ์šฉํ•˜๊ธฐ

  • JHTimeTable๋ทฐ๋ฅผ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค.

    JHTimeTable(lineColor : .secondary,
                lineWidth : 1,
                resources : $data,
                onTapAction : { classdata in 
                    //์‚ฌ์šฉ์ž๊ฐ€ ์ˆ˜์—…์„ ํ„ฐ์น˜ํ–ˆ์„ ๋•Œ ์•ก์…˜
                })
    
  • JHTimeTable์—์„œ resources๋Š” ClassProtocol๋ฅผ ์ฑ„ํƒํ•œ ๊ตฌ์กฐ์ฒด ๋ฐฐ์—ด์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ClassProtocol์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    public protocol ClassProtocol : Identifiable {
    
        associatedtype TimeItem : ClassTimeProtocol
    
        /// ๊ฐ•์˜๋ช…
        var name : String { get set }
    
        /// ๊ฐ•์˜์‹ค
        var room : String? { get set }
    
        /// ์‹œ๊ฐ„ํ‘œ์— ํ‘œ์‹œ๋  ์ƒ‰์ƒ (16์ง„์ˆ˜ ์ฝ”๋“œ)
        var color : String { get set }
    
        /// ๊ฐ•์˜ ์‹œ๊ฐ„์— ๋Œ€ํ•œ ์ •๋ณด
        var times : [TimeItem] { get set }
    }
    
    
  • ๊ฐ•์˜ ์‹œ๊ฐ„์— ๋Œ€ํ•œ ์ •๋ณด๋Š” ClassTimeProtocol๋ฅผ ์ฑ„ํƒํ•ด์•ผํ•ฉ๋‹ˆ๋‹ค. ClassTimeProtocol๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    public protocol ClassTimeProtocol : Identifiable{
    
        /// ์ฃผ์ผ
        ///
        /// ์‹œ๊ฐ„ํ‘œ์— ์ฃผ์ผ์ด ํ‘œ์‹œ๋  ๋•Œ๋Š” ์ž๋™์œผ๋กœ ์ง€์—ญํ™”๋˜์–ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
        var weekday : ClassWeekType { get set }
    
        /// ์‹œ์ž‘๋˜๋Š” ์‹œ๊ฐ„
        ///
        /// HH : mm ์— ๋Œ€ํ•œ ์ •๋ณด๋งŒ ์ด์šฉํ•ฉ๋‹ˆ๋‹ค.
        var start : Date { get set }
    
        /// ๋๋‚˜๋Š” ์‹œ๊ฐ„
        ///
        /// HH : mm ์— ๋Œ€ํ•œ ์ •๋ณด๋งŒ ์ด์šฉํ•ฉ๋‹ˆ๋‹ค.
        var end : Date { get set }
    }
    
  • JHTimeTable/Example/ExampleModel.swift ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ๋ฐ์ดํ„ฐ ์˜ˆ์ œ๋ฅผ ํ™•์ธํ•˜์„ธ์š”.

์ปค์Šคํ…€ํ•˜๊ธฐ

  • JHTimeTable์€ ๋ทฐ๋ฅผ ์ปค์Šคํ…€ํ•  ์ˆ˜ ์žˆ๋Š” EnvironmentKey๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ œ๊ณตํ•˜๋Š” EnvironmentKeyํ•ญ๋ชฉ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    EnvironmentKey content
    timetableWeek ์‹œ๊ฐ„ํ‘œ์— ํ‘œ์‹œ๋  ์ฃผ์ผ (์ž๋™์œผ๋กœ ์ง€์—ญํ™” ๋˜์–ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.)
    timetableWeekFont ์‹œ๊ฐ„ํ‘œ ์ฃผ์ผ ํฐํŠธ
    timetableWeekColor ์‹œ๊ฐ„ํ‘œ ์ฃผ์ผ ์ƒ‰์ƒ
    timetableWeekHeight ์‹œ๊ฐ„ํ‘œ ์ฃผ์ผ์„ ๋‚˜ํƒ€๋‚ด๋Š” ๋ถ€๋ถ„์˜ ๋†’์ด
    timetableMinTime ์‹œ๊ฐ„ํ‘œ ์‹œ์ž‘ ์‹œ๊ฐ„
    timetableMaxTime ์‹œ๊ฐ„ํ‘œ ์ตœ๋Œ€ ์‹œ๊ฐ„
    timetableTimeFont ์‹œ๊ฐ„ํ‘œ ์‹œ๊ฐ„ ํฐํŠธ
    timetableTimeColor ์‹œ๊ฐ„ํ‘œ ์‹œ๊ฐ„ ์ƒ‰์ƒ
    timetableTimeWidth ์‹œ๊ฐ„ํ‘œ ์‹œ๊ฐ„์„ ๋‚˜ํƒ€๋‚ด๋Š” ๋ถ€๋ถ„์˜ ๋„“์ด
    timetableClassFont ์‹œ๊ฐ„ํ‘œ ์ˆ˜์—… ์ด๋ฆ„ ํฐํŠธ
    timetableRoomFont ์‹œ๊ฐ„ํ‘œ ๊ฐ•์˜์‹ค ํฐํŠธ
    timetableHeight ์‹œ๊ฐ„ํ‘œ ์…€์˜ ๋†’์ด
    timetableCornerRadius ์‹œ๊ฐ„ํ‘œ ํ…Œ๋‘๋ฆฌ ๊ณก๋ฅ  (์ตœ๋Œ€ 23)
  • ์˜ˆ์‹œ

    JHTimeTable(lineColor:.secondary.opacity(0.3),
                lineWidth: 1,
                resources: $data)
            .frame(width:300) //์‹œ๊ฐ„ํ‘œ ๋„“์ด ์ง€์ •
            .environment(\.timetableWeek, [.Mon,.Tue,.Wed,.Thu,.Fri]) //์‹œ๊ฐ„ํ‘œ์— ํ‘œ์‹œ๋  ์ฃผ์ผ ์ง€์ •
            .environment(\.timetableWeekHeight, 20) //์‹œ๊ฐ„ํ‘œ ์ฃผ์ผ ๋†’์ด ์ง€์ •
            .environment(\.timetableCornerRadius, 20) //์‹œ๊ฐ„ํ‘œ ํ…Œ๋‘๋ฆฌ ๊ณก๋ฅ  ์ง€์ •
            .environment(\.timetableMaxTime, 17) //์‹œ๊ฐ„ํ‘œ ์ตœ๋Œ€ ์‹œ๊ฐ„ ์ง€์ •
            .environment(\.timetableMinTime, 9) //์‹œ๊ฐ„ํ‘œ ์‹œ์ž‘ ์‹œ๊ฐ„ ์ง€์ •
            .environment(\.timetableHeight, 40) //์‹œ๊ฐ„ํ‘œ ์‹œ๊ฐ„ ์…€ ๋†’์ด ์ง€์ •
    

GitHub

link
Stars: 1
Last commit: 4 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1.0.4
4 days ago

Support WatchOS

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics