Skip to content

Instantly share code, notes, and snippets.

@jesulink2514
Last active November 18, 2020 22:54
Show Gist options
  • Save jesulink2514/840162f14d8171400daba04983fa5035 to your computer and use it in GitHub Desktop.
Save jesulink2514/840162f14d8171400daba04983fa5035 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace FormsIcons.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class TechieSwitch : ITechiesSwitchController
{
public static BindableProperty IsOnProperty = BindableProperty.Create(nameof(IsOn), typeof(bool),
typeof(TechieSwitch), false, BindingMode.TwoWay, propertyChanged: OnPropertyChanged);
public TechieSwitch()
{
InitializeComponent();
}
public bool IsOn
{
get => (bool)GetValue(IsOnProperty);
set
{
SetValue(IsOnProperty, value);
}
}
private async void ClickGestureRecognizer_OnClicked(object sender, EventArgs e)
{
IsOn = !IsOn;
var position = new Rectangle
{
Left = 20,
Top = 2,
Width = 16,
Height = 16
};
var uncheckedPosition = new Rectangle
{
Left = 2,
Top = 2,
Width = 16,
Height = 16
};
await Thumb.LayoutTo(IsOn ? position : uncheckedPosition, 300, Easing.SinIn);
}
private static void OnPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment