Code Monkey home page Code Monkey logo

xamarin.forms.backgroundkit's People

Contributors

bentmar avatar chasakisd avatar ff5h avatar tranb3r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xamarin.forms.backgroundkit's Issues

Ripple not working if applied via a Style with an IsEnabled trigger

So, this is a tough one, but I managed to narrow down the problem and make a simple repro.

Take this style:

<Style TargetType="bgKitControls:MaterialContentView" x:Key="TestStyle">
    <Setter Property="IsClickable" Value="True" />
    <Setter Property="Background">
        <bgKitControls:Background Color="DodgerBlue" IsRippleEnabled="True" RippleColor="Magenta" />
    </Setter>

    <Style.Triggers>
        <Trigger TargetType="bgKitControls:MaterialContentView" Property="IsEnabled" Value="False">
            <Setter Property="Background" Value="{bgKitMarkup:BgProvider Color=Gray}" />
        </Trigger>
    </Style.Triggers>
</Style>

Apply it to this view:

<bgKitControls:MaterialContentView
    Style="{StaticResource TestStyle}"
    WidthRequest="100" HeightRequest="40"
    IsEnabled="{Binding ShouldBeEnabled}">
</bgKitControls:MaterialContentView>

Now, the ripple is not working, when IsEnabled=true.

Remove the Trigger in the Style, or remove IsEnabled on the view (without touching the Style), and the ripple is showing up again.

Also, IsEnabled must be a Binding. It works if you pass "True" directly.

But... if the property that was bound in the Binding (ShouldBeEnabled in my example) was always true from the beginning, it works. However, if it goes from false to true at least once, there the ripple is broken.

I have this in my (ReactiveUI) ViewModel to demonstrate this non-deterministic effect:

public class Vm : ReactiveObject {
    [Reactive]
    public bool ShouldBeEnabled { get; set; } = false;

    public Vm(long roomId) {
        Device.StartTimer(TimeSpan.FromSeconds(2), () => {
            ShouldBeEnabled = true;
            return false;
        });
    }
}

If you replace false by true, no problem, it's working as intended.

Shape Support

BackgroundKit should let developers provide a custom shape to their views.

TODO Shapes

BackgroundKit will support the following shapes:
Rectangle (In PR)
Round Rectangle (In PR)
Arc (In PR)
Diagonal - pending
CornerClip - pending
Triangle - pending
Custom (Developer will be able to register custom providers) - pending

API Changes

public interface IBackgroundShape
{
        bool NeedsBorderInset { get; }
        VisualElement Parent { get; set; }
        IMaterialVisualElement Background { get; }

        event EventHandler<EventArgs> ShapeInvalidateRequested;
}
public class BaseShape : BindableObject, IBackgroundShape
{
        public VisualElement Parent { get; set; }

        public IMaterialVisualElement Background =>
            Parent is IBackgroundElement backgroundElement ? backgroundElement.Background : null;

        public bool NeedsBorderInset =>
            Background != null && Background.BorderStyle == BorderStyle.Outer && Background.BorderWidth > 0;

        public event EventHandler<EventArgs> ShapeInvalidateRequested;

        public virtual void InvalidateShape()
        {
            ShapeInvalidateRequested?.Invoke(this, EventArgs.Empty);
        }
}

Every shape will derive from BaseShape. e.g. Arc:

public class Arc : BaseShape
{
        public static readonly BindableProperty PositionProperty = BindableProperty.Create();

        public ArcPosition Position
        {
            get => (ArcPosition)GetValue(PositionProperty);
            set => SetValue(PositionProperty, value);
        }

        public static readonly BindableProperty IsCropInsideProperty = BindableProperty.Create()

        public bool IsCropInside
        {
            get => (bool)GetValue(IsCropInsideProperty);
            set => SetValue(IsCropInsideProperty, value);
        }

        public static readonly BindableProperty ArcHeightProperty = BindableProperty.Create();

        public double ArcHeight
        {
            get => (double)GetValue(ArcHeightProperty);
            set => SetValue(ArcHeightProperty, value);
        }
}

Every shape will have a Platform Path Provider in order to generate a path for the view. For example, for iOS:

public interface IPathProvider : IDisposable
{
        CGPath Path { get; }
        bool IsPathDirty { get; }
        bool IsBorderPathDirty { get; }
        bool IsBorderSupported { get; }
        bool CanHandledByOutline { get; }

        void Invalidate();
        void SetShape(IBackgroundShape shape);

        CGPath CreatePath(CGRect bounds);
        CGPath CreateBorderedPath(CGRect bounds);
}

Every Path Provider will derive from BasePathProvider that implements the IPathProvider and override the following 2 methods for getting a path with or without border. For example, RectPathProvider on iOS:

public class RectPathProvider : BasePathProvider<Rect>
{
        public override bool IsBorderSupported => true;

        public override void CreatePath(Rect shape, CGRect bounds)
        {
            Path = UIBezierPath.FromRect(bounds).CGPath;
        }

        public override void CreateBorderedPath(Rect shape, CGRect bounds, double strokeWidth)
        {
            BorderPath = UIBezierPath.FromRect(bounds.Inset((float)strokeWidth, (float)strokeWidth)).CGPath;
        }
}

Same goes for Android.

Type BgProvider not found

hi @ChasakisD, i found error with your BackgroundKit.
Type BgProvider not found in xmlns http://xamarin.com/schemas/2014/forms/background
in xamarin previewer just fine, but when I build the project an error occurs
I'm using visual studio for mac 8.3.7
please the solution

XamarinBackgroundKit.Android not found

hello, XamarinBackgroundKit.Android.BackgroundKit.Init(); is not found in my MainActivity

/Users/agusibrahim/Projects/testbgkit/testbgkit.Android/MainActivity.cs(13,13): Error CS0234: The type or namespace name 'Android' does not exist in the namespace 'XamarinBackgroundKit' (are you missing an assembly reference?) (CS0234) (testbgkit.Android)

please refer screenshot
Screen Shot 2019-06-18 at 08 21 08

already added to nuget
Screen Shot 2019-06-18 at 08 23 53

please help

Is it possible to remove a Picker's underline?

Hello,

I'm trying to wrap inputs in MaterialContentViews to given them elevation and rounded corners, I have an Entry and a Picker.

In Xamarin Forms Android, entries and pickers have an underline that cannot be removed via shared code.
Actually, I managed to remove it with Xamarin.Forms.BackgroundKit on entries, but not on the picker.

I tried various solutions without success, and here's the last iteration of it (clutter removed, but there's more code that should not be relevant to our problem):

<bgKitControls:MaterialContentView 
    Background="{bgKitMarkup:BgProvider Elevation=4, Color=White}"
    IsCornerRadiusHalfHeight="True">

    <Picker bgKitEffects:BackgroundEffect.Background="{bgKitMarkup:BgProvider Color=White}" />
</bgKitControls:MaterialContentView>

Picker is the first control, Entry is the second:
image

