{"id":20492555,"url":"https://github.com/redmadrobot/textvalue","last_synced_at":"2025-03-05T17:41:28.309Z","repository":{"id":238140827,"uuid":"792744623","full_name":"RedMadRobot/TextValue","owner":"RedMadRobot","description":"TextValue is an abstraction over Android text","archived":false,"fork":false,"pushed_at":"2024-05-13T15:43:11.000Z","size":65,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-01-16T05:55:05.707Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RedMadRobot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2024-04-27T13:03:58.000Z","updated_at":"2024-05-13T15:43:15.000Z","dependencies_parsed_at":"2024-05-04T15:36:51.599Z","dependency_job_id":"0767da29-132c-43be-b243-caf75a6317a0","html_url":"https://github.com/RedMadRobot/TextValue","commit_stats":null,"previous_names":["redmadrobot/textvalue"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2FTextValue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2FTextValue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2FTextValue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedMadRobot%2FTextValue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RedMadRobot","download_url":"https://codeload.github.com/RedMadRobot/TextValue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242073744,"owners_count":20067898,"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":[],"created_at":"2024-11-15T17:29:36.688Z","updated_at":"2025-03-05T17:41:28.290Z","avatar_url":"https://github.com/RedMadRobot.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TextValue \u003cGitHub path=\"RedMadRobot/textvalue/tree/main/\"/\u003e\n[![Version](https://img.shields.io/maven-central/v/com.redmadrobot.textvalue/textvalue?style=flat-square)][mavenCentral]\n[![License](https://img.shields.io/github/license/RedMadRobot/textvalue?style=flat-square)][license]\n\nTextValue is an abstraction allowing to work with a `String` and a string resource ID the same way.\n\n---\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Contributing](#contributing)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Installation\n\nAdd the dependency:\n```groovy\nrepositories {\n    mavenCentral()\n    google()\n}\n\ndependencies {\n    // Views version\n    implementation(\"com.redmadrobot.textvalue:textvalue:1.0.0\")\n\n    // Compose extensions for textvalue\n    implementation(\"com.redmadrobot.textvalue:textvalue-compose:1.0.0\")\n}\n```\n\n## Usage\n\n**TextValue** is a wrapper to make it possible to work with plain `String` and `StringRes` in the same way.\nIt may be useful for cases when you want to fallback to `StringRes` if desired string value is `null`.\n\nYou can wrap `String` and `StringRes` with `TextValue` using `TextValue(String)`, `TextValue(Int)` or `TextValue(String?, Int))`, and use method `TextValue.get(Resource)` to retrieve `String`:\n\n```kotlin\n// in some place where we can't access Context\nval errorMessage = TextValue(exception.message, defaultResourceId = R.string.unknown_error)\nshowMessage(errorMessage)\n\n// in Activity, Fragment or View\nfun showMessage(text: TextValue) {\n    val messageText = text.get(resources)\n    //...\n}\n```\n\n`TextValue` also could be used with Jetpack Compose:\n\n```kotlin\n// in Composable functions\n@Composable\nfun Screen(title: TextValue) {\n    // Remember to add com.redmadrobot.textvalue:textvalue-compose dependency\n    Text(text = stringResource(title))\n}\n```\n\nThere are extensions to work with `TextValue` like with `StringRes`:\n\n- `Context.getString(text: TextValue): String`\n- `View.getString(text: TextValue): String`\n- `Resources.getString(text: TextValue): String`\n\n## Contributing\n\nMerge requests are welcome.\nFor major changes, please open an issue first to discuss what you would like to change.\n\n[mavenCentral]: https://search.maven.org/artifact/com.redmadrobot.textvalue/textvalue\n[license]: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredmadrobot%2Ftextvalue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredmadrobot%2Ftextvalue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredmadrobot%2Ftextvalue/lists"}