-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from Go-Socket-Project/feature/44_publishing_f…
…or_checkbox 🔀 :: (#44) publishing for checkbox
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
core/designsystem/src/main/java/com/chat/designsystem/component/checkbox/GoSocketCheckbox.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) {} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
core/designsystem/src/main/java/com/chat/designsystem/theme/Color.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |