/
AttachmentsPickerTabFactories.kt
60 lines (57 loc) · 2.61 KB
/
AttachmentsPickerTabFactories.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* Copyright (c) 2014-2022 Stream.io Inc. All rights reserved.
*
* Licensed under the Stream License;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/GetStream/stream-chat-android/blob/main/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.getstream.chat.android.compose.ui.messages.attachments.factory
/**
* Provides different attachment picker tab factories that build tab icons and tab contents for
* the attachment picker.
*/
public object AttachmentsPickerTabFactories {
/**
* Builds the default list of attachment picker tab factories.
*
* @param imagesTabEnabled If the factory that allows users to pick images is included in the resulting list.
* @param filesTabEnabled If the factory that allows users to pick files is included in the resulting list.
* @param takeImageEnabled If the factory that allows users to start image capture is included in the resulting list.
* @param recordVideoEnabled If the factory that allows users to start video capture is included in the resulting list.
* @return The default list of attachment picker tab factories.
*/
public fun defaultFactories(
imagesTabEnabled: Boolean = true,
filesTabEnabled: Boolean = true,
takeImageEnabled: Boolean = true,
recordVideoEnabled: Boolean = true,
): List<AttachmentsPickerTabFactory> {
return listOfNotNull(
if (imagesTabEnabled) AttachmentsPickerImagesTabFactory() else null,
if (filesTabEnabled) AttachmentsPickerFilesTabFactory() else null,
when {
takeImageEnabled && recordVideoEnabled ->
AttachmentsPickerMediaCaptureTabFactory(
AttachmentsPickerMediaCaptureTabFactory.PickerMediaMode.PHOTO_AND_VIDEO
)
takeImageEnabled ->
AttachmentsPickerMediaCaptureTabFactory(
AttachmentsPickerMediaCaptureTabFactory.PickerMediaMode.PHOTO
)
recordVideoEnabled ->
AttachmentsPickerMediaCaptureTabFactory(
AttachmentsPickerMediaCaptureTabFactory.PickerMediaMode.VIDEO
)
else -> null
}
)
}
}