Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ComposeX components and Coil dependencies #12

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading