-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement PollMessageContent (3) (#5311)
* Implement AttachmentsPickerPollTabFactory and add it into the AttachmentsPickerTabFactory * Implement animating content systems for the full screen attachment * Implement PollOptionHeader and relevant actions * Implement PollOptionInput and PollOptionQuestions composable components * Improve full screen attachment height size animation and fix flickering bugs * Implement maxLength parameter on PollOptionInput * Rename poll components name * Implement reoderable PollQuestionList and nested scroll * Implement poll question list item following the design guidelines * Improve reordering performance for PollQuestionList * Refactor PollQuestionList to use PollOptionItem * Refactor PollQuestionList * implement eror handling for option item list creation * Refactor to hold poll option item list * Check if the title is not blank * Implemetn PollCreationDiscardDialog Composable * Implement the skeleton of the PollSwitchList and relevant data classes * Complete PollSwitchList composable * Implement poll switch inputs * Add default options * Update detekt baseline * Fix docs module to work * Import paparazzi plugin and implement BaseComposeTest * Implement PollUITest and generate snapshot images * Update detekt * Implement AttachmentsPickerPollTabFactory and make poll tab items customizable * Add missing docs for poll data classes * Implement AttachmentPickerAction interface * Update detektBaseline * Update attachment docs * Implement poll creation business logic for Compose UI * Add default lambda to the onAttachmentPickerAction composable * Update detektBaseline * Implement PollMessageContent composable * Implement PreviewPollData and the skeleton of the PollMessageContent * Implement casting a vote using a checkbox on the option * Implement PollOptionItem following the design guidelines * Check if the option is voted by mine * Update poll item uis based on the given models * Fix docs that are not related to v6 for attachment lambdas * Implement closing a poll * Fix ktlint and code formats * Implement removing a vote * Implement PollState and the skeleton of the PollMoreOptionDialog composable * Sepearate into the PollMoreOptionsDialog composable * Implement PollMoreOptionsTitle * Implement PollMoreOptionsDialog * Implement updating poll information * Fix poll relevant events * Implement UserAvatarRow * Implement PollSelectionType * Implement the sekeleton of PollViewResultDialog * Update detekt rules * Implement PollViewResultItem * Implement UserAvatar on the poll vote items * Remove unused listViewModel parameter on PollViewResultDialog * Implement poll created and closed message preview * Use AnimatedVisibility for preventing duplicated animation updates * Update detekt rules * Improve UserAvatarRow * Run spotless * Add initial doc files for the poll components * Add poll creation docs and relevant resources * Fix typo * Fix typo * Add docs for PollMessageContent * Implement Poll previews & screenshot unit tests (4) (#5330) * Implement previews for poll dialogs * Add ui tests for Poll dialogs * Generate screenshots from the ui test --------- Co-authored-by: Kanat Kiialbaev <[email protected]>
- Loading branch information
Showing
43 changed files
with
2,633 additions
and
22 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
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
99 changes: 94 additions & 5 deletions
99
stream-chat-android-compose/api/stream-chat-android-compose.api
Large diffs are not rendered by default.
Oops, something went wrong.
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
108 changes: 108 additions & 0 deletions
108
...id-compose/src/main/java/io/getstream/chat/android/compose/previewdata/PreviewPollData.kt
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,108 @@ | ||
/* | ||
* Copyright (c) 2014-2024 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.previewdata | ||
|
||
import io.getstream.chat.android.models.Option | ||
import io.getstream.chat.android.models.Poll | ||
import io.getstream.chat.android.models.Vote | ||
import io.getstream.chat.android.models.VotingVisibility | ||
import java.util.Date | ||
import java.util.UUID | ||
|
||
/** | ||
* Provides sample poll that will be used to render previews. | ||
*/ | ||
internal object PreviewPollData { | ||
|
||
private val option1 = Option( | ||
id = UUID.randomUUID().toString(), | ||
text = "option1", | ||
) | ||
|
||
private val option2 = Option( | ||
id = UUID.randomUUID().toString(), | ||
text = "option2", | ||
) | ||
|
||
private val option3 = Option( | ||
id = UUID.randomUUID().toString(), | ||
text = "option3", | ||
) | ||
|
||
val poll1 = Poll( | ||
id = UUID.randomUUID().toString(), | ||
name = "Vote an option!", | ||
description = "This is a poll", | ||
options = listOf(option1, option2, option3), | ||
votingVisibility = VotingVisibility.PUBLIC, | ||
enforceUniqueVote = true, | ||
maxVotesAllowed = 1, | ||
allowUserSuggestedOptions = false, | ||
allowAnswers = true, | ||
voteCountsByOption = mapOf( | ||
option1.id to 3, | ||
option2.id to 1, | ||
option3.id to 1, | ||
), | ||
votes = listOf( | ||
Vote( | ||
id = UUID.randomUUID().toString(), | ||
pollId = UUID.randomUUID().toString(), | ||
optionId = option1.id, | ||
createdAt = Date(), | ||
updatedAt = Date(), | ||
user = PreviewUserData.user1, | ||
), | ||
Vote( | ||
id = UUID.randomUUID().toString(), | ||
pollId = UUID.randomUUID().toString(), | ||
optionId = option1.id, | ||
createdAt = Date(), | ||
updatedAt = Date(), | ||
user = PreviewUserData.user2, | ||
), | ||
Vote( | ||
id = UUID.randomUUID().toString(), | ||
pollId = UUID.randomUUID().toString(), | ||
optionId = option1.id, | ||
createdAt = Date(), | ||
updatedAt = Date(), | ||
user = PreviewUserData.user3, | ||
), | ||
Vote( | ||
id = UUID.randomUUID().toString(), | ||
pollId = UUID.randomUUID().toString(), | ||
optionId = option2.id, | ||
createdAt = Date(), | ||
updatedAt = Date(), | ||
user = PreviewUserData.user4, | ||
), | ||
Vote( | ||
id = UUID.randomUUID().toString(), | ||
pollId = UUID.randomUUID().toString(), | ||
optionId = option3.id, | ||
createdAt = Date(), | ||
updatedAt = Date(), | ||
user = PreviewUserData.user5, | ||
), | ||
), | ||
ownVotes = listOf(), | ||
createdAt = Date(), | ||
updatedAt = Date(), | ||
closed = false, | ||
) | ||
} |
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
119 changes: 119 additions & 0 deletions
119
...ose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/UserAvatarRow.kt
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,119 @@ | ||
/* | ||
* Copyright (c) 2014-2024 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.components.avatar | ||
|
||
import androidx.compose.foundation.layout.Arrangement | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.IntrinsicSize | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.offset | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.layout.width | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.graphics.Shape | ||
import androidx.compose.ui.text.TextStyle | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import androidx.compose.ui.unit.Dp | ||
import androidx.compose.ui.unit.DpOffset | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.zIndex | ||
import io.getstream.chat.android.compose.previewdata.PreviewUserData | ||
import io.getstream.chat.android.compose.ui.theme.ChatTheme | ||
import io.getstream.chat.android.models.User | ||
|
||
/** | ||
* Represents the [User] avatar that's shown on the Messages screen or in headers of DMs. | ||
* | ||
* Based on the state within the [User], we either show an image or their initials. | ||
* | ||
* @param users The list of users whose avatar we want to show. | ||
* @param modifier Modifier for styling. | ||
* @param maxAvatarCount The maximum count for displaying the avatar row. | ||
* @param size The size of each user avatar. | ||
* @param offset The offset of the | ||
* @param shape The shape of the avatar. | ||
* @param textStyle The [TextStyle] that will be used for the initials. | ||
* @param contentDescription The content description of the avatar. | ||
* @param initialsAvatarOffset The initials offset to apply to the avatar. | ||
* @param onClick The handler when the user clicks on the avatar. | ||
*/ | ||
@Composable | ||
public fun UserAvatarRow( | ||
users: List<User>, | ||
modifier: Modifier = Modifier, | ||
maxAvatarCount: Int = 3, | ||
size: Dp = 20.dp, | ||
offset: Int = 7, | ||
shape: Shape = ChatTheme.shapes.avatar, | ||
textStyle: TextStyle = ChatTheme.typography.title3Bold, | ||
contentDescription: String? = null, | ||
initialsAvatarOffset: DpOffset = DpOffset(0.dp, 0.dp), | ||
onClick: (() -> Unit)? = null, | ||
) { | ||
if (users.isEmpty()) return | ||
|
||
Row( | ||
modifier = modifier.width(IntrinsicSize.Min), | ||
horizontalArrangement = Arrangement.spacedBy((-offset).dp), | ||
) { | ||
users.take(maxAvatarCount).forEachIndexed { index, user -> | ||
UserAvatar( | ||
modifier = Modifier | ||
.size(size) | ||
.zIndex((users.size - index).toFloat()), | ||
user = user, | ||
shape = shape, | ||
textStyle = textStyle, | ||
showOnlineIndicator = false, | ||
contentDescription = contentDescription, | ||
initialsAvatarOffset = initialsAvatarOffset, | ||
onClick = onClick, | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Preview | ||
@Composable | ||
private fun UserAvatarRowPreview() { | ||
ChatTheme { | ||
Column( | ||
horizontalAlignment = Alignment.End, | ||
) { | ||
UserAvatarRow( | ||
users = listOf( | ||
PreviewUserData.user1, | ||
), | ||
) | ||
UserAvatarRow( | ||
users = listOf( | ||
PreviewUserData.user1, | ||
PreviewUserData.user2, | ||
), | ||
) | ||
UserAvatarRow( | ||
users = listOf( | ||
PreviewUserData.user1, | ||
PreviewUserData.user2, | ||
PreviewUserData.user3, | ||
), | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.