(yeah the button has a terrible shadow, that's because I still use the one provided by Xamarin.Forms for now :p)

While the exact same technique works on entries, it does not here. Instead of, or accompanying, Color=White on the Picker, I also tried adding BorderWidth=0 or BorderColor=Transparent.

I'm also still using MaterialContentView because of IsCornerRadiusHalfHeight and because I can apply a padding on it, which I can't on the Picker. I also seem to have less rendering problems (elevation shadow not rounded while the background, and more, but anyway).

Another test, without MaterialContentView, terrible rendering:

image

(This one has {bgKitMarkup:BgProvider Color=White, CornerRadius=24, Elevation=4, BorderWidth=5, BorderColor=White}) and some more (unrelated) Xamarin.Forms properties.

But maybe there's a better solution to my problem?

I'll also try on iOS tomorrow to see how that works on that platform.

A last word. Thank you so much for your work ; this must have been hard. I use Xamarin.Forms occasionally for years and this is probably the best library I've discovered for everyday work. I mean, really: if you've got a PayPal or something, that'd be my pleasure to make a little donation.

[Android] ClipPathManager should clip only when corner radius is not uniform

When corner radius is uniform(the same on each corner) the clipping is done by the ViewOutlineProvider.

When the corner radius is not uniform, ViewOutlineProvider only draws the shadow and the clipping is done by the ClipPathManager.

Right now, the manager clips the child view in any case. It should be more effective, if the manager clips the child views only when the corner radius is not uniform.

Not working on Android Lollipop

Are using BackgroundKit in my app which is working great but it is crashing when using Android Lollipop phones. Getting error about getForeground.

Have debugged it and see that this line is crashing, on view.Foreground:

public static ShapeDrawable GetRippleMaskDrawable(this AView view)
{
    if (!(view.Foreground is RippleDrawable rippleDrawable)) return null;

    return rippleDrawable.GetDrawable(0) as ShapeDrawable;
}

If I fix it and return null I get a Scroll error which I don't really understand:
Java.Lang.ClassNotFoundException: 'mono.android.view.View_OnScrollChangeListenerImplementor'

Should Backgroundkit work on Android Lollipop?

Issues with namespace

Hi

I have added the nugget and did the instanciation is the ios and android classes.

I use the xmlns:background="http://xamarin.com/schemas/2014/forms/background"

When I add the background code I have the issue that:
Error Position 47:14. Type background:Background not found in xmlns http://xamarin.com/schemas/2014/forms/background

My code is this:

Can you help please?

</CarouselView.ItemTemplate>
< background:BackgroundEffect.Background >
<background:Background
CornerRadius="5"
Elevation="4"
IsRippleEnabled="True"
RippleColor="White"
Color="Red" />
</background:BackgroundEffect.Background>

(Android) MaterialShapeManager.InitializeClipPath() - ObjectDisposedException

Hi @ChasakisD,

I'm using MaterialContentView inside CollectionView (XF 4.4) and I'm getting a random ObjectDisposedExpection while scrolling through the list.

Exception points to this method (MaterialShapeManager, line 122); it seems that "_clipPath" is sometimes disposed:

    private void InitializeClipPath(int width, int height)
    {
        if (width <= 0 || height <= 0) return;

        var canvasBounds = new RectF(0, 0, width, height);
        canvasBounds.Inset(-1, -1);

        /* Always prefer border path. If there is no need, the provider will return the default one */
        var clipPath = PathProvider.CreateBorderedPath(width, height);

        _clipPath.Reset();
        _clipPath.Set(clipPath);

        _maskPath.Reset();
        _maskPath.AddRect(canvasBounds, Path.Direction.Cw);
        _maskPath.InvokeOp(_clipPath, Path.Op.Difference);
    }

StackTrace:

at Java.Interop.JniPeerMembers.AssertSelf (Java.Interop.IJavaPeerable self) [0x00029] in :0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x00000] in :0
at Android.Graphics.Path.Reset () [0x0000a] in :0
at XamarinBackgroundKit.Android.Renderers.MaterialShapeManager.InitializeClipPath (System.Int32 width, System.Int32 height) [0x0003b] in /Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.Android/Renderers/MaterialShapeManager.cs:122
at XamarinBackgroundKit.Android.Renderers.MaterialShapeManager.Draw (Android.Views.View view, Android.Graphics.Canvas canvas, System.Action dispatchDraw) [0x00009] in /Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.Android/Renderers/MaterialShapeManager.cs:99
at XamarinBackgroundKit.Android.Renderers.MaterialBackgroundManager.Draw (Android.Views.View view, Android.Graphics.Canvas canvas, System.Action dispatchDraw) [0x00000] in /Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.Android/Renderers/MaterialBackgroundManager.cs:402
at XamarinBackgroundKit.Android.Renderers.MaterialContentViewRenderer.DispatchDraw (Android.Graphics.Canvas canvas) [0x00014] in /Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.Android/Renderers/MaterialContentViewRenderer.cs:53
at Android.Views.View.n_DispatchDraw_Landroid_graphics_Canvas_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_canvas) [0x00011] in :0
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.77(intptr,intptr,intptr)

Object reference not set to an instance of an object iOS

{System.NullReferenceException: Object reference not set to an instance of an object at XamarinBackgroundKit.iOS.Renderers.MaterialContentViewRenderer.TouchesEnded (Foundation.NSSet touches, UIKit.UIEvent evt) [0x00026] in /Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.iOS/Renderers/MaterialContentViewRenderer.cs:93 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.10.0.17/src/Xamarin.iOS/UIKit/UIApplication.cs:86 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.10.0.17/src/Xamarin.iOS/UIKit/UIApplication.cs:65 at Vitreo.App.iOS.Application.Main (System.String[] args) [0x00001] in C:\projects\Vitreo.App\Vitreo.App.iOS\Main.cs:17 }

