mono0926 / adaptive_dialog

Show alert dialog or modal action sheet adaptively according to platform.
https://pub.dev/packages/adaptive_dialog
MIT License
361 stars 63 forks source link

DialogTextField color change for dark mode #134

Open vgavrilovikj opened 4 months ago

vgavrilovikj commented 4 months ago

Here's my code for the textinputdialog:

showTextInputDialog(
  context: context,
  textFields: [
    DialogTextField(
        initialText: widget
            .recentChatBlockEntity
            .title,
        hintText: 'Title'),
  ],
  title: 'Rename chat')

This works great - however when the app is in dark mode it shows black text on a black background - I want to change the color of the text of the DialogTextField, the initialText to be white and hintText to have lightgray color...

How can I achieve this?

P.S. Would be good to add some more documentation regarding the package and it's configutations

mono0926 commented 4 months ago

@vgavrilovikj

Does this fix the problem? https://github.com/mono0926/adaptive_dialog?tab=readme-ov-file#the-input-text-color-same-with-backgound-when-using-cupertinotextinputdialog

devnta commented 1 day ago

@mono0926 But it's effect for whole project. How to custom only DialogTextField? Sorry for my bad English.

mono0926 commented 1 day ago

@devnta

You can change the theme partially like this: https://github.com/mono0926/adaptive_dialog/blob/382f98164d081bbf9e76895aef001ef5c25f8dcf/example/lib/pages/alert_page.dart#L130-L142

devnta commented 1 day ago

@mono0926 Thanks for your reply. I will try it and report the result.

devnta commented 1 day ago

@mono0926

final result = await showTextInputDialog(
                      context: context,
                      textFields: [
                        DialogTextField(
                          hintText: LocaleKeys.enter_bmi_value.tr(),
                        )
                      ],
                      builder: (context, child) {
                        return Theme(
                          data: ThemeData(
                            textButtonTheme: TextButtonThemeData(
                              style: TextButton.styleFrom(
                                foregroundColor: Colors.orange,
                              ),
                            ),
                            // If this is commented out, the color for cupertino will be default blue/red.
                            cupertinoOverrideTheme: const CupertinoThemeData(
                              primaryColor: Colors.purple,
                              textTheme: CupertinoTextThemeData(
                                textStyle: TextStyle(
                                  color: Colors.white,
                                ),
                              ),
                            ),
                          ),
                          child: child,
                        );
                      },
                    );

Not work in dark theme

Allenxuxu commented 10 hours ago

I have the same issue.