{"id":13712512,"url":"https://github.com/IeuanWalker/Xamarin.Forms.CustomSwitch","last_synced_at":"2025-05-06T22:31:20.854Z","repository":{"id":43659919,"uuid":"320913320","full_name":"IeuanWalker/Xamarin.Forms.CustomSwitch","owner":"IeuanWalker","description":"Simple control to create custom switches in Xamarin.Forms","archived":false,"fork":false,"pushed_at":"2023-04-05T17:22:38.000Z","size":10678,"stargazers_count":44,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-24T16:41:24.057Z","etag":null,"topics":["custom","nuget","switch","toggle","toggle-switches","xamarin","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IeuanWalker.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"github":"IeuanWalker"}},"created_at":"2020-12-12T20:00:57.000Z","updated_at":"2025-03-14T11:09:28.000Z","dependencies_parsed_at":"2024-06-21T20:20:12.582Z","dependency_job_id":"1c629ed3-acbf-420c-b0cf-bcb17867ee17","html_url":"https://github.com/IeuanWalker/Xamarin.Forms.CustomSwitch","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IeuanWalker%2FXamarin.Forms.CustomSwitch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IeuanWalker%2FXamarin.Forms.CustomSwitch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IeuanWalker%2FXamarin.Forms.CustomSwitch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IeuanWalker%2FXamarin.Forms.CustomSwitch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IeuanWalker","download_url":"https://codeload.github.com/IeuanWalker/Xamarin.Forms.CustomSwitch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252779025,"owners_count":21802867,"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":["custom","nuget","switch","toggle","toggle-switches","xamarin","xamarin-forms"],"created_at":"2024-08-02T23:01:19.328Z","updated_at":"2025-05-06T22:31:17.189Z","avatar_url":"https://github.com/IeuanWalker.png","language":"C#","funding_links":["https://github.com/sponsors/IeuanWalker"],"categories":["UI"],"sub_categories":[],"readme":"| :warning:        | This NuGet/ repo is now in maintenance mode and support will end once xamarin.forms is no longer supported. _Bug fixes only._ \u003c/br\u003e MAUI repo - https://github.com/IeuanWalker/Maui.witch  |\n|---------------|:------------------------|\n\n# Xamarin.Forms.CustomSwitch [![Nuget](https://img.shields.io/nuget/v/IeuanWalker.CustomSwitch)](https://www.nuget.org/packages/IeuanWalker.CustomSwitch) [![Nuget](https://img.shields.io/nuget/dt/IeuanWalker.CustomSwitch)](https://www.nuget.org/packages/IeuanWalker.CustomSwitch) \n\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FIeuanWalker%2FXamarin.Forms.CustomSwitch.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FIeuanWalker%2FXamarin.Forms.CustomSwitch?ref=badge_shield)\n\n\u003e Breaking changes in version 2.1.0, please see [release notes](https://github.com/IeuanWalker/Xamarin.Forms.CustomSwitch/releases/tag/2.1.0) for more details.\n\n\nThis is a switch/ toggle control that would allow you to create any style switch you'd like. \u003cbr\u003e\nThis component is built on top/ from this great libary - https://github.com/Phenek/Global.InputForms. Fixes a few issues, adds more options for styling and improved accessibility.\n\nTake a look at the sample app included within this project -\n\n![Sample App](Doc/SampleApp.gif)\n\n## How to use it?\nInstall the [NuGet package](https://www.nuget.org/packages/IeuanWalker.CustomSwitch) into your shared project project\n```\nInstall-Package IeuanWalker.CustomSwitch\n```\n#### For android\nPermission to use the [vibration](https://docs.microsoft.com/en-us/xamarin/essentials/vibrate?tabs=android) feature is needed.\nOpen the AndroidManifest.xml file under the Properties folder and add the following inside of the manifest node.\n```\n\u003cuses-permission android:name=\"android.permission.VIBRATE\" /\u003e\n```\n#### For iOS\nAdd `CustomSwitchRenderer.Init();` to the `AppDelegate.cs \u003e FinishedLaunching()`\n\n____\n\nThe best place to learn how to create a new switch is by looking at the [samples](/Sample/Sample/Sample/Examples/).\n\nThese are the key things to know - \n- `BackgroundContent` is used to set the content of the switch\n- `KnobContent` is used to set the content on the knob. The content on the knob is hidden/shown by utilising the `IsClippedToBounds` property.\nSo essentially, as the knob moves from one side to the other it is just revealing a different part of the content.\n- The `SwitchPanUpdate` is used transition from true to false, i.e. color fading etc. \n\n## What can I do with it?\n### Properties\n| Property | What it does | Extra info |\n|---|---|---- |\n| IsToggled | A `bool` to indicate the togles status of the switch | Default value is **false** |\n| KnobHeight | The height of the knob on the switch | Default value is **0** |\n| KnobWidth | The width of the knob on the switch | Default value is **0** |\n| KnobColor | The solid color of the knob | Default value is **Color.Default** |\n| KnobBackground | The background for the knob, this supports XF brushes to enable gradients, lean more on [MS docs](https://devblogs.microsoft.com/xamarin/xamarinforms-4-8-gradients-brushes/) | Default value is **Brush.Default** |\n| KnobCornerRadius | A `CornerRadius` object representing each individual corner's radius for the knob. \u003cbr\u003e This is property is implemented using XF corner radius object  | More info on how to use this in the [MS docs](https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.cornerradius?view=xamarin-forms) \u003cbr\u003e Default value is **default(CornerRadius)** |\n| HeightRequest | The Height of the switch  | Default value is **0** |\n| WidthRequest | The width of the switch  | Default value is **0** |\n| CornerRadius | A `CornerRadius` object representing each individual corner's radius for the knob. \u003cbr\u003e This is property is implemented using XF corner radius object  | More info on how to use this in the [MS docs](https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.cornerradius?view=xamarin-forms) \u003cbr\u003e Default value is **default(CornerRadius)** |\n| BackgroundColor | The solid color of the switch | Default value is **Color.Default** |\n| Background | The background for the switch, this supports XF brushes to enable gradients, lean more on [MS docs](https://devblogs.microsoft.com/xamarin/xamarinforms-4-8-gradients-brushes/) | Default value is **Brush.Default** |\n| BackgroundContent | Sets the content of the switch.  \u003cbr\u003e See [samples](/Sample/Sample/Sample/Examples/) for an  idea how to utilise it  | Default value is **null** |\n| KnobContent | Sets the content of the knob.  \u003cbr\u003e See [samples](/Sample/Sample/Sample/Examples/) for an  idea how to utilise it | Default value is **null** |\n| HorizontalKnobMargin | Adds a margin to the max distance the knob can travel | Default value is **0** |\n| KnobLimit | Used to calculate the knob position.  \u003cbr\u003e See [samples](/Sample/Sample/Sample/Examples/) for an  idea how to utilise it | Default value is **KnobLimitEnum.Boundary** |\n| VibrateDuration | Used to set the duration of the vibration when the switch is toggles | Default value is **20** \u003cbr\u003e To disble the vibrate set the value to `0` |\n| ToggleAnimationDuration | Used to set the duration of the toggle animation | Default value is **100** \u003cbr\u003e To disble the animation set the value to `0` |\n\n### Events\n| Event | What it does \n|---|---|\n| Toggled | Triggered when the switch is toggled |\n| SwitchPanUpdate | Triggered when the switch is toggled or dragged. Used to handle the transition of the switch from one side to the other. \u003cbr\u003e See [samples](/Sample/Sample/Sample/Examples/) for an  idea how to utilise it | \n\n### Commands\n| Command | What it does \n|---|---|\n| ToggledCommand | Triggered when the switch is toggled |\n\n### Accessibility\nBoth iOS and android see's this control as a native switch. So from an accessibility POV it behaves like a native switch.\n\n## Examples\n### iOS ([xaml](/Sample/Sample/Sample/Examples/IosSwitch.xaml) / [code behind](/Sample/Sample/Sample/Examples/IosSwitch.xaml.cs))\n![iOS example](Doc/iOS.gif)\n\n### Android ([xaml](/Sample/Sample/Sample/Examples/AndroidSwitch.xaml) / [code behind](/Sample/Sample/Sample/Examples/AndroidSwitch.xaml.cs))\n![iOS example](Doc/Android.gif)\n\n### Theme 1 ([xaml](/Sample/Sample/Sample/Examples/Theme1Switch.xaml) / [code behind](/Sample/Sample/Sample/Examples/Theme1Switch.xaml.cs))\n![Theme 1 example](Doc/Theme1.gif)\n\n### Theme 2 ([xaml](/Sample/Sample/Sample/Examples/Theme2Switch.xaml) / [code behind](/Sample/Sample/Sample/Examples/Theme2Switch.xaml.cs))\n![Theme 2 example](Doc/Theme2.gif)\n\n### Other 1 ([xaml](/Sample/Sample/Sample/Examples/Other1Switch.xaml) / [code behind](/Sample/Sample/Sample/Examples/Other1Switch.xaml.cs))\n![Other 1 example](Doc/Other1.gif)\n\n### Other 2 ([xaml](/Sample/Sample/Sample/Examples/Other2Switch.xaml) / [code behind](/Sample/Sample/Sample/Examples/Other2Switch.xaml.cs))\n![Other 2 example](Doc/Other2.gif)\n\n### Other 3 ([xaml](/Sample/Sample/Sample/Examples/Other3Switch.xaml) / [code behind](/Sample/Sample/Sample/Examples/Other3Switch.xaml.cs))\n![Other 3 example](Doc/Other3.gif)\n\n### Other 4 ([xaml](/Sample/Sample/Sample/Examples/Other4Switch.xaml) / [code behind](/Sample/Sample/Sample/Examples/Other4Switch.xaml.cs))\n![Other 4 example](Doc/Other4.gif)\n\n### Other 5 ([xaml](/Sample/Sample/Sample/Examples/Other5Switch.xaml) / [code behind](/Sample/Sample/Sample/Examples/Other5Switch.xaml.cs))\n![Other 5 example](Doc/Other5.gif)\n\n## License\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FIeuanWalker%2FXamarin.Forms.CustomSwitch.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FIeuanWalker%2FXamarin.Forms.CustomSwitch?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIeuanWalker%2FXamarin.Forms.CustomSwitch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIeuanWalker%2FXamarin.Forms.CustomSwitch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIeuanWalker%2FXamarin.Forms.CustomSwitch/lists"}