From 03193fe957317c63671666289d00cf55e09bfb97 Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Mon, 12 Feb 2024 13:32:44 +0530 Subject: [PATCH 1/3] added functional group field --- .../content/component/ComponentData.kt | 2 +- .../content/component/ComponentSheet.kt | 27 ++- .../content/component/ComponentType.kt | 1 + .../res/layout/sheet_component_filter.xml | 10 +- .../com/alfresco/content/data/ProcessEntry.kt | 33 +++ .../content/data/payloads/FieldsData.kt | 1 + .../content/process/ui/FormDetailScreen.kt | 219 +++++++++--------- .../process/ui/components/AmountInputField.kt | 1 - .../process/ui/components/CheckboxField.kt | 53 ++++- .../process/ui/components/DateTimeField.kt | 1 - .../process/ui/components/DropdownField.kt | 1 - .../process/ui/components/FormScreen.kt | 18 +- .../process/ui/components/InputChip.kt | 10 +- .../ui/components/IntegerInputField.kt | 1 - .../ui/components/MultiLineInputField.kt | 1 - .../process/ui/components/PeopleField.kt | 4 +- .../process/ui/components/ReadOnlyField.kt | 1 - .../ui/components/SingleLineInputField.kt | 6 +- .../ui/components/TextLayoutHandler.kt | 20 ++ .../ui/components/TrailingInputField.kt | 58 +++-- .../content/process/ui/components/Utils.kt | 4 +- 21 files changed, 297 insertions(+), 175 deletions(-) create mode 100644 process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TextLayoutHandler.kt diff --git a/component/src/main/java/com/alfresco/content/component/ComponentData.kt b/component/src/main/java/com/alfresco/content/component/ComponentData.kt index 7f46ea30d..439e9174a 100644 --- a/component/src/main/java/com/alfresco/content/component/ComponentData.kt +++ b/component/src/main/java/com/alfresco/content/component/ComponentData.kt @@ -54,7 +54,7 @@ data class ComponentData( return ComponentData( id = fieldsData.id, name = fieldsData.name, - selector = ComponentType.RADIO.value, + selector = ComponentType.DROPDOWN_RADIO.value, options = fieldsData.options.filter { it.id != "empty" }.map { ComponentOptions.withProcess(it) }, selectedName = name, selectedQuery = query, diff --git a/component/src/main/java/com/alfresco/content/component/ComponentSheet.kt b/component/src/main/java/com/alfresco/content/component/ComponentSheet.kt index aa7581e1f..8412a6fd5 100644 --- a/component/src/main/java/com/alfresco/content/component/ComponentSheet.kt +++ b/component/src/main/java/com/alfresco/content/component/ComponentSheet.kt @@ -197,6 +197,11 @@ class ComponentSheet : BottomSheetDialogFragment(), MavericksView { binding.parentView.addView(binding.topView) binding.parentView.addView(binding.separator) + if (state.parent?.selector != ComponentType.DROPDOWN_RADIO.value) { + binding.bottomSeparator.visibility = View.VISIBLE + binding.bottomView.visibility = View.VISIBLE + } + val replacedString = state.parent?.name?.replace(" ", ".") ?: "" val localizedName = requireContext().getLocalizedName(replacedString) if (localizedName == replacedString) { @@ -211,7 +216,7 @@ class ComponentSheet : BottomSheetDialogFragment(), MavericksView { ComponentType.TASK_PROCESS_PRIORITY.value -> setupTaskPriorityComponent(state) ComponentType.VIEW_TEXT.value -> setupTextComponent(state) ComponentType.CHECK_LIST.value -> setupCheckListComponent(viewModel) - ComponentType.RADIO.value -> setupRadioListComponent(state, viewModel) + ComponentType.RADIO.value, ComponentType.DROPDOWN_RADIO.value -> setupRadioListComponent(state, viewModel) ComponentType.NUMBER_RANGE.value -> setupNumberRangeComponent(state, viewModel) ComponentType.SLIDER.value -> setupSliderComponent(state, viewModel) ComponentType.DATE_RANGE.value, ComponentType.DATE_RANGE_FUTURE.value -> { @@ -233,6 +238,7 @@ class ComponentSheet : BottomSheetDialogFragment(), MavericksView { } } } + ComponentType.FACETS.value -> setupFacetComponent(state, viewModel) } } @@ -251,6 +257,7 @@ class ComponentSheet : BottomSheetDialogFragment(), MavericksView { dismiss() } } + ComponentType.DATE_RANGE_FUTURE.value -> { if (viewModel.fromDate.isEmpty() && viewModel.toDate.isEmpty()) { binding.dateRangeComponent.fromInputLayout.error = getString(R.string.component_number_range_empty) @@ -259,6 +266,7 @@ class ComponentSheet : BottomSheetDialogFragment(), MavericksView { dismiss() } } + else -> { onApply?.invoke(state.parent?.selectedName ?: "", state.parent?.selectedQuery ?: "", state.parent?.selectedQueryMap ?: mapOf()) dismiss() @@ -285,9 +293,11 @@ class ComponentSheet : BottomSheetDialogFragment(), MavericksView { ComponentType.CHECK_LIST.value -> { epoxyCheckListController.requestModelBuild() } - ComponentType.RADIO.value -> { + + ComponentType.RADIO.value, ComponentType.DROPDOWN_RADIO.value -> { epoxyRadioListController.requestModelBuild() } + ComponentType.FACETS.value -> { epoxyCheckFacetListController.requestModelBuild() } @@ -317,10 +327,15 @@ class ComponentSheet : BottomSheetDialogFragment(), MavericksView { data(option) optionSelected(viewModel.isOptionSelected(state, option)) clickListener { model, _, _, _ -> - viewModel.updateSingleComponentData( - requireContext().getLocalizedName(model.data().label), - model.data().query, - ) + if (state.parent.selector == ComponentType.DROPDOWN_RADIO.value) { + onApply?.invoke(requireContext().getLocalizedName(model.data().label), model.data().query, mapOf()) + dismiss() + } else { + viewModel.updateSingleComponentData( + requireContext().getLocalizedName(model.data().label), + model.data().query, + ) + } } } } diff --git a/component/src/main/java/com/alfresco/content/component/ComponentType.kt b/component/src/main/java/com/alfresco/content/component/ComponentType.kt index 4179bc899..8c31ea5ac 100644 --- a/component/src/main/java/com/alfresco/content/component/ComponentType.kt +++ b/component/src/main/java/com/alfresco/content/component/ComponentType.kt @@ -13,6 +13,7 @@ enum class ComponentType(val value: String) { DATE_RANGE("date-range"), DATE_RANGE_FUTURE("date-range-future"), RADIO("radio"), + DROPDOWN_RADIO("dropdown_radio"), FACETS("facets"), TASK_PROCESS_PRIORITY("task-process-priority"), None("none"), diff --git a/component/src/main/res/layout/sheet_component_filter.xml b/component/src/main/res/layout/sheet_component_filter.xml index 2d9968c29..0e36e3da5 100644 --- a/component/src/main/res/layout/sheet_component_filter.xml +++ b/component/src/main/res/layout/sheet_component_filter.xml @@ -3,10 +3,10 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" + android:layout_height="match_parent" android:orientation="vertical" android:paddingTop="16dp" - android:paddingBottom="16dp" - android:layout_height="match_parent"> + android:paddingBottom="16dp"> + android:background="@color/color_view_line" + android:visibility="gone" /> + android:orientation="vertical" + android:visibility="gone"> - when (field.type) { - FieldType.TEXT.value() -> { - var textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } - SingleLineInputField( - textFieldValue = textFieldValue, - onValueChanged = { newText -> - textFieldValue = newText - viewModel.updateFieldValue(field.id, newText, state) - }, - field, - ) - } + ) { + LazyColumn( + modifier = Modifier + .fillMaxSize() + ) { + items(items = formList) { field -> + when (field.type) { + FieldType.TEXT.value() -> { + var textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } + SingleLineInputField( + textFieldValue = textFieldValue, + onValueChanged = { newText -> + textFieldValue = newText + viewModel.updateFieldValue(field.id, newText, state) + }, + field, + ) + } - FieldType.MULTI_LINE_TEXT.value() -> { - var textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } - MultiLineInputField( - textFieldValue = textFieldValue, - onValueChanged = { newText -> - textFieldValue = newText - viewModel.updateFieldValue(field.id, newText, state) - }, - field, - ) - } + FieldType.MULTI_LINE_TEXT.value() -> { + var textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } + MultiLineInputField( + textFieldValue = textFieldValue, + onValueChanged = { newText -> + textFieldValue = newText + viewModel.updateFieldValue(field.id, newText, state) + }, + field, + ) + } - FieldType.INTEGER.value() -> { - var textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } - IntegerInputField( - textFieldValue = textFieldValue, - onValueChanged = { newText -> - textFieldValue = newText - viewModel.updateFieldValue(field.id, newText, state) - }, - field, - ) - } + FieldType.INTEGER.value() -> { + var textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } + IntegerInputField( + textFieldValue = textFieldValue, + onValueChanged = { newText -> + textFieldValue = newText + viewModel.updateFieldValue(field.id, newText, state) + }, + field, + ) + } - FieldType.AMOUNT.value() -> { - var textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } - AmountInputField( - textFieldValue = textFieldValue, - onValueChanged = { newText -> - textFieldValue = newText - viewModel.updateFieldValue(field.id, newText, state) - }, - field, - ) - } + FieldType.AMOUNT.value() -> { + var textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } + AmountInputField( + textFieldValue = textFieldValue, + onValueChanged = { newText -> + textFieldValue = newText + viewModel.updateFieldValue(field.id, newText, state) + }, + field, + ) + } - FieldType.BOOLEAN.value() -> { - var checkedValue by remember { mutableStateOf(field.value as? Boolean ?: false) } - CheckBoxField( - checkedValue = checkedValue, - onCheckChanged = { newChecked -> - checkedValue = newChecked - }, - field, - ) - } + FieldType.BOOLEAN.value() -> { + var checkedValue by remember { mutableStateOf(field.value as? Boolean ?: false) } + CheckBoxField( + checkedValue = checkedValue, + onCheckChanged = { newChecked -> + checkedValue = newChecked + }, + field, + ) + } - FieldType.DATETIME.value(), FieldType.DATE.value() -> { - var textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } - DateTimeField( - dateTimeValue = textFieldValue, - onValueChanged = { newText -> - textFieldValue = newText - }, - field, - ) - } + FieldType.DATETIME.value(), FieldType.DATE.value() -> { + var textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } + DateTimeField( + dateTimeValue = textFieldValue, + onValueChanged = { newText -> + textFieldValue = newText + }, + field, + ) + } - FieldType.DROPDOWN.value() -> { - var textFieldValue by remember { mutableStateOf(field.placeHolder ?: "") } - var textFieldQuery by remember { mutableStateOf("") } - DropdownField( - nameText = textFieldValue, - queryText = textFieldQuery, - onValueChanged = { (newText, newQuery) -> - textFieldValue = newText - textFieldQuery = newQuery - }, - fieldsData = field, - ) - } + FieldType.DROPDOWN.value(),FieldType.RADIO_BUTTONS.value() -> { + var textFieldValue by remember { mutableStateOf(field.placeHolder ?: "") } + var textFieldQuery by remember { mutableStateOf("") } + DropdownField( + nameText = textFieldValue, + queryText = textFieldQuery, + onValueChanged = { (newText, newQuery) -> + textFieldValue = newText + textFieldQuery = newQuery + }, + fieldsData = field, + ) + } - FieldType.RADIO_BUTTONS.value() -> { - var textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } - var textFieldQuery by remember { mutableStateOf("") } - RadioButtonField( - selectedOption = textFieldValue, - selectedQuery = textFieldQuery, - onSelectedOption = { (newText, newQuery) -> - textFieldValue = newText - textFieldQuery = newQuery - }, - fieldsData = field, - ) - } - - FieldType.READONLY_TEXT.value(), FieldType.READONLY.value() -> { - val textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } - ReadOnlyField( - textFieldValue = textFieldValue, - fieldsData = field, - ) - } + FieldType.READONLY_TEXT.value(), FieldType.READONLY.value() -> { + val textFieldValue by remember { mutableStateOf(field.value as? String ?: "") } + ReadOnlyField( + textFieldValue = textFieldValue, + fieldsData = field, + ) + } - FieldType.PEOPLE.value() -> { - var userDetailValue by remember { mutableStateOf(null) } - PeopleField( - userDetail = userDetailValue, - onAssigneeSelected = { userDetails -> - userDetailValue = userDetails - }, - fieldsData = field, - processEntry = state.parent, - ) + FieldType.PEOPLE.value(),FieldType.FUNCTIONAL_GROUP.value() -> { + var userDetailValue by remember { mutableStateOf(null) } + PeopleField( + userDetail = userDetailValue, + onAssigneeSelected = { userDetails -> + userDetailValue = userDetails + }, + fieldsData = field, + processEntry = ProcessEntry.withProcess(state.parent,field.type), + ) + } } } } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/AmountInputField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/AmountInputField.kt index ea98fc227..27a70c63a 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/AmountInputField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/AmountInputField.kt @@ -10,7 +10,6 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import com.alfresco.content.data.payloads.FieldsData import com.alfresco.content.process.R -import inputField @Composable fun AmountInputField( diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt index 86bb140bd..c2fc8d354 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt @@ -14,10 +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.graphics.Color import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.SpanStyle +import androidx.compose.ui.text.TextLayoutResult import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.style.TextAlign +import androidx.compose.ui.text.style.TextDecoration +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import com.alfresco.content.data.payloads.FieldsData @@ -41,16 +45,29 @@ fun CheckBoxField( var showError by remember { mutableStateOf(false) } + var expandedState by remember { mutableStateOf(false) } + var showReadMoreButtonState by remember { mutableStateOf(false) } + val minimumLineLength = 2 // Change this to your desired value + val maxLines = if (expandedState) Int.MAX_VALUE else minimumLineLength + + val textLayoutHandler = remember { + TextLayoutHandler(minimumLineLength) { isEllipsized -> + showReadMoreButtonState = isEllipsized + } + } Column( - modifier = Modifier.fillMaxWidth(), + modifier = Modifier + .fillMaxWidth(), horizontalAlignment = Alignment.Start, ) { Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier - .fillMaxWidth(), + .fillMaxWidth() + .padding(horizontal = 16.dp), ) { Checkbox( + modifier = Modifier.align(alignment = Alignment.Top), checked = checkedValue, onCheckedChange = { isChecked -> onCheckChanged(isChecked) @@ -60,9 +77,35 @@ fun CheckBoxField( }, ) Text( - text = labelWithAsterisk, - modifier = Modifier.padding(end = 4.dp), + maxLines = minimumLineLength, + overflow = TextOverflow.Ellipsis, + text = buildAnnotatedString { + withStyle( + style = SpanStyle( + textDecoration = TextDecoration.LineThrough, + color = Color.Gray + ) + ) { + append(labelWithAsterisk) + } + }, + modifier = Modifier + .padding(end = 4.dp, top = 6.dp) + .align(alignment = Alignment.Top), + onTextLayout = { textLayoutResult: TextLayoutResult -> + textLayoutHandler.handleTextLayout(textLayoutResult) + } ) + /*if (showReadMoreButtonState) { + Text( + text = if (expandedState) "Read Less" else "Read More", + color = Color.Gray, + modifier = Modifier.clickable { + expandedState = !expandedState + }, + style = MaterialTheme.typography.bodySmall + ) + }*/ } if (showError) { @@ -70,7 +113,7 @@ fun CheckBoxField( text = stringResource(R.string.error_required_field), color = AlfrescoError, modifier = Modifier - .padding(start = 16.dp, top = 0.dp), // Adjust padding as needed + .padding(horizontal = 16.dp, vertical = 0.dp), // Adjust padding as needed style = MaterialTheme.typography.titleSmall, textAlign = TextAlign.Start, ) diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/DateTimeField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/DateTimeField.kt index e3876f9cc..4e715cf22 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/DateTimeField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/DateTimeField.kt @@ -15,7 +15,6 @@ import com.alfresco.content.DATE_FORMAT_4 import com.alfresco.content.component.DatePickerBuilder import com.alfresco.content.data.payloads.FieldsData import com.alfresco.content.process.R -import inputField @Composable fun DateTimeField( diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/DropdownField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/DropdownField.kt index 06b719152..e1f663c88 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/DropdownField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/DropdownField.kt @@ -15,7 +15,6 @@ import com.alfresco.content.component.ComponentBuilder import com.alfresco.content.component.ComponentData import com.alfresco.content.data.payloads.FieldsData import com.alfresco.content.process.R -import inputField @Composable fun DropdownField( diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FormScreen.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FormScreen.kt index eb7942818..ae3aea69d 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FormScreen.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FormScreen.kt @@ -1,7 +1,6 @@ package com.alfresco.content.process.ui.components import ComposeTopBar -import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.rememberScrollState @@ -31,22 +30,19 @@ fun FormScreen(navController: NavController) { val colorScheme = MaterialTheme.colorScheme // Wrap the content in a Column with verticalScroll - Column( + Surface( modifier = Modifier - .verticalScroll(rememberScrollState()) .padding(padding) .statusBarsPadding(), + color = colorScheme.background, + contentColor = colorScheme.onBackground, ) { - Surface( - color = colorScheme.background, - contentColor = colorScheme.onBackground, - ) { - if (state.requestStartForm is Loading) { - CustomLinearProgressIndicator(padding) - } - FormDetailScreen(state, viewModel) + if (state.requestStartForm is Loading) { + CustomLinearProgressIndicator(padding) } + FormDetailScreen(state, viewModel) } + }, ) } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/InputChip.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/InputChip.kt index 9c378bf10..30c0ec8b9 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/InputChip.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/InputChip.kt @@ -35,13 +35,19 @@ fun InputChip( modifier = Modifier.padding(vertical = 8.dp), onClick = { }, - label = { Text(context.getLocalizedName(userDetail.name)) }, + label = { + if (userDetail.groupName.isNotEmpty()) { + Text(context.getLocalizedName(userDetail.groupName)) + } else { + Text(context.getLocalizedName(userDetail.name)) + } + }, selected = true, shape = RoundedCornerShape(24.dp), border = InputChipDefaults.inputChipBorder( selectedBorderWidth = 0.dp, - ), + ), colors = getInputChipColors(), leadingIcon = { Text( diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/IntegerInputField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/IntegerInputField.kt index da8c00b3f..01c9a1d12 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/IntegerInputField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/IntegerInputField.kt @@ -9,7 +9,6 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import com.alfresco.content.data.payloads.FieldsData import com.alfresco.content.process.R -import inputField @Composable fun IntegerInputField( diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/MultiLineInputField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/MultiLineInputField.kt index f8b92fcc3..ae19f59e0 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/MultiLineInputField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/MultiLineInputField.kt @@ -9,7 +9,6 @@ import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import com.alfresco.content.data.payloads.FieldsData import com.alfresco.content.process.R -import inputField @Composable fun MultiLineInputField( diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt index b520ed719..13170844b 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt @@ -10,6 +10,7 @@ import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource @@ -54,7 +55,8 @@ fun PeopleField( Text( text = labelWithAsterisk, modifier = Modifier - .padding(end = 4.dp), + .padding(end = 4.dp) + .align(alignment = Alignment.CenterVertically), ) IconButton(onClick = { diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/ReadOnlyField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/ReadOnlyField.kt index 6d1b2b505..320726220 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/ReadOnlyField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/ReadOnlyField.kt @@ -9,7 +9,6 @@ import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import com.alfresco.content.data.payloads.FieldsData -import inputField @Composable fun ReadOnlyField( diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/SingleLineInputField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/SingleLineInputField.kt index a61e39e76..efce96bce 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/SingleLineInputField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/SingleLineInputField.kt @@ -4,12 +4,12 @@ import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.tooling.preview.Preview import com.alfresco.content.data.payloads.FieldsData import com.alfresco.content.process.R -import inputField @Composable fun SingleLineInputField( @@ -31,7 +31,9 @@ fun SingleLineInputField( } InputField( - modifier = Modifier.inputField(), + modifier = Modifier + .inputField() + .semantics(mergeDescendants = true) {}, maxLines = 1, textFieldValue = textFieldValue, onValueChanged = onValueChanged, diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TextLayoutHandler.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TextLayoutHandler.kt new file mode 100644 index 000000000..1b9658f41 --- /dev/null +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TextLayoutHandler.kt @@ -0,0 +1,20 @@ +package com.alfresco.content.process.ui.components + +import androidx.compose.ui.text.TextLayoutResult + +class TextLayoutHandler( + private val minimumLineLength: Int, + private val onEllipsisChanged: (Boolean) -> Unit +) { + fun handleTextLayout(textLayoutResult: TextLayoutResult) { + if (textLayoutResult.lineCount > minimumLineLength - 1) { + if (textLayoutResult.isLineEllipsized(minimumLineLength - 1)) { + onEllipsisChanged(true) + } else { + onEllipsisChanged(false) + } + } else { + onEllipsisChanged(false) + } + } +} \ No newline at end of file diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TrailingInputField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TrailingInputField.kt index f6c72ccf2..2982af7f0 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TrailingInputField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TrailingInputField.kt @@ -4,6 +4,7 @@ import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Cancel import androidx.compose.material.icons.filled.DateRange import androidx.compose.material.icons.filled.Error +import androidx.compose.material.icons.filled.KeyboardArrowDown import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme @@ -12,7 +13,6 @@ import androidx.compose.ui.res.stringResource import com.alfresco.content.data.payloads.FieldType import com.alfresco.content.data.payloads.FieldsData import com.alfresco.content.process.R -import trailingIconColor @Composable fun TrailingInputField( @@ -23,31 +23,41 @@ fun TrailingInputField( fieldsData: FieldsData = FieldsData(), onValueChanged: (String) -> Unit = { }, ) { - if (fieldsData.type == FieldType.DATETIME.value() || fieldsData.type == FieldType.DATE.value()) { - Icon( - imageVector = Icons.Default.DateRange, - contentDescription = stringResource(R.string.accessibility_date_icon), - tint = trailingIconColor(), - ) - } else { - if (focusState && !textValue.isNullOrEmpty()) { - if (isError) { - Icon( - imageVector = Icons.Default.Error, - contentDescription = errorMessage, - tint = MaterialTheme.colorScheme.error, - ) - } else { - IconButton( - onClick = { - onValueChanged("") - }, - ) { + when (fieldsData.type) { + FieldType.DATETIME.value(), FieldType.DATE.value() -> { + Icon( + imageVector = Icons.Default.DateRange, + contentDescription = stringResource(R.string.accessibility_date_icon), + tint = trailingIconColor(), + ) + } + FieldType.DROPDOWN.value(),FieldType.RADIO_BUTTONS.value() -> { + Icon( + imageVector = Icons.Default.KeyboardArrowDown, + contentDescription = stringResource(R.string.accessibility_date_icon), + tint = trailingIconColor(), + ) + } + else -> { + if (focusState && !textValue.isNullOrEmpty()) { + if (isError) { Icon( - imageVector = Icons.Default.Cancel, - contentDescription = stringResource(R.string.accessibility_clear_text), - tint = trailingIconColor(), + imageVector = Icons.Default.Error, + contentDescription = errorMessage, + tint = MaterialTheme.colorScheme.error, ) + } else { + IconButton( + onClick = { + onValueChanged("") + }, + ) { + Icon( + imageVector = Icons.Default.Cancel, + contentDescription = stringResource(R.string.accessibility_clear_text), + tint = trailingIconColor(), + ) + } } } } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Utils.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Utils.kt index 3de37f9ec..9948f6516 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Utils.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Utils.kt @@ -1,3 +1,5 @@ +package com.alfresco.content.process.ui.components + import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable @@ -13,4 +15,4 @@ fun trailingIconColor() = if (isNightMode()) White60 else AlfrescoGray90060 fun Modifier.inputField() = this .fillMaxWidth() - .padding(start = 16.dp, end = 16.dp, top = 12.dp) // Add padding or other modifiers as needed + .padding(start = 16.dp, end = 16.dp, top = 12.dp) // Add padding or other modifiers as needed \ No newline at end of file From 46fab4585959dd1463c2640e2d81c808ae0b66f9 Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Tue, 13 Feb 2024 15:10:24 +0530 Subject: [PATCH 2/3] added ammendments --- .../main/res/layout/fragment_task_detail.xml | 12 +- browse/src/main/res/values-de/strings.xml | 1 - browse/src/main/res/values-fr/strings.xml | 1 - browse/src/main/res/values-it/strings.xml | 1 - browse/src/main/res/values-nl/strings.xml | 1 - browse/src/main/res/values/strings.xml | 1 - common/src/main/res/values-de/strings.xml | 1 + common/src/main/res/values-es/strings.xml | 1 + common/src/main/res/values-fr/strings.xml | 1 + common/src/main/res/values-it/strings.xml | 1 + common/src/main/res/values-nl/strings.xml | 1 + common/src/main/res/values/strings.xml | 2 + .../component/ComponentSheetExtension.kt | 6 +- .../com/alfresco/content/data/ProcessEntry.kt | 2 +- .../content/process/ui/FormDetailScreen.kt | 13 +- .../process/ui/components/CheckboxField.kt | 140 ++++++++++++------ .../process/ui/components/FormScreen.kt | 3 - .../process/ui/components/InputChip.kt | 2 +- .../process/ui/components/PeopleField.kt | 4 +- .../ui/components/TextLayoutHandler.kt | 4 +- .../ui/components/TrailingInputField.kt | 2 +- .../content/process/ui/components/Utils.kt | 2 +- .../src/main/res/drawable/ic_edit_blue.xml | 9 ++ 23 files changed, 141 insertions(+), 70 deletions(-) create mode 100644 process-app/src/main/res/drawable/ic_edit_blue.xml diff --git a/browse/src/main/res/layout/fragment_task_detail.xml b/browse/src/main/res/layout/fragment_task_detail.xml index a7532fdbf..45697445d 100644 --- a/browse/src/main/res/layout/fragment_task_detail.xml +++ b/browse/src/main/res/layout/fragment_task_detail.xml @@ -61,7 +61,7 @@ android:layout_marginEnd="16dp" android:contentDescription="@string/icon_name_description_edit" android:scaleType="fitCenter" - android:src="@drawable/ic_edit" + android:src="@drawable/ic_edit_blue" android:visibility="gone" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -148,7 +148,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="fitCenter" - android:src="@drawable/ic_edit" + android:src="@drawable/ic_edit_blue" android:visibility="invisible" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_weight="1" @@ -230,7 +230,7 @@ android:layout_height="wrap_content" android:contentDescription="@string/icon_due_date_edit" android:scaleType="fitCenter" - android:src="@drawable/ic_edit" + android:src="@drawable/ic_edit_blue" android:visibility="invisible" /> @@ -305,7 +305,7 @@ android:layout_height="wrap_content" android:contentDescription="@string/icon_priority_edit" android:scaleType="fitCenter" - android:src="@drawable/ic_edit" + android:src="@drawable/ic_edit_blue" android:visibility="invisible" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_weight="1" @@ -372,7 +372,7 @@ android:layout_height="wrap_content" android:contentDescription="@string/icon_assignee_edit" android:scaleType="fitCenter" - android:src="@drawable/ic_edit" + android:src="@drawable/ic_edit_blue" android:visibility="invisible" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_weight="1" @@ -502,7 +502,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaleType="fitCenter" - android:src="@drawable/ic_edit" + android:src="@drawable/ic_edit_blue" android:visibility="invisible" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_weight="1" diff --git a/browse/src/main/res/values-de/strings.xml b/browse/src/main/res/values-de/strings.xml index 095d526d6..972b3bc62 100755 --- a/browse/src/main/res/values-de/strings.xml +++ b/browse/src/main/res/values-de/strings.xml @@ -79,7 +79,6 @@ Symbol \'Priorität bearbeiten\' Symbol \'Fälligkeitsdatum löschen\' Symbol \'Fälligkeitsdatum bearbeiten\' - ...Alle anzeigen Aufgabenfortschritt Möchten Sie den Fortschritt speichern? Als abgeschlossen markieren diff --git a/browse/src/main/res/values-fr/strings.xml b/browse/src/main/res/values-fr/strings.xml index a986e392a..2f0ef7b63 100755 --- a/browse/src/main/res/values-fr/strings.xml +++ b/browse/src/main/res/values-fr/strings.xml @@ -79,7 +79,6 @@ Icône Modifier la priorité Icône Effacer la date d\'échéance Icône Modifier la date d\'échéance - …Afficher tout Progression de la tâche Voulez-vous enregistrer la progression ? Marquer comme terminé diff --git a/browse/src/main/res/values-it/strings.xml b/browse/src/main/res/values-it/strings.xml index 29dd1f0a6..b6f7827c3 100755 --- a/browse/src/main/res/values-it/strings.xml +++ b/browse/src/main/res/values-it/strings.xml @@ -79,7 +79,6 @@ Icona Modifica priorità Icona Cancella scadenza Icona Modifica scadenza - ...Visualizza tutto Stato di avanzamento compito Vuoi salvare lo stato di avanzamento? Contrassegna come completato diff --git a/browse/src/main/res/values-nl/strings.xml b/browse/src/main/res/values-nl/strings.xml index 7c1751722..575f51886 100755 --- a/browse/src/main/res/values-nl/strings.xml +++ b/browse/src/main/res/values-nl/strings.xml @@ -79,7 +79,6 @@ Pictogram Prioriteit bewerken Pictogram Vervaldatum wissen Pictogram Vervaldatum bewerken - ...Alle weergeven Voortgang van de taak Wilt u de voortgang opslaan? Als voltooid markeren diff --git a/browse/src/main/res/values/strings.xml b/browse/src/main/res/values/strings.xml index cfad6d573..5a2a21b4c 100644 --- a/browse/src/main/res/values/strings.xml +++ b/browse/src/main/res/values/strings.xml @@ -79,7 +79,6 @@ Edit priority icon Clear due date icon Edit due date icon - …View all Task Progress Do you want to save progress? Mark as complete diff --git a/common/src/main/res/values-de/strings.xml b/common/src/main/res/values-de/strings.xml index b72ef0eab..eb63866b8 100755 --- a/common/src/main/res/values-de/strings.xml +++ b/common/src/main/res/values-de/strings.xml @@ -29,4 +29,5 @@ Keine %d Ausgewählt Bitte überprüfen Sie Ihre Internetverbindung und starten anschließend den Vorgang erneut. + ...Alle anzeigen diff --git a/common/src/main/res/values-es/strings.xml b/common/src/main/res/values-es/strings.xml index 9cc5789a3..47a692a7b 100755 --- a/common/src/main/res/values-es/strings.xml +++ b/common/src/main/res/values-es/strings.xml @@ -29,4 +29,5 @@ Ninguno %d Seleccionado Verifique su conexión a Internet y vuelva a intentarlo. + ...Ver todo diff --git a/common/src/main/res/values-fr/strings.xml b/common/src/main/res/values-fr/strings.xml index 55e646806..b16022c11 100755 --- a/common/src/main/res/values-fr/strings.xml +++ b/common/src/main/res/values-fr/strings.xml @@ -29,4 +29,5 @@ Aucun %d Sélectionné Veuillez vérifier votre connexion Internet et réessayer. + …Afficher tout diff --git a/common/src/main/res/values-it/strings.xml b/common/src/main/res/values-it/strings.xml index 5abd883aa..e8a40f0b1 100755 --- a/common/src/main/res/values-it/strings.xml +++ b/common/src/main/res/values-it/strings.xml @@ -29,4 +29,5 @@ Nessuno %d Selezionato Controlla la connessione Internet e riprova. + ...Visualizza tutto diff --git a/common/src/main/res/values-nl/strings.xml b/common/src/main/res/values-nl/strings.xml index 0cd81c2f5..778bbebe0 100755 --- a/common/src/main/res/values-nl/strings.xml +++ b/common/src/main/res/values-nl/strings.xml @@ -29,4 +29,5 @@ Geen %d Geselecteerd Controleer uw internetverbinding en probeer het opnieuw. + ...Alle weergeven diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index f84124ea2..ddba320d3 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -29,4 +29,6 @@ None %d Selected Please check your internet connection and Try again. + …View all + Workflow diff --git a/component/src/main/java/com/alfresco/content/component/ComponentSheetExtension.kt b/component/src/main/java/com/alfresco/content/component/ComponentSheetExtension.kt index be9fcc2dd..118b24ab6 100644 --- a/component/src/main/java/com/alfresco/content/component/ComponentSheetExtension.kt +++ b/component/src/main/java/com/alfresco/content/component/ComponentSheetExtension.kt @@ -189,7 +189,11 @@ fun ComponentSheet.setupFacetComponent(state: ComponentState, viewModel: Compone */ fun ComponentSheet.setupTextComponent(state: ComponentState) { binding.parentView.addView(binding.frameTitleDescription) - binding.titleDescriptionComponent.tvTitle.text = state.parent?.query ?: "" + if (state.parent?.query.isNullOrEmpty()) { + binding.titleDescriptionComponent.tvTitle.visibility = View.GONE + } else { + binding.titleDescriptionComponent.tvTitle.text = state.parent?.query ?: "" + } binding.titleDescriptionComponent.tvDescription.text = state.parent?.value ?: "" binding.bottomView.visibility = View.GONE diff --git a/data/src/main/kotlin/com/alfresco/content/data/ProcessEntry.kt b/data/src/main/kotlin/com/alfresco/content/data/ProcessEntry.kt index 999da08a0..d97879616 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/ProcessEntry.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/ProcessEntry.kt @@ -248,7 +248,7 @@ data class ProcessEntry( ) } - fun withProcess(data:ProcessEntry, fieldType: String): ProcessEntry{ + fun withProcess(data: ProcessEntry, fieldType: String): ProcessEntry { var reviewerType: ReviewerType = ReviewerType.PEOPLE if (fieldType == FieldType.FUNCTIONAL_GROUP.value()) { diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/FormDetailScreen.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/FormDetailScreen.kt index cc5148f20..85a8cf4d0 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/FormDetailScreen.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/FormDetailScreen.kt @@ -17,6 +17,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.platform.LocalSoftwareKeyboardController +import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import com.alfresco.content.data.ProcessEntry import com.alfresco.content.data.TaskRepository @@ -24,6 +25,7 @@ import com.alfresco.content.data.UserGroupDetails import com.alfresco.content.data.payloads.FieldType import com.alfresco.content.process.FormViewModel import com.alfresco.content.process.FormViewState +import com.alfresco.content.process.R import com.alfresco.content.process.ui.components.AmountInputField import com.alfresco.content.process.ui.components.CheckBoxField import com.alfresco.content.process.ui.components.DateTimeField @@ -53,10 +55,10 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel) { verticalArrangement = Arrangement.Top, horizontalAlignment = Alignment.CenterHorizontally, - ) { + ) { LazyColumn( modifier = Modifier - .fillMaxSize() + .fillMaxSize(), ) { items(items = formList) { field -> when (field.type) { @@ -111,6 +113,7 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel) { FieldType.BOOLEAN.value() -> { var checkedValue by remember { mutableStateOf(field.value as? Boolean ?: false) } CheckBoxField( + title = stringResource(id = R.string.title_workflow), checkedValue = checkedValue, onCheckChanged = { newChecked -> checkedValue = newChecked @@ -130,7 +133,7 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel) { ) } - FieldType.DROPDOWN.value(),FieldType.RADIO_BUTTONS.value() -> { + FieldType.DROPDOWN.value(), FieldType.RADIO_BUTTONS.value() -> { var textFieldValue by remember { mutableStateOf(field.placeHolder ?: "") } var textFieldQuery by remember { mutableStateOf("") } DropdownField( @@ -152,7 +155,7 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel) { ) } - FieldType.PEOPLE.value(),FieldType.FUNCTIONAL_GROUP.value() -> { + FieldType.PEOPLE.value(), FieldType.FUNCTIONAL_GROUP.value() -> { var userDetailValue by remember { mutableStateOf(null) } PeopleField( userDetail = userDetailValue, @@ -160,7 +163,7 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel) { userDetailValue = userDetails }, fieldsData = field, - processEntry = ProcessEntry.withProcess(state.parent,field.type), + processEntry = ProcessEntry.withProcess(state.parent, field.type), ) } } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt index c2fc8d354..7ccd60422 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/CheckboxField.kt @@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.text.ClickableText import androidx.compose.material3.Checkbox import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text @@ -14,47 +15,44 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.TextLayoutResult +import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.style.TextAlign -import androidx.compose.ui.text.style.TextDecoration -import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp +import com.alfresco.content.component.ComponentBuilder +import com.alfresco.content.component.ComponentData +import com.alfresco.content.component.ComponentType import com.alfresco.content.data.payloads.FieldsData import com.alfresco.content.process.R import com.alfresco.content.process.ui.theme.AlfrescoError @Composable fun CheckBoxField( + title: String = "", checkedValue: Boolean = false, onCheckChanged: (Boolean) -> Unit = {}, fieldsData: FieldsData = FieldsData(), ) { - val labelWithAsterisk = buildAnnotatedString { - append(fieldsData.name) - if (fieldsData.required) { - withStyle(style = SpanStyle(color = AlfrescoError)) { - append(" *") // Adding a red asterisk for mandatory fields - } - } - } - + val context = LocalContext.current var showError by remember { mutableStateOf(false) } - var expandedState by remember { mutableStateOf(false) } + val minimumLineLength = 2 // Change this to your desired value + var showReadMoreButtonState by remember { mutableStateOf(false) } - val minimumLineLength = 2 // Change this to your desired value - val maxLines = if (expandedState) Int.MAX_VALUE else minimumLineLength - val textLayoutHandler = remember { - TextLayoutHandler(minimumLineLength) { isEllipsized -> - showReadMoreButtonState = isEllipsized - } - } + var visibleText by remember { mutableStateOf("") } + val spaceAsteric = " *" + val readMore = stringResource(id = R.string.suffix_view_all) + val suffix = spaceAsteric + readMore + var lineCount = 1 + + val labelWithAsterisk = customLabel(visibleText, showReadMoreButtonState, fieldsData, spaceAsteric, readMore) + Column( modifier = Modifier .fillMaxWidth(), @@ -76,36 +74,46 @@ fun CheckBoxField( } }, ) - Text( + ClickableText( maxLines = minimumLineLength, - overflow = TextOverflow.Ellipsis, - text = buildAnnotatedString { - withStyle( - style = SpanStyle( - textDecoration = TextDecoration.LineThrough, - color = Color.Gray + text = labelWithAsterisk, + style = TextStyle( + color = MaterialTheme.colorScheme.onSurface, + ), + onClick = { + labelWithAsterisk.getStringAnnotations(it, it).firstOrNull()?.let { + ComponentBuilder( + context, + ComponentData( + name = title, + query = "", + value = fieldsData.name, + selector = ComponentType.VIEW_TEXT.value, + ), ) - ) { - append(labelWithAsterisk) + .onApply { name, query, _ -> + } + .onReset { name, query, _ -> + } + .onCancel { + } + .show() } }, modifier = Modifier - .padding(end = 4.dp, top = 6.dp) - .align(alignment = Alignment.Top), + .padding(end = 4.dp, top = if (lineCount == 1) 0.dp else 6.dp) + .align(alignment = if (lineCount == 1) Alignment.CenterVertically else Alignment.Top), onTextLayout = { textLayoutResult: TextLayoutResult -> - textLayoutHandler.handleTextLayout(textLayoutResult) - } + lineCount = textLayoutResult.lineCount + if (textLayoutResult.lineCount > minimumLineLength - 1 && !showReadMoreButtonState) { + val endIndex = textLayoutResult.getLineEnd(minimumLineLength - 1) + visibleText = with(labelWithAsterisk) { + this.substring(0, endIndex = endIndex - suffix.length) + } + showReadMoreButtonState = true + } + }, ) - /*if (showReadMoreButtonState) { - Text( - text = if (expandedState) "Read Less" else "Read More", - color = Color.Gray, - modifier = Modifier.clickable { - expandedState = !expandedState - }, - style = MaterialTheme.typography.bodySmall - ) - }*/ } if (showError) { @@ -120,3 +128,49 @@ fun CheckBoxField( } } } + +@Composable +private fun customLabel(visibleText: String, showReadMoreButtonState: Boolean, fieldsData: FieldsData, spaceAsteric: String, readMore: String) = + if (visibleText.isNotEmpty() && showReadMoreButtonState) { + buildAnnotatedString { + val labelReadMore = (visibleText) + spaceAsteric + readMore + + val startIndexReadMore = labelReadMore.indexOf(readMore) + val endIndexReadMore = startIndexReadMore + readMore.length + + val startIndexAsteric = labelReadMore.indexOf(spaceAsteric) + val endIndexAsteric = startIndexAsteric + spaceAsteric.length + + append(labelReadMore) + + if (fieldsData.required) { + addStyle( + style = SpanStyle(color = AlfrescoError), + start = startIndexAsteric, + end = endIndexAsteric, + ) + } + + addStyle( + style = SpanStyle(color = MaterialTheme.colorScheme.primary), + start = startIndexReadMore, + end = endIndexReadMore, + ) + + addStringAnnotation( + "tagMinified", + readMore, + start = startIndexReadMore, + end = endIndexReadMore, + ) + } + } else { + buildAnnotatedString { + append(fieldsData.name) + if (fieldsData.required) { + withStyle(style = SpanStyle(color = AlfrescoError)) { + append(" *") // Adding a red asterisk for mandatory fields + } + } + } + } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FormScreen.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FormScreen.kt index ae3aea69d..ed691dd14 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FormScreen.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FormScreen.kt @@ -3,8 +3,6 @@ package com.alfresco.content.process.ui.components import ComposeTopBar import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.statusBarsPadding -import androidx.compose.foundation.rememberScrollState -import androidx.compose.foundation.verticalScroll import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface @@ -42,7 +40,6 @@ fun FormScreen(navController: NavController) { } FormDetailScreen(state, viewModel) } - }, ) } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/InputChip.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/InputChip.kt index 30c0ec8b9..381ac3415 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/InputChip.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/InputChip.kt @@ -47,7 +47,7 @@ fun InputChip( border = InputChipDefaults.inputChipBorder( selectedBorderWidth = 0.dp, - ), + ), colors = getInputChipColors(), leadingIcon = { Text( diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt index 13170844b..2def343b4 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt @@ -24,6 +24,7 @@ import com.alfresco.content.data.ProcessEntry import com.alfresco.content.data.UserGroupDetails import com.alfresco.content.data.payloads.FieldsData import com.alfresco.content.process.R +import com.alfresco.content.process.ui.theme.AlfrescoBlue700 import com.alfresco.content.process.ui.theme.AlfrescoError @Composable @@ -70,7 +71,8 @@ fun PeopleField( .show() }) { Icon( - painterResource(R.drawable.ic_add), + painterResource(R.drawable.ic_edit_blue), + tint = AlfrescoBlue700, contentDescription = "", ) } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TextLayoutHandler.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TextLayoutHandler.kt index 1b9658f41..bef2f1f43 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TextLayoutHandler.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TextLayoutHandler.kt @@ -4,7 +4,7 @@ import androidx.compose.ui.text.TextLayoutResult class TextLayoutHandler( private val minimumLineLength: Int, - private val onEllipsisChanged: (Boolean) -> Unit + private val onEllipsisChanged: (Boolean) -> Unit, ) { fun handleTextLayout(textLayoutResult: TextLayoutResult) { if (textLayoutResult.lineCount > minimumLineLength - 1) { @@ -17,4 +17,4 @@ class TextLayoutHandler( onEllipsisChanged(false) } } -} \ No newline at end of file +} diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TrailingInputField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TrailingInputField.kt index 2982af7f0..cb021d53d 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TrailingInputField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/TrailingInputField.kt @@ -31,7 +31,7 @@ fun TrailingInputField( tint = trailingIconColor(), ) } - FieldType.DROPDOWN.value(),FieldType.RADIO_BUTTONS.value() -> { + FieldType.DROPDOWN.value(), FieldType.RADIO_BUTTONS.value() -> { Icon( imageVector = Icons.Default.KeyboardArrowDown, contentDescription = stringResource(R.string.accessibility_date_icon), diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Utils.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Utils.kt index 9948f6516..c9d4cb667 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Utils.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Utils.kt @@ -15,4 +15,4 @@ fun trailingIconColor() = if (isNightMode()) White60 else AlfrescoGray90060 fun Modifier.inputField() = this .fillMaxWidth() - .padding(start = 16.dp, end = 16.dp, top = 12.dp) // Add padding or other modifiers as needed \ No newline at end of file + .padding(start = 16.dp, end = 16.dp, top = 12.dp) // Add padding or other modifiers as needed diff --git a/process-app/src/main/res/drawable/ic_edit_blue.xml b/process-app/src/main/res/drawable/ic_edit_blue.xml new file mode 100644 index 000000000..2655e9347 --- /dev/null +++ b/process-app/src/main/res/drawable/ic_edit_blue.xml @@ -0,0 +1,9 @@ + + + From 4e52cd0e2b8ba03492facfb7059e6b98dbd7007a Mon Sep 17 00:00:00 2001 From: Amanpal Singh <87360222+aman-alfresco@users.noreply.github.com> Date: Wed, 14 Feb 2024 09:44:17 +0530 Subject: [PATCH 3/3] set the size of checkbox --- .../alfresco/content/process/ui/components/PeopleField.kt | 2 +- process-app/src/main/res/drawable/ic_edit_blue.xml | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt index 2def343b4..8f6c61b45 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/PeopleField.kt @@ -47,7 +47,7 @@ fun PeopleField( Column( modifier = Modifier .fillMaxSize() - .padding(all = 16.dp), + .padding(top = 16.dp, bottom = 0.dp, start = 16.dp, end = 16.dp), ) { Row( horizontalArrangement = Arrangement.SpaceBetween, diff --git a/process-app/src/main/res/drawable/ic_edit_blue.xml b/process-app/src/main/res/drawable/ic_edit_blue.xml index 2655e9347..2037477dc 100644 --- a/process-app/src/main/res/drawable/ic_edit_blue.xml +++ b/process-app/src/main/res/drawable/ic_edit_blue.xml @@ -3,7 +3,8 @@ android:height="40dp" android:viewportWidth="40" android:viewportHeight="40"> - +