Ejemplo n.º 1
0
        public Theme2Switch()
        {
            InitializeComponent();
            SwitchPanUpdate += (sender, e) =>
            {
                Color fromColorGradient1 = IsToggled ? Color.FromHex("#16d4f4") : Color.FromHex("#4a467e");
                Color toColorGradient1   = IsToggled ? Color.FromHex("#4a467e") : Color.FromHex("#16d4f4");

                Color fromColorGradient2 = IsToggled ? Color.FromHex("#cffdfc") : Color.FromHex("#21103a");
                Color toColorGradient2   = IsToggled ? Color.FromHex("#21103a") : Color.FromHex("#cffdfc");

                double t = e.Percentage * 0.01;

                Flex.TranslationX            = -(e.TranslateX + e.XRef);
                BackgroundColorGradientStops = new Xamarin.Forms.PancakeView.GradientStopCollection
                {
                    new Xamarin.Forms.PancakeView.GradientStop
                    {
                        Color  = ColorAnimationUtil.ColorAnimation(fromColorGradient1, toColorGradient1, t),
                        Offset = 0
                    },
                    new Xamarin.Forms.PancakeView.GradientStop
                    {
                        Color  = ColorAnimationUtil.ColorAnimation(fromColorGradient2, toColorGradient2, t),
                        Offset = 1
                    }
                };
            };
        }
        public Other2Switch()
        {
            InitializeComponent();
            SwitchPanUpdate += (sender, e) =>
            {
                Color fromColorGradient1 = IsToggled ? Color.FromHex("#a8ff78") : Color.FromHex("#FF512F");
                Color toColorGradient1   = IsToggled ? Color.FromHex("#FF512F") : Color.FromHex("#a8ff78");

                Color fromColorGradient2 = IsToggled ? Color.FromHex("#78ffd6") : Color.FromHex("#DD2476");
                Color toColorGradient2   = IsToggled ? Color.FromHex("#DD2476") : Color.FromHex("#78ffd6");

                double t = e.Percentage * 0.01;

                KnobColorGradientStops = new Xamarin.Forms.PancakeView.GradientStopCollection
                {
                    new Xamarin.Forms.PancakeView.GradientStop
                    {
                        Color  = ColorAnimationUtil.ColorAnimation(fromColorGradient1, toColorGradient1, t),
                        Offset = 0
                    },
                    new Xamarin.Forms.PancakeView.GradientStop
                    {
                        Color  = ColorAnimationUtil.ColorAnimation(fromColorGradient2, toColorGradient2, t),
                        Offset = 1
                    }
                };
            };
        }
Ejemplo n.º 3
0
        public Other3Switch()
        {
            InitializeComponent();
            SwitchPanUpdate += (sender, e) =>
            {
                //Color Animation
                Color fromColor = IsToggled ? Color.FromHex("#33b68d") : Color.FromHex("#e7640f");
                Color toColor   = IsToggled ? Color.FromHex("#e7640f") : Color.FromHex("#33b68d");

                double t = e.Percentage * 0.01;

                BackgroundColor = ColorAnimationUtil.ColorAnimation(fromColor, toColor, t);
            };
        }
Ejemplo n.º 4
0
        public IosSwitch()
        {
            InitializeComponent();

            SwitchPanUpdate += (sender, e) =>
            {
                //Color Animation
                Color fromColor = IsToggled ? Color.FromHex("#4ACC64") : Color.FromHex("#EBECEC");
                Color toColor   = IsToggled ? Color.FromHex("#EBECEC") : Color.FromHex("#4ACC64");

                double t = e.Percentage * 0.01;

                BackgroundColor = ColorAnimationUtil.ColorAnimation(fromColor, toColor, t);
            };
        }
Ejemplo n.º 5
0
        public Other1Switch()
        {
            InitializeComponent();
            SwitchPanUpdate += (sender, e) =>
            {
                Flex.TranslationX = -(e.TranslateX + e.XRef);

                Color fromColorLight = IsToggled ? Color.FromHex("#cdf4cc") : Color.FromHex("#f7cccc");
                Color toColorLight   = IsToggled ? Color.FromHex("#f7cccc") : Color.FromHex("#cdf4cc");

                Color fromColorDark = IsToggled ? Color.FromHex("#46d744") : Color.FromHex("#dd2424");
                Color toColorDark   = IsToggled ? Color.FromHex("#dd2424") : Color.FromHex("#46d744");

                double t = e.Percentage * 0.01;

                KnobCornerRadius = IsToggled ? new CornerRadius(0, 5, 0, 5) : new CornerRadius(5, 0, 5, 0);
                KnobColor        = ColorAnimationUtil.ColorAnimation(fromColorLight, toColorLight, t);
                KnobBorder.Color = ColorAnimationUtil.ColorAnimation(fromColorDark, toColorDark, t);
            };
        }
Ejemplo n.º 6
0
        public AndroidSwitch()
        {
            InitializeComponent();

            SwitchPanUpdate += (sender, e) =>
            {
                //Switch Color Animation
                Color fromSwitchColor = e.IsToggled ? Color.FromHex("#6200ee") : Color.FromHex("#fafafa");
                Color toSwitchColor   = e.IsToggled ? Color.FromHex("#fafafa") : Color.FromHex("#6200ee");

                //BackGroundColor Animation
                Color fromColor = e.IsToggled ? Color.FromHex("#a472ea") : Color.FromHex("#9b9b9b");
                Color toColor   = e.IsToggled ? Color.FromHex("#9b9b9b") : Color.FromHex("#a472ea");

                double t = e.Percentage * 0.01;

                KnobColor       = ColorAnimationUtil.ColorAnimation(fromSwitchColor, toSwitchColor, t);
                BackgroundColor = ColorAnimationUtil.ColorAnimation(fromColor, toColor, t);
            };
        }
Ejemplo n.º 7
0
        public Theme1Switch()
        {
            InitializeComponent();
            SwitchPanUpdate += (sender, e) =>
            {
                Color fromBackgroundColor = IsToggled ? Color.FromHex("#001f48") : Color.White;
                Color toBackgroundColor   = IsToggled ? Color.White : Color.FromHex("#001f48");

                Color fromBorderColor = IsToggled ? Color.FromHex("#16447a") : Color.FromHex("#f1ca1b");
                Color toBorderColor   = IsToggled ? Color.FromHex("#f1ca1b") : Color.FromHex("#16447a");

                double t = e.Percentage * 0.01;

                Flex.TranslationX = -(e.TranslateX + e.XRef);
                BackgroundColor   = ColorAnimationUtil.ColorAnimation(fromBackgroundColor, toBackgroundColor, t);
                Border            = new Border
                {
                    Color     = ColorAnimationUtil.ColorAnimation(fromBorderColor, toBorderColor, t),
                    Thickness = 5
                };
            };
        }