Skip to content

Commit

Permalink
Add spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
tj-devel709 committed Oct 23, 2023
1 parent 1506121 commit 3393eb4
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,34 @@ public static class KeyboardAutoManagerScroll
static CGRect? CursorRect = null;
internal static bool IsKeyboardShowing = false;
static int TextViewTopDistance = 20;
static int DebounceCount = 0;
static NSObject? WillShowToken = null;
static NSObject? WillHideToken = null;
static NSObject? DidHideToken = null;
static NSObject? TextFieldToken = null;
static NSObject? TextViewToken = null;

static int DebounceCount;
static NSObject? WillShowToken;
static NSObject? WillHideToken;
static NSObject? DidHideToken;
static NSObject? TextFieldToken;
static NSObject? TextViewToken;
static bool? ShouldConnect;

/// <summary>
/// Enables automatic scrolling with keyboard interactions on iOS devices.
/// </summary>
/// <remarks>
/// This method is being called by default on iOS and will scroll the page when the keyboard
/// comes up. Call the method 'KeyboardAutoManagerScroll.Disconnect()'
/// to remove this scrolling behavior.
/// </remarks>
public static void Connect()
{
// if Disconnect was called prior to the first Connect
// call in the Created Lifecycle event, do not connect
if (ShouldConnect is false)
{
ShouldConnect = true;
return;
}

ShouldConnect = true;

if (TextFieldToken is not null)
return;

Expand All @@ -55,8 +74,19 @@ public static void Connect()
DidHideToken = NSNotificationCenter.DefaultCenter.AddObserver(new NSString("UIKeyboardDidHideNotification"), DidHideKeyboard);
}

/// <summary>
/// Disables automatic scrolling with keyboard interactions on iOS devices.
/// </summary>
/// <remarks>
/// When this method is called, scrolling will not automatically happen when the keyboard comes up.
/// </remarks>
public static void Disconnect()
{
// if Disconnect is called prior to Connect, signal to not
// Connect during the Created Lifecycle event
if (ShouldConnect is null)
ShouldConnect = false;

if (WillShowToken is not null)
{
NSNotificationCenter.DefaultCenter.RemoveObserver(WillShowToken);
Expand Down

0 comments on commit 3393eb4

Please sign in to comment.