Contents

TimelineEntry

A type that specifies the date to display a widget, and, optionally, indicates the current relevance of the widget’s content.

Declaration

protocol TimelineEntry

Mentioned in

Overview

A TimelineProvider creates one or more timeline entries with dates that tell WidgetKit when to display a widget. To render a widget, WidgetKit executes the content block of the widget’s configuration, passing the corresponding timeline entry.

When you declare a structure conforming to TimelineEntry, include any additional information that the configuration’s content block requires to render the widget. The following code shows a timeline entry structure for a widget that displays a game character’s health level.

struct CharacterDetailEntry: TimelineEntry {
    var date: Date
    var healthLevel: Double
}

The content block of the widget’s configuration receives the entry as a parameter and then passes the relevant information to the view that renders your widget.

struct CharacterDetailWidget: Widget {
    var body: some WidgetConfiguration {
        StaticConfiguration(
            kind: "com.mygame.character-detail",
            provider: CharacterDetailProvider()) { entry in
            CharacterDetailView(entry: entry)
        }
        .configurationDisplayName("Character Details")
        .description("Displays a character's health and other details")
        .supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
    }
}

Topics

Configuring Timeline Entry Properties

See Also

Timeline updates