Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AND-287] Add component factory for AttachmentsPicker send button. #5607

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
- Create thread list component factories. [#5602](https://github.com/GetStream/stream-chat-android/pull/5602)
- Create pinned message list component factories. [#5603](https://github.com/GetStream/stream-chat-android/pull/5603)
- Create search input stateless component factories. [#5604](https://github.com/GetStream/stream-chat-android/pull/5604)
- Create attachments picker send button component factory. [#5607](https://github.com/GetStream/stream-chat-android/pull/5607)

### ✅ Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,7 @@ public final class io/getstream/chat/android/compose/ui/theme/ChannelOptionsThem
}

public abstract interface class io/getstream/chat/android/compose/ui/theme/ChatComponentFactory {
public abstract fun AttachmentsPickerSendButton (ZLkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;I)V
public abstract fun Avatar--oyy2HM (Landroidx/compose/ui/Modifier;Ljava/lang/String;Ljava/lang/String;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/graphics/painter/Painter;Ljava/lang/String;JLkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;I)V
public abstract fun ChannelAvatar (Landroidx/compose/ui/Modifier;Lio/getstream/chat/android/models/Channel;Lio/getstream/chat/android/models/User;Lkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;I)V
public abstract fun ChannelItemCenterContent (Landroidx/compose/foundation/layout/RowScope;Lio/getstream/chat/android/compose/state/channels/list/ItemState$ChannelItemState;Lio/getstream/chat/android/models/User;Landroidx/compose/runtime/Composer;I)V
Expand Down Expand Up @@ -2228,6 +2229,7 @@ public abstract interface class io/getstream/chat/android/compose/ui/theme/ChatC
}

public final class io/getstream/chat/android/compose/ui/theme/ChatComponentFactory$DefaultImpls {
public static fun AttachmentsPickerSendButton (Lio/getstream/chat/android/compose/ui/theme/ChatComponentFactory;ZLkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;I)V
public static fun Avatar--oyy2HM (Lio/getstream/chat/android/compose/ui/theme/ChatComponentFactory;Landroidx/compose/ui/Modifier;Ljava/lang/String;Ljava/lang/String;Landroidx/compose/ui/graphics/Shape;Landroidx/compose/ui/text/TextStyle;Landroidx/compose/ui/graphics/painter/Painter;Ljava/lang/String;JLkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;I)V
public static fun ChannelAvatar (Lio/getstream/chat/android/compose/ui/theme/ChatComponentFactory;Landroidx/compose/ui/Modifier;Lio/getstream/chat/android/models/Channel;Lio/getstream/chat/android/models/User;Lkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;I)V
public static fun ChannelItemCenterContent (Lio/getstream/chat/android/compose/ui/theme/ChatComponentFactory;Landroidx/compose/foundation/layout/RowScope;Lio/getstream/chat/android/compose/state/channels/list/ItemState$ChannelItemState;Lio/getstream/chat/android/models/User;Landroidx/compose/runtime/Composer;I)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,26 +227,41 @@ internal fun AttachmentPickerOptions(

Spacer(modifier = Modifier.weight(1f))

IconButton(
enabled = hasPickedAttachments,
ChatTheme.componentFactory.AttachmentsPickerSendButton(
hasPickedAttachments = hasPickedAttachments,
onClick = onSendAttachmentsClick,
content = {
val layoutDirection = LocalLayoutDirection.current

Icon(
modifier = Modifier
.weight(1f)
.mirrorRtl(layoutDirection = layoutDirection)
.testTag("Stream_AttachmentPickerSendButton"),
painter = painterResource(id = R.drawable.stream_compose_ic_left),
contentDescription = stringResource(id = R.string.stream_compose_send_attachment),
tint = if (hasPickedAttachments) {
ChatTheme.colors.primaryAccent
} else {
ChatTheme.colors.textLowEmphasis
},
)
},
)
}
}

/**
* The default "Send" button in the attachments picker heading.
*
* @param hasPickedAttachments Indicator if there are selected attachments.
* @param onClick The action to be taken when the button is clicked.
*/
@Composable
internal fun DefaultAttachmentsPickerSendButton(
andremion marked this conversation as resolved.
Show resolved Hide resolved
hasPickedAttachments: Boolean,
onClick: () -> Unit,
) {
IconButton(
enabled = hasPickedAttachments,
onClick = onClick,
content = {
val layoutDirection = LocalLayoutDirection.current
Icon(
modifier = Modifier
.mirrorRtl(layoutDirection = layoutDirection)
.testTag("Stream_AttachmentPickerSendButton"),
painter = painterResource(id = R.drawable.stream_compose_ic_left),
contentDescription = stringResource(id = R.string.stream_compose_send_attachment),
tint = if (hasPickedAttachments) {
ChatTheme.colors.primaryAccent
} else {
ChatTheme.colors.textLowEmphasis
},
)
},
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ import io.getstream.chat.android.compose.ui.components.suggestions.mentions.Defa
import io.getstream.chat.android.compose.ui.components.suggestions.mentions.MentionSuggestionItem
import io.getstream.chat.android.compose.ui.components.suggestions.mentions.MentionSuggestionList
import io.getstream.chat.android.compose.ui.components.userreactions.UserReactions
import io.getstream.chat.android.compose.ui.messages.attachments.DefaultAttachmentsPickerSendButton
import io.getstream.chat.android.compose.ui.messages.composer.AttachmentsButton
import io.getstream.chat.android.compose.ui.messages.composer.CommandsButton
import io.getstream.chat.android.compose.ui.messages.composer.DefaultComposerInputContent
Expand Down Expand Up @@ -2391,4 +2392,22 @@ public interface ChatComponentFactory {
public fun PinnedMessageListLoadingMoreContent() {
DefaultPinnedMessageListLoadingMoreContent()
}

/**
* The default 'Send' button in the attachments picker.
* Shown as ">" icon in the attachments picker header, enabled when there is at least one selected attachment.
*
* @param hasPickedAttachments If there are any attachments picked.
* @param onClick The click handler for the button.
*/
@Composable
public fun AttachmentsPickerSendButton(
andremion marked this conversation as resolved.
Show resolved Hide resolved
hasPickedAttachments: Boolean,
onClick: () -> Unit,
) {
DefaultAttachmentsPickerSendButton(
hasPickedAttachments = hasPickedAttachments,
onClick = onClick,
)
}
}
Loading