Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingtoncabral authored Feb 21, 2022
1 parent cb804e1 commit 1eccc96
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ It looks like:
<img src="misc/example_4.png">
</kbd>

### Creating extensions like components
## Creating extensions like components
You can create extension functions to build custom decoration components.\
In the example below, we created 3 custom components: `h1`, `title`, `divider`, and `contactList`.

Expand Down Expand Up @@ -256,6 +256,19 @@ It looks like:
<img src="misc/example_5.png">
</kbd>

## Initializing the spantastic with a known text
If you already have an instance of `SpannableStringBuilder`, you can pass it to the `spantastic` builder to be appended in the context. For example, you can pass the `editText.text` as `SpannableStringBuilder` to the spantastic calling `asSpannableStringBuilder` like that:

```kotlin
binding.editText.text = spantastic(binding.editText.text.asSpannableStringBuilder()) {
bold()
}
```

The bold decorator will be applied to the existing text in the EditText component.

## Show case

### Adding clickable areas
Spantastic provides 2 ways to work with clickable areas: `url` and `clickable`.
Take a look in this simple example:
Expand Down Expand Up @@ -439,11 +452,11 @@ It looks like:
<img src="misc/example_12.png">
</kbd>

### More examples
## More examples
To see more and use case implementations, please take a look at the sample app.\
https://github.com/wellingtoncabral/android-spantastic/tree/main/sample/src/main/java/com/wcabral/spantastic

### References
## References
1. https://developer.android.com/reference/android/text/Spannable.html
2. https://developer.android.com/guide/topics/text/spans
3. https://medium.com/androiddevelopers/spantastic-text-styling-with-spans-17b0c16b4568
Expand Down

0 comments on commit 1eccc96

Please sign in to comment.