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
#region Public Methods | |
public override bool OnTouchEvent(MotionEvent e) | |
{ | |
var draggView = Element as DraggableView; | |
float x = e.RawX; | |
float y = e.RawY; | |
switch (e.Action) | |
{ | |
case MotionEventActions.Down: |
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
public static readonly BindableProperty NewXProperty = BindableProperty.Create( | |
propertyName: nameof(NewX), | |
returnType: typeof(double), | |
declaringType: typeof(DraggableView)); | |
public double NewX | |
{ | |
get => (double)GetValue(NewXProperty); | |
set => SetValue(NewXProperty, value); | |
} |
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
#region Protected Methods | |
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e) | |
{ | |
base.OnElementChanged(e); | |
if (e.OldElement != null) | |
{ | |
LongClick -= HandleLongClick; | |
_draggableView = null; |
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
[assembly: ExportRenderer(typeof(DraggableView), typeof(DraggableViewRenderer))] | |
namespace LOTR.Android.Renderer | |
{ | |
public class DraggableViewRenderer : VisualElementRenderer<Xamarin.Forms.View> | |
{ | |
#region Fields | |
private CancellationTokenSource _throttleCts = new(); | |
private float _deltaX; |
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
public class DraggableView : ContentView, IDisposable | |
{ | |
public DraggableArea LimitArea { get; set; } | |
protected override void OnParentSet() | |
{ | |
base.OnParentSet(); | |
if (Parent is View parent) | |
{ |
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
public class DraggableArea | |
{ | |
public DraggableArea(double x, | |
double y, | |
double width, | |
double height) | |
{ | |
X = x; | |
Y = y; | |
Width = width; |
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
// Import Required NuGet Packages | |
#addin "nuget:?package=Cake.Xamarin" | |
#addin "nuget:?package=Cake.Android.Adb" | |
#addin "nuget:?package=Cake.AppleSimulator" | |
using System.Threading; | |
// Script Predefined Arguments | |
var target = Argument("target", "Default"); | |
var iosSimulators = Argument("iosSimulators", new string[] {"iPhone SE", "iPhone 13"}); |
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
Task("Default") | |
.IsDependentOn("BuildAndRunAndroid") | |
.IsDependentOn("BuildAndRuniOS") | |
.Does(() => {}); | |
RunTarget(target); |
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
Task("BuildAndRuniOS") | |
.Does(() => | |
{ | |
MSBuild(IOS, configurator => configurator | |
.SetConfiguration("Debug") | |
.SetVerbosity(Verbosity.Minimal)); | |
var simulators = ListAppleSimulators(); | |
Information($"Found Simulators: {simulators.Count}"); |
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
var settings = new XBuildSettings() | |
.WithProperty("SolutionDir", new string[] { SOLUTION_DIR }) | |
.WithProperty("OutputPath", new string[] { IOS_ARTIFACTS }) | |
//to test on simulators use "iPhoneSimulator" to test on real devices use "iPhone" | |
.SetConfiguration("iPhoneSimulator") | |
.SetVerbosity(Verbosity.Quiet) | |
.WithTarget("Build"); | |
XBuild(IOS, settings); |