Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/the49ltd/The49.Maui.MaterialSwitch
Adds the ability to use android Material 3 switches instead of the default
https://github.com/the49ltd/The49.Maui.MaterialSwitch
android dotnet material-ui maui the49
Last synced: 30 days ago
JSON representation
Adds the ability to use android Material 3 switches instead of the default
- Host: GitHub
- URL: https://github.com/the49ltd/The49.Maui.MaterialSwitch
- Owner: the49ltd
- License: mit
- Created: 2023-01-11T13:25:58.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-11T19:26:04.000Z (almost 2 years ago)
- Last Synced: 2024-11-12T12:54:28.772Z (about 1 month ago)
- Topics: android, dotnet, material-ui, maui, the49
- Language: C#
- Homepage:
- Size: 257 KB
- Stars: 17
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-dotnet-maui - The49.Maui.MaterialSwitch - square)](https://github.com/the49code/The49.Maui.MaterialSwitch/stargazers)|[![GitHub last-commit](https://img.shields.io/github/last-commit/the49code/The49.Maui.MaterialSwitch?style=flat-square)](https://github.com/the49code/The49.Maui.MaterialSwitch/commits) (Plugins)
README
## What is Maui.MaterialSwitch?
The .NET MAUI MaterialSwitch plugin adds the ability to use android Material 3 switches instead of the `SwitchCompat` used as default.
Default | MaterialSwitch enabled |
|:---:|:---:|
|| |## Getting Started
In order to use the plugin you need to call the extension method in your `MauiProgram.cs` file as follows:
```cs
using Plugin.ContextMenu;public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
// Initialise the plugin
builder.UseMauiApp()
.UseMaterialSwitch();// the rest of your logic...
}
}
```You also need to make sure your application's theme extends the Material3 theme. This mean you need a `Platforms/Android/Resources/values/styles.xml` file with the following content:
```xml
```
If you aleready have this file, just make sure the `Maui.MainTheme` style inherits the `Theme.Material3.DayNight` parent.
## Selectively use the MaterialSwitch
You can decide to not change the default `Switch` control. Call `UseMaterialSwitch` with `applyToAll` set to false.
```cs
.UseMaterialSwitch(applyToAll: false)
```You can then use the `MaterialSwitch` control selectively. Simply add the following namespace:
```xml
xmlns:the49="https://schemas.the49.com/dotnet/2023/maui"
```Then use `` alongside ``.
## Notes
This will NOT change the switches on any other platform than Android
---
Made within The49