Providing timeline entries to your widget
To display information in a widget, you will configure the widget’s timeline provider. This generates a timeline consisting of timeline entries. Each entry specifies the date and time to update the widget’s content. You’ll use the SharedData
class to get the list of journal entries, create timeline entries for each journal entry, and configure them to be displayed every five minutes. Follow these steps:
- Stop your widget if it is running. Click the JRNLWidget file inside the JRNLWidget group in the Project navigator. Widgets are built using SwiftUI, so just like in Chapter 24, Getting Started with SwiftUI, you’ll see your widget’s code on the left side of the editor, and a canvas containing a preview on the right side.
- Click the Resume arrow to preview the widget in the canvas. It just displays the time and an emoji.
- Your widget is declared and defined in the
JRNLWidget
structure. Modify...