Skip to content

Commit

Permalink
feat(swipecontrol): Implement SwipeTestHooks
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Apr 19, 2021
1 parent bb90161 commit dcdd0fc
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 83 deletions.
115 changes: 58 additions & 57 deletions src/Uno.UI/UI/Xaml/Controls/SwipeControl/SwipeTestHooks.cs
Original file line number Diff line number Diff line change
@@ -1,125 +1,126 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using Windows.Foundation;
using Windows.UI.Xaml.Controls;

namespace Windows.UI.Xaml.Controls
{
internal partial class SwipeTestHooks
{
com_ptr<SwipeTestHooks> SwipeTestHooks.s_testHooks { };
//com_ptr<SwipeTestHooks> SwipeTestHooks.s_testHooks { };

com_ptr<SwipeTestHooks> EnsureGlobalTestHooks()
public static SwipeTestHooks EnsureGlobalTestHooks()
{
static bool s_initialized =

[]
()

{
s_testHooks = winrt.new SwipeTestHooks();
return true;
}
();
return s_testHooks;
return s_testHooks ?? new SwipeTestHooks();
}

winrt.SwipeControl GetLastInteractedWithSwipeControl()
public SwipeControl GetLastInteractedWithSwipeControl()
{
return SwipeControl.GetLastInteractedWithSwipeControl();
}

bool GetIsOpen(winrt.SwipeControl& swipeControl)
public bool GetIsOpen(SwipeControl swipeControl)
{
if (swipeControl)
if (swipeControl is { })
{
return winrt.get_self<SwipeControl>(swipeControl).GetIsOpen();
return ((SwipeControl)swipeControl).GetIsOpen();
}
else
{
if (var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl())
var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl();
if (lastInteractedWithSwipeControl is {})
{
return winrt.get_self<SwipeControl>(lastInteractedWithSwipeControl).GetIsOpen();
return ((SwipeControl)lastInteractedWithSwipeControl).GetIsOpen();
}
return false;
}
}

bool GetIsIdle(winrt.SwipeControl& swipeControl)
public bool GetIsIdle(SwipeControl swipeControl)
{
if (swipeControl)
if (swipeControl is {})
{
return winrt.get_self<SwipeControl>(swipeControl).GetIsIdle();
return ((SwipeControl)swipeControl).GetIsIdle();
}
else
{
if (var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl())
var lastInteractedWithSwipeControl = SwipeControl.GetLastInteractedWithSwipeControl();
if (lastInteractedWithSwipeControl is { })
{
return winrt.get_self<SwipeControl>(lastInteractedWithSwipeControl).GetIsIdle();
return ((SwipeControl)lastInteractedWithSwipeControl).GetIsIdle();
}
return false;
}
}

void NotifyLastInteractedWithSwipeControlChanged()
public void NotifyLastInteractedWithSwipeControlChanged()
{
var hooks = EnsureGlobalTestHooks();
if (hooks.m_lastInteractedWithSwipeControlChangedEventSource)
if (hooks.m_lastInteractedWithSwipeControlChangedEventSource is {})
{
hooks.m_lastInteractedWithSwipeControlChangedEventSource(null, null);
}
}

winrt.event_token LastInteractedWithSwipeControlChanged(winrt.TypedEventHandler<winrt.DependencyObject, winrt.DependencyObject> & value)
{
var hooks = EnsureGlobalTestHooks();
return hooks.m_lastInteractedWithSwipeControlChangedEventSource.add(value);
}

void LastInteractedWithSwipeControlChanged(winrt.event_token & token)
public event TypedEventHandler<DependencyObject, DependencyObject> LastInteractedWithSwipeControlChanged
{
var hooks = EnsureGlobalTestHooks();
hooks.m_lastInteractedWithSwipeControlChangedEventSource.remove(token);
add
{
var hooks = EnsureGlobalTestHooks();
hooks.m_lastInteractedWithSwipeControlChangedEventSource += value;
}
remove
{
var hooks = EnsureGlobalTestHooks();
hooks.m_lastInteractedWithSwipeControlChangedEventSource -= value;
}
}

void NotifyOpenedStatusChanged(winrt.SwipeControl& sender)
public void NotifyOpenedStatusChanged(SwipeControl sender)
{
var hooks = EnsureGlobalTestHooks();
if (hooks.m_openedStatusChangedEventSource)
if (hooks.m_openedStatusChangedEventSource is {})
{
hooks.m_openedStatusChangedEventSource(sender, null);
}
}

winrt.event_token OpenedStatusChanged(winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject> & value)
{
var hooks = EnsureGlobalTestHooks();
return hooks.m_openedStatusChangedEventSource.add(value);
}

void OpenedStatusChanged(winrt.event_token & token)
public event TypedEventHandler<SwipeControl, DependencyObject> OpenedStatusChanged
{
var hooks = EnsureGlobalTestHooks();
hooks.m_openedStatusChangedEventSource.remove(token);
add
{
var hooks = EnsureGlobalTestHooks();
hooks.m_openedStatusChangedEventSource += value;
}
remove
{
var hooks = EnsureGlobalTestHooks();
hooks.m_openedStatusChangedEventSource-= value;
}
}

void NotifyIdleStatusChanged(winrt.SwipeControl& sender)
public void NotifyIdleStatusChanged(SwipeControl sender)
{
var hooks = EnsureGlobalTestHooks();
if (hooks.m_idleStatusChangedEventSource)
if (hooks.m_idleStatusChangedEventSource is {})
{
hooks.m_idleStatusChangedEventSource(sender, null);
}
}

winrt.event_token IdleStatusChanged(winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject> & value)
{
var hooks = EnsureGlobalTestHooks();
return hooks.m_idleStatusChangedEventSource.add(value);
}

void IdleStatusChanged(winrt.event_token & token)
public event TypedEventHandler<SwipeControl, DependencyObject> IdleStatusChanged
{
var hooks = EnsureGlobalTestHooks();
hooks.m_idleStatusChangedEventSource.remove(token);
add
{
var hooks = EnsureGlobalTestHooks();
hooks.m_idleStatusChangedEventSource += value;
}
remove
{
var hooks = EnsureGlobalTestHooks();
hooks.m_idleStatusChangedEventSource -= value;
}
}
}
}
54 changes: 28 additions & 26 deletions src/Uno.UI/UI/Xaml/Controls/SwipeControl/SwipeTestHooks.h.cs
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using Windows.Foundation;

#pragma once

namespace Windows.UI.Xaml.Controls
{
internal partial class SwipeTestHooks
{
//class SwipeTestHooks :

class SwipeTestHooks :

public winrt.implementation.SwipeTestHooksT<SwipeTestHooks>
{
//public implementation.SwipeTestHooksT<SwipeTestHooks>
//{

public:
//public:

static com_ptr<SwipeTestHooks> GetGlobalTestHooks()
public static SwipeTestHooks GetGlobalTestHooks()
{
return s_testHooks;
}

static com_ptr<SwipeTestHooks> EnsureGlobalTestHooks();
//static com_ptr<SwipeTestHooks> EnsureGlobalTestHooks();

//static SwipeControl GetLastInteractedWithSwipeControl();

static winrt.SwipeControl GetLastInteractedWithSwipeControl();
//static bool GetIsOpen(SwipeControl& swipeControl);

static bool GetIsOpen(winrt.SwipeControl& swipeControl);
//static bool GetIsIdle(SwipeControl& swipeControl);

static bool GetIsIdle(winrt.SwipeControl& swipeControl);
//static void NotifyLastInteractedWithSwipeControlChanged();

static void NotifyLastInteractedWithSwipeControlChanged();
//static event_token LastInteractedWithSwipeControlChanged(TypedEventHandler<DependencyObject, DependencyObject> & value);

static winrt.event_token LastInteractedWithSwipeControlChanged(winrt.TypedEventHandler<winrt.DependencyObject, winrt.DependencyObject> & value);
//static void LastInteractedWithSwipeControlChanged(event_token & token);

static void LastInteractedWithSwipeControlChanged(winrt.event_token & token);
//static void NotifyOpenedStatusChanged(SwipeControl& sender);

static void NotifyOpenedStatusChanged(winrt.SwipeControl& sender);
//static event_token OpenedStatusChanged(TypedEventHandler<SwipeControl, DependencyObject> & value);

static winrt.event_token OpenedStatusChanged(winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject> & value);
//static void OpenedStatusChanged(event_token & token);

static void OpenedStatusChanged(winrt.event_token & token);
//static void NotifyIdleStatusChanged(SwipeControl& sender);

static void NotifyIdleStatusChanged(winrt.SwipeControl& sender);
//static event_token IdleStatusChanged(TypedEventHandler<SwipeControl, DependencyObject> & value);

static winrt.event_token IdleStatusChanged(winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject> & value);
//static void IdleStatusChanged(event_token & token);

static void IdleStatusChanged(winrt.event_token & token);
//private:

private:
private static SwipeTestHooks s_testHooks;

static com_ptr<SwipeTestHooks> s_testHooks;
winrt.event<winrt.TypedEventHandler<winrt.DependencyObject, winrt.DependencyObject>> m_lastInteractedWithSwipeControlChangedEventSource;
private event TypedEventHandler<DependencyObject, DependencyObject> m_lastInteractedWithSwipeControlChangedEventSource;

winrt.event<winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject>> m_openedStatusChangedEventSource;
private event TypedEventHandler<SwipeControl, DependencyObject> m_openedStatusChangedEventSource;

winrt.event<winrt.TypedEventHandler<winrt.SwipeControl, winrt.DependencyObject>> m_idleStatusChangedEventSource;
};
}}
private event TypedEventHandler<SwipeControl, DependencyObject> m_idleStatusChangedEventSource;
}
}

0 comments on commit dcdd0fc

Please sign in to comment.