vanhung / KSTimeline

Simple custom timeline written in swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

KSTimeline

KSTimeline, written in swift, is a simple and customizable view which supports showing a series of events in a vertically time-sorted structure.

Preview

Demo1

  • adjust the time scale by pinch gesture
  • display different time mode according to time scale

Demo2

  • play next event automatically
  • scroll to seek video
  • press > to next video
  • press < to previous video

Usage

Delegate

@objc public protocol KSTimelineDelegate: NSObjectProtocol {
    
    func timelineStartScroll(_ timeline: KSTimelineView)
    
    func timelineEndScroll(_ timeline: KSTimelineView)
    
    func timeline(_ timeline: KSTimelineView, didScrollTo date: Date)
    
}

Datasource

@objc public protocol KSTimelineDatasource: NSObjectProtocol {
    
    func numberOfEvents(_ timeline: KSTimelineView) -> Int
    
    func event(_ timeline: KSTimelineView, at index: Int) -> KSTimelineEvent
    
}

KSTimelineEvent

@objc public class KSTimelineEvent: NSObject {
    
    public var start: Date
    
    public var end: Date
    
    public var duration: Double
    
    public var videoURL: URL
    
    public init(start: Date, end: Date, duration: Double, videoURL: URL) {
        
        self.start = start
        
        self.end = end
        
        self.duration = duration
        
        self.videoURL = videoURL
        
        super.init()
        
    }
        
}

Installation

Cocoapods

KSTimeline can be added to your project using CocoaPods by adding the following line to your Podfile:

pod 'KSTimeline'

About

Simple custom timeline written in swift

License:MIT License


Languages

Language:Swift 97.3%Language:Ruby 1.5%Language:Objective-C 1.2%