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 CardContainer( | |
modifier: Modifier, | |
onClick: () -> Unit = { }, | |
contents: @Composable RowScope.() -> Unit | |
) { | |
var size by remember { mutableStateOf(Size.Zero) } | |
val shader = SweepGradientShader( | |
center = Offset(size.width / 2, size.height / 2), | |
colors = listOf(Color.Transparent, Color(0xFFF1C374)), | |
colorStops = listOf(0.5f, 1f), |
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 AnimatedBorderCard( | |
modifier: Modifier, | |
contents: @Composable RowScope.() -> Unit | |
) { | |
val containerSize = 200.dp | |
var offsetFloat by remember { mutableStateOf(0f) } | |
LaunchedEffect(null) { | |
delay(100) | |
offsetFloat = containerSize.value * 10f |
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
@ExperimentalCoroutinesApi | |
class RestaurantsViewModelTest { | |
private val dispatcher = StandardTestDispatcher() | |
private val scope = TestScope(dispatcher) | |
@Test | |
fun stateWithError_isProduced() = scope.runTest { | |
val testVM = getViewModel(shouldThrowException = true) | |
advanceUntilIdle() | |
val currentState = testVM.state.value |
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
// Consumer usage | |
class MyFragment : Fragment(R.layout.my_fragment) { | |
private val viewModel: MyViewModel by viewModels() | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | |
super.onViewCreated(view, savedInstanceState) | |
val consumer = consumeState(viewModel) | |
} | |
} |
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 FoodCategoryDetailsScreen(state: FoodCategoryDetailsContract.State) { | |
val scrollState = rememberLazyListState() | |
val scrollOffset: Float = min( | |
1f, | |
1 - (scrollState.firstVisibleItemScrollOffset / 600f + scrollState.firstVisibleItemIndex) | |
) | |
Column { | |
CategoryDetailsCollapsingToolbar(state.category, scrollOffset) | |
Spacer(modifier = Modifier.height(2.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
@Composable | |
private fun CategoryDetailsCollapsingToolbar(category: FoodItem?, scrollOffset: Float) { | |
val imageSize by animateDpAsState(targetValue = max(72.dp, 128.dp * scrollOffset)) | |
val dynamicLines = max(3f, scrollOffset * 6).toInt() | |
... | |
} |
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 CategoryDetailsCollapsingToolbar(category: FoodItem?, scrollOffset: Float) { | |
val imageSize by animateDpAsState(targetValue = max(72.dp, 128.dp * scrollOffset)) | |
val linesCount = max(3f, scrollOffset * 6).toInt() | |
Row { | |
Image(modifier = Modifier.size(imageSize), ...) | |
Column { | |
Text(text = item?.name) | |
Text( | |
text = item.description.trim(), |
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 FoodCategoryDetailsScreen(state: FoodCategoryDetailsContract.State) { | |
val scrollState = rememberLazyListState() | |
val scrollOffset: Float = min( | |
1f, | |
1 - (scrollState.firstVisibleItemScrollOffset / 600f + scrollState.firstVisibleItemIndex) | |
) | |
Column { | |
CategoryDetailsCollapsingToolbar(state.category, scrollOffset) | |
... |
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
val scrollOffset: Float = min( | |
1f, | |
1 - (scrollState.firstVisibleItemScrollOffset / 600f + | |
scrollState.firstVisibleItemIndex) | |
) |
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 FoodCategoryDetailsScreen(state: FoodCategoryDetailsContract.State) { | |
val scrollState = rememberLazyListState() | |
Column { | |
... | |
LazyColumn(state = scrollState) { ... } | |
} | |
} |
NewerOlder