-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5964bd4
commit b7fc497
Showing
9 changed files
with
172 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
source/TouchTracking/TouchTracking.MAUI/Platforms/Android/TouchEffect.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using TouchTracking.Droid; | ||
|
||
namespace TouchTracking.MAUI.Platforms.Android; | ||
|
||
public class TouchEffect : Microsoft.Maui.Controls.Platform.PlatformEffect | ||
{ | ||
private TouchHandler? _touchHandler; | ||
private global::Android.Views.View? _view; | ||
private TouchTracking.MAUI.TouchEffect? _touchEffect; | ||
|
||
protected override void OnAttached() | ||
{ | ||
_view = Control ?? Container; | ||
|
||
_touchEffect = | ||
(TouchTracking.MAUI.TouchEffect?)Element.Effects.FirstOrDefault(e => e is TouchTracking.MAUI.TouchEffect); | ||
|
||
if (_touchEffect == null) | ||
{ | ||
return; | ||
} | ||
_touchHandler = new TouchHandler(); | ||
_touchHandler.TouchAction += TouchHandlerOnTouch; | ||
_touchHandler.Capture = _touchEffect.Capture; | ||
_touchHandler.RegisterEvents(_view); | ||
} | ||
|
||
private void TouchHandlerOnTouch(object sender, TouchActionEventArgs args) | ||
{ | ||
_touchEffect?.OnTouchAction(sender, args); | ||
} | ||
|
||
protected override void OnDetached() | ||
{ | ||
if (_touchHandler == null) | ||
{ | ||
return; | ||
} | ||
|
||
_touchHandler.TouchAction -= TouchHandlerOnTouch; | ||
_touchHandler.UnregisterEvents(_view); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
source/TouchTracking/TouchTracking.MAUI/Platforms/Windows/PlatformClass1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace TouchTracking.MAUI; | ||
|
||
// All the code in this file is only included on Windows. | ||
public class PlatformClass1 | ||
{ | ||
} |
44 changes: 44 additions & 0 deletions
44
source/TouchTracking/TouchTracking.MAUI/Platforms/iOS/TouchEffect.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using TouchTracking.iOS; | ||
using UIKit; | ||
|
||
namespace TouchTracking.MAUI.Platforms.iOS; | ||
|
||
public class TouchEffect : Microsoft.Maui.Controls.Platform.PlatformEffect | ||
{ | ||
private TouchHandler? _touchHandler; | ||
private UIView? _view; | ||
private TouchTracking.MAUI.TouchEffect? _touchEffect; | ||
|
||
protected override void OnAttached() | ||
{ | ||
_view = Control ?? Container; | ||
|
||
_touchEffect = | ||
(TouchTracking.MAUI.TouchEffect?)Element.Effects.FirstOrDefault(e => e is TouchTracking.MAUI.TouchEffect); | ||
|
||
if (_touchEffect == null) | ||
{ | ||
return; | ||
} | ||
|
||
_touchHandler = new TouchHandler(); | ||
_touchHandler.TouchAction += TouchHandlerOnTouch; | ||
_touchHandler.Capture = _touchEffect.Capture; | ||
_touchHandler.RegisterEvents(_view); | ||
} | ||
|
||
private void TouchHandlerOnTouch(object sender, TouchActionEventArgs args) | ||
{ | ||
_touchEffect?.OnTouchAction(sender, args); | ||
} | ||
|
||
protected override void OnDetached() | ||
{ | ||
if (_touchHandler == null) | ||
{ | ||
return; | ||
} | ||
_touchHandler.TouchAction -= TouchHandlerOnTouch; | ||
_touchHandler.UnregisterEvents(_view); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace TouchTracking.MAUI; | ||
|
||
public class TouchEffect : RoutingEffect | ||
{ | ||
public event TouchActionEventHandler? TouchAction; | ||
|
||
public TouchEffect() : base("TouchTracking.TouchEffect") | ||
{ | ||
} | ||
|
||
public bool Capture { set; get; } | ||
|
||
public void OnTouchAction(object element, TouchActionEventArgs args) | ||
{ | ||
TouchAction?.Invoke(element, args); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
source/TouchTracking/TouchTracking.MAUI/TouchTracking.MAUI.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks> | ||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks> | ||
<UseMaui>true</UseMaui> | ||
<SingleProject>true</SingleProject> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion> | ||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion> | ||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Maui.Controls" /> | ||
<ProjectReference Include="..\TouchTracking\TouchTracking.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'" > | ||
<ProjectReference Include="..\TouchTracking.Droid\TouchTracking.Droid.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'" > | ||
<ProjectReference Include="..\TouchTracking.iOS\TouchTracking.iOS.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Platforms\MacCatalyst\" /> | ||
</ItemGroup> | ||
</Project> |