jamesmontemagno / ImageCirclePlugin

Circle Images for your Xamarin.Forms Applications
MIT License
240 stars 68 forks source link

Incorrect drawing on IOS #41

Closed protokovich closed 6 years ago

protokovich commented 6 years ago

Bug Information

Version Number of Plugin: 1.8.2.19-beta Device Tested On: Sony Xperia Z2 Simulator Tested On: Version of VS: 2017 15.2 26430.16 Version of Xamarin: Xamarin = 4.5.0.486, Xamarin.Android.SDK = 7.3.1.2, Xamarin.iOS = 10.10.0.37 Versions of other things you are using: Xamarin.Forms 2.3.5.256-pre6

Steps to reproduce the Behavior

i try simulate Floating Action Button for iOS. I'm use ImageCircle plugin for this:

<controls:CircleImageWithAnimation
                HeightRequest="60"
                WidthRequest="60"
                BorderThickness="1"
                BorderColor="LightGray"
                FillColor="{StaticResource BrandColor}"
                Aspect="AspectFit"
                HorizontalOptions="Center"
                VerticalOptions="Center" 
                Source="new"               

                x:Name="FloatBtnIos"

                RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-75}"
                RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=1, Constant=-75}"

                Command="{Binding NewTaskCommand}"
            >

                <controls:CircleImageWithAnimation.IsVisible>
                    <OnPlatform x:TypeArguments="x:Boolean" Android="False" iOS="True"/>
                </controls:CircleImageWithAnimation.IsVisible>

            </controls:CircleImageWithAnimation>

i use this code in Detail page on MasterDetail, its okay: bug_imagecircle_1_ok

then i open left master menu and navigate into another page (by setting Detail). and then i open my first page with "floating button" like in prev sample (by setting Detail). bug_imagecircle_2_bad

this is my CircleImageWithAnimation class (it just ImageCircle with simple effect and Command property)

// https://forums.xamarin.com/discussion/50693/how-to-create-button-pressed-effect
    public class CircleImageWithAnimation: CircleImage
    {
        public static readonly BindableProperty CommandProperty = BindableProperty.Create<CircleImageWithAnimation, ICommand>(p => p.Command, null);
        public ICommand Command
        {
            get => (ICommand)GetValue(CommandProperty);
            set => SetValue(CommandProperty, value);
        }

        public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create<CircleImageWithAnimation, object>(p => p.CommandParameter, null);
        public object CommandParameter
        {
            get => (object)GetValue(CommandParameterProperty);
            set => SetValue(CommandParameterProperty, value);
        }

        private ICommand TransitionCommand
        {
            get
            {
                return new Command(async () =>
                {
                    AnchorX = 0.48;
                    AnchorY = 0.48;
                    await this.ScaleTo(0.8, 50, Easing.Linear);
                    await Task.Delay(100);
                    await this.ScaleTo(1, 50, Easing.Linear);
                    Command?.Execute(CommandParameter);
                });
            }
        }

        public CircleImageWithAnimation()
        {
            Initialize();
        }

        public void Initialize()
        {
            GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = TransitionCommand
            });
        }
    }
jamesmontemagno commented 6 years ago

You should just pull the source code into your app and not subclass it as I dont' support that