TimelinePreview

public struct TimelinePreview
extension TimelinePreview: View
extension TimelinePreview: _ViewEmptyChecking

TimelinePreview is an view for showing a collection of tasks. It comes with a header and a collection view which uses TimelinePreviewItem to represent data items within it.

Usage

Create a struct that conforms to the protocol: TimelinePreviewItemModel, providing implementation for the required properties and methods:
struct TimelinePreviewItemModelImplementation: TimelinePreviewItemModel {
   var id: UUID
   var title: AttributedString
   var icon: Image?
   var timelineNode: FioriSwiftUICore.TimelineNodeType
   var due: Date
   var formatter: DateFormatter?
   var isFuture: Bool?
   var isCurrent: Bool?

   init(id: UUID = UUID(), title: AttributedString, icon: Image? = nil, timelineNode: FioriSwiftUICore.TimelineNodeType, due: Date, dateFormat: String? = nil, isFuture: Bool? = nil, isCurrent: Bool? = nil) {
       self.id = id
       self.title = title
       self.icon = icon
       self.timelineNode = timelineNode
       self.due = due
       self.formatter = DateFormatter()
       if let dateFormat {
           self.formatter.dateFormat = dateFormat
       } else {
           self.formatter.dateFormat = "MMMM dd yyyy"
       }
       self.isFuture = isFuture
       self.isCurrent = isCurrent
   }
}

Create a Protocol Instance array with Initial Value
@State private var items: [TimelinePreviewItemModelImplementation] = [TimelinePreviewItemModelImplementation(title: "Complete", timelineNode: TimelineNodeType.complete, due: ISO8601DateFormatter().date(from: "2023-07-21T12:00:00Z")!),TimelinePreviewItemModelImplementation(title: "End", timelineNode: TimelineNodeType.end, due: ISO8601DateFormatter().date(from: "2023-08-10T12:00:00Z")!)]

 Create TimelinePreview with the array
TimelinePreview(optionalTitle: { Text("Timeline") }, data: .constant(items.map { $0 as any TimelinePreviewItemModel }))