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 HomeScreen( | |
openSearch: () -> Unit, | |
openFilters: () -> Unit, | |
homeViewModel: HomeViewModel = viewModel(), | |
) { | |
Scaffold(topBar = { | |
HomeAppBar( | |
title = "Epic World", |
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 GameItem(game: GameResultsEntity) { | |
Card( | |
elevation = 20.dp, | |
backgroundColor = Color.Black, | |
modifier = | |
Modifier.padding(16.dp) | |
.clip(RoundedCornerShape(10.dp)) | |
.height(250.dp) | |
.fillMaxWidth() |
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 GameListing( | |
games: Flow<PagingData<GameResultsEntity>> | |
) { | |
val lazyGameItems = games.collectAsLazyPagingItems() | |
LazyVerticalGrid( | |
cells = GridCells.Fixed(2), | |
content = { | |
items(lazyGameItems.itemCount) { index -> | |
lazyGameItems[index]?.let { GameItem(it) } |
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 AppBarTest { | |
@get:Rule val composeTestRule = createComposeRule() | |
@Test | |
fun given_title_should_be_displayed_in_home_app_bar() { | |
// Load our composable | |
composeTestRule.setContent { | |
EpicWorldTheme { | |
HomeAppBar( |
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 HomeScreenTest { | |
@get:Rule val composeTestRule = createComposeRule() | |
//Mock the viewmodel | |
private val homeViewModel = mockk<HomeViewModel>() | |
@Before | |
fun init() { | |
MockKAnnotations.init(this, true) |
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 GameDetails( | |
gameDetails: GameDetailsEntity, | |
openGameTrailer: () -> Unit | |
) { | |
val scrollState = rememberScrollState() | |
Column( | |
modifier = | |
Modifier.fillMaxSize() |
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 PlayTrailer( | |
modifier: Modifier = Modifier, | |
openGameTrailer: () -> Unit | |
) { | |
Box(modifier = modifier) { | |
IconButton(onClick = openGameTrailer) { | |
Image( | |
modifier = | |
Modifier.width(50.dp) |
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 BottomRoundedArcShape : Shape { | |
override fun createOutline( | |
size: Size, | |
layoutDirection: LayoutDirection, | |
density: Density | |
): Outline { | |
return Outline.Generic( | |
path = drawArcPath(size = size) | |
) | |
} |
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
fun drawArcPath(size: Size): Path { | |
return Path().apply { | |
reset() | |
// go from (0,0) to (width, 0) | |
lineTo(size.width, 0f) | |
// go from (width, 0) to (width, height) | |
lineTo(size.width, size.height) |