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
Surface( | |
modifier = Modifier.fillMaxSize(), | |
color = MaterialTheme.colorScheme.background | |
) { | |
val appBarMaxHeightPx = with(LocalDensity.current) { AppBarHeight.roundToPx() } | |
val connection = remember(appBarMaxHeightPx) { | |
CollapsingAppBarNestedScrollConnection(appBarMaxHeightPx) | |
} | |
val density = LocalDensity.current | |
val spaceHeight by remember(density) { |
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
Surface( | |
modifier = Modifier.fillMaxSize(), | |
color = MaterialTheme.colorScheme.background | |
) { | |
val appBarMaxHeightPx = with(LocalDensity.current) { AppBarHeight.roundToPx() } | |
val connection = remember(appBarMaxHeightPx) { | |
CollapsingAppBarNestedScrollConnection(appBarMaxHeightPx) | |
} | |
Box(Modifier.nestedScroll(connection)) { |
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
private class CollapsingAppBarNestedScrollConnection( | |
val appBarMaxHeight: Int | |
) : NestedScrollConnection { | |
var appBarOffset: Int by mutableIntStateOf(0) | |
private set | |
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset { | |
val delta = available.y.toInt() | |
val newOffset = appBarOffset + delta |
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
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset { | |
val delta = available.y.toInt() | |
val newOffset = appBarOffset + delta | |
val previousOffset = appBarOffset | |
appBarOffset = newOffset.coerceIn(-appBarMaxHeight, 0) | |
val consumed = appBarOffset - previousOffset | |
return Offset(0f, consumed.toFloat()) | |
} |
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 appBarOffset by remember { mutableIntStateOf(0) } | |
Surface( | |
modifier = Modifier.fillMaxSize(), | |
color = MaterialTheme.colorScheme.background | |
) { | |
val connection = remember { | |
object : NestedScrollConnection { | |
override fun onPreScroll( | |
available: Offset, |
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 appBarOffset by remember { mutableIntStateOf(0) } | |
Surface( | |
modifier = Modifier.fillMaxSize(), | |
color = MaterialTheme.colorScheme.background | |
) { | |
Box { | |
LazyColumn(contentPadding = PaddingValues(top = AppBarHeight)) { | |
items(Contents) { | |
ListItem(item = 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
val AppBarHeight = 56.dp | |
val Purple40 = Color(0xFF6650a4) | |
Surface( | |
modifier = Modifier.fillMaxSize(), | |
color = MaterialTheme.colorScheme.background | |
) { | |
Box { | |
LazyColumn(contentPadding = PaddingValues(top = AppBarHeight)) { | |
items(Contents) { |
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
<application | |
android:name="com.levimoreira.cinemabuff.infrastructure.application.CinemaBuffApp" | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:networkSecurityConfig="@xml/network_security_config"> | |
... | |
</application> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<network-security-config> | |
<debug-overrides> | |
<trust-anchors> | |
<certificates src="user" /> | |
</trust-anchors> | |
</debug-overrides> | |
</network-security-config> |
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
@RunWith(AndroidJUnit4::class) | |
class SampleTest { | |
private lateinit var personDao: PersonDao | |
private lateinit var db: AppDatabase | |
@Before | |
fun createDb() { | |
db = Room.inMemoryDatabaseBuilder( | |
InstrumentationRegistry.getContext(), AppDatabase::class.java).build() |
NewerOlder