Skip to content

Commit

Permalink
added z indix to canvas modifier to register clicks when palette is h…
Browse files Browse the repository at this point in the history
…idden
  • Loading branch information
Shivam Dhuria authored and Shivam Dhuria committed Feb 5, 2022
1 parent d2c9cef commit 1a013ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
14 changes: 6 additions & 8 deletions app/src/main/java/com/elixer/colorapp/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
Expand All @@ -27,21 +25,18 @@ class MainActivity : ComponentActivity() {
ColorAppTheme {
// A surface container using the 'background' color from the theme
Surface(modifier = Modifier.fillMaxSize(), color = MaterialTheme.colors.background) {

Heading()
Palette(
defaultColor = Color.Blue,
buttonSize = 210.dp,
onColorSelected = { onColorSelected(it) },
swatches = Presets.material(),
)
Column {
Heading()
}

}
}
}
}

private fun onColorSelected(it: Color) {
}
}
Expand All @@ -55,6 +50,9 @@ private fun Heading() {
) {
Text(text = "palette", fontSize = 80.sp, color = Color.DarkGray, textAlign = TextAlign.Center)
Text(text = "color picker made with Jetpack Compose", fontSize = 15.sp, color = Color.DarkGray, textAlign = TextAlign.Center)
TextButton(onClick = { }) {
Text("Some lccikable ", modifier = Modifier.padding(40.dp))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.elixer.palette.composables
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.*
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.detectDragGestures
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.BoxWithConstraints
Expand All @@ -20,6 +21,7 @@ import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.zIndex
import com.elixer.palette.Presets
import com.elixer.palette.constraints.HorizontalAlignment
import com.elixer.palette.constraints.HorizontalAlignment.*
Expand Down Expand Up @@ -150,6 +152,7 @@ fun Palette(

BoxWithConstraints(
modifier = Modifier
.zIndex(if (isPaletteDisplayed.value) 0f else -3f)
.fillMaxSize()
.pointerInput(Unit) {
detectDragGestures(
Expand Down

0 comments on commit 1a013ea

Please sign in to comment.