Skip to content

Commit d2764ea

Browse files
Made AttachmentPickerView public
1 parent 41458bd commit d2764ea

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Composer/AttachmentPickerView.swift

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import SwiftUI
88

99
/// View for the attachment picker.
1010
public struct AttachmentPickerView<Factory: ViewFactory>: View {
11+
1112
@Injected(\.colors) private var colors
1213
@Injected(\.fonts) private var fonts
1314

@@ -28,6 +29,40 @@ public struct AttachmentPickerView<Factory: ViewFactory>: View {
2829
var isDisplayed: Bool
2930
var height: CGFloat
3031

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+
3166
public var body: some View {
3267
VStack(spacing: 0) {
3368
viewFactory.makeAttachmentSourcePickerView(
@@ -83,14 +118,23 @@ public struct AttachmentPickerView<Factory: ViewFactory>: View {
83118
}
84119

85120
/// View for picking the source of the attachment (photo, files or camera).
86-
struct AttachmentSourcePickerView: View {
121+
public struct AttachmentSourcePickerView: View {
122+
87123
@Injected(\.colors) private var colors
88124
@Injected(\.images) private var images
89125

90126
var selected: AttachmentPickerState
91127
var onTap: (AttachmentPickerState) -> Void
92128

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 {
94138

95139
HStack(alignment: .center, spacing: 24) {
96140
AttachmentPickerButton(

0 commit comments

Comments
 (0)