Skip to content

Commit

Permalink
Merge pull request #45 from Go-Socket-Project/feature/44_publishing_f…
Browse files Browse the repository at this point in the history
…or_checkbox

🔀 :: (#44) publishing for checkbox
  • Loading branch information
Cjsghkd authored Aug 8, 2024
2 parents 22b1089 + b5da77e commit 5f9bdd6
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.chat.designsystem.component.checkbox

import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Checkbox
import androidx.compose.material3.CheckboxDefaults
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.draw.clip
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.chat.designsystem.theme.N3
import com.chat.designsystem.theme.P1
import com.chat.designsystem.util.clickableNoRipple

@Composable
fun GoSocketCheckbox(
modifier: Modifier = Modifier,
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
) {
var isChecked by remember { mutableStateOf(checked) }

Checkbox(
modifier = modifier
.size(20.dp)
.clip(RoundedCornerShape(8.dp))
.border(
width = 2.dp,
color = if (isChecked) P1 else N3,
shape = RoundedCornerShape(8.dp)
)
.clickableNoRipple {
isChecked = !isChecked
onCheckedChange(isChecked)
},
checked = isChecked,
onCheckedChange = null,
colors = CheckboxDefaults.colors(checkedColor = P1)
)
}

@Preview
@Composable
fun GoSocketCheckboxPreview() {
Column {
GoSocketCheckbox(checked = true) {}
Spacer(modifier = Modifier.height(10.dp))
GoSocketCheckbox(checked = false) {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.chat.designsystem.theme

import androidx.compose.ui.graphics.Color

val P1 = Color(0xFF6263FB)

val N3 = Color(0xFFBBBBCC)

0 comments on commit 5f9bdd6

Please sign in to comment.