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

The prompts displayed by DisplayAlert do not follow the theme set #6092

Closed
emorell96 opened this issue Apr 14, 2022 · 10 comments · Fixed by #13318
Closed

The prompts displayed by DisplayAlert do not follow the theme set #6092

emorell96 opened this issue Apr 14, 2022 · 10 comments · Fixed by #13318
Assignees
Labels
area-controls-dialogalert DisplayAlert, dialog fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! platform/android 🤖 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@emorell96
Copy link

Description

The prompts displayed by DisplayAlert do not adhere to the theme set by using Application.Current.UserAppTheme.

image

Steps to Reproduce

  1. Set the theme to dark using Application.Current.UserAppTheme = AppTheme.Dark;
  2. Send a DisplayAlert on the main page on Android. The theme will not be respected and it will use the default light theme.

Version with bug

Release Candidate 1 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

API 30, Android 11

Did you find any workaround?

No response

Relevant log output

No response

@emorell96 emorell96 added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Apr 14, 2022
@Eilon Eilon added legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor area-controls-dialogalert DisplayAlert, dialog labels Apr 14, 2022
@kristinx0211 kristinx0211 removed the s/needs-verification Indicates that this issue needs initial verification before further triage will happen label Apr 18, 2022
@kristinx0211
Copy link

@emorell96 Thank you so much for your bug report! Unfortunately, we cannot reproduce your issue with the information above, could you provide a sample project/screenshots or more details that we can reproduce your issue? That should greatly speed up the process, thanks!

@kristinx0211 kristinx0211 added the s/needs-repro Attach a solution or code which reproduces the issue label Apr 18, 2022
@ghost
Copy link

ghost commented Apr 18, 2022

Hi @emorell96. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@jsuarezruiz jsuarezruiz self-assigned this Apr 18, 2022
@jsuarezruiz jsuarezruiz added this to the 6.0.300-rc.2 milestone Apr 18, 2022
@Redth Redth modified the milestones: 6.0.300-rc.2, 6.0.300-rc.3 Apr 20, 2022
@ghost ghost added the s/no-recent-activity Issue has had no recent activity label Apr 25, 2022
@ghost
Copy link

ghost commented Apr 25, 2022

This issue has been automatically marked as stale because it has been marked as requiring author feedback to reproduce the issue but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

@rachelkang rachelkang added s/verified Verified / Reproducible Issue ready for Engineering Triage and removed s/needs-repro Attach a solution or code which reproduces the issue labels Apr 25, 2022
@ghost ghost removed the s/no-recent-activity Issue has had no recent activity label Apr 25, 2022
@mtanml
Copy link

mtanml commented Oct 13, 2022

Hi, I'm not sure I understand why #7601 was closed as a duplicate of this issue... it is a completely separate issue that I am experiencing as well. On an Android device set to dark mode, DisplayAlert is presented with a dark gray background and dark (purple?) text that is barely readable. Has a workaround been identified for that issue? Thanks

@LaraSQP
Copy link

LaraSQP commented Dec 9, 2022

THIS IS A BIG PROBLEM.

@jerry08
Copy link

jerry08 commented Jan 4, 2023

Application.Current.UserAppTheme only applys for the theme defined with AppThemeBinding as mentioned in this post. That means DisplayAlert, Picker, etc. don't inherit the specified theme. To fix this problem, make sure to run this code when switching themes:

#if ANDROID
            AndroidX.AppCompat.App.AppCompatDelegate.DefaultNightMode = Current.UserAppTheme switch
            {
                AppTheme.Light => AndroidX.AppCompat.App.AppCompatDelegate.ModeNightNo,
                AppTheme.Dark => AndroidX.AppCompat.App.AppCompatDelegate.ModeNightYes,
                _ => AndroidX.AppCompat.App.AppCompatDelegate.ModeNightFollowSystem
            };
#elif IOS
            Platform.GetCurrentUIViewController().OverrideUserInterfaceStyle = Current.UserAppTheme switch
            {
                AppTheme.Light => UIKit.UIUserInterfaceStyle.Light,
                AppTheme.Dark => UIKit.UIUserInterfaceStyle.Dark,
                _ => UIKit.UIUserInterfaceStyle.Unspecified
            };
#endif

I haven't tested on iOS but it should work.

@LaraSQP
Copy link

LaraSQP commented Jan 4, 2023

Much appreciated. You rock, sir.

@SurkusGH
Copy link

So is there any solution for this? Since the one above is for xamarin forms?

@SurkusGH
Copy link

Okay, so just go:

$"[YourProject]"/Platforms/Android/Resources/values/colors. Change it there. That is it.

@jerry08
Copy link

jerry08 commented Jan 21, 2023

The solution I mentioned is for both xamarin and MAUI. It works fine for me. From my knowledge, changing the values in Platforms/Android/Resources/values/colors.xml only changes the default button color in the dialog and in a few other areas. It doesn't change the dialog color.

I created a plugin that handles some workarounds (maui). If you want, you can check it out here.

@jsuarezruiz jsuarezruiz self-assigned this Feb 14, 2023
@jsuarezruiz jsuarezruiz moved this from Todo to In Progress in MAUI SDK Ongoing Feb 14, 2023
rmarinho added a commit that referenced this issue Mar 14, 2023
…id and iOS (#13318) Fixes #6092

* Use the correct colors by themes with Alerts on Android and iOS

* Code refactoring

* Fix build errors

* More pending changes

---------

Co-authored-by: Rui Marinho <me@ruimarinho.net>
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Mar 14, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! label Apr 12, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 12, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-dialogalert DisplayAlert, dialog fixed-in-8.0.0-preview.3.8149 Look for this fix in 8.0.0-preview.3.8149! platform/android 🤖 s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.