-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #428 from AndreasReitberger/421-add-syncfusionmaui…
…buttons-and-corresponding-styles Added styles for the `SfSegmentedControl`
- Loading branch information
Showing
20 changed files
with
385 additions
and
18 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
35 changes: 35 additions & 0 deletions
35
src/SharedMauiXamlStylesLibrary.SampleApp/ViewModels/SfSegmentedControlPageViewModel.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,35 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace SharedMauiXamlStylesLibrary.SampleApp.ViewModels | ||
{ | ||
public partial class SfSegmentedControlPageViewModel : BaseViewModel | ||
{ | ||
|
||
#region Properties | ||
|
||
[ObservableProperty] | ||
ObservableCollection<string> sizes = [ | ||
"S", "M", "L", "XL", "XXL" | ||
]; | ||
|
||
[ObservableProperty] | ||
int selectedSizeIndex = 0; | ||
partial void OnSelectedSizeIndexChanged(int value) => SelectedSize = Sizes[value]; | ||
|
||
[ObservableProperty] | ||
string selectedSize = string.Empty; | ||
#endregion | ||
|
||
#region Constructor, LoadSettings | ||
|
||
public SfSegmentedControlPageViewModel(IDispatcher dispatcher, IServiceProvider provider) : base(dispatcher, provider) | ||
{ | ||
Dispatcher = dispatcher; | ||
UpdateVersionBuild(); | ||
} | ||
|
||
#endregion | ||
|
||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/SharedMauiXamlStylesLibrary.SampleApp/Views/SfSegmentedControlPage.xaml
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,50 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="SharedMauiXamlStylesLibrary.SampleApp.Views.SfSegmentedControlPage" | ||
|
||
xmlns:viewModels="clr-namespace:SharedMauiXamlStylesLibrary.SampleApp.ViewModels" | ||
|
||
xmlns:converters="clr-namespace:AndreasReitberger.Shared.Core.Converters;assembly=SharedMauiCoreLibrary" | ||
|
||
xmlns:icons="clr-namespace:AndreasReitberger.Shared.FontIcons;assembly=SharedMauiXamlStylesLibrary" | ||
xmlns:iconsSyncfusion="clr-namespace:AndreasReitberger.Shared.Syncfusion.FontIcons;assembly=SharedMauiXamlStylesLibrary.Syncfusion" | ||
xmlns:buttons="clr-namespace:Syncfusion.Maui.Buttons;assembly=Syncfusion.Maui.Buttons" | ||
|
||
Title="SfSegmentedControlPage" | ||
Style="{StaticResource Style.Core.ContentPage.Default}" | ||
x:DataType="viewModels:SfSegmentedControlPageViewModel" | ||
> | ||
<ContentPage.Resources> | ||
<converters:BrushToBlackWhiteConverter x:Key="BrushToBlackWhiteConverter" /> | ||
</ContentPage.Resources> | ||
<ScrollView> | ||
<VerticalStackLayout> | ||
<Label | ||
Margin="2,16" | ||
Text="Segmented Control (Syncfusion)" | ||
VerticalTextAlignment="Center" | ||
HorizontalTextAlignment="Center" | ||
Style="{StaticResource Style.Core.Label.Default}" | ||
/> | ||
<!-- | ||
Style="{StaticResource Style.Syncfusion.SfSegmentedControl.Default}" | ||
--> | ||
<buttons:SfSegmentedControl | ||
Margin="4,16" | ||
ItemsSource="{Binding Sizes}" | ||
SelectedIndex="{Binding SelectedSizeIndex, Mode=TwoWay}" | ||
Style="{StaticResource Style.Syncfusion.SfSegmentedControl.Default}" | ||
/> | ||
|
||
<buttons:SfSegmentedControl | ||
Margin="4,16" | ||
ItemsSource="{Binding Sizes}" | ||
SelectedIndex="{Binding SelectedSizeIndex, Mode=TwoWay}" | ||
Style="{StaticResource Style.Syncfusion.SfSegmentedControl.Borderless}" | ||
/> | ||
|
||
</VerticalStackLayout> | ||
</ScrollView> | ||
</ContentPage> |
12 changes: 12 additions & 0 deletions
12
src/SharedMauiXamlStylesLibrary.SampleApp/Views/SfSegmentedControlPage.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,12 @@ | ||
using SharedMauiXamlStylesLibrary.SampleApp.ViewModels; | ||
|
||
namespace SharedMauiXamlStylesLibrary.SampleApp.Views; | ||
|
||
public partial class SfSegmentedControlPage : ContentPage | ||
{ | ||
public SfSegmentedControlPage(SfSegmentedControlPageViewModel viewModel) | ||
{ | ||
InitializeComponent(); | ||
BindingContext = viewModel; | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/SharedMauiXamlStylesLibrary.Syncfusion/Resources/Themes/Controls/SfButton.xaml
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,90 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<?xaml-comp compile="true" ?> | ||
<ResourceDictionary | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
|
||
xmlns:converters="clr-namespace:AndreasReitberger.Shared.Core.Converters;assembly=SharedMauiCoreLibrary" | ||
xmlns:shared="clr-namespace:AndreasReitberger.Shared;assembly=SharedMauiXamlStylesLibrary" | ||
xmlns:icons="clr-namespace:AndreasReitberger.Shared.Syncfusion.FontIcons" | ||
xmlns:iconsCore="clr-namespace:AndreasReitberger.Shared.FontIcons;assembly=SharedMauiXamlStylesLibrary" | ||
|
||
xmlns:core="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core" | ||
xmlns:buttons="clr-namespace:Syncfusion.Maui.Buttons;assembly=Syncfusion.Maui.Buttons" | ||
> | ||
<ResourceDictionary.MergedDictionaries> | ||
<shared:Colors /> | ||
<shared:Fonts /> | ||
<ResourceDictionary Source="/Resources/Themes/SharedFonts.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
|
||
<converters:BrushToBlackWhiteConverter x:Key="BrushToBlackWhiteConverter"/> | ||
|
||
<!-- Docs: https://help.syncfusion.com/maui/button/overview --> | ||
<Style x:Key="Style.Syncfusion.SfButton.Default" TargetType="buttons:SfButton"> | ||
<Setter Property="FontFamily" Value="{StaticResource MontserratSemiBold}" /> | ||
<Setter Property="Background" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}" /> | ||
<Setter Property="TextColor" Value="{Binding Source={RelativeSource Self}, Path=Background, Converter={StaticResource BrushToBlackWhiteConverter}}" /> | ||
<Setter Property="FontSize" Value="Small" /> | ||
<Setter Property="VisualStateManager.VisualStateGroups"> | ||
<VisualStateGroupList> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal"> | ||
<VisualState.Setters> | ||
<Setter Property="Background" Value="{DynamicResource PrimaryColor}"/> | ||
<Setter Property="TextColor" Value="{Binding Source={RelativeSource Self}, Path=Background, Converter={StaticResource BrushToBlackWhiteConverter}}" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
<VisualState x:Name="Disabled"> | ||
<VisualState.Setters> | ||
<Setter Property="Background" Value="{AppThemeBinding Light={StaticResource LightGray}, Dark={StaticResource DarkGray}}" /> | ||
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource DarkGray}, Dark={StaticResource LightGray}}" /> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateGroupList> | ||
</Setter> | ||
</Style> | ||
|
||
<Style TargetType="buttons:SfButton" BasedOn="{StaticResource Style.Syncfusion.SfButton.Default}"/> | ||
|
||
<Style x:Key="Style.Syncfusion.SfButton.Icon" TargetType="buttons:SfButton" BasedOn="{StaticResource Style.Syncfusion.SfButton.Default}"> | ||
<Setter Property="Background" Value="{StaticResource Transparent}" /> | ||
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray600}, Dark={StaticResource Gray400}}" /> | ||
<Setter Property="FontFamily" Value="{StaticResource FontIcons}" /> | ||
<Setter Property="FontSize" Value="{OnIdiom Desktop=Medium, Default=Large}" /> | ||
<Setter Property="HorizontalTextAlignment" Value="Center" /> | ||
<Setter Property="VerticalTextAlignment" Value="Center" /> | ||
<Setter Property="HeightRequest" Value="{OnIdiom Phone=40, Default=60}" /> | ||
<Setter Property="WidthRequest" Value="{OnIdiom Phone=40, Default=60}" /> | ||
</Style> | ||
|
||
<Style x:Key="Style.Syncfusion.SfButton.Icon.MaterialDesign" TargetType="buttons:SfButton" BasedOn="{StaticResource Style.Syncfusion.SfButton.Icon}"> | ||
<Setter Property="FontFamily" Value="{StaticResource MaterialDesignIcons}" /> | ||
<Setter Property="FontSize" Value="{OnIdiom Desktop=32, Tablet=26, Default=22}" /> | ||
</Style> | ||
|
||
<Style x:Key="Style.Syncfusion.SfButton.IconRound.MaterialDesign" TargetType="buttons:SfButton"> | ||
<Setter Property="Background" Value="{StaticResource Transparent}" /> | ||
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Gray600}, Dark={StaticResource Gray400}}" /> | ||
<Setter Property="FontFamily" Value="{StaticResource MaterialDesignIcons}" /> | ||
<Setter Property="FontSize" Value="{OnIdiom Desktop=32, Tablet=32, Phone=22, Default=22}" /> | ||
<Setter Property="HorizontalTextAlignment" Value="Center" /> | ||
<Setter Property="VerticalTextAlignment" Value="Center" /> | ||
<Setter Property="HeightRequest" Value="{OnIdiom Phone=40, Default=60}" /> | ||
<Setter Property="WidthRequest" Value="{OnIdiom Phone=40, Default=60}" /> | ||
<Setter Property="CornerRadius" Value="{OnIdiom Phone=20, Default=30}" /> | ||
</Style> | ||
|
||
<Style x:Key="Style.Syncfusion.SfButton.IconRound.EmergencyStop" TargetType="buttons:SfButton" BasedOn="{StaticResource Style.Syncfusion.SfButton.IconRound.MaterialDesign}"> | ||
<Setter Property="Text" Value="{x:Static iconsCore:MaterialIcons.HandBackRight}" /> | ||
<Setter Property="Background" Value="{StaticResource Red}" /> | ||
<Setter Property="TextColor" Value="{StaticResource White}" /> | ||
<Setter Property="Stroke" Value="{StaticResource Yellow}" /> | ||
<Setter Property="StrokeThickness" Value="3" /> | ||
<Setter Property="HeightRequest" Value="{OnIdiom Phone=50, Default=70}" /> | ||
<Setter Property="WidthRequest" Value="{OnIdiom Phone=50, Default=70}" /> | ||
<Setter Property="CornerRadius" Value="{OnIdiom Phone=25, Default=35}" /> | ||
</Style> | ||
|
||
</ResourceDictionary> |
84 changes: 84 additions & 0 deletions
84
src/SharedMauiXamlStylesLibrary.Syncfusion/Resources/Themes/Controls/SfSegmentedControl.xaml
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,84 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<?xaml-comp compile="true" ?> | ||
<ResourceDictionary | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
|
||
xmlns:converters="clr-namespace:AndreasReitberger.Shared.Core.Converters;assembly=SharedMauiCoreLibrary" | ||
xmlns:core="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core" | ||
xmlns:buttons="clr-namespace:Syncfusion.Maui.Buttons;assembly=Syncfusion.Maui.Buttons" | ||
xmlns:shared="clr-namespace:AndreasReitberger.Shared;assembly=SharedMauiXamlStylesLibrary" | ||
> | ||
<ResourceDictionary.MergedDictionaries> | ||
<shared:Colors /> | ||
<shared:Fonts /> | ||
<ResourceDictionary Source="/Resources/Themes/SharedFonts.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
|
||
<converters:BrushToBlackWhiteConverter x:Key="BrushToBlackWhiteConverter"/> | ||
|
||
<!-- Docs: https://help.syncfusion.com/maui/segmented-control/overviews --> | ||
<Style x:Key="Style.Syncfusion.SfSegmentedControl.Default" TargetType="buttons:SfSegmentedControl"> | ||
<Setter Property="TextStyle"> | ||
<Setter.Value> | ||
<buttons:SegmentTextStyle | ||
FontSize="{OnIdiom Phone=14, Default=18}" | ||
FontFamily="{StaticResource MontserratBold}" | ||
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" | ||
/> | ||
</Setter.Value> | ||
</Setter> | ||
<!-- | ||
Causes exception => Operation is not valid due to the current state of the object. | ||
TextColor="{Binding Source={RelativeSource Self}, Path=Background, Converter={StaticResource BrushToBlackWhiteConverter}}" | ||
--> | ||
<Setter Property="SelectionIndicatorSettings"> | ||
<Setter.Value> | ||
<buttons:SelectionIndicatorSettings | ||
Background="{DynamicResource PrimaryColor}" | ||
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" | ||
/> | ||
</Setter.Value> | ||
</Setter> | ||
|
||
<Setter Property="StrokeThickness" Value="2" /> | ||
<Setter Property="Stroke" Value="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Gray800}}" /> | ||
<Setter Property="CornerRadius" Value="8" /> | ||
<Setter Property="SegmentCornerRadius" Value="0" /> | ||
</Style> | ||
|
||
<Style x:Key="Style.Syncfusion.SfSegmentedControl.Printers" TargetType="buttons:SfSegmentedControl" BasedOn="{StaticResource Style.Syncfusion.SfSegmentedControl.Default}"> | ||
<Setter Property="SegmentBackground" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}" /> | ||
<Setter Property="Stroke" Value="{AppThemeBinding Light={StaticResource White}, Dark={StaticResource Black}}" /> | ||
<Setter Property="SegmentWidth" Value="48" /> | ||
</Style> | ||
|
||
<Style x:Key="Style.Syncfusion.SfSegmentedControl.Borderless" TargetType="buttons:SfSegmentedControl" BasedOn="{StaticResource Style.Syncfusion.SfSegmentedControl.Default}"> | ||
<Setter Property="TextStyle"> | ||
<Setter.Value> | ||
<buttons:SegmentTextStyle | ||
FontSize="{OnIdiom Phone=10, Default=14}" | ||
FontFamily="{StaticResource MontserratBold}" | ||
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" | ||
/> | ||
</Setter.Value> | ||
</Setter> | ||
<!-- | ||
Causes exception => Operation is not valid due to the current state of the object. | ||
TextColor="{Binding Source={RelativeSource Self}, Path=Background, Converter={StaticResource BrushToBlackWhiteConverter}}" | ||
--> | ||
<Setter Property="SelectionIndicatorSettings"> | ||
<Setter.Value> | ||
<buttons:SelectionIndicatorSettings | ||
Background="{DynamicResource PrimaryColor}" | ||
TextColor="{AppThemeBinding Light={StaticResource Black}, Dark={StaticResource White}}" | ||
SelectionIndicatorPlacement="Border" | ||
/> | ||
</Setter.Value> | ||
</Setter> | ||
<Setter Property="StrokeThickness" Value="0" /> | ||
<Setter Property="SegmentWidth" Value="{OnIdiom Phone=32, Default=64}" /> | ||
<Setter Property="CornerRadius" Value="{OnIdiom Phone=16, Default=32}" /> | ||
<Setter Property="SegmentCornerRadius" Value="{OnIdiom Phone=16, Default=32}" /> | ||
</Style> | ||
</ResourceDictionary> |
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
12 changes: 12 additions & 0 deletions
12
src/SharedMauiXamlStylesLibrary.Syncfusion/Resources/Themes/SharedConverters.xaml
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ResourceDictionary | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="AndreasReitberger.Shared.Syncfusion.SharedConverters" | ||
|
||
xmlns:converters="clr-namespace:AndreasReitberger.Shared.Syncfusion.Converters" | ||
> | ||
<!-- Syncfusion Converters --> | ||
<converters:BooleanToBadgeIconConverter x:Key="BooleanToBadgeIconConverter" /> | ||
<converters:DictionaryToChartSeriesCollectionConverter x:Key="DictionaryToChartSeriesCollectionConverter" /> | ||
</ResourceDictionary> |
9 changes: 9 additions & 0 deletions
9
src/SharedMauiXamlStylesLibrary.Syncfusion/Resources/Themes/SharedConverters.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,9 @@ | ||
namespace AndreasReitberger.Shared.Syncfusion; | ||
|
||
public partial class SharedConverters | ||
{ | ||
public SharedConverters() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
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
Oops, something went wrong.