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
| /** | |
| * Make sure final lib.versions.toml is added into the .gitignore | |
| */ | |
| dependencyResolutionManagement { | |
| versionCatalogs { | |
| create("libs") { | |
| from(mergedToml()) | |
| } | |
| } | |
| repositories { |
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
| tasks.register("updateProguardFromApiDump") { | |
| group = "verification" | |
| description = | |
| "Updates proguard-rules.pro with -keep rules for public classes found in a .api dump (default: uses the first .api file under api/)." | |
| dependsOn("apiDump") | |
| doLast { | |
| val apiDir = file("api") | |
| val proguardFile = file("proguard-rules.pro") | |
| val apiFilePath = if (project.hasProperty("apiFile")) project.property("apiFile") else 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 SampleScreen(modifier: Modifier = Modifier) { | |
| Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> | |
| //when modifierLocalConsumer { } block is called, next composition | |
| // will make this local prop non null. | |
| val myScope by remember { mutableStateOf<MyScope?>(null) } | |
| Column { | |
| MyLayout( | |
| modifier = Modifier | |
| .padding(innerPadding) |
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
| val ModifierLocalMyScope = | |
| modifierLocalOf<MyScope> { error("Scope not provided") } | |
| @Composable | |
| fun MyLayout( | |
| modifier: Modifier = Modifier, | |
| properties: MyProperties = MyProperties(), | |
| colors: MyLayoutColors = MyLayoutDefaults.colors(), | |
| content: @Composable (MyScope.() -> Unit) | |
| ) { |
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
| /** | |
| * Searches largest parent with [LayoutCoordinates] | |
| * | |
| * @param selector property selector | |
| * | |
| * @return Largest parent in the tree [LayoutCoordinates] starting from calling | |
| * receiver and searching up the tree until the last parent is visited. If receiver object doesn't | |
| * have parent, it assumes this is the max. | |
| */ | |
| inline fun <reified P : Comparable<P>> LayoutCoordinates.maxOf(selector: LayoutCoordinates.() -> P): LayoutCoordinates { |
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
| @file:OptIn(ExperimentalComposeUiApi::class) | |
| import androidx.annotation.DrawableRes | |
| import androidx.annotation.IdRes | |
| import androidx.annotation.RawRes | |
| import androidx.annotation.StringRes | |
| import androidx.compose.ui.ExperimentalComposeUiApi | |
| import androidx.compose.ui.Modifier | |
| import androidx.compose.ui.input.pointer.PointerEventPass | |
| import androidx.compose.ui.input.pointer.PointerInputChange |
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
| /** | |
| * Should warn when making unattended a viewmodel function in a composable without considering | |
| * potential recompositions | |
| * | |
| * Should warn when: | |
| * | |
| * @Composable | |
| * fun MyComposable(viewModel : MyViewModel) { | |
| * | |
| * viewModel.startOperation() |
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.draw.DrawModifier | |
| import androidx.compose.ui.geometry.Rect | |
| import androidx.compose.ui.graphics.BlendMode | |
| import androidx.compose.ui.graphics.Color | |
| import androidx.compose.ui.graphics.ColorFilter | |
| import androidx.compose.ui.graphics.Paint | |
| import androidx.compose.ui.graphics.drawscope.ContentDrawScope | |
| import androidx.compose.ui.graphics.drawscope.drawIntoCanvas |
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.camera.core.CameraSelector | |
| import androidx.camera.view.CameraController | |
| import androidx.camera.view.LifecycleCameraController | |
| import androidx.compose.runtime.Composable | |
| import androidx.compose.runtime.CompositionLocalProvider | |
| import androidx.compose.runtime.LaunchedEffect | |
| import androidx.compose.runtime.compositionLocalOf | |
| import androidx.compose.runtime.getValue | |
| import androidx.compose.runtime.mutableStateOf | |
| import androidx.compose.runtime.remember |
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
| /** | |
| * Converts [MlKitAnalyzer.Result] into [kotlin.Result] | |
| * @param detector Any [Detector] | |
| * @returns [kotlin.Result] | |
| */ | |
| fun <T> MlKitAnalyzer.Result.toResult(detector: Detector<T>): Result<T> = | |
| kotlin.runCatching { | |
| val value = getValue(detector) ?: throw getThrowable(detector)!! | |
| value | |
| } |
NewerOlder