Skip to content

Commit

Permalink
[ANDROAPP-5039] Review: Implement screen (#42)
Browse files Browse the repository at this point in the history
* SettingsUiState.kt

* create ButtonUiState.kt

* use reviewButtonUiState on ManageStockViewModel.kt

* Remove toolbar title property

* Remove local properties on BackdropComponent.kt

* ktlintCheck

* collect by viewmodels

* ktlintCheck

* Add transaction date to SettingsUiState.kt

* collect settingsUiState in MainContent.kt

* ktlintCheck

* Mobe fromLabel and deliver label to SettingsUiState.kt

* Move fromLabel and deliver label to SettingsUiState.kt

* Remove hardcoded programUid

* remove items from cache when cleared

* remove activity_manage_stock.xml

* [ANDROAPP-5039] Filter list with entries when on Review click

* populate table

* [ANDROAPP-5039] Create DataEntryUiState.kt

* [ANDROAPP-5039] Hide button on completed step

* [ANDROAPP-5039] Hide button on completed step

Co-authored-by: andresmr <[email protected]>
  • Loading branch information
andresmr and andresmr committed Feb 8, 2023
1 parent ea52015 commit d2e6d6b
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class HomeActivity : AppCompatActivity(), OnOrgUnitSelectionFinished {
Color(colorResource(themeColor).toArgb()),
supportFragmentManager,
barcodeLauncher,
::navigateToReviewStock
{ _, _ -> manageStockViewModel.onButtonClick() }
) { scope, scaffold ->
synchronizeData(
scope,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.dhis2.android.rtsm.ui.home.model

data class DataEntryUiState(
val step: DataEntryStep = DataEntryStep.EDITING,
val button: ButtonUiState = ButtonUiState()
)

enum class DataEntryStep {
LISTING,
EDITING,
REVIEWING,
COMPLETED
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import com.journeyapps.barcodescanner.ScanOptions
import kotlinx.coroutines.CoroutineScope
import org.dhis2.android.rtsm.R
import org.dhis2.android.rtsm.ui.home.HomeViewModel
import org.dhis2.android.rtsm.ui.home.model.ButtonVisibilityState
import org.dhis2.android.rtsm.ui.home.model.ButtonVisibilityState.ENABLED
import org.dhis2.android.rtsm.ui.home.model.ButtonVisibilityState.HIDDEN
import org.dhis2.android.rtsm.ui.home.screens.components.Backdrop
import org.dhis2.android.rtsm.ui.managestock.ManageStockViewModel

Expand All @@ -55,19 +56,19 @@ fun HomeScreen(
) {
val scaffoldState = rememberScaffoldState()
val scope = rememberCoroutineScope()
val buttonUiState by manageStockViewModel.reviewButtonUiState.collectAsState()
val dataEntryUiState by manageStockViewModel.dataEntryUiState.collectAsState()

Scaffold(
scaffoldState = scaffoldState,
floatingActionButton = {
AnimatedVisibility(
visible = buttonUiState.visibility != ButtonVisibilityState.HIDDEN,
visible = dataEntryUiState.button.visibility != HIDDEN,
enter = fadeIn(),
exit = fadeOut()
) {
CompositionLocalProvider(
LocalRippleTheme provides
if (buttonUiState.visibility == ButtonVisibilityState.ENABLED) {
if (dataEntryUiState.button.visibility == ENABLED) {
LocalRippleTheme.current
} else {
NoRippleTheme
Expand All @@ -86,10 +87,10 @@ fun HomeScreen(
),
icon = {
Icon(
painter = painterResource(buttonUiState.icon),
contentDescription = stringResource(buttonUiState.text),
painter = painterResource(dataEntryUiState.button.icon),
contentDescription = stringResource(dataEntryUiState.button.text),
tint = if (
buttonUiState.visibility == ButtonVisibilityState.ENABLED
dataEntryUiState.button.visibility == ENABLED
) {
themeColor
} else {
Expand All @@ -99,9 +100,9 @@ fun HomeScreen(
},
text = {
Text(
stringResource(buttonUiState.text),
stringResource(dataEntryUiState.button.text),
color = if (
buttonUiState.visibility == ButtonVisibilityState.ENABLED
dataEntryUiState.button.visibility == ENABLED
) {
themeColor
} else {
Expand All @@ -110,12 +111,12 @@ fun HomeScreen(
)
},
onClick = {
if (buttonUiState.visibility == ButtonVisibilityState.ENABLED) {
if (dataEntryUiState.button.visibility == ENABLED) {
proceedAction(scope, scaffoldState)
}
},
backgroundColor = if (
buttonUiState.visibility == ButtonVisibilityState.ENABLED
dataEntryUiState.button.visibility == ENABLED
) {
Color.White
} else {
Expand Down
Loading

0 comments on commit d2e6d6b

Please sign in to comment.