home_widget
home_widget copied to clipboard
LockScreen widget for IOS 16?
Is there a possibility to create the new lockscreen widgets for IOS 16 with this plugin or is it planned?
Thanks
its possible, use families
private var supportedFamilies: [WidgetFamily] { if #available(iOSApplicationExtension 16.0, *) { return [ .systemSmall, .systemMedium, .systemLarge, .accessoryCircular, .accessoryRectangular, .accessoryInline ] } else { return [ .systemSmall, .systemMedium, .systemLarge ] } }
var body: some WidgetConfiguration {
StaticConfiguration(kind: kind, provider: Provider()) { entry in
HomeWidgetExampleEntryView(entry: entry)
}
.configurationDisplayName("title")
.description("description")
.supportedFamilies(supportedFamilies)
}
then:
struct HomeWidgetExampleEntryView : View { var entry: Provider.Entry let data = UserDefaults.init(suiteName:widgetGroupId) @Environment(.widgetFamily) private var family
var body: some View {
switch family {
case .systemSmall:
SmallWidgetView(entry: entry)
case .systemMedium:
MediumWidgetView(entry: entry)
case .systemLarge, .systemExtraLarge:
LargeWidgetView(entry: entry)
case .accessoryCircular:
yourWidget()
case .accessoryInline:
yourWidget()
case .accessoryRectangular:
yourWidget()
default:
EmptyView()
}
}
}
accesoryCircular and AccesoryRectangular is LockScreen widgets!
thank you very much. I tried the code but its only working without accesoryCircular and accesoryRectangular. I get an white widget. This behavior affects the normal widgets and the new screenlock widgets.
I think I found the issue. It seems that the new LockScreen widgets has a limitation that is lower than the normal widgets. I have set too many entries.