Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,33 @@

A small Android library for representing and resolving text at the right time and place — without scattering string resolution logic across your UI.

## Installation

Add the dependencies to your `build.gradle`:
```kotlin
dependencies {
implementation("io.github.dkmarkell.textresource:core:<version>")

// If you use Compose:
implementation("io.github.dkmarkell.textresource:compose:<version>")
}
```

## Quick Start

```kotlin
// ViewModel
val title = TextResource.simple(R.string.greeting, userName)

// Compose
Text(title.resolveString())

// Views
textView.text = title.resolveString(context)
```

Check out the [Sample app](./sample) for a complete demo.

## Why?

In a clean architecture, your ViewModel (or presenter) should decide what text is displayed, but not actually need to hold a Context to do it. With Android’s resource system, resolving strings usually requires a Context — which is either unavailable or awkward to inject.
Expand Down Expand Up @@ -68,16 +95,6 @@ textView.text = greeting.resolveString(context)
```
The UI (Activity/Fragment/Composable) provides the context at render time when resolving the string.

## Installation

Add the dependencies to your `build.gradle`:
```kotlin
dependencies {
implementation("io.github.dkmarkell.textresource:core:<version>")
implementation("io.github.dkmarkell.textresource:compose:<version>")
}
```

## Usage

### Creating TextResource
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ kotlin.code.style=official
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
GROUP=io.github.dkmarkell
VERSION_NAME=0.2.0
VERSION_NAME=0.2.1-SNAPSHOT
kotlin.explicitApi=strict
Loading