CommunityToolkit / CommunityToolkit/Maui
[Proposal] IViewSwitcher
- 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
Assessment
This issue has not been assessed yet.