[#1089] Remove circular progress bar from Home

* [#1089] Remove circular progress bar from Home

Closes #1089

* Fix ktlint warning
This commit is contained in:
Honza Rychnovský 2023-12-05 12:29:15 +01:00 committed by GitHub
parent b88a64de9d
commit dd81b90fbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 159 deletions

View File

@ -10,8 +10,7 @@ import java.util.concurrent.atomic.AtomicInteger
class HomeTestSetup( class HomeTestSetup(
private val composeTestRule: ComposeContentTestRule, private val composeTestRule: ComposeContentTestRule,
private val walletSnapshot: WalletSnapshot, private val walletSnapshot: WalletSnapshot,
private val isShowFiatConversion: Boolean, private val isShowFiatConversion: Boolean
private val isCircularProgressBar: Boolean
) { ) {
private val onSettingsCount = AtomicInteger(0) private val onSettingsCount = AtomicInteger(0)
private val onReceiveCount = AtomicInteger(0) private val onReceiveCount = AtomicInteger(0)
@ -51,7 +50,6 @@ class HomeTestSetup(
isUpdateAvailable = false, isUpdateAvailable = false,
isKeepScreenOnDuringSync = false, isKeepScreenOnDuringSync = false,
isFiatConversionEnabled = isShowFiatConversion, isFiatConversionEnabled = isShowFiatConversion,
isCircularProgressBarEnabled = isCircularProgressBar,
goSettings = { goSettings = {
onSettingsCount.incrementAndGet() onSettingsCount.incrementAndGet()
}, },

View File

@ -1,6 +1,5 @@
package co.electriccoin.zcash.ui.screen.home.integration 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.assertIsDisplayed
import androidx.compose.ui.test.assertWidthIsAtLeast import androidx.compose.ui.test.assertWidthIsAtLeast
import androidx.compose.ui.test.junit4.StateRestorationTester import androidx.compose.ui.test.junit4.StateRestorationTester
@ -27,8 +26,7 @@ class HomeViewIntegrationTest : UiTestPrerequisites() {
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup( private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
composeTestRule, composeTestRule,
walletSnapshot, walletSnapshot,
isShowFiatConversion = false, isShowFiatConversion = false
isCircularProgressBar = true
) )
// This is just basic sanity check that we still have UI set up as expected after the state restore // 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) assertNotEquals(WalletSnapshotFixture.PROGRESS, testSetup.getWalletSnapshot().progress)
assertEquals(0.5f, testSetup.getWalletSnapshot().progress.decimal) 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 { composeTestRule.onNodeWithTag(HomeTag.SINGLE_LINE_TEXT).also {
it.assertIsDisplayed() it.assertIsDisplayed()
it.assertWidthIsAtLeast(1.dp) it.assertWidthIsAtLeast(1.dp)

View File

@ -1,6 +1,5 @@
package co.electriccoin.zcash.ui.screen.home.view 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.assertIsDisplayed
import androidx.compose.ui.test.junit4.ComposeContentTestRule import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createComposeRule 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.onNodeWithText
import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performScrollTo
import androidx.compose.ui.unit.dp
import androidx.test.filters.MediumTest 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.test.UiTestPrerequisites
import co.electriccoin.zcash.ui.R import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture 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 @Test
@MediumTest @MediumTest
fun click_receive_button() { fun click_receive_button() {
@ -147,13 +110,11 @@ class HomeViewTest : UiTestPrerequisites() {
private fun newTestSetup( private fun newTestSetup(
isShowFiatConversion: Boolean = true, isShowFiatConversion: Boolean = true,
isCircularProgressBar: Boolean = true,
walletSnapshot: WalletSnapshot = WalletSnapshotFixture.new() walletSnapshot: WalletSnapshot = WalletSnapshotFixture.new()
) = HomeTestSetup( ) = HomeTestSetup(
composeTestRule, composeTestRule,
walletSnapshot = walletSnapshot, walletSnapshot = walletSnapshot,
isShowFiatConversion = isShowFiatConversion, isShowFiatConversion = isShowFiatConversion
isCircularProgressBar = isCircularProgressBar
).apply { ).apply {
setDefaultContent() setDefaultContent()
} }

View File

@ -15,11 +15,4 @@ object ConfigurationEntries {
* A troubleshooting step. If we fix our bugs, this should be unnecessary. * A troubleshooting step. If we fix our bugs, this should be unnecessary.
*/ */
val IS_RESCAN_ENABLED = BooleanConfigurationEntry(ConfigKey("is_rescan_enabled"), true) 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)
} }

View File

@ -67,8 +67,6 @@ internal fun WrapHome(
val isKeepScreenOnWhileSyncing = settingsViewModel.isKeepScreenOnWhileSyncing.collectAsStateWithLifecycle().value val isKeepScreenOnWhileSyncing = settingsViewModel.isKeepScreenOnWhileSyncing.collectAsStateWithLifecycle().value
val isFiatConversionEnabled = ConfigurationEntries.IS_FIAT_CONVERSION_ENABLED.getValue(RemoteConfig.current) 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) { if (null == walletSnapshot) {
// Display loading indicator // Display loading indicator
@ -78,7 +76,6 @@ internal fun WrapHome(
isUpdateAvailable = updateAvailable, isUpdateAvailable = updateAvailable,
isKeepScreenOnDuringSync = isKeepScreenOnWhileSyncing, isKeepScreenOnDuringSync = isKeepScreenOnWhileSyncing,
isFiatConversionEnabled = isFiatConversionEnabled, isFiatConversionEnabled = isFiatConversionEnabled,
isCircularProgressBarEnabled = isCircularProgressBarEnabled,
goSettings = goSettings, goSettings = goSettings,
goReceive = goReceive, goReceive = goReceive,
goSend = goSend, goSend = goSend,

View File

@ -5,7 +5,6 @@ package co.electriccoin.zcash.ui.screen.home
*/ */
object HomeTag { object HomeTag {
const val STATUS_VIEWS = "status_views" const val STATUS_VIEWS = "status_views"
const val PROGRESS = "progress_bar"
const val SINGLE_LINE_TEXT = "single_line_text" const val SINGLE_LINE_TEXT = "single_line_text"
const val FIAT_CONVERSION = "fiat_conversion" const val FIAT_CONVERSION = "fiat_conversion"
const val SETTINGS_TOP_BAR_BUTTON = "settings_top_bar_button" const val SETTINGS_TOP_BAR_BUTTON = "settings_top_bar_button"

View File

@ -2,36 +2,27 @@
package co.electriccoin.zcash.ui.screen.home.view 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.Column
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier 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.LocalContext
import androidx.compose.ui.platform.testTag import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview 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.Synchronizer
import cash.z.ecc.android.sdk.model.FiatCurrencyConversionRateState 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.R
import co.electriccoin.zcash.ui.common.DisableScreenTimeout import co.electriccoin.zcash.ui.common.DisableScreenTimeout
import co.electriccoin.zcash.ui.design.MINIMAL_WEIGHT import co.electriccoin.zcash.ui.design.MINIMAL_WEIGHT
@ -58,7 +49,6 @@ private fun ComposablePreview() {
isUpdateAvailable = false, isUpdateAvailable = false,
isKeepScreenOnDuringSync = false, isKeepScreenOnDuringSync = false,
isFiatConversionEnabled = false, isFiatConversionEnabled = false,
isCircularProgressBarEnabled = false,
goSettings = {}, goSettings = {},
goReceive = {}, goReceive = {},
goSend = {}, goSend = {},
@ -75,7 +65,6 @@ fun Home(
isUpdateAvailable: Boolean, isUpdateAvailable: Boolean,
isKeepScreenOnDuringSync: Boolean?, isKeepScreenOnDuringSync: Boolean?,
isFiatConversionEnabled: Boolean, isFiatConversionEnabled: Boolean,
isCircularProgressBarEnabled: Boolean,
goSettings: () -> Unit, goSettings: () -> Unit,
goReceive: () -> Unit, goReceive: () -> Unit,
goSend: () -> Unit, goSend: () -> Unit,
@ -89,7 +78,6 @@ fun Home(
isUpdateAvailable = isUpdateAvailable, isUpdateAvailable = isUpdateAvailable,
isKeepScreenOnDuringSync = isKeepScreenOnDuringSync, isKeepScreenOnDuringSync = isKeepScreenOnDuringSync,
isFiatConversionEnabled = isFiatConversionEnabled, isFiatConversionEnabled = isFiatConversionEnabled,
isCircularProgressBarEnabled = isCircularProgressBarEnabled,
goReceive = goReceive, goReceive = goReceive,
goSend = goSend, goSend = goSend,
goHistory = goHistory, goHistory = goHistory,
@ -130,7 +118,6 @@ private fun HomeMainContent(
isUpdateAvailable: Boolean, isUpdateAvailable: Boolean,
isKeepScreenOnDuringSync: Boolean?, isKeepScreenOnDuringSync: Boolean?,
isFiatConversionEnabled: Boolean, isFiatConversionEnabled: Boolean,
isCircularProgressBarEnabled: Boolean,
goReceive: () -> Unit, goReceive: () -> Unit,
goSend: () -> Unit, goSend: () -> Unit,
goHistory: () -> Unit, goHistory: () -> Unit,
@ -145,7 +132,9 @@ private fun HomeMainContent(
.then(modifier), .then(modifier),
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
Status(walletSnapshot, isUpdateAvailable, isFiatConversionEnabled, isCircularProgressBarEnabled) Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingDefault))
Status(walletSnapshot, isUpdateAvailable, isFiatConversionEnabled)
Spacer( Spacer(
modifier = Modifier modifier = Modifier
@ -182,60 +171,18 @@ private fun HomeMainContent(
private fun Status( private fun Status(
walletSnapshot: WalletSnapshot, walletSnapshot: WalletSnapshot,
updateAvailable: Boolean, updateAvailable: Boolean,
isFiatConversionEnabled: Boolean, isFiatConversionEnabled: Boolean
isCircularProgressBarEnabled: 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( val walletDisplayValues = WalletDisplayValues.getNextValues(
LocalContext.current, LocalContext.current,
walletSnapshot, walletSnapshot,
updateAvailable updateAvailable
) )
// wrapper box
Box(
Modifier
.fillMaxWidth()
.testTag(HomeTag.STATUS_VIEWS),
contentAlignment = Alignment.Center
) {
// 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( Column(
modifier = Modifier modifier = Modifier
.padding(contentPadding) .fillMaxWidth()
.wrapContentSize(), .testTag(HomeTag.STATUS_VIEWS),
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
) { ) {
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingLarge)) Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingLarge))
@ -276,6 +223,4 @@ private fun Status(
) )
} }
} }
}
}
} }