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 InstructionsView(modifier: Modifier = Modifier, instructions: String) { | |
ExpandableSection(modifier = modifier, title = stringResource(id = R.string.how_to_prepare)) { | |
Text( | |
modifier = Modifier.padding(8.dp), | |
text = instructions, | |
color = MaterialTheme.colorScheme.onSecondaryContainer | |
) | |
} | |
} |
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 ExpandableSection( | |
modifier: Modifier = Modifier, | |
title: String, | |
content: @Composable () -> Unit | |
) { | |
var isExpanded by rememberSaveable { mutableStateOf(false) } | |
Column( | |
modifier = modifier | |
.clickable { isExpanded = !isExpanded } |
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 ExpandableSectionTitle(modifier: Modifier = Modifier, isExpanded: Boolean, title: String) { | |
val icon = if (isExpanded) Icons.Rounded.KeyboardArrowUp else Icons.Rounded.KeyboardArrowDown | |
Row(modifier = modifier.padding(8.dp), verticalAlignment = Alignment.CenterVertically) { | |
Image( | |
modifier = Modifier.size(32.dp), | |
imageVector = icon, | |
colorFilter = ColorFilter.tint(color = MaterialTheme.colorScheme.onPrimaryContainer), |
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 CategoryImageView( | |
modifier: Modifier = Modifier, | |
categoryName: String, | |
imageUrl: String | |
) { | |
val painter = rememberAsyncImagePainter( | |
model = ImageRequest.Builder(LocalContext.current) | |
.data(imageUrl) | |
.crossfade(200) |
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 ShimmerEffectBrush(): ShaderBrush { | |
val infiniteTransition = rememberInfiniteTransition(label = "shimmer transition") | |
val offset by infiniteTransition.animateFloat( | |
initialValue = 0f, | |
targetValue = 1f, | |
animationSpec = infiniteRepeatable( | |
animation = tween(durationMillis = 1_000), | |
), |
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
@Serializable | |
data class NetworkCategoriesWrapper( | |
@SerialName(value = "categories") val categories: List<NetworkCategory> | |
) |
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 CategoriesApiServiceTest { | |
private lateinit var apiService: CategoriesApiService | |
private lateinit var mockWebServer: MockWebServer | |
private val json = Json { ignoreUnknownKeys = true } | |
@Before | |
fun setup() { | |
mockWebServer = MockWebServer().apply(MockWebServer::start) |
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
interface CategoriesApiService { | |
@GET("categories.php") | |
suspend fun getCategories(): NetworkCategoriesWrapper | |
} |
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
{ | |
"categories": [ | |
{ | |
"idCategory": "1", | |
"strCategory": "first category", | |
"strCategoryThumb": "first thumb", | |
"strCategoryDescription": "first description" | |
}, | |
{ | |
"idCategory": "2", |
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
@Serializable | |
data class NetworkCategory( | |
@SerialName(value = "idCategory") val id: String?, | |
@SerialName(value = "strCategory") val name: String?, | |
@SerialName(value = "strCategoryThumb") val imageUrl: String?, | |
@SerialName(value = "strCategoryDescription") val description: String? | |
) |
NewerOlder