Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
👌 Changes the loading to only be hidden when the page finishes rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
hernandazevedozup committed Jun 7, 2022
1 parent 3d8ad2d commit c32c995
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package br.zup.com.nimbus.compose.core.ui.internal

import androidx.compose.foundation.layout.Spacer
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTag
import br.zup.com.nimbus.compose.NimbusTheme
import br.zup.com.nimbus.compose.model.NimbusPageState
import br.zup.com.nimbus.compose.model.Page
Expand All @@ -14,10 +18,10 @@ internal fun NimbusView(
page: Page
) {
var loading by remember { mutableStateOf(false) }
if (loading) {
NimbusTheme.nimbusAppState.config.loadingView()
}
page.content.let { nimbusPageState ->
if (loading) {
NimbusTheme.nimbusAppState.config.loadingView()
}
when (nimbusPageState) {
is NimbusPageState.PageStateOnLoading -> {
loading = true
Expand All @@ -31,6 +35,9 @@ internal fun NimbusView(
}
is NimbusPageState.PageStateOnShowPage -> {
NimbusServerDrivenView(viewTree = nimbusPageState.serverDrivenNode)
Spacer(modifier = Modifier.semantics(true) {
testTag = "NimbusPage:${page.id}"
})
loading = false
}
}
Expand Down

0 comments on commit c32c995

Please sign in to comment.