Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[iOS] Fix popup default color and dark mode #1041

Merged
merged 10 commits into from
Mar 13, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
using Android.App;
using Android.Content;
using Android.Graphics.Drawables;
using Android.OS;
using Android.Views;
using Android.Widget;
using AndroidX.Core.Content;
using Xamarin.CommunityToolkit.UI.Views;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using static Android.App.ActionBar;
using AColor = Android.Graphics.Color;
using AColorRes = Android.Resource.Color;
using AView = Android.Views.View;
using FormsPlatform = Xamarin.Forms.Platform.Android.Platform;
using GravityFlags = Android.Views.GravityFlags;
Expand Down Expand Up @@ -124,7 +128,17 @@ void SetEvents()

void SetColor()
{
AndreiMisiukevich marked this conversation as resolved.
Show resolved Hide resolved
Window.SetBackgroundDrawable(new ColorDrawable(Element.Color.ToAndroid()));
Window.SetBackgroundDrawable(new ColorDrawable(GetWindowColor()));
}
AndreiMisiukevich marked this conversation as resolved.
Show resolved Hide resolved

AColor GetWindowColor()
{
if (Element.Color != Color.Default)
return Element.Color.ToAndroid();

return Build.VERSION.SdkInt >= BuildVersionCodes.M
? Context.Resources.GetColor(AColorRes.BackgroundLight, Context.Theme)
: new AColor(ContextCompat.GetColor(Context, AColorRes.BackgroundLight));
}

void SetSize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public abstract class BasePopup : VisualElement
/// </summary>
protected BasePopup()
{
Color = Color.White;
geskill marked this conversation as resolved.
Show resolved Hide resolved
VerticalOptions = LayoutOptions.CenterAndExpand;
HorizontalOptions = LayoutOptions.CenterAndExpand;
IsLightDismissEnabled = true;
Expand Down