CommunityToolkit / CommunityToolkit/Maui

[Proposal] IViewSwitcher

Open
#123 0 comments 0 reactions 0 assignees View on GitHub
new proposal
Dominant language
C#
Stars
2.7k
Forks
500
Avg merge
2d 14h
Merged PRs (30d)
7

Description

# ViewSwitcher

* [x] Proposed
* [ ] Prototype: Not Started
* [ ] Implementation: Not Started
* [ ] iOS Support
* [ ] Android Support
* [ ] macOS Support
* [ ] Windows Support
* [ ] Unit Tests: Not Started
* [ ] Sample: Not Started
* [ ] Documentation: Not Started

## Summary
[summary]: #summary

Allows transitions between VisualElement

## Detailed Design
[design]: #detailed-design

### IViewSwitcher.shared.cs

```cs
interface IViewSwitcher
{
uint TransitionDuration { get; set; }
TransitionType TransitionType { get; set; }
}
```

### ImageSwitcher.shared.cs

```cs
class ImageSwitcher : Image, IViewSwitcher
{
public static readonly BindableProperty TransitionDurationProperty;
public static readonly BindableProperty TransitionTypeProperty;

public uint TransitionDuration { get; set; }
public TransitionType TransitionType { get; set; }
}
```

### TextSwitcher.shared.cs
```cs
public class TextSwitcher : Label, IViewSwitcher
{
public static readonly BindableProperty TransitionDurationProperty;
public static readonly BindableProperty TransitionTypeProperty;

public uint TransitionDuration { get; set; }
public TransitionType TransitionType { get; set; }
}
```

### TransitionType.shared.cs
```cs
public enum TransitionType { Fade, MoveInFromLeft }
```

## Usage Syntax
[usage]: #usage-syntax

### XAML Usage

```xml


```

### C# Usage

```cs
Content = new StackLayout
{
new TextSwitcher
{
Text = "Random Text",
FontSize = 30,
TextColor = Colors.Black,
}.Assign(out var switcher),

new Button
{
CommandParameter = switcher,
Command = new Command(textSwitcher => textSwitcher.Text = Path.GetRandomFileName())
}
};
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.