-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20a318e
commit 0693a7c
Showing
12 changed files
with
243 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<view:SwitchView x:Class="App.Controls.SwitchViewExamples.BorderSwitch" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:view="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"> | ||
<view:SwitchView.GestureRecognizers> | ||
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" /> | ||
</view:SwitchView.GestureRecognizers> | ||
<Border x:Name="SwitchBackground" | ||
Padding="16,8" | ||
Background="#2B0B98" | ||
HorizontalOptions="Center" | ||
Loaded="SwitchBackground_Loaded" | ||
MinimumWidthRequest="100" | ||
StrokeThickness="4"> | ||
<Label x:Name="SwitchText" | ||
FontAttributes="Bold" | ||
FontSize="18" | ||
HorizontalTextAlignment="Center" | ||
TextColor="White" /> | ||
</Border> | ||
</view:SwitchView> |
122 changes: 122 additions & 0 deletions
122
Demo/App/Controls/SwitchViewExamples/BorderSwitch.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
using IeuanWalker.Maui.Switch; | ||
using Microsoft.Maui.Controls.Shapes; | ||
|
||
namespace App.Controls.SwitchViewExamples; | ||
|
||
public partial class BorderSwitch : SwitchView | ||
{ | ||
public BorderSwitch() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
void SwitchBackground_Loaded(object sender, EventArgs e) | ||
{ | ||
StyleSwitch(); | ||
} | ||
|
||
void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e) | ||
{ | ||
IsToggled = !IsToggled; | ||
InvokeToggled(); | ||
StyleSwitch(); | ||
} | ||
|
||
void StyleSwitch() | ||
{ | ||
if (IsToggled) | ||
{ | ||
SwitchBackground.StrokeShape = new RoundRectangle | ||
{ | ||
CornerRadius = new CornerRadius(40, 0, 40, 0) | ||
}; | ||
SwitchBackground.Stroke = new LinearGradientBrush() | ||
{ | ||
EndPoint = new Point(1, 0), | ||
GradientStops = new GradientStopCollection | ||
{ | ||
new GradientStop | ||
{ | ||
Offset = 0.1f, | ||
Color = Colors.Transparent | ||
}, | ||
new GradientStop | ||
{ | ||
Offset = 1f, | ||
Color = Color.FromArgb("#a8ff78") | ||
} | ||
} | ||
}; | ||
SwitchBackground.Background = new LinearGradientBrush() | ||
{ | ||
EndPoint = new Point(1, 0), | ||
GradientStops = new GradientStopCollection | ||
{ | ||
new GradientStop | ||
{ | ||
Offset = 0.1f, | ||
Color = Colors.Transparent | ||
}, | ||
new GradientStop | ||
{ | ||
Offset = 0.5f, | ||
Color = Color.FromArgb("#78ffd6") | ||
}, | ||
new GradientStop | ||
{ | ||
Offset = 1f, | ||
Color = Color.FromArgb("#a8ff78") | ||
} | ||
} | ||
}; | ||
SwitchText.Text = "On"; | ||
} | ||
else | ||
{ | ||
SwitchBackground.StrokeShape = new RoundRectangle | ||
{ | ||
CornerRadius = new CornerRadius(0, 40, 0, 40) | ||
}; | ||
SwitchBackground.Stroke = new LinearGradientBrush() | ||
{ | ||
EndPoint = new Point(1, 0), | ||
GradientStops = new GradientStopCollection | ||
{ | ||
new GradientStop | ||
{ | ||
Offset = 0.1f, | ||
Color = Color.FromArgb("#FF512F") | ||
}, | ||
new GradientStop | ||
{ | ||
Offset = 1f, | ||
Color = Colors.Transparent | ||
} | ||
} | ||
}; | ||
SwitchBackground.Background = new LinearGradientBrush() | ||
{ | ||
EndPoint = new Point(1, 0), | ||
GradientStops = new GradientStopCollection | ||
{ | ||
new GradientStop | ||
{ | ||
Offset = 0.1f, | ||
Color = Color.FromArgb("#DD2476") | ||
}, | ||
new GradientStop | ||
{ | ||
Offset = 0.5f, | ||
Color = Color.FromArgb("#FF512F") | ||
}, | ||
new GradientStop | ||
{ | ||
Offset = 1f, | ||
Color = Colors.Transparent | ||
} | ||
} | ||
}; | ||
SwitchText.Text = "Off"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<view:SwitchView x:Class="App.Controls.SwitchViewExamples.ImageSwitch" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:view="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"> | ||
<view:SwitchView.GestureRecognizers> | ||
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" /> | ||
</view:SwitchView.GestureRecognizers> | ||
<Image x:Name="SwitchImage" | ||
HeightRequest="50" | ||
Loaded="SwitchImage_Loaded" | ||
WidthRequest="50" /> | ||
</view:SwitchView> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using IeuanWalker.Maui.Switch; | ||
|
||
namespace App.Controls.SwitchViewExamples; | ||
|
||
public partial class ImageSwitch : SwitchView | ||
{ | ||
public ImageSwitch() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
void SwitchImage_Loaded(object sender, EventArgs e) | ||
{ | ||
StyleSwitch(); | ||
} | ||
|
||
void TapGestureRecognizer_Tapped(object sender, TappedEventArgs e) | ||
{ | ||
IsToggled = !IsToggled; | ||
InvokeToggled(); | ||
StyleSwitch(); | ||
} | ||
|
||
void StyleSwitch() | ||
{ | ||
SwitchImage.Source = ImageSource.FromFile(IsToggled ? "sun_icon" : "moon_icon"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters