Skip to content

Commit

Permalink
added string resources
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-alfresco committed Mar 5, 2024
1 parent 76dbcda commit 71a7637
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<OptionsModel>) {
Expand All @@ -35,8 +37,8 @@ fun FloatingActionButton(outcomes: List<OptionsModel>) {
.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(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,63 +9,76 @@ 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
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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<OptionsModel>) {
Expand All @@ -19,6 +21,9 @@ fun Outcomes(outcomes: List<OptionsModel>) {
.padding(horizontal = 16.dp, vertical = 4.dp),
onClick = { },
shape = RoundedCornerShape(4.dp),
colors = ButtonDefaults.buttonColors(
contentColor = AlfrescoGray900,
),
) {
Text(it.name)
}
Expand Down
2 changes: 2 additions & 0 deletions process-app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
<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>
<string name="title_actions">Actions</string>
<string name="accessibility_process_actions">Process Actions Button</string>
</resources>

0 comments on commit 71a7637

Please sign in to comment.