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
@DevicesPreview | |
@Composable | |
fun WelcomeCoraPartnershipScreenPreview() { | |
WelcomeCoraPartnershipScreen() | |
} |
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
@Preview(showSystemUi = true, device = Devices.PHONE) | |
@Preview(showSystemUi = true, device = Devices.NEXUS_7_2013) | |
@Preview(showSystemUi = true, device = Devices.NEXUS_5) | |
@Preview(showSystemUi = true, device = Devices.FOLDABLE) | |
annotation class DevicesPreview |
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
@Preview | |
@Composable | |
fun WelcomeCoraPartnershipScreenPreview() { | |
WelcomeCoraPartnershipScreen() | |
} |
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
// Código ilustrativo da tela inicial do fluxo de Parceria Cora | |
@Composable | |
fun WelcomeCoraPartnershipScreen() | |
Box(modifier = Modifier.fillMaxSize()) { | |
Column( | |
Modifier | |
.verticalScroll(rememberScrollState()) | |
.align(Alignment.TopStart) | |
) { | |
WelcomeCoraPartnershipHeader() |
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
debugImplementation "androidx.compose.ui:ui-tooling:1.3.0" | |
implementation "androidx.compose.ui:ui-tooling-preview:1.3.0" | |
// Se o projeto foi criado como um projeto compose, essas dependencias são adicionadas automaticamente |
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
@Composable | |
private fun animateAlignmentAsState( | |
targetAlignment: Alignment, | |
finishedListener: (Float) -> Unit | |
): State<Alignment> { | |
val biased = targetAlignment as BiasAlignment | |
val horizontal by animateFloatAsState( | |
biased.horizontalBias, | |
finishedListener = finishedListener | |
) |
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
class TestandoSharedFlow(val useCase: TestandoSharedFlowUseCase) : ViewModel() { | |
private val states = MutableSharedFlow<Int>( | |
onBufferOverflow = BufferOverflow.DROP_LATEST, | |
extraBufferCapacity = 1 | |
) | |
fun observeStates() = states.asSharedFlow() |
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
@Composable | |
fun CharacterItem(character: CharacterUi) { | |
Row( | |
modifier = Modifier | |
.padding(start = 16.dp, top = 16.dp, end = 16.dp) | |
.fillMaxWidth(), | |
horizontalArrangement = Arrangement.SpaceBetween, | |
verticalAlignment = Alignment.CenterVertically, | |
) { | |
CharacterImage( |
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
@Composable | |
fun CharacterList(characters: Flow<PagingData<CharacterUi>>) { | |
val lazyCharacters: LazyPagingItems<CharacterUi> = characters.collectAsLazyPagingItems() | |
LazyColumn { | |
items(lazyPagingItems = lazyCharacters) { character -> | |
character?.let { | |
CharacterItem(character = character) |
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
class PersonageViewModel( | |
private val repository: PersonageRepository | |
) : ViewModel() { | |
fun getCharacters(): Flow<PagingData<CharacterUi>> { | |
return repository.getPersonages().cachedIn(viewModelScope) | |
} | |
} |
NewerOlder