diff --git a/openfeedback-m3/src/commonMain/kotlin/io/openfeedback/m3/OpenFeedbackLayout.kt b/openfeedback-m3/src/commonMain/kotlin/io/openfeedback/m3/OpenFeedbackLayout.kt index 2e96f06..cc64467 100644 --- a/openfeedback-m3/src/commonMain/kotlin/io/openfeedback/m3/OpenFeedbackLayout.kt +++ b/openfeedback-m3/src/commonMain/kotlin/io/openfeedback/m3/OpenFeedbackLayout.kt @@ -4,9 +4,7 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope -import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment @@ -23,6 +21,7 @@ import io.openfeedback.ui.models.UIVoteItem * @param sessionFeedback Ui model for vote items, new comment value and comments. * @param modifier The modifier to be applied to the component. * @param columnCount Number of column to display for vote items. + * @param displayComments Flag to display comments or not. * @param horizontalArrangement The horizontal arrangement of the vote items layout. * @param verticalArrangement The vertical arrangement to display between every column. * @param comment API slot for the list of comments. @@ -35,8 +34,9 @@ fun OpenFeedbackLayout( sessionFeedback: UISessionFeedback, modifier: Modifier = Modifier, columnCount: Int = 2, + displayComments: Boolean = true, horizontalArrangement: Arrangement.Horizontal = Arrangement.spacedBy(8.dp), - verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(8.dp), + verticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(16.dp), comment: @Composable ColumnScope.(UIComment) -> Unit, commentInput: @Composable ColumnScope.() -> Unit, voteItem: @Composable ColumnScope.(UIVoteItem) -> Unit @@ -52,16 +52,13 @@ fun OpenFeedbackLayout( verticalArrangement = verticalArrangement, content = voteItem ) - if (sessionFeedback.comments.isNotEmpty()) { - Spacer(modifier = Modifier.height(8.dp)) + if (displayComments) { CommentItems( comments = sessionFeedback.comments, - verticalArrangement = verticalArrangement, commentInput = commentInput, comment = comment ) } - Spacer(modifier = Modifier.height(8.dp)) Box( modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center diff --git a/openfeedback-viewmodel/src/commonMain/kotlin/io/openfeedback/OpenFeedback.kt b/openfeedback-viewmodel/src/commonMain/kotlin/io/openfeedback/OpenFeedback.kt index 918759c..5d310f0 100644 --- a/openfeedback-viewmodel/src/commonMain/kotlin/io/openfeedback/OpenFeedback.kt +++ b/openfeedback-viewmodel/src/commonMain/kotlin/io/openfeedback/OpenFeedback.kt @@ -31,6 +31,7 @@ import io.openfeedback.viewmodels.getFirebaseApp * @param sessionId Firestore session id * @param modifier The modifier to be applied to the component. * @param columnCount Number of column to display for vote items. + * @param displayComments Flag to display comments or not. * @param languageCode Language code of the user. * @param appName Locale openfeedback name, used to restore openfeedback configuration. * @param loading Component to display when the view model fetch vote items. @@ -43,6 +44,7 @@ fun OpenFeedback( sessionId: String, modifier: Modifier = Modifier, columnCount: Int = 2, + displayComments: Boolean = true, languageCode: String = Locale.from(Locales.currentLocaleString()).language.code, appName: String? = null, loading: @Composable () -> Unit = { Loading(modifier = modifier) }, @@ -67,6 +69,7 @@ fun OpenFeedback( sessionFeedback = session, modifier = modifier, columnCount = columnCount, + displayComments = displayComments, comment = { Comment( comment = it, diff --git a/sample-app-shared/src/commonMain/kotlin/io/openfeedback/shared/main.kt b/sample-app-shared/src/commonMain/kotlin/io/openfeedback/shared/main.kt index 53b5184..c6a1845 100644 --- a/sample-app-shared/src/commonMain/kotlin/io/openfeedback/shared/main.kt +++ b/sample-app-shared/src/commonMain/kotlin/io/openfeedback/shared/main.kt @@ -42,7 +42,8 @@ fun SampleApp( OpenFeedback( projectId = "eaJnyMXD3oNfhrrnBYDT", sessionId = "100", - modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp) + modifier = Modifier.padding(horizontal = 8.dp, vertical = 4.dp), + displayComments = true ) } }