Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom actions - Center actions #88

Open
flogaribal opened this issue Nov 20, 2020 · 2 comments
Open

Custom actions - Center actions #88

flogaribal opened this issue Nov 20, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@flogaribal
Copy link

Is your feature request related to a problem? Please describe.
I want to center the actions buttons I added in the actionsBuilder property on the showRateDialog method.
However, as the builder must return a List<Widget>, I cannot specify the alignment.

Describe the solution you'd like
Be able to custom the entire dialog using Widget builder or with an improved DialogStyle class

Describe alternatives you've considered

  • Specifying the buttons alignment in the dialogStyle property
  • Meeting Flutter standard and change the builder to make it return a Widget as every other ..builder property are doing in the entire framework

Additional context
Your package is really cool and helps! Thanks a lot!

@flogaribal flogaribal added the enhancement New feature or request label Nov 20, 2020
@Skyost
Copy link
Owner

Skyost commented Nov 20, 2020

Why don't you jsut pass your actions in the content via the contentBuilder parameter ?

@flogaribal
Copy link
Author

I tried using the following code but:

  • My row overflow on the fight side and I cannot fiw its width using a Container, it is still the same
  • The overall popup height is weird and some white space is present under my actions even if I do not have any Widget... I tried to set the content height but still the save and even if it worked, it would work for other screen sizes..
void _onDisplayRating(BuildContext context) {
    final AppLocalizations loc = AppLocalizations.of(context);
    final ThemeData theme = Theme.of(context);
    bloc.rateMyApp.showRateDialog(
      context,
      ignoreNativeDialog: Platform.isAndroid,
      // Only use native popup on iOS
      // Called when the user dismissed the dialog (either by taping outside
      // or by pressing the "back" button).
      onDismissed: () => bloc.rateMyApp.callEvent(
        RateMyAppEventType.laterButtonPressed,
      ),
      title: loc.translate(Message.ratingDialogTitle),
      contentBuilder: (_, Widget title) => _ratingContent(loc, theme),
      dialogStyle: DialogStyle(
        titleAlign: TextAlign.center,
        titleStyle: theme.textTheme.headline3.copyWith(
          color: theme.colorScheme.secondary,
        ),
        dialogShape: const RoundedRectangleBorder(
          borderRadius: BorderRadius.all(
            Radius.circular(10),
          ),
        ),
      ),
    );
  }

Widget _ratingContent(AppLocalizations loc, ThemeData theme) => Column(
      mainAxisSize: MainAxisSize.min,
      children: <Widget>[
        Container(
          child: Text(
            loc.translate(Message.ratingDialogSubTitle),
            style: theme.textTheme.headline6
                .copyWith(color: AppTheme.greenColor),
            textAlign: TextAlign.center,
          ),
        ),
        Container(
          height: _ratingVectorSize,
          child: Vectors.carrotHeart,
        ),
        Row(
          children: <Widget>[
            _ratingActionBuilder(
              () => bloc.onRateClick(),
              Message.ratingDialogRateButton,
            ),
            _ratingActionBuilder(
              () => bloc.onRateLaterClick(),
              Message.ratingDialogLaterButton,
            ),
            _ratingActionBuilder(
              () => bloc.onNoClick(),
              Message.ratingDialogNoThanksButton,
            ),
          ],
        )
      ],
    );

Widget _ratingActionBuilder(void Function() onPressed, Message text) =>
    FlatButton(
      onPressed: onPressed,
      child: Text(
        AppLocalizations.of(context).translate(text),
        style: Theme.of(context)
            .textTheme
            .headline6
            .copyWith(color: Theme.of(context).colorScheme.secondary),
      ),
    );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants