Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply container background to widgets #2126

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .xcode-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.3.1
15.0.1
1 change: 1 addition & 0 deletions Widgets/LockScreenWidgets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct LockScreenWidgetView: View {
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Circle().foregroundColor(.white.opacity(0.3)))
.widgetContainerBackground()
}

}
10 changes: 10 additions & 0 deletions Widgets/WidgetViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ struct FavoritesWidgetView: View {
.padding(EdgeInsets(top: widgetFamily == .systemLarge ? 48 : 60, leading: 0, bottom: 0, trailing: 0))

}
.widgetContainerBackground()
}
}

Expand Down Expand Up @@ -239,12 +240,21 @@ struct SearchWidgetView: View {
}
}.accessibilityHidden(true)
}
.widgetContainerBackground()
}
}

// See https://stackoverflow.com/a/59228385/73479
extension View {

@ViewBuilder func widgetContainerBackground() -> some View {
if #available(iOSApplicationExtension 17.0, *) {
containerBackground(for: .widget) {
Color.clear
}
}
}

/// Hide or show the view based on a boolean value.
///
/// Example for visibility:
Expand Down
Loading