Skip to content

Commit

Permalink
added string resource
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-alfresco committed Jan 15, 2024
1 parent 522d92f commit a0ce22e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import com.alfresco.content.data.payloads.FieldsData
import com.alfresco.content.process.R
import com.alfresco.content.process.ui.theme.AlfrescoError

@Composable
Expand All @@ -28,7 +30,6 @@ fun CheckBoxField(
onCheckChanged: (Boolean) -> Unit = {},
fieldsData: FieldsData = FieldsData(),
) {

val labelWithAsterisk = buildAnnotatedString {
append(fieldsData.name)
if (fieldsData.required) {
Expand All @@ -42,20 +43,21 @@ fun CheckBoxField(

Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.Start
horizontalAlignment = Alignment.Start,
) {
Row(
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.fillMaxWidth(),
) {
Checkbox(
checked = checkedValue,
onCheckedChange = { isChecked ->
onCheckChanged(isChecked)
if (fieldsData.required)
if (fieldsData.required) {
showError = !isChecked
}
}
},
)
Text(
text = labelWithAsterisk,
Expand All @@ -65,15 +67,13 @@ fun CheckBoxField(

if (showError) {
Text(
text = "This is a required field.",
text = stringResource(R.string.error_required_field),
color = AlfrescoError,
modifier = Modifier
.padding(start = 16.dp, top = 0.dp), // Adjust padding as needed
style = MaterialTheme.typography.titleSmall,
textAlign = TextAlign.Start
textAlign = TextAlign.Start,
)
}

}

}
}
1 change: 1 addition & 0 deletions process-app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<string name="error_min_value">Can\'t be less than %1$d</string>
<string name="error_max_value">Can\'t be greater than %1$d</string>
<string name="error_invalid_format">Use a different number format</string>
<string name="error_required_field">This is a required field.</string>
</resources>

0 comments on commit a0ce22e

Please sign in to comment.