-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Introduce backport wrapper for Views to allow easier API availability checks
- Loading branch information
Showing
7 changed files
with
82 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Created for xikolo-ios under GPL-3.0 license. | ||
// Copyright © HPI. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct Backport<Content> { | ||
let content: Content | ||
} | ||
|
||
extension View { | ||
var backport: Backport<Self> { Backport(content: self) } | ||
} | ||
|
||
extension Backport where Content: View { | ||
@ViewBuilder func widgetBackground<V: View>(@ViewBuilder backgroundView: () -> V = { Color(UIColor.systemBackground) }) -> some View { | ||
if #available(iOS 17, *) { | ||
content.containerBackground(for: .widget, content: backgroundView) | ||
} else { | ||
content | ||
} | ||
} | ||
|
||
@ViewBuilder func widgetPadding() -> some View { | ||
if #available(iOS 17, *) { | ||
content | ||
} else { | ||
content.padding() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters