Skip to content

Instantly share code, notes, and snippets.

View bbenetskyy's full-sized avatar
👾
Making Apps with MAUI 😛

Bohdan Benetskyi bbenetskyy

👾
Making Apps with MAUI 😛
View GitHub Profile
#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:
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);
}
#region Protected Methods
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
LongClick -= HandleLongClick;
_draggableView = null;
[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;
public class DraggableView : ContentView, IDisposable
{
public DraggableArea LimitArea { get; set; }
protected override void OnParentSet()
{
base.OnParentSet();
if (Parent is View parent)
{
public class DraggableArea
{
public DraggableArea(double x,
double y,
double width,
double height)
{
X = x;
Y = y;
Width = width;
// 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"});
Task("Default")
.IsDependentOn("BuildAndRunAndroid")
.IsDependentOn("BuildAndRuniOS")
.Does(() => {});
RunTarget(target);
Task("BuildAndRuniOS")
.Does(() =>
{
MSBuild(IOS, configurator => configurator
.SetConfiguration("Debug")
.SetVerbosity(Verbosity.Minimal));
var simulators = ListAppleSimulators();
Information($"Found Simulators: {simulators.Count}");
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);