[#1382] Improve Onboarding screen dynamic height calculation
- Closes #1382 - Changelog update
This commit is contained in:
parent
5c21a776d5
commit
c3cf711ee6
|
@ -22,7 +22,8 @@ directly impact users rather than highlighting other key architectural updates.*
|
||||||
design
|
design
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Transparent funds shielding action has been improved to address the latest user feedback
|
- Transparent funds shielding action has been improved to address the latest user feedback
|
||||||
|
- Onboarding screen dynamic height calculation has been improved
|
||||||
- A few more minor UI improvements
|
- A few more minor UI improvements
|
||||||
|
|
||||||
## [1.0 (638)] - 2024-04-26
|
## [1.0 (638)] - 2024-04-26
|
||||||
|
|
|
@ -1,70 +1,60 @@
|
||||||
package co.electriccoin.zcash.ui.design.util
|
package co.electriccoin.zcash.ui.design.util
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.navigationBars
|
import androidx.compose.foundation.layout.asPaddingValues
|
||||||
import androidx.compose.foundation.layout.statusBars
|
import androidx.compose.foundation.layout.navigationBarsIgnoringVisibility
|
||||||
|
import androidx.compose.foundation.layout.statusBarsIgnoringVisibility
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.ui.platform.LocalConfiguration
|
import androidx.compose.ui.platform.LocalConfiguration
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import co.electriccoin.zcash.spackle.Twig
|
import co.electriccoin.zcash.spackle.Twig
|
||||||
import kotlin.math.roundToInt
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This operation performs calculation of the screen height together with remembering its result for a further calls.
|
* This operation performs calculation of the screen height.
|
||||||
*
|
*
|
||||||
* @param cacheKey The cache defining key. Use a different one for recalculation.
|
* @return [ScreenHeight] a wrapper object of the calculated heights in density pixels.
|
||||||
*
|
|
||||||
* @return Wrapper object of the calculated heights in density pixels.
|
|
||||||
*/
|
*/
|
||||||
|
@OptIn(ExperimentalLayoutApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun screenHeight(cacheKey: Any = true): ScreenHeight {
|
fun screenHeight(): ScreenHeight {
|
||||||
val density = LocalDensity.current
|
|
||||||
val configuration = LocalConfiguration.current
|
val configuration = LocalConfiguration.current
|
||||||
val statusBars = WindowInsets.statusBars
|
|
||||||
val navigationBars = WindowInsets.navigationBars
|
|
||||||
|
|
||||||
val cachedResult =
|
val statusBars = WindowInsets.statusBarsIgnoringVisibility.asPaddingValues().calculateTopPadding()
|
||||||
remember(cacheKey) {
|
Twig.debug { "Screen height: Status bar height raw: $statusBars" }
|
||||||
val contentHeightPx = with(density) { configuration.screenHeightDp.dp.roundToPx() }
|
|
||||||
Twig.debug { "Screen content height in pixels: $contentHeightPx" }
|
|
||||||
|
|
||||||
// TODO [#1382]: Analyse zero status and navigation bars height
|
val navigationBars = WindowInsets.navigationBarsIgnoringVisibility.asPaddingValues().calculateBottomPadding()
|
||||||
// TODO [#1382]: https://github.com/Electric-Coin-Company/zashi-android/issues/1382
|
Twig.debug { "Screen height: Navigation bar height raw: $navigationBars" }
|
||||||
val statusBarHeight =
|
|
||||||
statusBars.getTop(density).dp.run {
|
|
||||||
if (value <= 0f) {
|
|
||||||
48.dp
|
|
||||||
} else {
|
|
||||||
this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Twig.debug { "Status bar height: $statusBarHeight" }
|
|
||||||
|
|
||||||
val navigationBarHeight =
|
val contentHeight = configuration.screenHeightDp.dp
|
||||||
navigationBars.getBottom(density).dp.run {
|
Twig.debug { "Screen height: Screen content height: $contentHeight" }
|
||||||
if (value <= 0f) {
|
|
||||||
88.dp
|
|
||||||
} else {
|
|
||||||
this
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Twig.debug { "Navigation bar height: $navigationBarHeight" }
|
|
||||||
|
|
||||||
val contentHeight = (contentHeightPx / density.density.roundToInt()).dp
|
val statusBarHeight =
|
||||||
Twig.debug { "Screen content height in dps: $contentHeight" }
|
statusBars.run {
|
||||||
|
if (value <= 0f) {
|
||||||
ScreenHeight(
|
24.dp
|
||||||
contentHeight = contentHeight,
|
} else {
|
||||||
systemStatusBarHeight = statusBarHeight,
|
this
|
||||||
systemNavigationBarHeight = navigationBarHeight,
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Twig.debug { "Screen total height: $cachedResult" }
|
Twig.debug { "Screen height: Status bar height: $statusBarHeight" }
|
||||||
|
|
||||||
return cachedResult
|
val navigationBarHeight =
|
||||||
|
navigationBars.run {
|
||||||
|
if (value <= 0f) {
|
||||||
|
88.dp
|
||||||
|
} else {
|
||||||
|
this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Twig.debug { "Screen height: Navigation bar height: $navigationBarHeight" }
|
||||||
|
|
||||||
|
return ScreenHeight(
|
||||||
|
contentHeight = contentHeight,
|
||||||
|
systemStatusBarHeight = statusBarHeight,
|
||||||
|
systemNavigationBarHeight = navigationBarHeight
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
data class ScreenHeight(
|
data class ScreenHeight(
|
||||||
|
@ -74,13 +64,13 @@ data class ScreenHeight(
|
||||||
) {
|
) {
|
||||||
fun overallScreenHeight(): Dp {
|
fun overallScreenHeight(): Dp {
|
||||||
return (contentHeight + systemBarsHeight()).also {
|
return (contentHeight + systemBarsHeight()).also {
|
||||||
Twig.debug { "Screen overall height: $it" }
|
Twig.debug { "Screen height: Overall height: $it" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun systemBarsHeight(): Dp {
|
fun systemBarsHeight(): Dp {
|
||||||
return (systemStatusBarHeight + systemNavigationBarHeight).also {
|
return (systemStatusBarHeight + systemNavigationBarHeight).also {
|
||||||
Twig.debug { "System bars height: $this" }
|
Twig.debug { "Screen height: System bars height: $it" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import co.electriccoin.zcash.ui.test.getStringResource
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
import kotlin.test.Ignore
|
||||||
|
|
||||||
class OnboardingViewTest : UiTestPrerequisites() {
|
class OnboardingViewTest : UiTestPrerequisites() {
|
||||||
@get:Rule
|
@get:Rule
|
||||||
|
@ -66,6 +67,7 @@ class OnboardingViewTest : UiTestPrerequisites() {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@MediumTest
|
@MediumTest
|
||||||
|
@Ignore("Disabling this until [SemanticNodeInteraction.performScrollTo] works as expected")
|
||||||
fun click_import_wallet() {
|
fun click_import_wallet() {
|
||||||
val testSetup = newTestSetup()
|
val testSetup = newTestSetup()
|
||||||
|
|
||||||
|
|
|
@ -113,13 +113,13 @@ fun ShortOnboarding(
|
||||||
onFixtureWallet = onFixtureWallet,
|
onFixtureWallet = onFixtureWallet,
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
|
.height(screenHeight.overallScreenHeight())
|
||||||
.padding(
|
.padding(
|
||||||
top = paddingValues.calculateTopPadding() + ZcashTheme.dimens.spacingHuge,
|
top = paddingValues.calculateTopPadding() + ZcashTheme.dimens.spacingHuge,
|
||||||
bottom = paddingValues.calculateBottomPadding() + ZcashTheme.dimens.spacingDefault,
|
bottom = paddingValues.calculateBottomPadding() + ZcashTheme.dimens.spacingBig,
|
||||||
start = ZcashTheme.dimens.screenHorizontalSpacingBig,
|
start = ZcashTheme.dimens.screenHorizontalSpacingBig,
|
||||||
end = ZcashTheme.dimens.screenHorizontalSpacingBig
|
end = ZcashTheme.dimens.screenHorizontalSpacingBig
|
||||||
)
|
)
|
||||||
.height(screenHeight.contentHeight - paddingValues.calculateBottomPadding())
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue