Skip to content

Commit

Permalink
fix: bug when the name of subcategory is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
dixidroid committed Mar 19, 2024
1 parent beedcb3 commit bfd0507
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package org.openedx.discussion.domain.model

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import org.openedx.discussion.R


data class TopicsData(
val coursewareTopics: List<Topic>,
val nonCoursewareTopics: List<Topic>
Expand All @@ -10,4 +15,10 @@ data class Topic(
val name: String,
val threadListUrl: String,
val children: List<Topic>
)
) {

@Composable
fun getTopicName(): String {
return name.ifEmpty { stringResource(id = R.string.discussion_unnamed_subcategory) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,24 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.*
import androidx.compose.material.Card
import androidx.compose.material.Divider
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ChevronRight
import androidx.compose.material.icons.outlined.HelpOutline
Expand Down Expand Up @@ -616,16 +631,17 @@ fun TopicItem(
topic: Topic,
onClick: (String, String) -> Unit,
) {
val topicName = topic.getTopicName()
Row(
modifier = Modifier
.fillMaxWidth()
.clickable { onClick(topic.id, topic.name) }
.clickable { onClick(topic.id, topicName) }
.padding(horizontal = 8.dp, vertical = 24.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
text = topic.name, style = MaterialTheme.appTypography.titleMedium,
text = topicName, style = MaterialTheme.appTypography.titleMedium,
color = MaterialTheme.appColors.textPrimary
)
Icon(
Expand Down
1 change: 1 addition & 0 deletions discussion/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<string name="discussion_anonymous">anonymous</string>
<string name="discussion_no_yet">No discussions yet</string>
<string name="discussion_click_button_create_discussion">Click the button below to create your first discussion.</string>
<string name="discussion_unnamed_subcategory">Unnamed subcategory</string>


<plurals name="discussion_votes">
Expand Down

0 comments on commit bfd0507

Please sign in to comment.