Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dofire/composeeasier
contain useful composables and helper functions
https://github.com/dofire/composeeasier
android-library composable jetpack-compose
Last synced: 3 days ago
JSON representation
contain useful composables and helper functions
- Host: GitHub
- URL: https://github.com/dofire/composeeasier
- Owner: dofire
- Created: 2022-10-29T07:01:49.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-12-31T14:32:51.000Z (about 2 years ago)
- Last Synced: 2024-12-18T03:16:17.884Z (about 2 months ago)
- Topics: android-library, composable, jetpack-compose
- Language: Kotlin
- Homepage:
- Size: 170 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Compose-Easier
| CheckBox | Switch | Button | TextField |
| :---------------------------: | :------------------------: | :------------------------: | :---------------------------: |
| ![](screenshots/checkbox.png) | ![](screenshots/switch.png)| ![](screenshots/button.png)| ![](screenshots/textfield.png)|
![]()
![]()
![]()
## Getting started 🍕🍔🍟
Ensure your app’s minimum SDK version is 21+ and `mavenCentral()` included
1. Ensure your app’s minimum SDK version is 21+. This is declared in the module-level `build.gradle` file
```gradle
android {
defaultConfig {
...
minSdk 21
}
```2. Ensure the `mavenCentral()` repository is declared in the project-level `build.gradle` or `setting.gradle` file:
build.gradle (project-level)
```gradle
allprojects {
repositories {
mavenCentral()
...
}
...
}
```
settings.gradle (alternative step If "allprojects" not found in the above step)
```gradle
pluginManagement {
repositories {
...
mavenCentral()
}
}
dependencyResolutionManagement {
...
repositories {
...
mavenCentral()
}
}
```
Declare the dependencies in the module-level `build.gradle` file
```gradle
dependencies {
implementation("io.github.torrydo:compose-easier:")
}
```## Usage 🚗🏍🚄
> the parameters are quite similar to the default composable. you can use it without hassle ✨🎉
1. CheckBox ✅
```kotlin
var state by remember { mutableStateOf(false) }CheckBoxEz.RoundedCorner(checked = state, onChange = { state = it })
```
2. Switch 🥪
```kotlin
var state by remember { mutableStateOf(false) }SwitchEz.Border(isOn = state, onChange = { state = it })
SwitchEz.Fill(isOn = state, onChange = { state = it })```
3. Button 🚀
```kotlin
ButtonEz.Flat(onClick = {}) {
Text(text = "Flat Button")
}ButtonEz.Outline(onClick = {}) {
Text(text = "Outlined Button")
}ButtonEz.Gradient(onClick = {}) {
Text(text = "Gradient Button")
}```
4. TextField 🍻
```kotlin
var str by remember { mutableStateOf("") }TextFieldEz.EditText(
value = str,
onValueChange = { str = it },
placeHolderText = { Text(text = "type me!") },
textStyle = TextStyle(...),
onDone = {},
trailingIcon = { },
modifier = Modifier.background(Color.Transparent)
)```
5. Composable Helpers 🌎
```kotlin
// modifier extensions
fun Modifier.noRippleClickable(onClick: () -> Unit)
fun Modifier.leftRoundedCorner(dp: Dp)
fun Modifier.topRoundedCorner(dp: Dp)
fun Modifier.dashedBorder(width: Dp, radius: Dp, color: Color)// side effect extensions
var num = 5
LaunchedEffectWith(num){ n: Int ->
...
}// listen composable lifecycle
OnLifecycleEvent{ owner, event ->
...
}// lazyColumn/Row
val lazyState = rememberLazyListState()
val isScrollingUp = lazyState.isScrollingUp() // value auto change when scrolling up
// different way
lazyState.listenScrollDirection(
onScrollUp = {...},
onScrollDown = {...}
)```
## License 📃
```
Copyright 2022 TorryDo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.```