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
@Test | |
fun getSearchedResult_receivedResponse_wrongPageSize_shouldFail() { | |
runBlocking { | |
enqueueMockResponse("ImageResponse.json") | |
val responseBody = service.getSearchedImage("nature", 5).body() | |
val photoList = responseBody!!.photos | |
assertThat(photoList.size).isEqualTo(6) | |
} | |
} |
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 MovieListContent(allMovies: List<Movie>, navController: NavHostController) { | |
LazyColumn( | |
contentPadding = PaddingValues(horizontal = 8.dp, vertical = 4.dp) | |
) { | |
items( | |
items = allMovies, | |
itemContent = { | |
MovieListItem(movie = it, navController = navController) |
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 Movie( | |
val movieId: Int, | |
val overview: String, | |
val imageId: Int, | |
val title: String, | |
val rating: String, | |
val releaseDate: String, | |
):Serializable |
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 RowScope.BottomItem( | |
screen: BottomNavigationItem, | |
currentDestination: NavDestination?, | |
navController: NavHostController, | |
) { | |
//RowScope.BottomNavigationItem | |
BottomNavigationItem( | |
icon = { Icon(painterResource(id = screen.icon), contentDescription = screen.title) }, | |
selected = currentDestination?.hierarchy?.any { |
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 MainScreen() { | |
val navController = rememberNavController() | |
Scaffold( | |
bottomBar = { | |
BottomAppBar { | |
CustomBottomNavigation(navController = navController) | |
} | |
} | |
) { |
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 AppViewModel : ViewModel() { | |
private val _titleInputFlow = MutableStateFlow<String>("") | |
val titleInputFlow: StateFlow<String> get() = _titleInputFlow | |
fun setTitle(title: String) { | |
_titleInputFlow.value = title | |
} | |
fun resetTitle() { | |
_titleInputFlow.value = "" |
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
private val viewModel = AppViewModel() | |
@Composable | |
fun MainContent(viewModel: AppViewModel) { | |
val title by viewModel.titleInputFlow.collectAsState() | |
Content(title = title, onTitleChange = { | |
viewModel.setTitle(it) | |
}, onResetClicked = { viewModel.resetTitle() }) | |
} |