Skip to content

dialog: Use Cupertino-flavored alert dialogs on iOS #996

Open
@chrisbobbe

Description

@chrisbobbe

We should experiment with the AlertDialog.adaptive constructor, instead of AlertDialog, which forces a Material-style dialog on iOS:

Current Should be more like
image image

The "after" screenshot was made by simply changing AlertDialog( to AlertDialog.adaptive(. A complete fix will be a little more complicated than that, though. See the code sample on the AlertDialog.adaptive doc, which shows a platform switch for the dialog's action buttons, to style those appropriately (including the buttons' on-press appearance):

  Widget adaptiveAction(
      {required BuildContext context,
      required VoidCallback onPressed,
      required Widget child}) {
    final ThemeData theme = Theme.of(context);
    switch (theme.platform) {
      case TargetPlatform.android:
      case TargetPlatform.fuchsia:
      case TargetPlatform.linux:
      case TargetPlatform.windows:
        return TextButton(onPressed: onPressed, child: child);
      case TargetPlatform.iOS:
      case TargetPlatform.macOS:
        return CupertinoDialogAction(onPressed: onPressed, child: child);
    }
  }

Relatedly, I think the TextAlign.end in our _dialogActionText helper should not be applied on iOS because on iOS the button text is meant to be center-aligned.

I also notice that our "Source Sans 3" font isn't being applied in the Cupertino-style dialog in the screenshot. I think we want it to be, so we should debug and fix this. Probably should leave this be, actually; it's supposed to mimic the native iOS alert, which uses a system font, not an app's chosen font.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-designVisual and UX designa-iOSIssues specific to iOS, or requiring iOS-specific work

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions