Skip to content

Commit 54889d8

Browse files
committed
Update readme
1 parent b8dfe70 commit 54889d8

File tree

4 files changed

+147
-27
lines changed

4 files changed

+147
-27
lines changed

.idea/androidTestResultsUserPreferences.xml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Cédric Kossi
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,35 @@
1-
# Compose_Nice_CheckBox
1+
# Compose-Round-CheckBox
2+
[![](https://jitpack.io/v/kosher9/Compose-Round-CheckBox.svg)](https://jitpack.io/#kosher9/Compose-Round-CheckBox)
3+
4+
RoundCheckboxes allow users to select one or more items from a set. RoundCheckboxes can turn an option on or off.
5+
6+
## Preview
7+
https://github.com/kosher9/Compose-Round-CheckBox/assets/34873327/dee17090-e20a-4309-9595-2b16f9028206
8+
9+
## Gradle Setup
10+
11+
To get a Git project into your build:
12+
13+
* Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end
14+
of repositories:
15+
16+
```
17+
allprojects {
18+
repositories {
19+
...
20+
maven { url 'https://jitpack.io' }
21+
}
22+
}
23+
```
24+
25+
* Step 2. Add the dependency
26+
27+
```
28+
dependencies {
29+
implementation 'com.github.kosher9:Compose-Round-CheckBox:Tag'
30+
}
31+
```
32+
33+
## 📝 License
34+
35+
This project is [MIT](./LICENSE.md) licensed.

app/src/main/java/com/kosher9/app/MainActivity.kt

Lines changed: 90 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import androidx.activity.ComponentActivity
66
import androidx.activity.compose.setContent
77
import androidx.annotation.RequiresApi
88
import androidx.compose.foundation.layout.Arrangement
9+
import androidx.compose.foundation.layout.Column
910
import androidx.compose.foundation.layout.Row
1011
import androidx.compose.foundation.layout.fillMaxSize
1112
import androidx.compose.foundation.layout.fillMaxWidth
1213
import androidx.compose.foundation.layout.padding
1314
import androidx.compose.foundation.layout.width
1415
import androidx.compose.material3.MaterialTheme
15-
import androidx.compose.material3.RadioButton
1616
import androidx.compose.material3.Surface
1717
import androidx.compose.material3.Text
1818
import androidx.compose.runtime.Composable
@@ -22,10 +22,12 @@ import androidx.compose.runtime.remember
2222
import androidx.compose.runtime.setValue
2323
import androidx.compose.ui.Alignment
2424
import androidx.compose.ui.Modifier
25+
import androidx.compose.ui.graphics.Color
2526
import androidx.compose.ui.tooling.preview.Preview
2627
import androidx.compose.ui.unit.dp
2728
import com.kosher9.app.ui.theme.ComposeNiceCheckBoxTheme
2829
import com.kosher9.roundcheckbox.RoundCheckBox
30+
import com.kosher9.roundcheckbox.RoundCheckBoxDefaults
2931

3032
class MainActivity : ComponentActivity() {
3133
@RequiresApi(Build.VERSION_CODES.Q)
@@ -38,49 +40,111 @@ class MainActivity : ComponentActivity() {
3840
modifier = Modifier.fillMaxSize(),
3941
color = MaterialTheme.colorScheme.background
4042
) {
41-
Greeting("Android")
43+
RoundCheckBoxes()
4244
}
4345
}
4446
}
4547
}
4648
}
4749

