[AVLE Refactoring] New Voting Dialog

in Steemit Dev Group3 years ago

I refactored the voting dialog.

The AVLE dapp is made in Flutter (with Dart lang).

Previously, I used the StatefulBuilder in the dialog to update the state of voting like this:

    late AwesomeDialog dialog;
    dialog = AwesomeDialog(
      context: context,
      headerAnimationLoop: false,
      dialogType: DialogType.SUCCES,
      width: UIConst.SCREEN_MAX_WIDTH,
      body: StatefulBuilder(
        builder: (context, setState) {
          return Center(
            child: Column(
...

But it is not desirable in Flutter. Instead I applied a cubit for handling states of voting dialog like:

      body: BlocProvider(
        create: (context) => VotingCubit(
          authBloc: context.read<AuthBloc>(),
          settingsBloc: context.read<SettingsBloc>(),
          steemPostRepository: context.read<SteemPostRepository>(),
        ),
        child: BlocConsumer<VotingCubit, VotingState>(
          listener: (context, state) {
            if (state.status == VotingStatus.voted) {

The way to use a cubit is much neat compared to StatefulBuilder case. I will refactor other dialogs like the way I did for the voting dialog.

The dialog UI looks the same but its logic is clearer and simpler.
image.png


Please vote for me as a witness.

I am ranked at 30 now. I go up slowly day by day. Thank you guys who vote for me.

https://steemitwallet.com/~witnesses
(find etainclub ranked at 30)
or here:
https://steemyy.com/witness-voting/?witness=etainclub&action=approve

@steemcurator01, Thank you for Your Support

Sort:  

Upvoted! Thank you for supporting witness @jswit.
default.jpg

Coin Marketplace

STEEM 0.20
TRX 0.19
JST 0.034
BTC 91222.02
ETH 3113.00
USDT 1.00
SBD 2.90