Skip to content

Commit

Permalink
feat: Add ComposeX components and Coil dependencies (#12)
Browse files Browse the repository at this point in the history
- Introduce `AppTextOnlyReadField` component in `composex` module for read-only text fields.
- Add `AvatarComponent` to handle image loading with Coil in a circular shape.
- Update dependencies to include `coilCompose` and `coilNetwork` for image handling.
- Add new string resource for "avatar".
- Increment version to `1.0.4` in `Configs`.
  • Loading branch information
doananhtuan22111996 authored Jan 4, 2025
1 parent 156c8c4 commit 9f5e556
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 1 deletion.
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/vn/core/libx/buildSrc/Configs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ object Configs {
const val GROUP_ID = "vn.core.libs"
const val ARTIFACT_COMPOSE_ID = "compose"
const val ARTIFACT_MDC_ID = "mdc"
const val VERSION = "1.0.3"
const val VERSION = "1.0.4"
}
}
5 changes: 5 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
corePlugins = "1.0.1"
domain = "1.0.0"

coilCompose = "3.0.4"

[libraries]
corePlugins = { group = "vn.core.libs", name = "plugins", version.ref = "corePlugins" }
domain = { group = "vn.core.libs", name = "domain", version.ref = "domain" }

coilCompose = { group = "io.coil-kt.coil3", name = "coil-compose", version.ref = "coilCompose" }
coilNetwork = { group = "io.coil-kt.coil3", name = "coil-network-okhttp", version.ref = "coilCompose" }

[plugins]
3 changes: 3 additions & 0 deletions libx/composex/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ android {

dependencies {
implementation(libs.domain)

implementation(libs.coilCompose)
implementation(libs.coilNetwork)
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package vn.core.composex.uikit.avatar

import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import coil3.compose.AsyncImage
import coil3.request.ImageRequest
import coil3.request.crossfade
import vn.core.libx.composex.R

@Composable
fun AvatarComponent(url: String) {
AsyncImage(
model = ImageRequest.Builder(LocalContext.current).data(url).crossfade(true).build(),
placeholder = painterResource(R.drawable.avatar_default),
contentDescription = stringResource(R.string.avatar),
contentScale = ContentScale.Crop,
modifier = Modifier
.size(100.dp)
.clip(CircleShape),
onError = {
println(it.result.throwable.printStackTrace())
},
onSuccess = {
println(it.result.dataSource.toString())
},
onLoading = {
println("AsyncImage is loading")
},
error = painterResource(R.drawable.avatar_default),
fallback = painterResource(R.drawable.avatar_default),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package vn.core.composex.uikit.textField

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.material3.OutlinedTextField
import androidx.compose.ui.Modifier
import vn.core.composex.EMPTY_STRING

@Composable
fun AppTextOnlyReadField(
value: String = EMPTY_STRING,
label: String,
placeHolder: String,
modifier: Modifier = Modifier,
) {
OutlinedTextField(
modifier = modifier.fillMaxWidth(),
value = value,
label = {
Text(
text = label,
style = MaterialTheme.typography.labelMedium.copy(color = MaterialTheme.colorScheme.onSurface)
)
},
onValueChange = { _ -> },
enabled = false,
readOnly = true,
isError = false,
placeholder = { Text(text = placeHolder) },
singleLine = true,
maxLines = 1,
)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions libx/composex/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
<string name="password">Password</string>
<string name="example_password">●●●●●●●●</string>
<string name="cancel">Cancel</string>
<string name="avatar">Avatar</string>
</resources>

0 comments on commit 9f5e556

Please sign in to comment.