Skip to content

Commit c1f9946

Browse files
authored
Merge pull request #13 from Vaibhav2002/JetpackCompose
Jetpack compose
2 parents fbddf8c + 97408c0 commit c1f9946

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,36 @@ class MainActivity : AppCompatActivity() {
179179
}
180180

181181
}
182+
```
182183

183-
🌟 You are all set!
184+
You can also directly integrate livedata to your button. This will automatically change the state of
185+
button according to the livedata.
186+
187+
```kotlin
188+
189+
//This is an enum that contains all button states, use this for livedata
190+
enum class ButtonStates {
191+
LOADING, ENABLED, DISABLED, FINISHED
192+
}
184193

185-
## 🍰 Contribute
194+
//liveData variable
195+
val buttonState = MutableLiveData<ButtonStates>()
196+
197+
//In Fragment or Activity
198+
binding.progressButton.attachToLiveData(buttonState)
199+
200+
```
201+
202+
Just post the button state to the livedata like
203+
`livedata.postValue(ButtonStates.LOADING)` and button will change to loading state automatically
204+
205+
🌟 You are all set!
186206

187-
Feel free to fork this project, to optimise the code or to add new features.
207+
## 🍰 Contribute
188208

209+
Feel free to fork this project, to optimise the code or to add new features.
189210

190-
## 📝 TODO
211+
## 📝 TODO
191212

192213
* Lottie support
193214

0 commit comments

Comments
 (0)