Skip to content

FreakySwitch

Gulam Ali H edited this page Feb 27, 2024 · 10 revisions

BREAKING CHANGE!!

FreakySwitch was rewritten in Skiasharp to avoid unexpected/native platform errors, Note all the previous APIs related to FreakySwitch i.e. the Material3 themes and stuff will be removed in the next Major release, please get rid of them ASAP.

FreakySwitch is a custom control that provides a visually appealing switch with customizable colours and behaviours.

Properties

OutlineColor

  • Type: Color
  • Description: Gets or sets the color of the switch outline.

ThumbOffColor

  • Type: Color
  • Description: Gets or sets the on color of the switch thumb.

ThumbOnColor

  • Type: Color
  • Description: Gets or sets the off color of the switch thumb.

OnColor

  • Type: Color
  • Description: Gets or sets the color of the switch when it is in the "on" state.

OffColor

  • Type: Color
  • Description: Gets or sets the color of the switch when it is in the "off" state.

ToggledCommand

  • Type: ICommand
  • Description: Gets or sets the command to be executed when the switch is toggled.

IsToggled

  • Type: bool
  • Description: Gets or sets a value indicating whether the switch is in the "on" or "off" state.

Events

Toggled

  • Type: EventHandler<ToggledEventArgs>
  • Description: Raised when the switch is toggled between the "on" and "off" states.

Old doc:

FreakySwitch is specifically an upgrade for Android to support the Material 3 switch design All you need to do for this to work is as follows:

Make sure your Android theme inherits from a Material3 theme instead of the default Maui theme, you can do this by just using the Theme that you like or you can use our default theme that I have created so you don't have to do major rework for finding and fixing your theme, all you need to do is use our default theme

    // Needs version 0.4.8-pre or above for you to find this theme, you can still use this control before 4.8 
    // but you will not be able to find this default theme and you might have to create it from scratch.
    // Post version 0.4.8-pre you can also find the dark version of the theme with "@style/FreakyControls.MainTheme.Dark"
    [Activity(Theme = "@style/FreakyControls.MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | 
    ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | 
    ConfigChanges.Density)]
    public class MainActivity : FreakyMauiAppCompatActivity

Once done you can use this control whenever you like just like you do for the default Maui Switch.

All the supported APIs remain the same, if you guys have any API suggestions feel free to raise a feature request.