Skip to content

Commit

Permalink
Added widgetContentMarginsCompability.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvorobei committed Oct 5, 2023
1 parent eec32c3 commit 6b1b5d3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Sources/SwiftUIExtension/Compability/WidgetViewCompability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ import SwiftUI
#if canImport(WidgetKit)
import WidgetKit

extension EnvironmentValues {

public var widgetContentMarginsCompability: EdgeInsets {
get {
if #available(iOS 17.0, *) {
return self.widgetContentMargins
} else {
return .init(top: 16, leading: 16, bottom: 16, trailing: 16)
}
}
}
}

extension View {

public func containerBackgroundForWidgetCompability<Background>(background: @escaping () -> Background) -> some View where Background: View {
Expand Down

0 comments on commit 6b1b5d3

Please sign in to comment.