Skip to content

Instantly share code, notes, and snippets.

View 7kashif's full-sized avatar
🎯
Focusing

Kashif Masood 7kashif

🎯
Focusing
View GitHub Profile
suspend fun LazyListState.getFirstVisibleAsState(index: (Int) -> Unit) {
this.interactionSource.interactions.collectLatest {
index(this.firstVisibleItemIndex)
}
}
data class WeeklyStat(
val earning: Float = 0.0f
)
@7kashif
7kashif / SwipeGestureListener.kt
Created May 7, 2022 18:43
Detect left and right swipe on a view.
class SwipeGestureListener internal constructor(
private val onSwipe: (String) -> Unit,
) : View.OnTouchListener {
companion object {
const val minDistance = 200
}
private var anchorX = 0F
override fun onTouch(view: View, event: MotionEvent): Boolean {
@7kashif
7kashif / TriStateToggle.kt
Created March 22, 2022 18:17
A toggle button with more than one states.
@Composable
fun TriStateToggle() {
val states = listOf(
"State 1",
"State 2",
"State 3",
)
var selectedOption by remember {
mutableStateOf(states[1])
}
*****Notes on Testing*****
Why we need it:-
It takes a lot of time and effort to test every functionality in our software manually. And every time we are about to scale our
project we'd have to run our software and test each and every functionality manually to check whether it is still working correctly or not.
To overcome this effort we write Test Cases for our app so that with single click we can check anytime that whether a given piece of code is working correctly or not.
We get JUnit out of the box in our android project to test our code with a single click whenever we want to.
There are basically three types of test cases:-
-> Unit Tests:-