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 MapDataManager
class to get restaurant details, create timeline entries for each restaurant, and configure them to be displayed every five minutes. Follow these steps:
- Stop your app if it is running. Click the
LetsEatWidget
file inside theLetsEatWidget
folder in the Project navigator. 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 of the right side. - Click the Resume button to preview the widget in the canvas. It just displays the time at the moment.
- Your widget is declared and defined in the
LetsEatWidget
structure. Modify it as follows:@main...