4850
@Composable
49-
fun Greeting(name: String, modifier: Modifier = Modifier) {
51+
fun RoundCheckBoxes(modifier: Modifier = Modifier) {
5052

51-
var radioButtonState by remember { mutableStateOf(false) }
52-
var niceCheckBoxState by remember { mutableStateOf(false) }
53+
var roundCheckBoxEnableState by remember { mutableStateOf(false) }
54+
var roundCheckBoxDisableState by remember { mutableStateOf(false) }
55+
var roundCheckBoxCheckedDisableState by remember { mutableStateOf(true) }
56+
var customRoundCheckBoxDisableState by remember { mutableStateOf(false) }
5357

54-
Row(
55-
modifier = Modifier
56-
.fillMaxWidth()
57-
.padding(5.dp),
58-
horizontalArrangement = Arrangement.SpaceBetween,
59-
verticalAlignment = Alignment.CenterVertically
60-
) {
58+
Column(modifier = Modifier.padding(top = 50.dp)) {
59+
Row(
60+
modifier = Modifier
61+
.fillMaxWidth()
62+
.padding(5.dp),
63+
horizontalArrangement = Arrangement.SpaceBetween,
64+
verticalAlignment = Alignment.CenterVertically
65+
) {
66+
Text(
67+
text = "Enabled",
68+
modifier = modifier
69+
)
6170

62-
Text(
63-
text = "Hello $name!",
64-
modifier = modifier
65-
)
66-
// Checkbox(checked = , onCheckedChange = )
71+
RoundCheckBox(
72+
modifier = Modifier.width(60.dp),
73+
isChecked = roundCheckBoxEnableState,
74+
onClick = { roundCheckBoxEnableState = !roundCheckBoxEnableState },
75+
enabled = true
76+
)
77+
}
78+
79+
Row(
80+
modifier = Modifier
81+
.fillMaxWidth()
82+
.padding(5.dp),
83+
horizontalArrangement = Arrangement.SpaceBetween,
84+
verticalAlignment = Alignment.CenterVertically
85+
) {
86+
Text(
87+
text = "Disabled",
88+
modifier = modifier
89+
)
6790

68-
RadioButton(selected = radioButtonState, onClick = { radioButtonState = !radioButtonState })
91+
RoundCheckBox(
92+
modifier = Modifier.width(60.dp),
93+
isChecked = roundCheckBoxDisableState,
94+
onClick = { roundCheckBoxDisableState = !roundCheckBoxDisableState },
95+
enabled = false
96+
)
97+
}
6998

70-
RoundCheckBox(
71-
modifier = Modifier.width(60.dp),
72-
radius = 10.dp,
73-
isChecked = niceCheckBoxState,
74-
onClick = { niceCheckBoxState = !niceCheckBoxState },
75-
enabled = true
76-
)
99+
Row(
100+
modifier = Modifier
101+
.fillMaxWidth()
102+
.padding(5.dp),
103+
horizontalArrangement = Arrangement.SpaceBetween,
104+
verticalAlignment = Alignment.CenterVertically
105+
) {
106+
Text(
107+
text = "Disabled & Checked",
108+
modifier = modifier
109+
)
110+
111+
RoundCheckBox(
112+
modifier = Modifier.width(60.dp),
113+
isChecked = roundCheckBoxCheckedDisableState,
114+
onClick = { roundCheckBoxCheckedDisableState = !roundCheckBoxCheckedDisableState },
115+
enabled = false
116+
)
117+
}
118+
119+
Row(
120+
modifier = Modifier
121+
.fillMaxWidth()
122+
.padding(5.dp),
123+
horizontalArrangement = Arrangement.SpaceBetween,
124+
verticalAlignment = Alignment.CenterVertically
125+
) {
126+
Text(
127+
text = "Custom",
128+
modifier = modifier
129+
)
130+
131+
RoundCheckBox(
132+
modifier = Modifier.width(60.dp),
133+
radius = 10.dp,
134+
color = RoundCheckBoxDefaults.colors(Color(20, 138, 254), Color(0, 0, 0), Color(20, 138, 254), Color.White, Color(20, 138, 254)),
135+
isChecked = customRoundCheckBoxDisableState,
136+
onClick = { customRoundCheckBoxDisableState = !customRoundCheckBoxDisableState },
137+
enabled = true
138+
)
139+
}
77140
}
141+
78142
}
79143

80144
@Preview(showBackground = true)
81145
@Composable
82146
fun GreetingPreview() {
83147
ComposeNiceCheckBoxTheme {
84-
Greeting("Android")
148+
RoundCheckBoxes()
85149
}
86150
}

0 commit comments

Comments
 (0)