{"id":13609526,"url":"https://github.com/erolaksoy/compose-impression","last_synced_at":"2025-04-12T20:32:06.590Z","repository":{"id":226161744,"uuid":"650267450","full_name":"erolaksoy/compose-impression","owner":"erolaksoy","description":"A library provides a way to track impressions of items in a lazy list with Jetpack Compose.","archived":false,"fork":false,"pushed_at":"2024-03-06T22:55:26.000Z","size":2277,"stargazers_count":51,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-07T15:45:33.648Z","etag":null,"topics":["android","android-library","compose","impression","jetpack-compose","jetpack-compose-library","jetpack-compose-tutorial","lazycolumn","lazyrow","mvvm-android"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/erolaksoy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-06T17:49:02.000Z","updated_at":"2024-10-30T07:35:27.000Z","dependencies_parsed_at":"2024-03-06T07:40:07.019Z","dependency_job_id":"e37e7817-d61c-4421-ba6b-2001bc83c8b5","html_url":"https://github.com/erolaksoy/compose-impression","commit_stats":null,"previous_names":["erolaksoy/compose-impression"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erolaksoy%2Fcompose-impression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erolaksoy%2Fcompose-impression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erolaksoy%2Fcompose-impression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/erolaksoy%2Fcompose-impression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/erolaksoy","download_url":"https://codeload.github.com/erolaksoy/compose-impression/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248629801,"owners_count":21136320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","compose","impression","jetpack-compose","jetpack-compose-library","jetpack-compose-tutorial","lazycolumn","lazyrow","mvvm-android"],"created_at":"2024-08-01T19:01:35.608Z","updated_at":"2025-04-12T20:32:04.107Z","avatar_url":"https://github.com/erolaksoy.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# Compose Impression\n\nThis library provides a way to track whether items appear on the screen in lazy lists.\n\n| \u003cimg src=\"./art/lazy-column-sample.gif\" width=200/\u003e | \u003cimg src=\"./art/lazy-row-sample.gif\" width=200/\u003e  |\n| --------------------------------------------------- | ------------------------------------------------- |\n| Lazy Column                                         | Lazy Row                                          |\n\n## Usage\n\nTo use the impression, first create an `ImpressionState` with rememberImpressionState. Then, use the impression modifier to track impressions for items in your list.\n\n⚠️ The item key you use in the lazy list has to be the same as the key you give to the impression modifier.\n\n```kotlin\n    val lazyListState = rememberLazyListState()\n    val impressionState = rememberImpressionState(lazyListState)\n\n    LaunchedEffect(Unit) {\n        impressionState.seenEvent.collectLatest {\n            // collect impression events\n        }\n    }\n\n    LazyRow(\n        modifier = modifier.fillMaxSize(),\n        state = lazyListState,\n        contentPadding = PaddingValues(16.dp),\n        horizontalArrangement = Arrangement.spacedBy(12.dp)\n    ) {\n        items(list, key = { it }) {\n            CardItem(\n                key = it,\n                modifier = Modifier\n                    .width(250.dp)\n                    .height(120.dp)\n                    .impression(it, impressionState),\n            )\n        }\n    }\n```\n\nor\n\n```kotlin\n    val lazyListState = rememberLazyListState()\n    val impressionState = rememberImpressionState(lazyListState)\n\n    LazyRow(\n        modifier = modifier.fillMaxSize(),\n        state = lazyListState,\n        contentPadding = PaddingValues(16.dp),\n        horizontalArrangement = Arrangement.spacedBy(12.dp)\n    ) {\n        items(list, key = { it }) {\n            CardItem(\n                key = it,\n                modifier = Modifier\n                    .width(250.dp)\n                    .height(120.dp)\n                    .impression(\n                        key = it,\n                        impressionState = impressionState,\n                        onImpressionHappened = {\n                            // collect impression event\n                        }\n                    ),\n            )\n        }\n    }\n```\n\n## Validators\n\nThe `VisibilityPercentImpressionValidator` validates impressions based on the visibility percentage of an item.\n\n```kotlin\nval impressionState = rememberImpressionState(lazyListState) {\n    addValidator(VisibilityPercentImpressionValidator(0.5f)) // set the visibility percentage threshold to 50%\n}\n```\n\nWith this configuration, when an item is 50% visible, the impression will be validated and happened.\n\nYou can create your own validator by extending from ImpressionValidator.\n\n## Including in your project\n\n[](https://github.com/erolaksoy/compose-impression#including-in-your-project)\n\n1. Add the JitPack repository to your project-level `build.gradle` file:\n\n```\nallprojects {\n    repositories {\n        ...\n        maven { url 'https://jitpack.io' }\n    }\n}\n```\n\n1. Add the dependency to your app-level `build.gradle` file:\n\n```\ndependencies {\n    implementation 'com.github.erolaksoy:compose-impression:0.1.1'\n}\n```\n\n1. Sync your project with Gradle files.\n\n## License\n\n```xml\nCopyright 2023 Erol Aksoy\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferolaksoy%2Fcompose-impression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferolaksoy%2Fcompose-impression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferolaksoy%2Fcompose-impression/lists"}