Skip to content

Commit

Permalink
Hides the timer and difficulty infos if the current grid is still get…
Browse files Browse the repository at this point in the history
…ting calculated
  • Loading branch information
meikpiep committed Jan 9, 2025
1 parent e9362d3 commit 2ab8f3e
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GameTopFragment :

private lateinit var binding: FragmentMainGameTopBinding

private var showtimer = false
private val showtimer = applicationPreferences.showTimer()

override fun onCreateView(
inflater: LayoutInflater,
Expand Down Expand Up @@ -81,9 +81,6 @@ class GameTopFragment :
}

override fun onResume() {
this.showtimer = applicationPreferences.showTimer()
updateTimerVisibility()

gameLifecycle.addPlayTimeListener(this)

super.onResume()
Expand All @@ -101,11 +98,20 @@ class GameTopFragment :
if (it.state == MainUiState.PLAYING || it.state == MainUiState.ALREADY_SOLVED) {
freshGridWasCreated()
}

if (it.state == MainUiState.CALCULATING_NEW_GRID) {
binding.difficulty.visibility = View.INVISIBLE
binding.playtime.visibility = View.INVISIBLE
binding.ratingStarOne.visibility = View.INVISIBLE
binding.ratingStarTwo.visibility = View.INVISIBLE
binding.ratingStarThree.visibility = View.INVISIBLE
binding.ratingStarFour.visibility = View.INVISIBLE
} else {
updateTimerVisibility()
}
}
}
}

updateTimerVisibility()
}

private fun updateTimerVisibility() {
Expand Down Expand Up @@ -142,6 +148,7 @@ class GameTopFragment :
binding.ratingStarThree.visibility = visibilityOfStars
binding.ratingStarFour.visibility = visibilityOfStars

binding.difficulty.visibility = View.VISIBLE
binding.playtime.text = Utils.displayableGameDuration(game.grid.playTime)
}

Expand Down

0 comments on commit 2ab8f3e

Please sign in to comment.