Skip to content

Commit 1d322cb

Browse files
authored
Merge pull request #659 from dimonovdd/fixIncorrectWindowLevel
Setting UIWindowLevel.Normal during removal
2 parents c4f2d12 + d2e648c commit 1d322cb

File tree

6 files changed

+61
-1
lines changed

6 files changed

+61
-1
lines changed

Rg.Plugins.Popup/Platforms/Ios/Impl/PopupPlatformIos.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ public async Task RemoveAsync(PopupPage page)
105105
window.Dispose();
106106
window = null;
107107
}
108-
if (UIApplication.SharedApplication.KeyWindow.WindowLevel == -1 && _windows.Count == 0)
108+
109+
if(_windows.Count > 0)
110+
_windows.Last().WindowLevel = UIWindowLevel.Normal;
111+
else if (UIApplication.SharedApplication.KeyWindow.WindowLevel == -1)
109112
UIApplication.SharedApplication.KeyWindow.WindowLevel = UIWindowLevel.Normal;
110113
}
111114
}

Samples/Demo/Demo.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
<ItemGroup>
1818
<PackageReference Include="Xamarin.Forms" Version="4.5.0.657" />
19+
<PackageReference Include="Xamarin.Essentials" Version="1.6.1" />
1920
</ItemGroup>
2021

2122
<ItemGroup>

Samples/Demo/Pages/MainPage.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
Clicked="OnOpenUserAnimationFromStyle" />
2626
<Button Text="Open Settings" Clicked="OnOpenSettingsPage" />
2727
<Button Text="Open MvvmPage" Clicked="OnOpenMvvmPage" />
28+
<Button Text="Open TestCurrentViewController" Clicked="OnTestCurrentViewController"/>
2829
</StackLayout>
2930
</ScrollView>
3031
</ContentPage>

Samples/Demo/Pages/MainPage.xaml.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,12 @@ private async void OnOpenMvvmPage(object sender, EventArgs e)
7474

7575
await PopupNavigation.Instance.PushAsync(page);
7676
}
77+
78+
private async void OnTestCurrentViewController(object sender, EventArgs e)
79+
{
80+
var page = new TestCurrentViewController(0);
81+
82+
await PopupNavigation.Instance.PushAsync(page);
83+
}
7784
}
7885
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<rg:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:rg="http://rotorgames.com"
5+
xmlns:animations="clr-namespace:Demo.Animations;assembly=Demo"
6+
x:Class="Demo.Pages.TestCurrentViewController">
7+
8+
<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
9+
<Frame BackgroundColor="Silver">
10+
<StackLayout Spacing="20">
11+
<Label HorizontalOptions="Center" Text="index" FontSize="16"></Label>
12+
<Label HorizontalOptions="Center" FontSize="16" x:Name="indexLable"></Label>
13+
<Button Text="Open TestCurrentViewController" Clicked="OnTestCurrentViewController"></Button>
14+
<Button Text="Open file picker" Clicked="OnFilePicker"></Button>
15+
</StackLayout>
16+
</Frame>
17+
</StackLayout>
18+
</rg:PopupPage>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using Rg.Plugins.Popup.Pages;
3+
using Rg.Plugins.Popup.Services;
4+
5+
namespace Demo.Pages
6+
{
7+
public partial class TestCurrentViewController : PopupPage
8+
{
9+
private int index = 0;
10+
11+
public TestCurrentViewController(int index)
12+
{
13+
InitializeComponent();
14+
this.index = index;
15+
indexLable.Text = this.index.ToString();
16+
}
17+
18+
private async void OnTestCurrentViewController(object sender, EventArgs e)
19+
{
20+
var page = new TestCurrentViewController(index + 1);
21+
22+
await PopupNavigation.Instance.PushAsync(page);
23+
}
24+
25+
private async void OnFilePicker(object sender, EventArgs e)
26+
{
27+
var file = await Xamarin.Essentials.FilePicker.PickAsync();
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)