[#1089] Remove circular progress bar from Home
* [#1089] Remove circular progress bar from Home Closes #1089 * Fix ktlint warning
This commit is contained in:
parent
b88a64de9d
commit
dd81b90fbf
|
@ -10,8 +10,7 @@ import java.util.concurrent.atomic.AtomicInteger
|
|||
class HomeTestSetup(
|
||||
private val composeTestRule: ComposeContentTestRule,
|
||||
private val walletSnapshot: WalletSnapshot,
|
||||
private val isShowFiatConversion: Boolean,
|
||||
private val isCircularProgressBar: Boolean
|
||||
private val isShowFiatConversion: Boolean
|
||||
) {
|
||||
private val onSettingsCount = AtomicInteger(0)
|
||||
private val onReceiveCount = AtomicInteger(0)
|
||||
|
@ -51,7 +50,6 @@ class HomeTestSetup(
|
|||
isUpdateAvailable = false,
|
||||
isKeepScreenOnDuringSync = false,
|
||||
isFiatConversionEnabled = isShowFiatConversion,
|
||||
isCircularProgressBarEnabled = isCircularProgressBar,
|
||||
goSettings = {
|
||||
onSettingsCount.incrementAndGet()
|
||||
},
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package co.electriccoin.zcash.ui.screen.home.integration
|
||||
|
||||
import androidx.compose.ui.test.assertHeightIsAtLeast
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.assertWidthIsAtLeast
|
||||
import androidx.compose.ui.test.junit4.StateRestorationTester
|
||||
|
@ -27,8 +26,7 @@ class HomeViewIntegrationTest : UiTestPrerequisites() {
|
|||
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
|
||||
composeTestRule,
|
||||
walletSnapshot,
|
||||
isShowFiatConversion = false,
|
||||
isCircularProgressBar = true
|
||||
isShowFiatConversion = false
|
||||
)
|
||||
|
||||
// This is just basic sanity check that we still have UI set up as expected after the state restore
|
||||
|
@ -60,16 +58,6 @@ class HomeViewIntegrationTest : UiTestPrerequisites() {
|
|||
assertNotEquals(WalletSnapshotFixture.PROGRESS, testSetup.getWalletSnapshot().progress)
|
||||
assertEquals(0.5f, testSetup.getWalletSnapshot().progress.decimal)
|
||||
|
||||
composeTestRule.onNodeWithTag(HomeTag.PROGRESS).also {
|
||||
it.assertIsDisplayed()
|
||||
it.assertHeightIsAtLeast(1.dp)
|
||||
}
|
||||
|
||||
composeTestRule.onNodeWithTag(HomeTag.PROGRESS).also {
|
||||
it.assertIsDisplayed()
|
||||
it.assertHeightIsAtLeast(1.dp)
|
||||
}
|
||||
|
||||
composeTestRule.onNodeWithTag(HomeTag.SINGLE_LINE_TEXT).also {
|
||||
it.assertIsDisplayed()
|
||||
it.assertWidthIsAtLeast(1.dp)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package co.electriccoin.zcash.ui.screen.home.view
|
||||
|
||||
import androidx.compose.ui.test.assertHeightIsAtLeast
|
||||
import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.junit4.ComposeContentTestRule
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
|
@ -9,10 +8,7 @@ import androidx.compose.ui.test.onNodeWithTag
|
|||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performScrollTo
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.test.filters.MediumTest
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.model.PercentDecimal
|
||||
import co.electriccoin.zcash.test.UiTestPrerequisites
|
||||
import co.electriccoin.zcash.ui.R
|
||||
import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture
|
||||
|
@ -64,39 +60,6 @@ class HomeViewTest : UiTestPrerequisites() {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
fun show_circular_progress_bar() {
|
||||
newTestSetup(
|
||||
isCircularProgressBar = true,
|
||||
walletSnapshot = WalletSnapshotFixture.new(
|
||||
status = Synchronizer.Status.SYNCING,
|
||||
progress = PercentDecimal.ONE_HUNDRED_PERCENT
|
||||
)
|
||||
)
|
||||
|
||||
composeTestRule.onNodeWithTag(HomeTag.PROGRESS).also {
|
||||
it.assertExists()
|
||||
it.assertHeightIsAtLeast(1.dp)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
fun hide_circular_progress_bar() {
|
||||
newTestSetup(
|
||||
isCircularProgressBar = false,
|
||||
walletSnapshot = WalletSnapshotFixture.new(
|
||||
status = Synchronizer.Status.SYNCING,
|
||||
progress = PercentDecimal.ONE_HUNDRED_PERCENT
|
||||
)
|
||||
)
|
||||
|
||||
composeTestRule.onNodeWithTag(HomeTag.PROGRESS).also {
|
||||
it.assertDoesNotExist()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
fun click_receive_button() {
|
||||
|
@ -147,13 +110,11 @@ class HomeViewTest : UiTestPrerequisites() {
|
|||
|
||||
private fun newTestSetup(
|
||||
isShowFiatConversion: Boolean = true,
|
||||
isCircularProgressBar: Boolean = true,
|
||||
walletSnapshot: WalletSnapshot = WalletSnapshotFixture.new()
|
||||
) = HomeTestSetup(
|
||||
composeTestRule,
|
||||
walletSnapshot = walletSnapshot,
|
||||
isShowFiatConversion = isShowFiatConversion,
|
||||
isCircularProgressBar = isCircularProgressBar
|
||||
isShowFiatConversion = isShowFiatConversion
|
||||
).apply {
|
||||
setDefaultContent()
|
||||
}
|
||||
|
|
|
@ -15,11 +15,4 @@ object ConfigurationEntries {
|
|||
* A troubleshooting step. If we fix our bugs, this should be unnecessary.
|
||||
*/
|
||||
val IS_RESCAN_ENABLED = BooleanConfigurationEntry(ConfigKey("is_rescan_enabled"), true)
|
||||
|
||||
/*
|
||||
* Circular progress bar's scaffolding on the Home screen is done, but it is disabled by default for the initial
|
||||
* minimal feature set.
|
||||
*/
|
||||
val IS_HOME_CIRCULAR_PROGRESS_BAR_ENABLED =
|
||||
BooleanConfigurationEntry(ConfigKey("is_home_circular_progress_bar_enabled"), false)
|
||||
}
|
||||
|
|
|
@ -67,8 +67,6 @@ internal fun WrapHome(
|
|||
|
||||
val isKeepScreenOnWhileSyncing = settingsViewModel.isKeepScreenOnWhileSyncing.collectAsStateWithLifecycle().value
|
||||
val isFiatConversionEnabled = ConfigurationEntries.IS_FIAT_CONVERSION_ENABLED.getValue(RemoteConfig.current)
|
||||
val isCircularProgressBarEnabled =
|
||||
ConfigurationEntries.IS_HOME_CIRCULAR_PROGRESS_BAR_ENABLED.getValue(RemoteConfig.current)
|
||||
|
||||
if (null == walletSnapshot) {
|
||||
// Display loading indicator
|
||||
|
@ -78,7 +76,6 @@ internal fun WrapHome(
|
|||
isUpdateAvailable = updateAvailable,
|
||||
isKeepScreenOnDuringSync = isKeepScreenOnWhileSyncing,
|
||||
isFiatConversionEnabled = isFiatConversionEnabled,
|
||||
isCircularProgressBarEnabled = isCircularProgressBarEnabled,
|
||||
goSettings = goSettings,
|
||||
goReceive = goReceive,
|
||||
goSend = goSend,
|
||||
|
|
|
@ -5,7 +5,6 @@ package co.electriccoin.zcash.ui.screen.home
|
|||
*/
|
||||
object HomeTag {
|
||||
const val STATUS_VIEWS = "status_views"
|
||||
const val PROGRESS = "progress_bar"
|
||||
const val SINGLE_LINE_TEXT = "single_line_text"
|
||||
const val FIAT_CONVERSION = "fiat_conversion"
|
||||
const val SETTINGS_TOP_BAR_BUTTON = "settings_top_bar_button"
|
||||
|
|
|
@ -2,36 +2,27 @@
|
|||
|
||||
package co.electriccoin.zcash.ui.screen.home.view
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.model.FiatCurrencyConversionRateState
|
||||
import cash.z.ecc.android.sdk.model.PercentDecimal
|
||||
import co.electriccoin.zcash.ui.R
|
||||
import co.electriccoin.zcash.ui.common.DisableScreenTimeout
|
||||
import co.electriccoin.zcash.ui.design.MINIMAL_WEIGHT
|
||||
|
@ -58,7 +49,6 @@ private fun ComposablePreview() {
|
|||
isUpdateAvailable = false,
|
||||
isKeepScreenOnDuringSync = false,
|
||||
isFiatConversionEnabled = false,
|
||||
isCircularProgressBarEnabled = false,
|
||||
goSettings = {},
|
||||
goReceive = {},
|
||||
goSend = {},
|
||||
|
@ -75,7 +65,6 @@ fun Home(
|
|||
isUpdateAvailable: Boolean,
|
||||
isKeepScreenOnDuringSync: Boolean?,
|
||||
isFiatConversionEnabled: Boolean,
|
||||
isCircularProgressBarEnabled: Boolean,
|
||||
goSettings: () -> Unit,
|
||||
goReceive: () -> Unit,
|
||||
goSend: () -> Unit,
|
||||
|
@ -89,7 +78,6 @@ fun Home(
|
|||
isUpdateAvailable = isUpdateAvailable,
|
||||
isKeepScreenOnDuringSync = isKeepScreenOnDuringSync,
|
||||
isFiatConversionEnabled = isFiatConversionEnabled,
|
||||
isCircularProgressBarEnabled = isCircularProgressBarEnabled,
|
||||
goReceive = goReceive,
|
||||
goSend = goSend,
|
||||
goHistory = goHistory,
|
||||
|
@ -130,7 +118,6 @@ private fun HomeMainContent(
|
|||
isUpdateAvailable: Boolean,
|
||||
isKeepScreenOnDuringSync: Boolean?,
|
||||
isFiatConversionEnabled: Boolean,
|
||||
isCircularProgressBarEnabled: Boolean,
|
||||
goReceive: () -> Unit,
|
||||
goSend: () -> Unit,
|
||||
goHistory: () -> Unit,
|
||||
|
@ -145,7 +132,9 @@ private fun HomeMainContent(
|
|||
.then(modifier),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Status(walletSnapshot, isUpdateAvailable, isFiatConversionEnabled, isCircularProgressBarEnabled)
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingDefault))
|
||||
|
||||
Status(walletSnapshot, isUpdateAvailable, isFiatConversionEnabled)
|
||||
|
||||
Spacer(
|
||||
modifier = Modifier
|
||||
|
@ -182,100 +171,56 @@ private fun HomeMainContent(
|
|||
private fun Status(
|
||||
walletSnapshot: WalletSnapshot,
|
||||
updateAvailable: Boolean,
|
||||
isFiatConversionEnabled: Boolean,
|
||||
isCircularProgressBarEnabled: Boolean
|
||||
isFiatConversionEnabled: Boolean
|
||||
) {
|
||||
val configuration = LocalConfiguration.current
|
||||
val contentSizeRatioRatio = if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
0.45f
|
||||
} else {
|
||||
0.9f
|
||||
}
|
||||
|
||||
// UI parts sizes
|
||||
val progressCircleStroke = 12.dp
|
||||
val progressCirclePadding = progressCircleStroke + 6.dp
|
||||
val contentPadding = progressCircleStroke + progressCirclePadding + 10.dp
|
||||
|
||||
val walletDisplayValues = WalletDisplayValues.getNextValues(
|
||||
LocalContext.current,
|
||||
walletSnapshot,
|
||||
updateAvailable
|
||||
)
|
||||
|
||||
// wrapper box
|
||||
Box(
|
||||
Modifier
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.testTag(HomeTag.STATUS_VIEWS),
|
||||
contentAlignment = Alignment.Center
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
// relatively sized box
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth(contentSizeRatioRatio)
|
||||
.aspectRatio(1f),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
// progress circle
|
||||
if (isCircularProgressBarEnabled) {
|
||||
if (walletDisplayValues.progress.decimal > PercentDecimal.ZERO_PERCENT.decimal) {
|
||||
CircularProgressIndicator(
|
||||
progress = walletDisplayValues.progress.decimal,
|
||||
color = Color.Gray,
|
||||
strokeWidth = progressCircleStroke,
|
||||
modifier = Modifier
|
||||
.matchParentSize()
|
||||
.padding(progressCirclePadding)
|
||||
.testTag(HomeTag.PROGRESS)
|
||||
)
|
||||
}
|
||||
}
|
||||
// texts
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(contentPadding)
|
||||
.wrapContentSize(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingLarge))
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingLarge))
|
||||
|
||||
if (walletDisplayValues.zecAmountText.isNotEmpty()) {
|
||||
HeaderWithZecIcon(amount = walletDisplayValues.zecAmountText)
|
||||
}
|
||||
if (walletDisplayValues.zecAmountText.isNotEmpty()) {
|
||||
HeaderWithZecIcon(amount = walletDisplayValues.zecAmountText)
|
||||
}
|
||||
|
||||
if (isFiatConversionEnabled) {
|
||||
Column(Modifier.testTag(HomeTag.FIAT_CONVERSION)) {
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingSmall))
|
||||
if (isFiatConversionEnabled) {
|
||||
Column(Modifier.testTag(HomeTag.FIAT_CONVERSION)) {
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingSmall))
|
||||
|
||||
when (walletDisplayValues.fiatCurrencyAmountState) {
|
||||
is FiatCurrencyConversionRateState.Current -> {
|
||||
BodyWithFiatCurrencySymbol(
|
||||
amount = walletDisplayValues.fiatCurrencyAmountText
|
||||
)
|
||||
}
|
||||
is FiatCurrencyConversionRateState.Stale -> {
|
||||
// Note: we should show information about staleness too
|
||||
BodyWithFiatCurrencySymbol(
|
||||
amount = walletDisplayValues.fiatCurrencyAmountText
|
||||
)
|
||||
}
|
||||
is FiatCurrencyConversionRateState.Unavailable -> {
|
||||
Body(text = walletDisplayValues.fiatCurrencyAmountText)
|
||||
}
|
||||
}
|
||||
when (walletDisplayValues.fiatCurrencyAmountState) {
|
||||
is FiatCurrencyConversionRateState.Current -> {
|
||||
BodyWithFiatCurrencySymbol(
|
||||
amount = walletDisplayValues.fiatCurrencyAmountText
|
||||
)
|
||||
}
|
||||
is FiatCurrencyConversionRateState.Stale -> {
|
||||
// Note: we should show information about staleness too
|
||||
BodyWithFiatCurrencySymbol(
|
||||
amount = walletDisplayValues.fiatCurrencyAmountText
|
||||
)
|
||||
}
|
||||
is FiatCurrencyConversionRateState.Unavailable -> {
|
||||
Body(text = walletDisplayValues.fiatCurrencyAmountText)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingLarge))
|
||||
|
||||
if (walletDisplayValues.statusText.isNotEmpty()) {
|
||||
Body(
|
||||
text = walletDisplayValues.statusText,
|
||||
modifier = Modifier.testTag(HomeTag.SINGLE_LINE_TEXT)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingLarge))
|
||||
|
||||
if (walletDisplayValues.statusText.isNotEmpty()) {
|
||||
Body(
|
||||
text = walletDisplayValues.statusText,
|
||||
modifier = Modifier.testTag(HomeTag.SINGLE_LINE_TEXT)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue