This repository has been archived by the owner on Oct 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b26dce
commit 4e20539
Showing
14 changed files
with
153 additions
and
103 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
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,43 @@ | ||
// | ||
// WidgetData.swift | ||
// Meta | ||
// | ||
// Created by david-swift on 15.08.24. | ||
// | ||
|
||
/// Data passed to widgets when initializing or updating the container. | ||
public struct WidgetData { | ||
|
||
/// The view modifiers. | ||
public var modifiers: [(AnyView) -> AnyView] = [] | ||
/// The scene storage of the parent scene element. | ||
public var sceneStorage: SceneStorage | ||
/// The app storage of the parent app. | ||
public var appStorage: any AppStorage | ||
/// Fields for custom data. | ||
public var fields: [String: Any] = [:] | ||
|
||
/// Modify the data so that there are no modifiers. | ||
public var noModifiers: Self { | ||
modify { $0.modifiers = [] } | ||
} | ||
|
||
/// Initialize widget data. | ||
/// - Parameters: | ||
/// - sceneStorage: The storage of the parent scene element. | ||
/// - appStorage: The storage of the parent app. | ||
public init(sceneStorage: SceneStorage, appStorage: any AppStorage) { | ||
self.sceneStorage = sceneStorage | ||
self.appStorage = appStorage | ||
} | ||
|
||
/// Modify the widget data. | ||
/// - Parameter action: The modification action. | ||
/// - Returns: The data. | ||
public func modify(action: (inout Self) -> Void) -> Self { | ||
var newSelf = self | ||
action(&newSelf) | ||
return newSelf | ||
} | ||
|
||
} |
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
Oops, something went wrong.