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
/* add dependency in gradle file */ | |
implementation 'ru.ldralighieri.corbind:corbind:{latest_version}' | |
findViewById<EditText>(R.id.et_name) | |
.textChanges() // Flow<CharSequence> | |
.onEach { /* handle text change events */ } | |
.launchIn(scope) |
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
/* add dependency in gradle file */ | |
implementation 'ru.ldralighieri.corbind:corbind-viewpager:{latest_version}' | |
launch { | |
findViewById<ViewPager>(R.id.vp_slides) | |
.pageSelections(scope) // ReceiveChannel<Int> | |
.consumeEach { | |
/* handle ViewPager events */ | |
} | |
} |
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
/* add dependency in gradle file */ | |
implementation 'ru.ldralighieri.corbind:corbind:{latest_version}' | |
launch { | |
findViewById<AppCompatButton>(R.id.bt_confirm) | |
.clicks { | |
/* perform an action on View click events */ | |
} | |
} |
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
data class SpacerItem(val height: Int) : FiberglassItem { | |
override val id: String = UUID.randomUUID().toString() | |
} | |
data class TitleItem(val title: String) : FiberglassItem { | |
override val id: String = title | |
} | |
data class LoremIpsumItem(private val words: Int) : FiberglassItem { | |
val text = LOREM_IPSUM_SOURCE.take(words).joinToString(separator = " ") |
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 spacerItemSlot(): FiberglassLazyItemSlot = { _, item -> | |
Spacer(modifier = Modifier.height((item as SpacerItem).height.dp)) | |
} | |
fun titleItemSlot(): FiberglassLazyItemSlot = { _, item -> | |
Text( | |
text = (item as TitleItem).title, | |
modifier = Modifier.padding(horizontal = AppTheme.dimensions.horizontalGuideline), | |
color = AppTheme.colors.onBackground, | |
style = AppTheme.typography.headlineMedium |
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 FiberglassColumnContent() { | |
val items: List<FiberglassItem> = remember { | |
buildList { | |
val count = 4 | |
repeat(count) { | |
val number = it + 1 | |
add(TitleItem("Block №$number")) | |
add(LoremIpsumItem(20 * number)) | |
if (number < count) add(SpacerItem(16)) |
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
onBackPressedDispatcher.backPresses(lifecycleOwner = this) | |
.onEach { currentFlowFragment?.onBackPressed() } | |
.launchIn(lifecycleScope) |
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
viewLifecycleOwner.lifecycleScope.launch { | |
repeatOnLifecycle(Lifecycle.State.STARTED) { | |
parentFragmentManager.resultEvents( | |
requestKey = RESULT_DATA_KEY, | |
lifecycleOwner = this@ResultFragment | |
) | |
.mapNotNull { it.bundle.toResultData() } | |
.onEach(::renderResultData) | |
.launchIn(this) | |
} |
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
viewLifecycleOwner.lifecycleScope.launch { | |
repeatOnLifecycle(Lifecycle.State.STARTED) { | |
detailsViewPager.pageScrollEvents() | |
.filter { it.positionOffset == 0f } | |
.map { it.position } | |
.distinctUntilChanged() | |
.onEach(::onPositionChanged) | |
.launchIn(this) | |
} | |
} |
OlderNewer