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 89c29761..942a5941 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 @@ -50,7 +50,9 @@ fun FormDetailScreen(state: FormViewState, viewModel: FormViewModel, outcomes: L verticalArrangement = Arrangement.Top, horizontalAlignment = Alignment.CenterHorizontally, ) { - items(items = formList) { field -> + items(key = { + it.id + }, items = formList) { field -> FormScrollContent(field, viewModel, state) } } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FloatingActionButton.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FloatingActionButton.kt index c47dd558..5f50cb64 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FloatingActionButton.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/FloatingActionButton.kt @@ -10,9 +10,11 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource import com.alfresco.content.component.ComponentBuilder import com.alfresco.content.component.ComponentData import com.alfresco.content.data.OptionsModel +import com.alfresco.content.process.R @Composable fun FloatingActionButton(outcomes: List) { @@ -35,8 +37,8 @@ fun FloatingActionButton(outcomes: List) { .show() }, containerColor = MaterialTheme.colorScheme.primary, - icon = { Icon(Icons.Filled.PlaylistAdd, "Extended floating action button.") }, - text = { Text(text = "Actions") }, + icon = { Icon(Icons.Filled.PlaylistAdd, stringResource(id = R.string.accessibility_process_actions)) }, + text = { Text(text = stringResource(id = R.string.title_actions)) }, modifier = Modifier.navigationBarsPadding(), ) } 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 e02fb967..5c525de6 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 @@ -9,12 +9,14 @@ import androidx.compose.material3.Scaffold import androidx.compose.material3.Surface import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue +import androidx.compose.ui.res.stringResource import androidx.navigation.NavController import com.airbnb.mvrx.Loading import com.airbnb.mvrx.compose.collectAsState import com.airbnb.mvrx.compose.mavericksActivityViewModel import com.alfresco.content.data.OptionsModel import com.alfresco.content.process.FormViewModel +import com.alfresco.content.process.R import com.alfresco.content.process.ui.FormDetailScreen @Composable @@ -22,50 +24,61 @@ fun FormScreen(navController: NavController) { // This will get or create a ViewModel scoped to the Activity. val viewModel: FormViewModel = mavericksActivityViewModel() val state by viewModel.collectAsState() - val customOutcomes = state.processOutcomes.ifEmpty { - listOf( - OptionsModel(name = "Start workflow"), - ) + + val customOutcomes = when { + state.formFields.isNotEmpty() && state.processOutcomes.isEmpty() -> { + listOf( + OptionsModel(name = stringResource(id = R.string.action_start_workflow)), + ) + } + + else -> { + state.processOutcomes + } } - if (customOutcomes.size < 3) { - Scaffold( - topBar = { ComposeTopBar() }, - ) { padding -> - val colorScheme = MaterialTheme.colorScheme - // Wrap the content in a Column with verticalScroll - Surface( - modifier = androidx.compose.ui.Modifier - .padding(padding) - .statusBarsPadding(), - color = colorScheme.background, - contentColor = colorScheme.onBackground, - ) { - if (state.requestStartForm is Loading) { - CustomLinearProgressIndicator(padding) + when { + customOutcomes.size < 3 -> { + Scaffold( + topBar = { ComposeTopBar() }, + ) { padding -> + val colorScheme = MaterialTheme.colorScheme + // Wrap the content in a Column with verticalScroll + Surface( + modifier = androidx.compose.ui.Modifier + .padding(padding) + .statusBarsPadding(), + color = colorScheme.background, + contentColor = colorScheme.onBackground, + ) { + if (state.requestStartForm is Loading) { + CustomLinearProgressIndicator(padding) + } + FormDetailScreen(state, viewModel, customOutcomes) } - FormDetailScreen(state, viewModel, customOutcomes) } } - } else { - Scaffold( - topBar = { ComposeTopBar() }, - floatingActionButton = { FloatingActionButton(customOutcomes) }, - floatingActionButtonPosition = FabPosition.End, - ) { padding -> - val colorScheme = MaterialTheme.colorScheme - // Wrap the content in a Column with verticalScroll - Surface( - modifier = androidx.compose.ui.Modifier - .padding(padding) - .statusBarsPadding(), - color = colorScheme.background, - contentColor = colorScheme.onBackground, - ) { - if (state.requestStartForm is Loading) { - CustomLinearProgressIndicator(padding) + + else -> { + Scaffold( + topBar = { ComposeTopBar() }, + floatingActionButton = { FloatingActionButton(customOutcomes) }, + floatingActionButtonPosition = FabPosition.End, + ) { padding -> + val colorScheme = MaterialTheme.colorScheme + // Wrap the content in a Column with verticalScroll + Surface( + modifier = androidx.compose.ui.Modifier + .padding(padding) + .statusBarsPadding(), + color = colorScheme.background, + contentColor = colorScheme.onBackground, + ) { + if (state.requestStartForm is Loading) { + CustomLinearProgressIndicator(padding) + } + FormDetailScreen(state, viewModel, emptyList()) } - FormDetailScreen(state, viewModel, customOutcomes) } } } diff --git a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Outcomes.kt b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Outcomes.kt index 8beedd32..0837731a 100644 --- a/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Outcomes.kt +++ b/process-app/src/main/kotlin/com/alfresco/content/process/ui/components/Outcomes.kt @@ -4,11 +4,13 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp import com.alfresco.content.data.OptionsModel +import com.alfresco.content.process.ui.theme.AlfrescoGray900 @Composable fun Outcomes(outcomes: List) { @@ -19,6 +21,9 @@ fun Outcomes(outcomes: List) { .padding(horizontal = 16.dp, vertical = 4.dp), onClick = { }, shape = RoundedCornerShape(4.dp), + colors = ButtonDefaults.buttonColors( + contentColor = AlfrescoGray900, + ), ) { Text(it.name) } diff --git a/process-app/src/main/res/values/strings.xml b/process-app/src/main/res/values/strings.xml index d2d39eaf..4f64f389 100644 --- a/process-app/src/main/res/values/strings.xml +++ b/process-app/src/main/res/values/strings.xml @@ -7,4 +7,6 @@ Can\'t be greater than %1$d Use a different number format This is a required field. + Actions + Process Actions Button