preetjdp / YouOweMe

Making it simpler to track those chillars
9 stars 6 forks source link

Abstracted YomButton #31

Closed preetjdp closed 4 years ago

preetjdp commented 4 years ago

What Does this PR do?.

This PR brings in another Abstraction YomButton and its partner YomButtonController .

Describe In brief the solution / approach you've gone with.

This is a simple controller based Button, which allows the controller to change the state of the button. The Possible state of the Button are.

enum YomButtonState { ACTIVE, LOADING, ERROR, SUCCESS }

Example:

final YomButtonController yomButtonController = YomButtonController();
YomButton(
 child: Text('Done'),
 controller: yomButtonController,
 onPressed:  () {
  yomButtonController.showLoading();
 }
),

Describe alternatives you may have considered

Other alternatives would be to write a ton a code each time to get a button with a spinner.

Additional context / quirks

Will have to extend more Widgets (For ex: FAB) with this to reuse more code.