-
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.
feat: Add ComposeX components and Coil dependencies (#12)
- 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
1 parent
156c8c4
commit 9f5e556
Showing
9 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
40 changes: 40 additions & 0 deletions
40
libx/composex/src/main/java/vn/core/composex/uikit/avatar/AvatarComponent.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,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), | ||
) | ||
} |
35 changes: 35 additions & 0 deletions
35
libx/composex/src/main/java/vn/core/composex/uikit/textField/AppTextOnlyReadField.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,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.
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