Skip to content

Commit

Permalink
Ensure header background on profile screen is not rendered in Loading…
Browse files Browse the repository at this point in the history
… and Error states
  • Loading branch information
Matthew Dolan committed Jan 26, 2021
1 parent de6adcc commit 5398805
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ProfileFragment : Fragment() {

ShadowScrollBehavior(requireContext()).onDependentViewChanged(
scrollingView = binding.recyclerView,
binding.background, binding.image, binding.name, binding.tagline, binding.location, binding.chipGroup
binding.background, binding.image, binding.name, binding.tagline, binding.location, binding.chipGroup, binding.pad
)

lifecycleScope.launch {
Expand All @@ -113,22 +113,19 @@ class ProfileFragment : Fragment() {
private fun render(state: ProfileState) {
when (state) {
ProfileState.Loading -> {
if (binding.mainView.currentState == R.id.error) {
println("trigger state change loading")
if (binding.mainView.currentState != R.id.loading) {
binding.mainView.setTransition(R.id.loadingToError)
binding.mainView.transitionToStart()
}
}
ProfileState.Error -> {
if (binding.mainView.currentState == R.id.loading) {
println("trigger state change error")
if (binding.mainView.currentState != R.id.error) {
binding.mainView.setTransition(R.id.loadingToError)
binding.mainView.transitionToEnd()
}
}
is ProfileState.Ready -> {
if (binding.mainView.currentState == R.id.loading) {
println("trigger state change ready")
binding.mainView.setTransition(R.id.loadingToReady)
binding.mainView.transitionToEnd()
}
Expand Down
6 changes: 6 additions & 0 deletions androidApp/src/main/res/xml/profile_fragment_scene.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
</Constraint>

<!-- content -->
<Constraint android:id="@+id/background">
<PropertySet android:visibility="invisible" />
</Constraint>
<Constraint android:id="@+id/image">
<PropertySet android:visibility="invisible" />
</Constraint>
Expand Down Expand Up @@ -69,6 +72,9 @@
</Constraint>

<!-- content -->
<Constraint android:id="@+id/background">
<PropertySet android:visibility="visible" />
</Constraint>
<Constraint android:id="@+id/image">
<PropertySet android:visibility="visible" />
</Constraint>
Expand Down

0 comments on commit 5398805

Please sign in to comment.