This file contains hidden or 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
// [...] Composable screen code | |
when (state) { | |
MainState.Loading -> { | |
ShimmerProvider { | |
ItemCard(item = fakeData) | |
} | |
} | |
is MainState.Success -> { | |
ItemCard(item = state.itemData) |
This file contains hidden or 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
@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) |
This file contains hidden or 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
// [...] Composable screen code | |
when (state) { | |
MainState.Loading -> { | |
ItemCard( | |
item = fakeData, | |
isLoading = true, | |
) | |
} | |
is MainState.Success -> { |
This file contains hidden or 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
@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) |
This file contains hidden or 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
@PreviewLightDark | |
@Composable | |
private fun ShimmerablePreview() { | |
ExampleTheme { | |
Column( | |
modifier = Modifier | |
.background(MaterialTheme.colorScheme.surface) | |
.padding(8.dp) | |
) { | |
Text( |
This file contains hidden or 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
@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 |
This file contains hidden or 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
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() } |
This file contains hidden or 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
//... | |
androidDependencies { | |
// Module responsible to download from Google Play | |
implementation(projects.libraries.splitInstall) | |
} | |
iosDependencies { | |
// Dynamic Module always available | |
implementation(projects.features.tracker) | |
} |
This file contains hidden or 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
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, |
NewerOlder