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

Compose Poll creation UI attachment components (1) #5305

Merged
merged 40 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
583e8f8
Implement AttachmentsPickerPollTabFactory and add it into the Attachm…
skydoves Jun 20, 2024
17a518b
Implement animating content systems for the full screen attachment
skydoves Jun 20, 2024
f16095e
Implement PollOptionHeader and relevant actions
skydoves Jun 20, 2024
a35b751
Implement PollOptionInput and PollOptionQuestions composable components
skydoves Jun 21, 2024
028c853
Improve full screen attachment height size animation and fix flickeri…
skydoves Jun 21, 2024
22a0afb
Implement maxLength parameter on PollOptionInput
skydoves Jun 24, 2024
6796a7d
Rename poll components name
skydoves Jun 24, 2024
a4dc985
Implement reoderable PollQuestionList and nested scroll
skydoves Jun 25, 2024
61b5638
Implement poll question list item following the design guidelines
skydoves Jun 25, 2024
11af39a
Merge into the develop branch
skydoves Jun 25, 2024
055824f
Improve reordering performance for PollQuestionList
skydoves Jun 25, 2024
df29273
Refactor PollQuestionList to use PollOptionItem
skydoves Jun 25, 2024
4af127f
Refactor PollQuestionList
skydoves Jun 25, 2024
c633d63
implement eror handling for option item list creation
skydoves Jun 26, 2024
793da2d
Refactor to hold poll option item list
skydoves Jun 26, 2024
5c0c898
Check if the title is not blank
skydoves Jun 26, 2024
813ddac
Implemetn PollCreationDiscardDialog Composable
skydoves Jun 26, 2024
796d8be
Implement the skeleton of the PollSwitchList and relevant data classes
skydoves Jun 26, 2024
1af8dbc
Complete PollSwitchList composable
skydoves Jun 27, 2024
ba507a4
Implement poll switch inputs
skydoves Jun 27, 2024
1880a2b
Add default options
skydoves Jun 27, 2024
2963fe4
Update detekt baseline
skydoves Jun 27, 2024
900027e
Fix docs module to work
skydoves Jun 27, 2024
d97e700
Merge into the develop branch
skydoves Jun 28, 2024
df4494d
Import paparazzi plugin and implement BaseComposeTest
skydoves Jun 28, 2024
59c122e
Implement PollUITest and generate snapshot images
skydoves Jun 28, 2024
c1f4d1c
Update detekt
skydoves Jun 28, 2024
368d583
Merge branch 'develop' into feature/compose-poll
skydoves Jun 30, 2024
fd536a4
Implement AttachmentsPickerPollTabFactory and make poll tab items cus…
skydoves Jul 1, 2024
d5aacad
Merge branch 'feature/compose-poll' of https://github.com/getstream/s…
skydoves Jul 1, 2024
647a83b
Add missing docs for poll data classes
skydoves Jul 1, 2024
fb83842
Implement AttachmentPickerAction interface
skydoves Jul 1, 2024
5126ba1
Update detektBaseline
skydoves Jul 1, 2024
441fe88
Update attachment docs
skydoves Jul 1, 2024
3094023
Merge branch 'develop' into feature/compose-poll
kanat Jul 8, 2024
57354ef
Fix docs that are not related to v6 for attachment lambdas
skydoves Jul 9, 2024
c5a02e8
Merge branch 'develop' into feature/compose-poll
skydoves Jul 9, 2024
2d8447c
Merge into the develop
skydoves Jul 18, 2024
61079f8
Merge branch 'develop' into feature/compose-poll
skydoves Jul 26, 2024
485837d
Merge branch 'develop' into feature/compose-poll
skydoves Jul 26, 2024
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
12 changes: 12 additions & 0 deletions .idea/inspectionProfiles/ktlint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ buildscript {
classpath Dependencies.gradleVersionsPlugin
classpath Dependencies.navigationSafeArgsGradlePlugin
classpath Dependencies.gradleNexusPublishPlugin
classpath Dependencies.paparazziPlugin
classpath Dependencies.baselineProfilePlugin
classpath Dependencies.dokka
classpath Dependencies.kotlinBinaryValidator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ object Versions {
internal const val ANDROIDX_ACTIVITY_KTX = "1.7.2"
internal const val ANDROIDX_ANNOTATIONS = "1.6.0"
internal const val ANDROIDX_APPCOMPAT = "1.6.1"
internal const val ANDROIDX_COMPOSE = "1.6.2"
internal const val ANDROIDX_COMPOSE = "1.6.8"
internal const val ANDROIDX_COMPOSE_MATERIAL3 = "1.2.1"
internal const val ANDROIDX_CORE_TEST = "2.2.0"
internal const val ANDROIDX_FRAGMENT = "1.6.1"
internal const val ANDROIDX_KTX = "1.10.1"
Expand Down Expand Up @@ -64,10 +65,12 @@ object Versions {
internal const val MOSHI = "1.15.0"
internal const val OK2CURL = "0.8.0"
internal const val OKHTTP = "4.11.0"
internal const val PAPARAZZI = "1.3.4"
internal const val PERMISSIONX = "1.7.1"
internal const val PHOTOVIEW = "1.0.1"
internal const val RETROFIT = "2.9.0"
internal const val ROBOLECTRIC = "4.10.3"
internal const val REORDERABLE = "2.1.1"
internal const val ROOM = "2.5.2"
internal const val SHIMMER = "0.5.0"
internal const val SHOT = "5.14.1"
Expand Down Expand Up @@ -123,6 +126,7 @@ object Dependencies {
const val composeUiTooling = "androidx.compose.ui:ui-tooling:${Versions.ANDROIDX_COMPOSE}"
const val composeFoundation = "androidx.compose.foundation:foundation:${Versions.ANDROIDX_COMPOSE}"
const val composeMaterial = "androidx.compose.material:material:${Versions.ANDROIDX_COMPOSE}"
const val composeMaterial3 = "androidx.compose.material3:material3:${Versions.ANDROIDX_COMPOSE_MATERIAL3}"
const val composeAccompanistPermissions =
"com.google.accompanist:accompanist-permissions:${Versions.COMPOSE_ACCOMPANIST}"
const val composeAccompanistPager = "com.google.accompanist:accompanist-pager:${Versions.COMPOSE_ACCOMPANIST}"
Expand Down Expand Up @@ -199,6 +203,7 @@ object Dependencies {
const val okhttp = "com.squareup.okhttp3:okhttp:${Versions.OKHTTP}"
const val okhttpLoggingInterceptor = "com.squareup.okhttp3:logging-interceptor:${Versions.OKHTTP}"
const val okhttpMockWebserver = "com.squareup.okhttp3:mockwebserver:${Versions.OKHTTP}"
const val paparazziPlugin = "app.cash.paparazzi:paparazzi-gradle-plugin:${Versions.PAPARAZZI}"
const val permissionx = "com.guolindev.permissionx:permissionx:${Versions.PERMISSIONX}"
const val photoview = "io.getstream:photoview:${Versions.PHOTOVIEW}"
const val photoviewDialog = "io.getstream:photoview-dialog:${Versions.PHOTOVIEW}"
Expand All @@ -209,6 +214,7 @@ object Dependencies {
const val roomKtx = "androidx.room:room-ktx:${Versions.ROOM}"
const val roomRuntime = "androidx.room:room-runtime:${Versions.ROOM}"
const val roomTesting = "androidx.room:room-testing:${Versions.ROOM}"
const val reorderable = "sh.calvin.reorderable:reorderable:${Versions.REORDERABLE}"
const val shimmer = "com.facebook.shimmer:shimmer:${Versions.SHIMMER}"
const val shot = "com.karumi:shot:${Versions.SHOT}"
const val spotlessGradlePlugin = "com.diffplug.spotless:spotless-plugin-gradle:${Versions.SPOTLESS}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class AttachmentsPickerCustomTabFactory: AttachmentsPickerTabFactory {

@Composable
override fun pickerTabContent(
onAttachmentPickerAction: (AttachmentPickerAction) -> Unit,
skydoves marked this conversation as resolved.
Show resolved Hide resolved
attachments: List<AttachmentPickerItemState>,
onAttachmentsChanged: (List<AttachmentPickerItemState>) -> Unit,
onAttachmentItemSelected: (AttachmentPickerItemState) -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class AttachmentsPickerCustomTabFactory: AttachmentsPickerTabFactory {

@Composable
override fun PickerTabContent(
onAttachmentPickerAction: (AttachmentPickerAction) -> Unit,
skydoves marked this conversation as resolved.
Show resolved Hide resolved
attachments: List<AttachmentPickerItemState>,
onAttachmentsChanged: (List<AttachmentPickerItemState>) -> Unit,
onAttachmentItemSelected: (AttachmentPickerItemState) -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ private fun CustomAttachmentsPicker(

tabFactories.getOrNull(selectedOptionIndex)
?.PickerTabContent(
onAttachmentPickerAction = { pickerAction ->
when (pickerAction) {
AttachmentPickerBack -> onDismiss.invoke()
AttachmentPickerPollCreation -> Unit
}
},
attachments = attachmentsPickerViewModel.attachments,
onAttachmentItemSelected = attachmentsPickerViewModel::changeSelectedAttachments,
onAttachmentsChanged = { attachmentsPickerViewModel.attachments = it },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class AttachmentsPickerCustomTabFactory: AttachmentsPickerTabFactory {

@Composable
override fun PickerTabContent(
onAttachmentPickerAction: (AttachmentPickerAction) -> Unit,
attachments: List<AttachmentPickerItemState>,
onAttachmentsChanged: (List<AttachmentPickerItemState>) -> Unit,
onAttachmentItemSelected: (AttachmentPickerItemState) -> Unit,
Expand Down
1 change: 1 addition & 0 deletions stream-chat-android-compose-sample/detekt-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<ID>LongMethod:MessagesActivity.kt$MessagesActivity$@Composable fun MyCustomUi()</ID>
<ID>MagicNumber:ChannelsActivity.kt$ChannelsActivity$0.5f</ID>
<ID>MagicNumber:MessagesActivity.kt$MessagesActivity$7f</ID>
<ID>MaxLineLength:MessagesActivity.kt$MessagesActivity$targetValue = if (isFullScreenContent) screenHeight.dp else ChatTheme.dimens.attachmentsPickerHeight</ID>
<ID>MaxLineLength:PredefinedUserCredentials.kt$PredefinedUserCredentials$token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiYW1pdCJ9.MNfrDsGkFINEZ3kCQ9hAqI38lZ6S-miHINAuH3kQy2o"</ID>
<ID>MaxLineLength:PredefinedUserCredentials.kt$PredefinedUserCredentials$token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiYmVsYWwifQ.a0DwMMb0V1Lona_1dIB7a4GtNl4oQ_WCp-W-UP3_CUQ"</ID>
<ID>MaxLineLength:PredefinedUserCredentials.kt$PredefinedUserCredentials$token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiZG1pdHJpaSJ9._j7pM2kqj46ztls0tG1DiUMl45l54VOLvl8jp5VCmZU"</ID>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.content.Intent
import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
Expand All @@ -36,16 +37,21 @@ import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Icon
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import io.getstream.chat.android.compose.sample.ChatApp
Expand Down Expand Up @@ -214,15 +220,28 @@ class MessagesActivity : BaseConnectedActivity() {
}

if (isShowingAttachments) {
var isFullScreenContent by rememberSaveable { mutableStateOf(false) }
val screenHeight = LocalConfiguration.current.screenHeightDp
val pickerHeight by animateDpAsState(
targetValue = if (isFullScreenContent) screenHeight.dp else ChatTheme.dimens.attachmentsPickerHeight,
label = "full sized picker animation",
)

AttachmentsPicker(
attachmentsPickerViewModel = attachmentsPickerViewModel,
modifier = Modifier
.align(Alignment.BottomCenter)
.height(350.dp),
.height(pickerHeight),
shape = if (isFullScreenContent) {
RoundedCornerShape(0.dp)
} else {
ChatTheme.shapes.bottomSheet
},
onAttachmentsSelected = { attachments ->
attachmentsPickerViewModel.changeAttachmentState(false)
composerViewModel.addSelectedAttachments(attachments)
},
onTabClick = { _, tab -> isFullScreenContent = tab.isFullContent },
onDismiss = {
attachmentsPickerViewModel.changeAttachmentState(false)
attachmentsPickerViewModel.dismissAttachments()
Expand Down
Loading
Loading