Skip to content

Commit

Permalink
🌟 add first click track
Browse files Browse the repository at this point in the history
  • Loading branch information
theapache64 committed Oct 22, 2021
1 parent 3e936a9 commit 2b7b5a2
Showing 1 changed file with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.theapache64.stackzy.ui.common.loading.funfact

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.unit.sp
Expand All @@ -12,6 +14,10 @@ import com.theapache64.stackzy.data.remote.FunFact
import com.theapache64.stackzy.ui.common.CenterBox
import com.theapache64.stackzy.util.PureRandom

/**
* App level config flag
*/
private var isClicked = false

@Composable
fun FunFact(
Expand All @@ -21,16 +27,31 @@ fun FunFact(
val pureRandom = remember { PureRandom(funFacts) }
var currentFunFact by remember { mutableStateOf(pureRandom.get()) }

Text(
text = "\"${currentFunFact.funFact}\"",
fontStyle = FontStyle.Italic,
color = MaterialTheme.colors.onSurface.copy(alpha = 0.5f),
fontSize = 15.sp,
modifier = modifier
.clickable {
currentFunFact = pureRandom.get()
}
)
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {

Text(
text = "\"${currentFunFact.funFact}\"",
fontStyle = FontStyle.Italic,
color = MaterialTheme.colors.onSurface.copy(alpha = 0.5f),
fontSize = 15.sp,
modifier = modifier
.clickable {
isClicked = true
currentFunFact = pureRandom.get()
}
)

if (!isClicked) {
Text(
text = "Click on the fact to get more",
color = MaterialTheme.colors.onSurface.copy(alpha = 0.3f),
fontSize = 13.sp,
)
}

}
}


Expand Down

0 comments on commit 2b7b5a2

Please # to comment.