Open alexpetin opened 2 months ago
For this there is property called HasSystemPadding
It's another props. The first one allow to get current padding sizes to accomodatge the content. The second one allows to use only left/right/top/bottom (or combination) paddings.
HasSystemPadding exists in Mopups too...
builder.ConfigureLifecycleEvents(static l =>
{
#if ANDROID
l.AddAndroid(static android =>
{
android.OnCreate(static (a, b) =>
{
if (a is not MainActivity) return;
var density = a.Resources.DisplayMetrics.Density;
float statusBarHeight = 0f;
int resourceId = a.Resources.GetIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0)
{
statusBarHeight = a.Resources.GetDimension(resourceId);
}
Settings.StatusBarHeight = statusBarHeight / density;
float navBarHeight = 0f;
resourceId = a.Resources.GetIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0)
{
navBarHeight = a.Resources.GetDimension(resourceId);
}
Settings.NavigationBarHeight = navBarHeight / density;
});
});
#else
l.AddiOS(static ios =>
{
ios.FinishedLaunching(static (a, d) =>
{
var window = PopupService.GetKeyWindow();
if (window is not null)
{
Settings.StatusBarHeight = window.SafeAreaInsets.Top;
Settings.NavigationBarHeight = window.SafeAreaInsets.Bottom;
}
return true;
});
});
#endif
Where Settings
is your shared preferences. also for iOS you may add all sides
a) You may just use regular Padding
on the PopupPage
and set it in code behind with values you got above like this:
public YourPopupPage()
{
InitializeComponent();
this.Padding = new Thickness(0, Settings.StatusBarHeight, 0, Settings.NavigationBarHeight);
}
b) Override the basic implementation and do it there. it is easy, because everything public/protected virtual. c) Propose a PR with your implementation of this, I will appreciate it.
Hope my answer helped you
Ok, thanks.
For iOS this package does not use API mentioned above, just MAUI's default ignore safe area or not.
But may be I will add such API to be public some day, but for now I'm very busy, sorry
Hi!
In order to migrate from Rg.Plugins.Popup / Mopups it would be great to implement these props. Thanks for great package, Mopups is almost unusable due to a lot of bugs...