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 | |
| internal fun FallItem( | |
| painter: VectorPainter, | |
| initialPositionX: Float, | |
| initialPositionY: Float, | |
| densityDpi: Float, | |
| ) { | |
| val windWidth = 150 * densityDpi * if (Random.nextBoolean()) 1 else -1 | |
| val fallSpeed = (Random.nextFloat() * 2.66f + 0.33f) * densityDpi | |
| val scale: Float = Random.nextFloat() * 0.66f + 0.33f |
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 ContactFullNameV1View( | |
| imageUrl: String, | |
| fullName: String, | |
| modifier: Modifier = Modifier, | |
| ) { | |
| Row( | |
| modifier = modifier | |
| .sizeIn( | |
| minHeight = 56.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
| fun searchTypeTokens( | |
| jsonObject: JSONObject, | |
| parentKey: String, | |
| result: MutableMap<String, T>, | |
| ) { | |
| for (key in jsonObject.keys()) { | |
| // 'medium - prominent' to 'mediumProminent' | |
| val keyFormatted = key.replace(" ", "").split("-").joinToString( | |
| separator = "", | |
| transform = { it.capitalized().trim() }, |
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
| @TaskAction | |
| fun taskAction() { | |
| val typeMap = mutableMapOf<String, T>() | |
| // read file | |
| val jsonObject = JSONObject(dsmFile.get().asFile.readText()) | |
| // find all type tokens | |
| searchTypeTokens(jsonObject.getJSONObject(rootDSMKey), rootDSMKey, typeMap) |
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
| open class DSMGeneratorPlugin : Plugin<Project> { | |
| override fun apply(project: Project) { | |
| // registers a callback on the application of the Android Application plugin | |
| project.plugins.withType(AppPlugin::class.java) { _ -> | |
| // look up the generic android component | |
| val androidComponents = project.extensions.getByType(ApplicationAndroidComponentsExtension::class.java) | |
| // run through all variants and create generator tasks | |
| androidComponents.onVariants( |
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
| internal abstract class ColorGeneratorTask : AbstractGeneratorTask<ComposeColor>() { | |
| companion object { | |
| private val COLOR = ClassName("androidx.compose.ui.graphics", "Color") | |
| } | |
| override val componentClassName: ClassName @Internal get() = COLOR | |
| override val generatedFileName: String @Internal get() = "ThemeColors" | |
| override val rootDSMKey: String @Internal get() = "color" |
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
| private fun AbstractGeneratorTask<*>.configure(flavor: String) { | |
| val android = project.extensions.getByType(CommonExtension::class.java) | |
| // app/src/international/assets/design-tokens.json | |
| val dsmTokensFile = project.layout.projectDirectory | |
| .dir("src") | |
| .dir(flavor) | |
| .dir("assets") | |
| .file("design-tokens.json") |
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
| internal abstract class AbstractGeneratorTask<T : GeneratedType> : DefaultTask() { | |
| @get:InputFile | |
| abstract val dsmFile: RegularFileProperty | |
| @get:OutputDirectory | |
| abstract val flavorDirectory: DirectoryProperty | |
| @get:Input | |
| abstract val `package`: Property<String> |
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
| internal data class ComposeColor(val value: String) : GeneratedType | |
| // replace color from #ffffffff to 0xffffffff | |
| internal val ComposeColor.valueFormatted: String get() = value.replace("#", "0x") |
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
| plugins { | |
| `java-gradle-plugin` | |
| alias(libs.plugins.kotlin.jvm) | |
| } | |
| java { | |
| toolchain { | |
| languageVersion.set(JavaLanguageVersion.of(17)) | |
| } | |
| } |
NewerOlder