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
| fun actions(): Flow<MoviesFlowAction> = merge( | |
| actionChannel.consumeAsFlow(), | |
| binding.refreshButton.clicks().map { MoviesAction.RefreshAction } | |
| ) |
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 SearchField( | |
| actionChannel: ActionChannel | |
| ) { | |
| ... | |
| Button( | |
| /*Send a new action in the actionChannel */ | |
| onClick = { actionChannel.trySend(MoviesAction.SearchMovieAction(query) }, | |
| ... | |
| ) { |
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 MoviesScreenContent( | |
| uiState: TransferScreenState, | |
| actionChannel: ActionChannel | |
| ) { | |
| ... | |
| } | |
| ... | |
| @Composable |
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
| class MoviesActivity : ComponentActivity() { | |
| private val viewModel by viewModels<MoviesViewModel>() | |
| private val actionChannel = Channel<MoviesAction>() | |
| private fun actions(): Flow<MoviesAction> = actionChannel.consumeAsFlow() | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) |
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 MoviesScreenContent( | |
| uiState: TransferScreenState, | |
| onSearchMovie: (String) -> Unit = { }, | |
| onCategoryChange: (String) -> Unit = { }, | |
| onFirstNameChange: (String) -> Unit = { }, | |
| onLastNameChange: (String) -> Unit = { }, | |
| onFavoriteChange: (String) -> Unit = { }, | |
| onDownloadClicked: (MovieUI) -> Unit = { }, | |
| onUploadClicked: () -> Unit = { }, |
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
| class MoviesViewModel @Inject constructor(private val mapper: MoviesUIMapper) : ViewModel() { | |
| private val _actionFlow = | |
| MutableSharedFlow<MoviesAction>(extraBufferCapacity = 16) | |
| init { | |
| _actionFlow.process().launchIn(viewModelScope) | |
| } | |
| private fun Flow<MoviesAction>.process() = onEach { | |
| when(it) { |
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
| sealed class MoviesAction { | |
| data class SearchMovieAction(val query: String): MoviesAction() | |
| data class AddToHistoryAction(val movieId: Int): MoviesAction() | |
| object RefreshMoviesAction: MoviesAction() | |
| } |
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
| data class TransactionUI( | |
| val title: String = "", | |
| val type: String = "", | |
| val image: String = "", | |
| val amount: String = "", | |
| val date: String = "", | |
| val color: Color = Color.Yellow | |
| ) |
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
| binding.title = transaction.title | |
| binding.type = transaction.type | |
| binding.image.load(transaction.image) | |
| binding.amount = transaction.amount | |
| binding.date = transaction.date |
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
| data class TransactionUI( | |
| val title: String = "", | |
| val type: String = "", | |
| val image: String = "", | |
| val amount: String = "", | |
| val date: String = "", | |
| @ColorRes val color: Int = R.color.yellow | |
| ) |
NewerOlder