@@ -8,6 +8,7 @@ import SwiftUI
8
8
9
9
/// View for the attachment picker.
10
10
public struct AttachmentPickerView < Factory: ViewFactory > : View {
11
+
11
12
@Injected ( \. colors) private var colors
12
13
@Injected ( \. fonts) private var fonts
13
14
@@ -28,6 +29,40 @@ public struct AttachmentPickerView<Factory: ViewFactory>: View {
28
29
var isDisplayed : Bool
29
30
var height : CGFloat
30
31
32
+ public init (
33
+ viewFactory: Factory ,
34
+ selectedPickerState: Binding < AttachmentPickerState > ,
35
+ filePickerShown: Binding < Bool > ,
36
+ cameraPickerShown: Binding < Bool > ,
37
+ addedFileURLs: Binding < [ URL ] > ,
38
+ onPickerStateChange: @escaping ( AttachmentPickerState ) -> Void ,
39
+ photoLibraryAssets: PHFetchResult < PHAsset > ? = nil ,
40
+ onAssetTap: @escaping ( AddedAsset ) -> Void ,
41
+ onCustomAttachmentTap: @escaping ( CustomAttachment ) -> Void ,
42
+ isAssetSelected: @escaping ( String ) -> Bool ,
43
+ addedCustomAttachments: [ CustomAttachment ] ,
44
+ cameraImageAdded: @escaping ( AddedAsset ) -> Void ,
45
+ askForAssetsAccessPermissions: @escaping ( ) -> Void ,
46
+ isDisplayed: Bool ,
47
+ height: CGFloat
48
+ ) {
49
+ self . viewFactory = viewFactory
50
+ _selectedPickerState = selectedPickerState
51
+ _filePickerShown = filePickerShown
52
+ _cameraPickerShown = cameraPickerShown
53
+ _addedFileURLs = addedFileURLs
54
+ self . onPickerStateChange = onPickerStateChange
55
+ self . photoLibraryAssets = photoLibraryAssets
56
+ self . onAssetTap = onAssetTap
57
+ self . onCustomAttachmentTap = onCustomAttachmentTap
58
+ self . isAssetSelected = isAssetSelected
59
+ self . addedCustomAttachments = addedCustomAttachments
60
+ self . cameraImageAdded = cameraImageAdded
61
+ self . askForAssetsAccessPermissions = askForAssetsAccessPermissions
62
+ self . isDisplayed = isDisplayed
63
+ self . height = height
64
+ }
65
+
31
66
public var body : some View {
32
67
VStack ( spacing: 0 ) {
33
68
viewFactory. makeAttachmentSourcePickerView (
@@ -83,14 +118,23 @@ public struct AttachmentPickerView<Factory: ViewFactory>: View {
83
118
}
84
119
85
120
/// View for picking the source of the attachment (photo, files or camera).
86
- struct AttachmentSourcePickerView : View {
121
+ public struct AttachmentSourcePickerView : View {
122
+
87
123
@Injected ( \. colors) private var colors
88
124
@Injected ( \. images) private var images
89
125
90
126
var selected : AttachmentPickerState
91
127
var onTap : ( AttachmentPickerState ) -> Void
92
128
93
- var body : some View {
129
+ public init (
130
+ selected: AttachmentPickerState ,
131
+ onTap: @escaping ( AttachmentPickerState ) -> Void
132
+ ) {
133
+ self . selected = selected
134
+ self . onTap = onTap
135
+ }
136
+
137
+ public var body : some View {
94
138
95
139
HStack ( alignment: . center, spacing: 24 ) {
96
140
AttachmentPickerButton (
0 commit comments