Skip to content

Commit d1afffd

Browse files
committed
Added: Code from PRs:
https://github.com/rotorgames/Rg.Plugins.Popup/pull/754/files rotorgames#752 Also added logic to keep soft keyboard open when popup displays
1 parent 8e5a166 commit d1afffd

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

Rg.Plugins.Popup/Animations/MoveAnimation.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public override Task Appearing(View content, PopupPage page)
5757

5858
if (content != null)
5959
{
60+
if (Device.RuntimePlatform == Device.iOS)
61+
{
62+
page.Opacity = 0;
63+
}
64+
6065
var topOffset = GetTopOffset(content, page);
6166
var leftOffset = GetLeftOffset(content, page);
6267

@@ -77,6 +82,11 @@ public override Task Appearing(View content, PopupPage page)
7782
content.TranslationX = leftOffset;
7883
}
7984

85+
if (Device.RuntimePlatform == Device.iOS)
86+
{
87+
taskList.Add(page.FadeTo(1, 1));
88+
}
89+
8090
taskList.Add(content.TranslateTo(_defaultTranslationX, _defaultTranslationY, DurationIn, EasingIn));
8191
}
8292

Rg.Plugins.Popup/Platforms/Android/Renderers/PopupPageRenderer.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,19 @@ protected override void OnLayout(bool changed, int l, int t, int r, int b)
142142

143143
protected override void OnAttachedToWindow()
144144
{
145-
Context.HideKeyboard(((Activity?)Context)?.Window?.DecorView);
145+
// Comment out so keyboard can be seen when popup displays
146+
//Context.HideKeyboard(((Activity?)Context)?.Window?.DecorView);
146147
base.OnAttachedToWindow();
147148
}
148149

149150
protected override void OnDetachedFromWindow()
150151
{
151-
Device.StartTimer(TimeSpan.FromMilliseconds(0), () =>
152-
{
153-
Popup.Context.HideKeyboard(((Activity?)Popup.Context)?.Window?.DecorView);
154-
return false;
155-
});
152+
// Comment out so keyboard can be seen when popup displays
153+
//Device.StartTimer(TimeSpan.FromMilliseconds(0), () =>
154+
//{
155+
// Popup.Context.HideKeyboard(((Activity?)Popup.Context)?.Window?.DecorView);
156+
// return false;
157+
//});
156158
base.OnDetachedFromWindow();
157159
}
158160

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,23 @@ public Task AddAsync(PopupPage page)
5555
PopupWindow window;
5656
if (IsiOS13OrNewer)
5757
{
58-
if (UIApplication.SharedApplication.ConnectedScenes.ToArray()
59-
.FirstOrDefault(x => x.ActivationState == UISceneActivationState.ForegroundActive && x is UIWindowScene) is UIWindowScene connectedScene)
60-
window = new PopupWindow(connectedScene);
58+
var connectedWindowScene = UIApplication.SharedApplication
59+
.ConnectedScenes
60+
.ToArray()
61+
.FirstOrDefault(scene =>
62+
{
63+
// The popup should only be displayed on a scene that displays interactive windows
64+
// on the device’s built-in display or an externally connected display.
65+
if (scene.Session?.Role != UIWindowSceneSessionRole.Application)
66+
{
67+
return false;
68+
}
69+
return scene.ActivationState == UISceneActivationState.ForegroundActive
70+
&& scene is UIWindowScene;
71+
}) as UIWindowScene;
72+
73+
if (connectedWindowScene != null)
74+
window = new PopupWindow(connectedWindowScene);
6175
else
6276
window = new PopupWindow();
6377

@@ -71,7 +85,11 @@ public Task AddAsync(PopupPage page)
7185
if (window.RootViewController.View != null)
7286
window.RootViewController.View.BackgroundColor = Color.Transparent.ToUIColor();
7387
window.WindowLevel = UIWindowLevel.Normal;
74-
window.MakeKeyAndVisible();
88+
// Comment out so keyboard can be seen when popup displays
89+
//window.MakeKeyAndVisible();
90+
91+
// Add so keyboard can be seen when popup displays
92+
window.Hidden = false;
7593

7694
if (!IsiOS9OrNewer)
7795
window.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);

Rg.Plugins.Popup/Rg.Plugins.Popup.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
<Description>Plugin for Xamarin forms. Allows you to open any page as a popup.</Description>
1919
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
2020
<UseWPF Condition=" '$(OS)' == 'Windows_NT' ">true</UseWPF>
21+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
22+
<Version>2.1.0.3</Version>
2123
</PropertyGroup>
2224

2325
<PropertyGroup Condition="$(TargetFramework.StartsWith('uap')) And '$(OS)' == 'Windows_NT'">

0 commit comments

Comments
 (0)