{"id":13712896,"url":"https://github.com/ChasakisD/XFShimmerLayout","last_synced_at":"2025-05-06T22:31:44.768Z","repository":{"id":97969427,"uuid":"155886331","full_name":"ChasakisD/XFShimmerLayout","owner":"ChasakisD","description":"Efficient way to add a shimmering effect to your Xamarin.Forms applications.","archived":false,"fork":false,"pushed_at":"2019-06-09T09:43:45.000Z","size":364,"stargazers_count":53,"open_issues_count":5,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-05T18:19:13.481Z","etag":null,"topics":["shimmer","shimmerlayout","xamarin","xamarin-animation","xamarin-forms"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChasakisD.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-02T15:34:18.000Z","updated_at":"2023-08-22T04:42:37.000Z","dependencies_parsed_at":"2023-04-29T19:48:43.264Z","dependency_job_id":null,"html_url":"https://github.com/ChasakisD/XFShimmerLayout","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChasakisD%2FXFShimmerLayout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChasakisD%2FXFShimmerLayout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChasakisD%2FXFShimmerLayout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChasakisD%2FXFShimmerLayout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChasakisD","download_url":"https://codeload.github.com/ChasakisD/XFShimmerLayout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252779130,"owners_count":21802891,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["shimmer","shimmerlayout","xamarin","xamarin-animation","xamarin-forms"],"created_at":"2024-08-02T23:01:24.193Z","updated_at":"2025-05-06T22:31:39.543Z","avatar_url":"https://github.com/ChasakisD.png","language":"C#","funding_links":[],"categories":["UI"],"sub_categories":[],"readme":"# XFShimmerLayout\nEfficient way to add a shimmering effect to your Xamarin.Forms applications.  \n\n[![BuildStatus](https://build.appcenter.ms/v0.1/apps/d7bb360c-2216-4cd7-8b42-889345b852f4/branches/master/badge)](https://appcenter.ms) [![Nuget Version](https://buildstats.info/nuget/XFShimmerLayout)](https://www.nuget.org/packages/XFShimmerLayout)\n\n# Documentation\n\n\n# How To Use\n\n* Add nuget package Xamarin.Essentials to all projects\n* Add Init method to ```App.cs``` constructor:\n```\nInitializeComponent();\nvar density = Xamarin.Essentials.DeviceDisplay.MainDisplayInfo.Density;\nShimmerLayout.Init(density);\n```\n\n* add reference:\n```xml\nxmlns:controls=\"clr-namespace:XFShimmerLayout.Controls;assembly=XFShimmerLayout\"\n```\n* Paste content inside shimmerLayout:\n```xml\n \u003ccontrols:ShimmerLayout Angle=\"-45\" GradientSize=\".2\" IsLoading=\"True\"\u003e\n    \u003c!--Yours awesome view--\u003e\n \u003c/controls:ShimmerLayout\u003e\n```\n# How it works\n\n## Drawing Process\n\nShimmerLayout processes the visual tree and by using Skia, tries to draw every element.\n\ne.g. if we have included this layout into the ShimmerLayout\n```xml\n\u003cStackLayout Spacing=\"8\"\u003e\n    \u003cBoxView Margin=\"16\" HeightRequest=\"20\" WidthRequest=\"100\" /\u003e\n\n    \u003cBoxView Margin=\"16\" HeightRequest=\"20\" WidthRequest=\"200\" /\u003e\n\u003c/StackLayout\u003e\n```\n\nThe ShimmerLayout will create a Canvas Layer above this StackLayout and will draw every VisualElement, except Layouts. In fact, it will create a copy layer of this View (including the right margins and paddings) and draws every VisualElement to this. In the above example, it will draw 2 rectangles.  \n\n* The first one as a Rectangle with X = 16, Y = 16, Width = 100, Height = 20\n* The second one as a Rectangle with X = 16, Y = 16 + 8(Spacing of StackLayout) + 20(Height of above view), Width = 200, Height = 20\n\nYou can have as deep Visual Tree wants, the shimmer layout will draw a right copy of it.\n\n## Round Corners and Padding\n\nYou can set default CornerRadius and padding of overlay for every element,\n```xml\n\u003ccontrols:ShimmerLayout \n CornerRadiusOverlayDefault=\"10\"\n PaddingOverlayDefault=\"5\" /\u003e\n```\n\u003cimg src=\"https://github.com/VasenevEA/XFShimmerLayout/blob/roundCorners/every.png\" width=\"300\"\u003e\n\nor set for single element using Attached Property\n```xml\n\u003ccontrols:ShimmerLayout ... \u003e\n\u003cBoxView \n         controls:ShimmerLayout.PaddingOverlay=\"7,1\"\n         controls:ShimmerLayout.CornerRadiusOverlay=\"5\"\n         ... /\u003e\n\u003c/controls:ShimmerLayout\u003e\n```\n\u003cimg src=\"https://github.com/VasenevEA/XFShimmerLayout/blob/roundCorners/single.png\" width=\"300\"\u003e\n\n## Shader\n\nBefore drawing the Canvas, we must specify a Shader. We used a LinearGradient Shader.  \nFirst of all, we must extract the 2 points from the specified Angle. This can be done with some maths and knowing that the diagonal distance of the triangle is ```Math.Pow(2, -0.5);```. The method that extracts the 2 points from the angle is in ```SkiaExtensions.cs``` and called ```public static IEnumerable\u003cPoint\u003e ToPoints(this double angle)```.  \n\nThe 2 points that we've got are in the range of [0,1]. So we must convert them to the actual width and height. This can be done easily by multiply e.g. the point with the width or height.\n\nFor the Gradient we must got 2 Points, the Start Point and the End Point:\n* The Start Point will start from the exported ratio multiplied by the width pixels. Then we must add the X Offset that will be added in order to make the animation happen. Multiply also the ratio for the Y of the start point.\n* The End Point must be the X Offset plus the calculated size of the gradient in pixels and then the result must be multiplied with the ratio that we've got from the extension method before. Y must be multiplied, also, with the ratio.\n\nThe method that is responsible for the Drawing is the ```OnMaskCanvasPaintSurface``` of the ```ShimmerLayout```\n\n## Animation\n\nTo make the animation happen, we need startX and endX:\n* The StartX will be 0 - GradientSizeInPixels\n* The EndX will be the Width + GradientSizeInPixels\n\nWe created an animation that animates a value from the StartX to EndX and every time we ```InvalidateSurface``` of the ```Canvas```.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChasakisD%2FXFShimmerLayout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FChasakisD%2FXFShimmerLayout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FChasakisD%2FXFShimmerLayout/lists"}