A small project to learn the fundamentals of how to create a simple Widget with an intent and configuration for iOS 17+.
- Functionality
- Tech Stack
- Frameworks
- Device Compatibility
- Screenshots
- Learnings
- Code Comments
- Pull Requests
- Credits
A simple Date Widget that changes the day at midnight and its theme every month. With iOS17+ it is also available in the StandBy mode.
- Xcode 15.0
- Swift 5.9
- SwiftUI
- WidgetKit
- iPhone with iOS 17+
- iPad with iOS 17+
Widget Normal Font | Intent |
---|---|
Configuration | Widget Fun Font |
---|---|
StandBy Mode (iOS17) |
---|
Different Days Overview |
---|
- A Widget comes in 4 "fixed" sizes: systemSmall, systemMedium, systemLarge, systemExtraLarge
- The shape of a Widget is given
- The content of a widget can only be implemented with SwiftUI (no UIKit)
- The IntentTimelineProvider creates the timeline of the widget when to update its content:
- placehoder: dummy data (in case there is no data from the snapshot eg. network call needed)
- getSnapshot: how does the widget look right now (this state is shown in the widget gallery)
- getTimeline: this is where the timeline actually gets created. It consists of an Array of entries (the data)
-
- Create a intent definition file add some intents with parameters
-
- Add the IntentConfiguration to the Widget, which then takes in a IntentTimelineProvider
I love putting in the effort of adding comments to my code, here is why.
When I create PRs I stick to this guideline.
- App Intents for Widget-Configuration and interactive Widgets
- Because I want to be able the new way of implementing App Intents in code rather than using the SiriKit definition file (prior to iOS17).
- Because I don't want to fidle around with
if #available(iOS 17, *) {...}
ππ½ Sean Allen iOS Courses
Made with a π Simon Berner