Skip to content

Commit

Permalink
feat: be able to hide comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
GerardPaligot committed Jul 15, 2024
1 parent 6a6345b commit deddcd3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) },
Expand All @@ -67,6 +69,7 @@ fun OpenFeedback(
sessionFeedback = session,
modifier = modifier,
columnCount = columnCount,
displayComments = displayComments,
comment = {
Comment(
comment = it,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}
Expand Down

0 comments on commit deddcd3

Please sign in to comment.