After iOS 17 / Xcode 15 the previews for my widgets are inset and squeezed into the view.
I added a .contentMarginsDisabled() modifier to the intent, which fixes this within the precise widgets on a tool, however the previews nonetheless present it with the padding.
struct SmallWidgetView_Previews: PreviewProvider {
static var previews: some View {
ForEach(BasketballWidgetEntry.mockEntries) { entry in
GeometryReader { geometry in
SmallWidgetView(
entry: entry,
width: geometry.measurement.width,
top: geometry.measurement.top,
colorSet: .colorSetOrange
)
}
.previewContext(
WidgetPreviewContext(household: .systemSmall)
)
}
}
}
@primary
struct BasketballWidgetAppWidget: Widget {
let sort: String = "BasketballWidgetAppWidget"
var physique: some WidgetConfiguration {
IntentConfiguration(
sort: sort,
intent: ConfigurationIntent.self,
supplier: Supplier()
) { entry in
WidgetEntryView(entry: entry)
}
.configurationDisplayName("Basketball Crew Scores")
.description("You favourite workforce's basketball workforce scores")
.supportedFamilies([
.systemSmall,
.systemMedium,
.systemLarge,
.accessoryCircular
])
.contentMarginsDisabled()
}
}
What am I presumably lacking right here? 🙂
// Replace
As requested right here can be the implementation of SmallWidgetView
struct SmallWidgetView: View {
let entry: BasketballWidgetEntry
let width: CGFloat
let top: CGFloat
let colorSet: WidgetColorSet
var physique: some View {
let index = entry.favoriteIndex
VStack(spacing: 0) {
StandingsListSmall(
entry: entry,
favoriteIndex: index,
width: width,
colorSet: colorSet
)
.padding(.backside, 0)
}
.font(.caption)
.body(width: width, top: top, alignment: .middle)
.backgroundColor(colorSet.backgroundMain)
.overlay(
NextGameSmallWidgetView(
width: width,
match: MatchFunctions.getNextMatch(matches: entry.matches),
favoriteId: entry.favoriteId,
colorSet: colorSet
),
alignment: .backside
)
.overlay(
FavoriteTeamHeader(
entry: entry,
index: index,
width: width,
colorSet: colorSet
),
alignment: .topLeading
)
.widgetBackground(Shade.black)
}
}