Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow GesturePlatformManager to be created for views with null window… #18938

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal class GestureManager
object? _containerView;
object? _platformView;
object? _handler;
bool _didHaveWindow;

public bool IsConnected => GesturePlatformManager != null;
public GesturePlatformManager? GesturePlatformManager { get; private set; }
Expand Down Expand Up @@ -48,24 +49,24 @@ void DisconnectGestures()
GesturePlatformManager?.Dispose();
GesturePlatformManager = null;
_handler = null;
_didHaveWindow = false;
_containerView = null;
_platformView = null;
}

void SetupGestureManager()
{
var handler = _view.Handler;
var window = _view.Window;

if (handler == null ||
window == null)

if (handler == null ||
(_didHaveWindow && _view.Window == null))
{
DisconnectGestures();
return;
}

if (_containerView != handler.ContainerView ||
_platformView != handler.PlatformView ||
if (_containerView != handler.ContainerView ||
_platformView != handler.PlatformView ||
_handler != handler)
{
DisconnectGestures();
Expand All @@ -79,6 +80,7 @@ void SetupGestureManager()
_handler = handler;
_containerView = handler.ContainerView;
_platformView = handler.PlatformView;
_didHaveWindow = _view.Window != null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public void DoesntConnectWithOnlyWindowSet()
}

[Fact]
public void DoesntConnectWithOnlyHandlerSet()
public void ConnectsWithOnlyHandlerSet()
{
var handler = Substitute.For<IViewHandler>();
var view = Substitute.For<IControlsView>();

view.Handler.Returns(handler);

GestureManager gestureManager = new GestureManager(view);
Assert.False(gestureManager.IsConnected);
Assert.True(gestureManager.IsConnected);
}

[Fact]
Expand Down
Loading