stryder-dev / flutter_platform_widgets

Target the specific design of Material for Android and Cupertino for iOS widgets through a common set of Platform aware widgets
MIT License
1.59k stars 173 forks source link

`showPlatformDialog` is not respecting theme on Material #463

Open martin-braun opened 5 months ago

martin-braun commented 5 months ago

This is a platform dialog spawned on Material:

image
              await showPlatformDialog<void>(
                context: context,
                builder: (_) => PlatformAlertDialog(
                  title: Text(l10n.cardCabinetDetailActionStartGrow),
                  content:
                      Text(l10n.cardCabinetDetailActionStartGrowInstructions),
                  actions: <Widget>[
                    PlatformDialogAction(
// ...

This is a platform date picker spawned on Material:

image
                        DateTime? startGrowTime = await showPlatformDatePicker(
                            context: context,
                            initialDate: now.add(const Duration(seconds: 1)),
                            firstDate: DateTime.now(),
                            lastDate: now.add(const Duration(days: 90)),
                            material: (context, data) =>
                                MaterialDatePickerData(),
                            cupertino: (context, data) =>
                                CupertinoDatePickerData(
                                  mode: CupertinoDatePickerMode.dateAndTime,
                                ));

Notice how the DateTime picker has a greenish tint to it? My ThemeData is has a colorScheme that was seeded from #0A7A34 and no explicit themes or colors are used here. So, the platform dialog does something differently here and it is wrong.

I noticed the solution is to set the PlatformAlertDialog color to surfaceContainerHigh:

                  material: (_, __) => MaterialAlertDialogData(
                    backgroundColor: theme.colorScheme.surfaceContainerHigh,
                  ),

Defaults should be changed here I guess.

martin-braun commented 5 months ago

Also I tried to use the surfaceTint instead, but no color would result in surfaceContainerHigh which is the color that the datetime picker uses.

philipvrx commented 3 months ago

Have you tried using colorScheme secondary color?

Also I tried to use the surfaceTint instead, but no color would result in surfaceContainerHigh which is the color that the datetime picker uses.

martin-braun commented 3 months ago

Have you tried using colorScheme secondary color?

@philipvrx It has no tint, despite me using secondary and tertiary colors in my theme. I have set almost every color that ThemeData allows me to set.

Even if there is any other field on ThemeData that controls this, it's clearly a bug. The DateTime picker uses the primary color as tint color, so the alert dialog should do the same for a coherent experience.