forked from dhis2/dhis2-android-capture-app
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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 Co-authored-by: andresmr <[email protected]>
- Loading branch information
Showing
17 changed files
with
233 additions
and
1,093 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"buildTime":"2022-12-08 10:37","gitSha":"7a66f01fe"} | ||
{"buildTime":"2023-01-09 10:19","gitSha":"6885dc400"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
stock-managment/src/main/java/org/dhis2/android/rtsm/ui/home/model/ButtonUiState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.dhis2.android.rtsm.ui.home.model | ||
|
||
import org.dhis2.android.rtsm.R | ||
import org.dhis2.android.rtsm.ui.home.model.ButtonVisibilityState.HIDDEN | ||
|
||
data class ButtonUiState( | ||
val text: Int = R.string.review, | ||
val icon: Int = R.drawable.proceed_icon, | ||
val visibility: ButtonVisibilityState = HIDDEN | ||
) | ||
|
||
enum class ButtonVisibilityState { | ||
HIDDEN, | ||
DISABLED, | ||
ENABLED | ||
} |
47 changes: 47 additions & 0 deletions
47
stock-managment/src/main/java/org/dhis2/android/rtsm/ui/home/model/SettingsUiState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.dhis2.android.rtsm.ui.home.model | ||
|
||
import java.time.LocalDateTime | ||
import org.dhis2.android.rtsm.R | ||
import org.dhis2.android.rtsm.data.TransactionType | ||
import org.dhis2.android.rtsm.data.TransactionType.CORRECTION | ||
import org.dhis2.android.rtsm.data.TransactionType.DISCARD | ||
import org.dhis2.android.rtsm.data.TransactionType.DISTRIBUTION | ||
import org.dhis2.android.rtsm.utils.UIText | ||
import org.hisp.dhis.android.core.option.Option | ||
import org.hisp.dhis.android.core.organisationunit.OrganisationUnit | ||
|
||
data class SettingsUiState( | ||
val programUid: String, | ||
val transactionType: TransactionType = DISTRIBUTION, | ||
val facility: OrganisationUnit? = null, | ||
val destination: Option? = null, | ||
val transactionDate: LocalDateTime = LocalDateTime.now() | ||
) { | ||
fun hasFacilitySelected() = facility != null | ||
fun hasDestinationSelected() = destination != null | ||
fun fromFacilitiesLabel(): UIText = facility?.let { | ||
val orgUnitName = it.displayName().toString() | ||
return when (transactionType) { | ||
DISTRIBUTION -> { | ||
UIText.StringRes(R.string.subtitle, orgUnitName) | ||
} | ||
DISCARD -> { | ||
UIText.StringRes(R.string.subtitle, orgUnitName) | ||
} | ||
CORRECTION -> { | ||
UIText.StringRes(R.string.subtitle, orgUnitName) | ||
} | ||
} | ||
} ?: UIText.StringRes(R.string.from_facility) | ||
|
||
fun deliverToLabel(): UIText? = when (transactionType) { | ||
DISTRIBUTION -> destination?.let { | ||
UIText.StringRes(R.string.subtitle, it.displayName().toString()) | ||
} ?: UIText.StringRes(R.string.to_facility) | ||
else -> null | ||
} | ||
|
||
fun facilityName() = facility?.let { | ||
it.displayName().toString() | ||
} ?: "" | ||
} |
Oops, something went wrong.