Support ShadowColor

In many design suggestion the shadow is much more subtle or its just not black. I gave your code a glimpse and saw that this should be pretty easy to add.

For iOS both GradientStrokeLayer and MDCCard support setting a shadowcolor.

for Android API 28 MaterialCardView supports .SetOutlineAmbientShadowColor and .SetOutlineSpotShadowColor

I would love to see this feature!

Thanks!

Support for dashed border

A core feature for background kit is dashed border.

Both Android and iOS support dashed border.

image

Android implementation on dev branch

Can't use transparent background colors

Hi again,

I was trying to use a transparent background color, but it seems the alpha channel is lost on Android (I haven't tested on iOS yet).

But I've found that it's working flawlessly with gradients.

This is not working :

{bgKitMarkup:BgProvider Color=Transparent}

While this works:

{bgKitMarkup:BgProvider GradientBrush={bgKitMarkup:LinearGradient Start=Transparent, End=Transparent}}

Getting a java.lang.NoSuchMethodError.

ava.lang.NoSuchMethodError: no non-static method "Lcom/xamarin/forms/platform/android/FormsViewGroup;.getForeground()Landroid/graphics/drawable/Drawable;"
07-17 21:18:31.104 I/mono-stdout( 7091): at mono.java.lang.RunnableImplementor.n_run(Native Method)
07-17 21:18:31.104 I/mono-stdout( 7091): at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
07-17 21:18:31.104 I/mono-stdout( 7091): at android.os.Handler.handleCallback(Handler.java:739)
07-17 21:18:31.104 I/mono-stdout( 7091): at android.os.Handler.dispatchMessage(Handler.java:95)
07-17 21:18:31.104 I/mono-stdout( 7091): at android.os.Looper.loop(Looper.java:135)
07-17 21:18:31.104 I/mono-stdout( 7091): at android.app.ActivityThread.main(ActivityThread.java:5254)
07-17 21:18:31.104 I/mono-stdout( 7091): at java.lang.reflect.Method.invoke(Native Method)
07-17 21:18:31.104 I/mono-stdout( 7091): at java.lang.reflect.Method.invoke(Method.java:372)
07-17 21:18:31.104 I/mono-stdout( 7091): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
07-17 21:18:31.104 I/mono-stdout( 7091): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Provide Platform GradientHandlers

Gradients on both platforms should be drawn through some king of managers.

Specifying a manager for a specific gradientbrush will allow us to easily manage linear, radial gradients etc. This way will also allow users to extend existing managers.

[bug] ios CAAnimations when size changes

hello,

i think this is what you need in :

            CATransaction.Begin();
            CATransaction.DisableActions = true;
            // update CALayer here
            CATransaction.Commit();

please note, that this shouldn't be optional, since the animation only applies to the background layer, the container (along with elevation shadow etc) is updated instantly, which leads to really ugly half animated updates. (when scrolling through a listview for example)

[iOS] MDCCard's ripple effect requires test on iOS

Material Components Card has ripple when Interactable = true. Further test is required when having subviews with background. Subviews should process touch to the parent in order to correctly show the ripple.

Unable to use Background in Style

For now, do not change the whole background instance. Just change its color.

Tested that (in my real app I'm changing Elevation though, Color is just an example), and that works, but the problem is, is that I use a Style. The Background is therefore shared between many views in the same page (eg. multiple buttons or form controls). If I change one, I change them all.

It looks like this:

<Style x:Key="BaseControlMaterialView" TargetType="bgKitControls:MaterialContentView">
    <Setter Property="IsCornerRadiusHalfHeight" Value="True" />
    <Setter Property="Background" Value="{bgKitMarkup:BgProvider Color={StaticResource BrandWhite}, Elevation={StaticResource BaseElevation}}" />
    
    <Style.Triggers>
        <Trigger TargetType="bgKitControls:MaterialContentView" Property="IsEnabled" Value="False">
            <Setter Property="Background" Value="{bgKitMarkup:BgProvider Color={StaticResource BrandWhite}, Elevation=0}" />
        </Trigger>
    </Style.Triggers>
</Style>

Here, a view that gets IsEnabled="False" will take another background and the other views aren't touched, and I don't have to manage it by hand.

Edit : doesn't work better on iOS either!

Thanks for your help!

Originally posted by @toverux in #63 (comment)

Make BackgroundKit take ICommand and not concrete Xamarin.Forms.Command implementation

Hello,

The library exposes a few command properties, I'll take the example of MaterialContentView.ClickedCommand.

This one holds a Xamarin.Forms.Command instance while typically it is recommended to use System.Windows.Input.ICommand instead. Even Xamarin.Forms uses it, see Button.Command for example.

I personally use ReactiveUI's ReactiveCommand to fulfill my needs. This implementation implements ICommand but does not inherit from Xamarin.Forms.Command, leading to this`kind of binding errors:

Binding: ReactiveUI.ReactiveCommand`2[Aterno.Binding.DisplayableRoom,System.Reactive.Unit] can not be converted to type 'Xamarin.Forms.Command'

Now I use a value converter to convert my commands on the fly:

public class ReactiveToXamarinCommandConverter : IValueConverter {
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
        var command = (ICommand) value;

        return new Command(param => command.Execute(param));
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
        throw new NotImplementedException();
    }
}

If you don't rely on this specific implementation of ICommand, could you use this base interface instead?

Control Elevation equals Thinckness

Hello, Guys!!!

Thanks develop the plugins is awesome....

Is possible control elevation(left, top, right, down)? Today some information a value about shadow width.

[Android] Workaround for API 22 and below

XamarinBackgroundKit is now working only for API 23 and above. Some features like Elevation and Ripple are not backwards compatible and should be enabled only if the device meets the API specification

Crash on android 4.4.2 Java.Lang.IncompatibleClassChangeError

Greetings,

Thank you for the great UI extensions. I'm currently using a gradient as such:

<bgkit:MaterialContentView Grid.Row="0" Grid.ColumnSpan="2" Background="{bgkit:BgProvider BorderWidth=4, GradientBrush={bgkit:LinearGradient Start=Blue, End=White, Angle=0}}"/>

This works fine on iphones and several android devices but is crashing on an older HTC ONE M7 running android 4.4.2.

Crash information is as such:

Java.Lang.IncompatibleClassChangeError: no method with name='getForeground' signature='()Landroid/graphics/drawable/Drawable;' in class Lcom/xamarin/forms/platform/android/FormsViewGroup;

Full Stack trace:

click to expand

JniEnvironment+InstanceMethods.GetMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature)
JniType.GetInstanceMethod (System.String name, System.String signature)
JniPeerMembers+JniInstanceMethods.GetMethodInfo (System.String encodedMember)
JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters)
View.get_Foreground ()
MaterialBackgroundManager.UpdateRipple () /Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.Android/Renderers/MaterialBackgroundManager.cs:335
MaterialBackgroundManager.UpdateBackground () /Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.Android/Renderers/MaterialBackgroundManager.cs:242
MaterialBackgroundManager.SetBackgroundElement (XamarinBackgroundKit.Abstractions.IMaterialVisualElement oldElement, XamarinBackgroundKit.Abstractions.IMaterialVisualElement newElement) /Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.Android/Renderers/MaterialBackgroundManager.cs:148
MaterialBackgroundManager.SetVisualElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) /Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.Android/Renderers/MaterialBackgroundManager.cs:126
/Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.Android/Renderers/MaterialBackgroundManager.cs:55
MaterialContentViewRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs1[TElement] e) /Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.Android/Renderers/MaterialContentViewRenderer.cs:37 VisualElementRenderer1[TElement].SetElement (TElement element) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:230
IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:127
Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:345
VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:138
VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:334
VisualElementPackager.Load () D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:110
VisualElementRenderer1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:439 VisualElementRenderer1[TElement].SetElement (TElement element) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:233
IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:127
Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:345
VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:138
VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:334
VisualElementPackager.Load () D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:110
VisualElementRenderer1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:439 VisualElementRenderer1[TElement].SetElement (TElement element) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:233
IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:127
Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:345
ScrollViewContainer.set_ChildView (Xamarin.Forms.View value) D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ScrollViewContainer.cs:37
ScrollViewRenderer.LoadContent () D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ScrollViewRenderer.cs:364
ScrollViewRenderer.SetElement (Xamarin.Forms.VisualElement element) D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ScrollViewRenderer.cs:97
Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:345
VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:138
VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:334
VisualElementPackager.Load () D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:110
VisualElementRenderer1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:439 VisualElementRenderer1[TElement].SetElement (TElement element) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:233
IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:127
Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:345
VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:138
VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:334
VisualElementPackager.Load () D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:110
VisualElementRenderer1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:439 VisualElementRenderer1[TElement].SetElement (TElement element) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:233
IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) D:\a\1\s\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:127
Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) D:\a\1\s\Xamarin.Forms.Platform.Android\Platform.cs:345
NavigationRenderer.SwitchContentAsync (Xamarin.Forms.Page view, System.Boolean animated, System.Boolean removed) D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\NavigationRenderer.cs:235
NavigationRenderer.OnPushAsync (Xamarin.Forms.Page view, System.Boolean animated) D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\NavigationRenderer.cs:165
NavigationRenderer.PushViewAsync (Xamarin.Forms.Page page, System.Boolean animated) D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\NavigationRenderer.cs:59
NavigationRenderer.OnPushed (System.Object sender, Xamarin.Forms.Internals.NavigationRequestedEventArgs e) D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\NavigationRenderer.cs:202
NavigationPage.PushAsyncInner (Xamarin.Forms.Page page, System.Boolean animated) D:\a\1\s\Xamarin.Forms.Core\NavigationPage.cs:421
NavigationPage.PushAsync (Xamarin.Forms.Page page, System.Boolean animated) D:\a\1\s\Xamarin.Forms.Core\NavigationPage.cs:242
BoatProfileListView.OnItemSelected (System.Object sender, Xamarin.Forms.SelectedItemChangedEventArgs e) D:\Repo\VSTS\VVM1\VesselViewMobile.UI\Features\Profile\BoatProfileListView.xaml.cs:76
AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state)
SyncContext+<>c__DisplayClass2_0.b__0 ()
Thread+RunnableImplementor.Run ()
IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this)
(wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.29(intptr,intptr)
java.lang.NoSuchMethodError: no method with name='getForeground' signature='()Landroid/graphics/drawable/Drawable;' in class Lcom/xamarin/forms/platform/android/FormsViewGroup;
md51558244f76c53b6aeda52c8a337f2c37.CellAdapter.n_onItemClick(Native Method)
md51558244f76c53b6aeda52c8a337f2c37.CellAdapter.onItemClick CellAdapter.java:89
android.widget.AdapterView.performItemClick AdapterView.java:299
android.widget.AbsListView.performItemClick AbsListView.java:1282
android.widget.ListView.performItemClick ListView.java:4450
android.widget.AbsListView$PerformClick.run AbsListView.java:3174
android.widget.AbsListView$3.run AbsListView.java:3925
android.os.Handler.handleCallback Handler.java:733
android.os.Handler.dispatchMessage Handler.java:95
android.os.Looper.loop Looper.java:157
android.app.ActivityThread.main ActivityThread.java:5872
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke Method.java:515
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run ZygoteInit.java:858
com.android.internal.os.ZygoteInit.main ZygoteInit.java:674
dalvik.system.NativeStart.main(Native Method)

Any assistance would be greatly appreciated. I'd like to include gradients in my UI, but also can't isolate users with older android devices.

Thanks,

Aaron

Object reference not set to an instance of an object at XamarinBackgroundKit.iOS.Renderers.MaterialContentViewRenderer.TouchesEnded

{System.NullReferenceException: Object reference not set to an instance of an object at XamarinBackgroundKit.iOS.Renderers.MaterialContentViewRenderer.TouchesEnded (Foundation.NSSet touches, UIKit.UIEvent evt) [0x00029] in /Users/chasakisd/Desktop/GitRepos/Xamarin.Forms.BackgroundKit-new/src/XamarinBackgroundKit.iOS/Renderers/MaterialContentViewRenderer.cs:99 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:86 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.16.0.13/src/Xamarin.iOS/UIKit/UIApplication.cs:65 at Vitreo.App.iOS.Application.Main (System.String[] args) [0x00001] in C:\projects\Vitreo.App\Vitreo.App.iOS\Main.cs:17 }

[bug] [iOS] strange background animations on MaterialContentView when size changes

hello,

on iOS when dynamically changing the size of a MaterialContentView some weird animations happen which i am unable to turn off. this inevitably happens for example if a ListView.ViewCell reusing/rebinding the previously disappearing cell template.

sometimes even rendering becomes incorrect for the corners when rebinding the margin: see attached example when tapping on a row. This i guess happens due to the fact that the curvature is calculated to the previous width/height of the view, but the background is stretched to the new size.

So the fix is probably listening to sizechange events of the host, and recalculating the background accordingly. (there is also an issue when IsCircle == true, and padding > 0, these maybe related to each other)

repro: IOSBug.zip

other than that: it is a great library! :)

[Android] Two components in a stacklayout

When adding two components to a horizontal oriented stacklayout the first component applies the styles to the second.

Example: In the first component I put blue color, with shadow, and elevation, it happened that in the other that was on the side it was white color, elevation and shadow even though I entered values ​​like 0 in elevation, transparent shadow and color.

[iOS] Test MDCShadowLayer

On iOS we add elevation by using the Shadow Layer of Material Components. Further testing is required for cases like when the device is rotated, in listview etc.

Cannot change the Background of a MaterialContentView

I came with the simplest code possible, basically:

<bgKitControls:MaterialContentView Background="{bgKitMarkup:BgProvider Color=Blue}" x:Name="TestMaterialView">
    <Button Text="Change color to red" Clicked="OnButtonClicked" />
</bgKitControls:MaterialContentView>
private void OnButtonClicked(object sender, EventArgs e) {
    TestMaterialView.Background = new Background { Color = Color.Red };
}

Click the button and... nothing happens! Button stays blue.

It is a simple test case to demonstrate what I encounter in my app (can't change the elevation of a wrapped button).

I didn't test on iOS yet.

Repro on an empty app: TestApp.zip

[Android] Clipping border bug

When adding border with corner radius, the outer stroke was not clipped via the canvas.ClipPath(_clipPath) on Android Pie (API 28)

Left API 27, Right API 28

|

XF 4 dependency

hello,

is there any reason you need an exact xf version dependency? unfortunatelly i cannot upgrade to 4.*, and stuck with 3.6

fyi you can specify package-ranges like this in the csproj:
<PackageReference Include="Xamarin.Forms" Version="(*,4.0.0.0)" />

[iOS] KVO Observer is not removed from NSObject

On BackgroundEffect on iOS, when OnDetached() is called, the View's layer sometimes is disposed. Since it is disposed, the observer cannot be removed, so when the user go back, a native crash is happening saying that KVO observers must be removed when a NSObject is destroyed.

Proposal:

Use Facebook's Key-Value Observing Controller KVOController instead of manually adding observers to the view's layer. Xamarin iOS Binding was implemented by NAXAM here

[bug] android release build fails with linker error

hello,

when attempting a release build on Android i get the following linker error, even though i'm not using MaterialCard, and do invoke XamarinBackgroundKit.Android.BackgroundKit.Init();

iOS builds fine.

2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: The "LinkAssemblies" task failed unexpectedly.
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018: Mono.Linker.MarkException: Error processing method: 'System.Void XamarinBackgroundKit.Android.Renderers.MaterialCardRenderer::.ctor(Android.Content.Context)' in assembly: 'XamarinBackgroundKit.Android.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve Xamarin.Forms.Material.Android.MaterialContextThemeWrapper Xamarin.Forms.Material.Android.MaterialContextThemeWrapper::Create(Android.Content.Context)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessQueue()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    --- End of inner exception stack trace ---
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessQueue()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Steps.MarkStep.Process()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at MonoDroid.Tuner.MonoDroidMarkStep.Process(LinkContext context)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Mono.Linker.Pipeline.Process(LinkContext context)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Xamarin.Android.Tasks.LinkAssemblies.Execute()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2129,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.