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 ArticleListViewModelRobot private constructor() { | |
| private lateinit var viewModel: ArticleListViewModel | |
| private val fakeRepository = FakeArticleRepository() | |
| private fun setup() { | |
| buildViewModel() | |
| } | |
| fun buildViewModel() = apply { |
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 ReorderableList( | |
| items: List<ReorderItem>, | |
| onMove: (Int, Int) -> Unit, | |
| modifier: Modifier = Modifier | |
| ) { | |
| val scope = rememberCoroutineScope() | |
| var overscrollJob by remember { mutableStateOf<Job?>(null) } |
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 DragDropList( | |
| items: List<ReorderItem>, | |
| onMove: (Int, Int) -> Unit, | |
| modifier: Modifier = Modifier | |
| ) { | |
| val scope = rememberCoroutineScope() | |
| var overscrollJob by remember { mutableStateOf<Job?>(null) } |
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
| // Requires Compose 1.1.0-alpha02+ | |
| // Best used with navigation animation transitions in Accompanist 0.17.0+ | |
| import androidx.compose.animation.* | |
| import androidx.compose.animation.core.FastOutLinearInEasing | |
| import androidx.compose.animation.core.LinearEasing | |
| import androidx.compose.animation.core.LinearOutSlowInEasing | |
| import androidx.compose.animation.core.tween | |
| import androidx.compose.ui.unit.Density | |
| import androidx.compose.ui.unit.dp |
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
| import androidx.compose.ui.Modifier | |
| import androidx.compose.ui.composed | |
| import androidx.compose.ui.draw.drawBehind | |
| import androidx.compose.ui.graphics.Color | |
| import androidx.compose.ui.graphics.Paint | |
| import androidx.compose.ui.graphics.drawscope.drawIntoCanvas | |
| import androidx.compose.ui.graphics.toArgb | |
| import androidx.compose.ui.unit.Dp | |
| import androidx.compose.ui.unit.dp |
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
| package glureau.frameradar | |
| import android.content.Context | |
| import android.graphics.Canvas | |
| import android.graphics.Color | |
| import android.graphics.Paint | |
| import android.util.AttributeSet | |
| import android.view.View | |
| import java.util.* |
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 Fragment : Fragment() { | |
| fun listenForNavigation() { | |
| lifecycleScope.launchWhenResumed { | |
| val directions = viewModel.navigationChannel.receive() | |
| findNavController().navigate(directions) | |
| } | |
| } | |
| } |
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
| // Here's an example based on a test that was meant to reproduce a race condition, | |
| // where we were launching several coroutines in a specific order without realizing | |
| // that a different order would introduce race conditions. The test code here was used to | |
| // reproduce the exact bad order. | |
| // Note: there are probably better approaches to doing this. | |
| val dispatcher = QueueDelegatingTestDispatcher() | |
| // ... TODO pass in the dispatcher to the tested code launching coroutines |
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
| package com.example.view | |
| import androidx.compose.runtime.* | |
| import androidx.compose.ui.Modifier | |
| import androidx.compose.ui.platform.LocalContext | |
| import androidx.compose.ui.platform.LocalLifecycleOwner | |
| import androidx.compose.ui.viewinterop.AndroidView | |
| import androidx.lifecycle.Lifecycle | |
| import androidx.lifecycle.LifecycleEventObserver | |
| import com.mapbox.geojson.Point |