Skip to content

Commit

Permalink
fixed color of action button (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-alfresco authored May 9, 2024
1 parent ec231f8 commit 4a7d103
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.alfresco.content.process.ui.components
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.PlaylistAdd
import androidx.compose.material3.ExtendedFloatingActionButton
import androidx.compose.material3.FloatingActionButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
Expand All @@ -11,6 +12,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.airbnb.mvrx.compose.collectAsState
import com.alfresco.content.component.ComponentBuilder
import com.alfresco.content.component.ComponentData
Expand Down Expand Up @@ -57,8 +59,14 @@ fun FloatingActionButton(outcomes: List<OptionsModel>, fragment: ProcessFragment
.show()
}
},
containerColor = MaterialTheme.colorScheme.primary,
containerColor = if (state.enabledOutcomes) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant,
icon = { Icon(Icons.Filled.PlaylistAdd, stringResource(id = R.string.accessibility_process_actions), tint = Color.White) },
text = { Text(text = stringResource(id = R.string.title_actions), color = Color.White) },
elevation = FloatingActionButtonDefaults.elevation(
defaultElevation = 0.dp,
pressedElevation = 0.dp,
focusedElevation = 0.dp,
hoveredElevation = 0.dp,
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,12 @@ class FormViewModel(
requireNotNull(state.parent)
viewModelScope.launch {
repository::actionOutcomes.asFlow(
outcome, state.parent.taskEntry,
outcome,
state.parent.taskEntry,
convertFieldsToValues(
state.formFields
.filter { it.type !in listOf(FieldType.READONLY.value(), FieldType.READONLY_TEXT.value()) },
)
),
).execute {
when (it) {
is Loading -> copy(requestOutcomes = Loading())
Expand Down Expand Up @@ -542,8 +543,10 @@ class FormViewModel(

private fun hasFieldValidData(fields: List<FieldsData>): Boolean {
val hasValidDataInRequiredFields = !fields.filter { it.required }.any { (it.value == null || it.errorData.first) }
val hasValidDataInDropDownRequiredFields = fields.filter { it.required && it.options.isNotEmpty() }
.any { field -> (field.options.find { option -> option.name == field.value }?.id != "empty") }
val hasValidDataInOtherFields = !fields.filter { !it.required }.any { it.errorData.first }
return (hasValidDataInRequiredFields && hasValidDataInOtherFields)
return (hasValidDataInRequiredFields && hasValidDataInOtherFields && hasValidDataInDropDownRequiredFields)
}

fun setListener(listener: EntryListener) {
Expand Down

0 comments on commit 4a7d103

Please sign in to comment.