Skip to content

Instantly share code, notes, and snippets.

View igorescodro's full-sized avatar
♥️
Coding with love

Igor Escodro igorescodro

♥️
Coding with love
View GitHub Profile
// [...] Composable screen code
when (state) {
MainState.Loading -> {
ShimmerProvider {
ItemCard(item = fakeData)
}
}
is MainState.Success -> {
ItemCard(item = state.itemData)
@Composable
fun Modifier.shimmerable(
shape: Shape = RoundedCornerShape(8.dp),
color: Color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f)
): Modifier {
if (!LocalShimmerState.current.isLoading) return this
return this
.shimmer()
.background(color = color, shape = shape)
// [...] Composable screen code
when (state) {
MainState.Loading -> {
ItemCard(
item = fakeData,
isLoading = true,
)
}
is MainState.Success -> {
@Composable
private fun ItemCard(
item: ItemData,
isLoading: Boolean = false
modifier: Modifier = Modifier
) {
Text(
text = item.description,
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.shimmerable(enabled = isLoading)
@PreviewLightDark
@Composable
private fun ShimmerablePreview() {
ExampleTheme {
Column(
modifier = Modifier
.background(MaterialTheme.colorScheme.surface)
.padding(8.dp)
) {
Text(
@Composable
fun Modifier.shimmerable(
enabled: Boolean,
color: Color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.6f),
shape: Shape = RoundedCornerShape(8.dp),
): Modifier {
if (!enabled) return this
return this
.shimmer() // 3rd party library call
package com.escodro.task.presentation.detail.main
//...
import dev.icerock.moko.mvvm.viewmodel.ViewModel
internal class TaskViewModel : ViewModel() {
fun loadTaskInfo() {
// Everything an Android ViewModel has
viewModelScope.launch { doSuspendStuff() }
//...
androidDependencies {
// Module responsible to download from Google Play
implementation(projects.libraries.splitInstall)
}
iosDependencies {
// Dynamic Module always available
implementation(projects.features.tracker)
}
@Composable
fun AlkaaNavGraph() {
ScreenRegistry {
taskScreenModule()
categoryScreenModule()
preferencesScreenModule()
}
BottomSheetNavigator {
Navigator(HomeScreen())
override fun scheduleTaskNotification(task: Task, timeInMillis: Long) {
val content = UNMutableNotificationContent()
content.setBody(task.title)
content.setCategoryIdentifier(CATEGORY_IDENTIFIER_TASK)
content.setUserInfo(mapOf(USER_INFO_TASK_ID to task.id))
val nsDate = NSDate.dateWithTimeIntervalSince1970(timeInMillis / 1000.0)
val dateComponents = NSCalendar.currentCalendar.components(
NSCalendarUnitYear or NSCalendarUnitMonth or NSCalendarUnitDay
or NSCalendarUnitHour or NSCalendarUnitMinute,