From 372a743c9082f91946f230244ca0003129c74409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Sua=CC=81rez=20Ruiz?= Date: Sun, 7 Feb 2021 13:11:52 +0100 Subject: [PATCH] Updated STATUS documentation --- STATUS.md | 123 +++++++++--------- .../Controls/Button/Button.shared.cs | 48 ++++++- .../Controls/Editor/Editor.shared.cs | 7 +- .../Controls/IButton.shared.cs | 97 ++++++++++++++ .../Slider/Slider.cupertino.shared.cs | 14 +- .../Controls/Slider/Slider.material.shared.cs | 7 +- .../Controls/Switch/Switch.fluent.shared.cs | 7 +- src/GraphicsControls/GraphicsControls.csproj | 3 +- 8 files changed, 234 insertions(+), 72 deletions(-) create mode 100644 src/GraphicsControls/Controls/IButton.shared.cs diff --git a/STATUS.md b/STATUS.md index eff56f8..cb59e90 100644 --- a/STATUS.md +++ b/STATUS.md @@ -14,58 +14,60 @@ Here you find a list of all controls with their (public) APIs and their status. **Properties** | API | Cupertino | Fluent | Material | | ----|:-------:|:---:|:-----:| -| Color | ⚠️ | ⚠️ | ⚠️ | -| IsRunning | ⚠️ | ⚠️ | ⚠️ | +| Color | ✅ | ✅ | ✅ | +| IsRunning | ✅ | ✅ | ✅ | **Features** | Feature | Description | | ----|:-------:| | Accesibility Support | ⚠️ | -| Dark Theme Support | ⚠️ | -| RTL Support | ⚠️ | +| Dark Theme Support | ✅ | +| RTL Support | ❎ | ### ⚠️ BoxView **Properties** | API | Description | | ----|:-------:| -| Color | ⚠️ | -| CornerRadius | ⚠️ | +| Color | ✅ | +| CornerRadius | ✅ | **Features** | Feature | Description | | ----|:-------:| | Accesibility Support | ⚠️ | | Dark Theme Support | ⚠️ | -| RTL Support | ⚠️ | +| RTL Support | ❎ | ### ⚠️ Button **Properties** | API | Cupertino | Fluent | Material | | ----|:-------:|:---:|:-----:| -| BackgroundColor | ⚠️ | ⚠️ | ⚠️ | +| BackgroundColor | ✅ | ✅ | ✅ | | BorderColor | ⚠️ | ⚠️ | ⚠️ | | BorderWidth | ⚠️ | ⚠️ | ⚠️ | | CharacterSpacing | ⚠️ | ⚠️ | ⚠️ | -| Clicked | ⚠️ | ⚠️ | ⚠️ | -| Command | ⚠️ | ⚠️ | ⚠️ | -| CommandParameter | ⚠️ | ⚠️ | ⚠️ | +| Clicked | ✅ | ✅ | ✅ | +| Command | ✅ | ✅ | ✅ | +| CommandParameter | ✅ | ✅ | ✅ | | ContentLayout | ⚠️ | ⚠️ | ⚠️ | -| CornerRadius | ⚠️ | ⚠️ | ⚠️ | +| CornerRadius | ✅ | ✅ | ✅ | | FontAttributes | ⚠️ | ⚠️ | ⚠️ | | FontFamily | ⚠️ | ⚠️ | ⚠️ | | FontSize | ⚠️ | ⚠️ | ⚠️ | | ImageSource | ⚠️ | ⚠️ | ⚠️ | | Padding | ⚠️ | ⚠️ | ⚠️ | -| Text | ⚠️ | ⚠️ | ⚠️ | +| Pressed | ✅ | ✅ | ✅ | +| Released | ✅ | ✅ | ✅ | +| Text | ✅ | ✅ | ✅ | | TextColor | ⚠️ | ⚠️ | ⚠️ | **Features** | Feature | Description | | ----|:-------:| | Accesibility Support | ⚠️ | -| Dark Theme Support | ⚠️ | +| Dark Theme Support | ✅ | | RTL Support | ⚠️ | ### ⚠️ CheckBox @@ -73,15 +75,15 @@ Here you find a list of all controls with their (public) APIs and their status. **Properties** | API | Cupertino | Fluent | Material | | ----|:-------:|:---:|:-----:| -| Color | ⚠️ | ⚠️ | ⚠️ | -| CheckedChanged | ⚠️ | ⚠️ | ⚠️ | -| IsChecked | ⚠️ | ⚠️ | ⚠️ | +| Color | ✅ | ✅ | ✅ | +| CheckedChanged | ✅ | ✅ | ✅ | +| IsChecked | ✅ | ✅ | ✅ | **Features** | Feature | Description | | ----|:-------:| | Accesibility Support | ⚠️ | -| Dark Theme Support | ⚠️ | +| Dark Theme Support | ✅ | | RTL Support | ⚠️ | ### ⚠️ DatePicker @@ -89,6 +91,7 @@ Here you find a list of all controls with their (public) APIs and their status. **Properties** | API | Cupertino | Fluent | Material | | ----|:-------:|:---:|:-----:| +| BackgroundColor | ✅ | ✅ | ✅ | | CharacterSpacing | ⚠️ | ⚠️ | ⚠️ | | Date | ⚠️ | ⚠️ | ⚠️ | | DateSelected | ⚠️ | ⚠️ | ⚠️ | @@ -113,14 +116,14 @@ Here you find a list of all controls with their (public) APIs and their status. | API | Cupertino | Fluent | Material | | ----|:-------:|:---:|:-----:| | AutoSize | ⚠️ | ⚠️ | ⚠️ | -| Completed | ⚠️ | ⚠️ | ⚠️ | +| Completed | ✅ | ✅ | ✅ | | CharacterSpacing | ⚠️ | ⚠️ | ⚠️ | | FontAttributes | ⚠️ | ⚠️ | ⚠️ | | FontFamily | ⚠️ | ⚠️ | ⚠️ | | FontSize | ⚠️ | ⚠️ | ⚠️ | | IsReadOnly | ⚠️ | ⚠️ | ⚠️ | | IsTextPredictionEnabled | ⚠️ | ⚠️ | ⚠️ | -| Text | ⚠️ | ⚠️ | ⚠️ | +| Text | ✅ | ✅ | ✅ | | TextColor | ⚠️ | ⚠️ | ⚠️ | | MaxLength | ⚠️ | ⚠️ | ⚠️ | @@ -128,7 +131,7 @@ Here you find a list of all controls with their (public) APIs and their status. | Feature | Description | | ----|:-------:| | Accesibility Support | ⚠️ | -| Dark Theme Support | ⚠️ | +| Dark Theme Support | ✅ | | RTL Support | ⚠️ | ### ⚠️ Entry @@ -146,31 +149,31 @@ Here you find a list of all controls with their (public) APIs and their status. | HorizontalTextAlignment | ⚠️ | ⚠️ | ⚠️ | | IsTextPredictionEnabled | ⚠️ | ⚠️ | ⚠️ | | IsPassword | ⚠️ | ⚠️ | ⚠️ | -| PlaceHolder | ⚠️ | ⚠️ | ⚠️ | +| PlaceHolder | ✅ | ✅ | ✅ | | PlaceHolderColor | ⚠️ | ⚠️ | ⚠️ | | VerticalTextAlignment | ⚠️ | ⚠️ | ⚠️ | | ReturnCommand | ⚠️ | ⚠️ | ⚠️ | | ReturnCommandParameter | ⚠️ | ⚠️ | ⚠️ | | ReturnType | ⚠️ | ⚠️ | ⚠️ | | SelectionLength | ⚠️ | ⚠️ | ⚠️ | -| Text | ⚠️ | ⚠️ | ⚠️ | +| Text | ✅ | ✅ | ✅ | | TextColor | ⚠️ | ⚠️ | ⚠️ | **Features** | Feature | Description | | ----|:-------:| | Accesibility Support | ⚠️ | -| Dark Theme Support | ⚠️ | -| RTL Support | ⚠️ | +| Dark Theme Support | ✅ | +| RTL Support | ✅ | ### ⚠️ Frame **Properties** | API | Status | | ----|:-------:| -| BorderColor | ⚠️ | -| CornerRadius | ⚠️ | -| HasShadow | ⚠️ | +| BorderColor | ✅ | +| CornerRadius | ✅ | +| HasShadow | ✅ | **Features** | Feature | Description | @@ -184,15 +187,15 @@ Here you find a list of all controls with their (public) APIs and their status. **Properties** | API | Cupertino | Fluent | Material | | ----|:-------:|:---:|:-----:| -| Progress | ⚠️ | ⚠️ | ⚠️ | -| ProgressColor | ⚠️ | ⚠️ | ⚠️ | -| ProgressTo | ⚠️ | ⚠️ | ⚠️ | +| Progress | ✅ | ✅ | ✅ | +| ProgressColor | ✅ | ✅ | ✅ | +| ProgressTo | ✅ | ✅ | ✅ | **Features** | Feature | Description | | ----|:-------:| | Accesibility Support | ⚠️ | -| Dark Theme Support | ⚠️ | +| Dark Theme Support | ✅ | | RTL Support | ⚠️ | ### ⚠️ RadioButton @@ -200,15 +203,15 @@ Here you find a list of all controls with their (public) APIs and their status. **Properties** | API | Cupertino | Fluent | Material | | ----|:-------:|:---:|:-----:| -| CheckedChanged | ⚠️ | ⚠️ | ⚠️ | -| GroupName | ⚠️ | ⚠️ | ⚠️ | -| IsChecked | ⚠️ | ⚠️ | ⚠️ | +| CheckedChanged | ✅ | ✅ | ✅ | +| GroupName | ✅ | ✅ | ✅ | +| IsChecked | ✅ | ⚠️ | ✅ | **Features** | Feature | Description | | ----|:-------:| | Accesibility Support | ⚠️ | -| Dark Theme Support | ⚠️ | +| Dark Theme Support | ✅ | | RTL Support | ⚠️ | ### ⚠️ Slider @@ -216,23 +219,23 @@ Here you find a list of all controls with their (public) APIs and their status. **Properties** | API | Cupertino | Fluent | Material | | ----|:-------:|:---:|:-----:| -| DragCompleted | ⚠️ | ⚠️ | ⚠️ | -| DragCompletedCommand | ⚠️ | ⚠️ | ⚠️ | -| DragStarted | ⚠️ | ⚠️ | ⚠️ | -| DragStartedCommand | ⚠️ | ⚠️ | ⚠️ | -| Maximum | ⚠️ | ⚠️ | ⚠️ | -| MaximumTrackColor | ⚠️ | ⚠️ | ⚠️ | -| Minimum | ⚠️ | ⚠️ | ⚠️ | -| MinimumTrackColor | ⚠️ | ⚠️ | ⚠️ | -| ThumbColor | ⚠️ | ⚠️ | ⚠️ | -| Value | ⚠️ | ⚠️ | ⚠️ | -| ValueChanged | ⚠️ | ⚠️ | ⚠️ | +| DragCompleted | ✅ | ✅ | ✅ | +| DragCompletedCommand | ✅ | ✅ | ✅ | +| DragStarted | ✅ | ✅ | ✅ | +| DragStartedCommand | ✅ | ✅ | ✅ | +| Maximum | ✅ | ✅ | ✅ | +| MaximumTrackColor | ✅ | ✅ | ✅ | +| Minimum | ✅ | ✅ | ✅ | +| MinimumTrackColor | ✅ | ✅ | ✅ | +| ThumbColor | ✅ | ✅ | ✅ | +| Value | ✅ | ✅ | ✅ | +| ValueChanged | ✅ | ✅ | ✅ | **Features** | Feature | Description | | ----|:-------:| | Accesibility Support | ⚠️ | -| Dark Theme Support | ⚠️ | +| Dark Theme Support | ✅ | | RTL Support | ⚠️ | ### ⚠️ Stepper @@ -240,34 +243,33 @@ Here you find a list of all controls with their (public) APIs and their status. **Properties** | API | Cupertino | Fluent | Material | | ----|:-------:|:---:|:-----:| -| Increment | ⚠️ | ⚠️ | ⚠️ | -| Maximum | ⚠️ | ⚠️ | ⚠️ | -| Minimum | ⚠️ | ⚠️ | ⚠️ | -| Value | ⚠️ | ⚠️ | ⚠️ | -| ValueChanged | ⚠️ | ⚠️ | ⚠️ | -| StepperPosition | ⚠️ | ⚠️ | ⚠️ | +| Increment | ✅ | ✅ | ✅ | +| Maximum | ✅ | ✅ | ✅ | +| Minimum | ✅ | ✅ | ✅ | +| Value | ✅ | ✅ | ✅ | +| ValueChanged | ✅ | ✅ | ✅ | **Features** | Feature | Description | | ----|:-------:| | Accesibility Support | ⚠️ | -| Dark Theme Support | ⚠️ | -| RTL Support | ⚠️ | +| Dark Theme Support | ✅ | +| RTL Support | ✅ | ### ⚠️ Switch **Properties** | API | Cupertino | Fluent | Material | | ----|:-------:|:---:|:-----:| -| IsToggled | ⚠️ | ⚠️ | ⚠️ | -| OnColor | ⚠️ | ⚠️ | ⚠️ | -| ThumbColor | ⚠️ | ⚠️ | ⚠️ | +| IsToggled | ✅ | ✅ | ✅ | +| OnColor | ✅ | ✅ | ✅ | +| ThumbColor | ✅ | ✅ | ✅ | **Features** | Feature | Description | | ----|:-------:| | Accesibility Support | ⚠️ | -| Dark Theme Support | ⚠️ | +| Dark Theme Support | ✅ | | RTL Support | ⚠️ | ### ⚠️ TimePicker @@ -275,6 +277,7 @@ Here you find a list of all controls with their (public) APIs and their status. **Properties** | API | Cupertino | Fluent | Material | | ----|:-------:|:---:|:-----:| +| BackgroundColor | ✅ | ✅ | ✅ | | CharacterSpacing | ⚠️ | ⚠️ | ⚠️ | | FontAttributes | ⚠️ | ⚠️ | ⚠️ | | FontFamily | ⚠️ | ⚠️ | ⚠️ | diff --git a/src/GraphicsControls/Controls/Button/Button.shared.cs b/src/GraphicsControls/Controls/Button/Button.shared.cs index 043454d..38c99ca 100644 --- a/src/GraphicsControls/Controls/Button/Button.shared.cs +++ b/src/GraphicsControls/Controls/Button/Button.shared.cs @@ -1,6 +1,8 @@ using System; +using System.ComponentModel; using System.Graphics; using System.Runtime.CompilerServices; +using System.Windows.Input; using GraphicsControls.Effects; using Xamarin.Forms; using Point = System.Graphics.Point; @@ -8,7 +10,7 @@ using XColor = Xamarin.Forms.Color; namespace GraphicsControls { - public partial class Button : GraphicsVisualView, ICornerRadius + public partial class Button : GraphicsVisualView, IButton, ICornerRadius { readonly RippleEffect _rippleEffect; RectangleF _backgroundRect; @@ -23,12 +25,35 @@ namespace GraphicsControls CornerRadius = 2; } + public static readonly BindableProperty CommandProperty = ButtonElement.CommandProperty; + + public static readonly BindableProperty CommandParameterProperty = ButtonElement.CommandParameterProperty; + + internal static readonly BindablePropertyKey IsPressedPropertyKey = + BindableProperty.CreateReadOnly(nameof(IsPressed), typeof(bool), typeof(Button), default(bool)); + + public static readonly BindableProperty IsPressedProperty = IsPressedPropertyKey.BindableProperty; + public static readonly BindableProperty TextProperty = TextElement.TextProperty; public static readonly BindableProperty TextColorProperty = TextElement.TextColorProperty; public static readonly BindableProperty CornerRadiusProperty = CornerRadiusElement.CornerRadiusProperty; + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + + public object CommandParameter + { + get { return GetValue(CommandParameterProperty); } + set { SetValue(CommandParameterProperty, value); } + } + + public bool IsPressed => (bool)GetValue(IsPressedProperty); + public string Text { get { return (string)GetValue(TextElement.TextProperty); } @@ -47,6 +72,26 @@ namespace GraphicsControls set { SetValue(CornerRadiusElement.CornerRadiusProperty, value); } } + bool IButton.IsEnabledCore + { + set { SetValueCore(IsEnabledProperty, value); } + } + + [EditorBrowsable(EditorBrowsableState.Never)] + void IButton.SetIsPressed(bool isPressed) => SetValue(IsPressedPropertyKey, isPressed); + + [EditorBrowsable(EditorBrowsableState.Never)] + void IButton.PropagateUpClicked() => Clicked?.Invoke(this, EventArgs.Empty); + + [EditorBrowsable(EditorBrowsableState.Never)] + void IButton.PropagateUpPressed() => Pressed?.Invoke(this, EventArgs.Empty); + + [EditorBrowsable(EditorBrowsableState.Never)] + void IButton.PropagateUpReleased() => Released?.Invoke(this, EventArgs.Empty); + + void IButton.OnCommandCanExecuteChanged(object sender, EventArgs e) => + ButtonElement.CommandCanExecuteChanged(this, EventArgs.Empty); + public event EventHandler Clicked; public event EventHandler Pressed; public event EventHandler Released; @@ -102,6 +147,7 @@ namespace GraphicsControls } Pressed?.Invoke(this, EventArgs.Empty); + Clicked?.Invoke(this, EventArgs.Empty); } diff --git a/src/GraphicsControls/Controls/Editor/Editor.shared.cs b/src/GraphicsControls/Controls/Editor/Editor.shared.cs index 57bb340..40d484a 100644 --- a/src/GraphicsControls/Controls/Editor/Editor.shared.cs +++ b/src/GraphicsControls/Controls/Editor/Editor.shared.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using System; +using System.ComponentModel; using System.Graphics; using System.Runtime.CompilerServices; using GraphicsControls.Extensions; @@ -87,6 +88,8 @@ namespace GraphicsControls set { SetValue(PlaceholderColorProperty, value); } } + public event EventHandler Completed; + public override void Load() { base.Load(); @@ -244,6 +247,8 @@ namespace GraphicsControls void OnEditorUnfocused(object sender, FocusEventArgs e) { UpdateIsFocused(false); + + Completed?.Invoke(this, EventArgs.Empty); } void FocusInternalEditorIfNeeded() diff --git a/src/GraphicsControls/Controls/IButton.shared.cs b/src/GraphicsControls/Controls/IButton.shared.cs new file mode 100644 index 0000000..c1440d4 --- /dev/null +++ b/src/GraphicsControls/Controls/IButton.shared.cs @@ -0,0 +1,97 @@ +using System; +using System.Windows.Input; +using Xamarin.Forms; + +namespace GraphicsControls +{ + public interface IButton + { + ICommand Command { get; } + object CommandParameter { get; } + bool IsPressed { get; } + + void PropagateUpClicked(); + void PropagateUpPressed(); + void PropagateUpReleased(); + void SetIsPressed(bool isPressed); + void OnCommandCanExecuteChanged(object sender, EventArgs e); + bool IsEnabledCore { set; } + } + + public static class ButtonElement + { + public static readonly BindableProperty CommandProperty = BindableProperty.Create(nameof(IButton.Command), typeof(ICommand), typeof(IButton), null, propertyChanging: OnCommandChanging, propertyChanged: OnCommandChanged); + + public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create(nameof(IButton.CommandParameter), typeof(object), typeof(IButton), null, + propertyChanged: (bindable, oldvalue, newvalue) => CommandCanExecuteChanged(bindable, EventArgs.Empty)); + + static void OnCommandChanged(BindableObject bo, object o, object n) + { + IButton button = (IButton)bo; + if (n is ICommand newCommand) + newCommand.CanExecuteChanged += button.OnCommandCanExecuteChanged; + + CommandChanged(button); + } + + static void OnCommandChanging(BindableObject bo, object o, object n) + { + IButton button = (IButton)bo; + if (o != null) + { + (o as ICommand).CanExecuteChanged -= button.OnCommandCanExecuteChanged; + } + } + + public const string PressedVisualState = "Pressed"; + + public static void CommandChanged(IButton sender) + { + if (sender.Command != null) + { + CommandCanExecuteChanged(sender, EventArgs.Empty); + } + else + { + sender.IsEnabledCore = true; + } + } + + public static void CommandCanExecuteChanged(object sender, EventArgs e) + { + IButton ButtonElementManager = (IButton)sender; + ICommand cmd = ButtonElementManager.Command; + if (cmd != null) + { + ButtonElementManager.IsEnabledCore = cmd.CanExecute(ButtonElementManager.CommandParameter); + } + } + + public static void ElementClicked(Xamarin.Forms.VisualElement visualElement, IButton ButtonElementManager) + { + if (visualElement.IsEnabled == true) + { + ButtonElementManager.Command?.Execute(ButtonElementManager.CommandParameter); + ButtonElementManager.PropagateUpClicked(); + } + } + + public static void ElementPressed(Xamarin.Forms.VisualElement visualElement, IButton ButtonElementManager) + { + if (visualElement.IsEnabled == true) + { + ButtonElementManager.SetIsPressed(true); + ButtonElementManager.PropagateUpPressed(); + } + } + + public static void ElementReleased(Xamarin.Forms.VisualElement visualElement, IButton ButtonElementManager) + { + if (visualElement.IsEnabled == true) + { + ButtonElementManager.SetIsPressed(false); + ButtonElementManager.PropagateUpReleased(); + } + } + } +} \ No newline at end of file diff --git a/src/GraphicsControls/Controls/Slider/Slider.cupertino.shared.cs b/src/GraphicsControls/Controls/Slider/Slider.cupertino.shared.cs index 829cf48..7cf7394 100644 --- a/src/GraphicsControls/Controls/Slider/Slider.cupertino.shared.cs +++ b/src/GraphicsControls/Controls/Slider/Slider.cupertino.shared.cs @@ -1,15 +1,19 @@ using System.Graphics; -using GColor = System.Graphics.Color; +using GraphicsControls.Extensions; namespace GraphicsControls { public partial class Slider { + const string DefaultCupertinoSliderTrackBackgroundColor = "#8E8E93"; + const string DefaultCupertinoSliderTrackProgressColor = "#007AFF"; + const string DefaultCupertinoSliderThumbColor = "#161313"; + void DrawCupertinoSliderTrackBackground(ICanvas canvas, RectangleF dirtyRect) { canvas.SaveState(); - canvas.FillColor = new GColor("#8E8E93"); + canvas.FillColor = MaximumTrackColor.ToGraphicsColor(DefaultCupertinoSliderTrackBackgroundColor); var x = dirtyRect.X; @@ -29,7 +33,7 @@ namespace GraphicsControls { canvas.SaveState(); - canvas.FillColor = new GColor("#007AFF"); + canvas.FillColor = MinimumTrackColor.ToGraphicsColor(DefaultCupertinoSliderTrackProgressColor); var x = dirtyRect.X; @@ -52,7 +56,7 @@ namespace GraphicsControls float size = 28f; float strokeWidth = 0.5f; - canvas.StrokeColor = new GColor("#161313"); + canvas.StrokeColor = ThumbColor.ToGraphicsColor(DefaultCupertinoSliderThumbColor); canvas.StrokeSize = strokeWidth; var value = ((double)Value).Clamp(0, 1); @@ -66,7 +70,7 @@ namespace GraphicsControls var y = (float)((HeightRequest - size) / 2); - canvas.FillColor = Colors.White; + canvas.FillColor = ThumbColor.ToGraphicsColor(Colors.White.ToHex()); canvas.SetShadow(new SizeF(1, 1), 2, CanvasDefaults.DefaultShadowColor); diff --git a/src/GraphicsControls/Controls/Slider/Slider.material.shared.cs b/src/GraphicsControls/Controls/Slider/Slider.material.shared.cs index e806929..5d2e88c 100644 --- a/src/GraphicsControls/Controls/Slider/Slider.material.shared.cs +++ b/src/GraphicsControls/Controls/Slider/Slider.material.shared.cs @@ -1,4 +1,5 @@ using System.Graphics; +using GraphicsControls.Extensions; using Xamarin.Forms; using GColor = System.Graphics.Color; @@ -25,7 +26,7 @@ namespace GraphicsControls { canvas.SaveState(); - canvas.FillColor = new GColor(Fluent.Color.Primary.ThemeLight); + canvas.FillColor = MaximumTrackColor.ToGraphicsColor(Material.Color.LightBlue); var x = dirtyRect.X; @@ -45,7 +46,7 @@ namespace GraphicsControls { canvas.SaveState(); - canvas.FillColor = new GColor(Material.Color.Blue); + canvas.FillColor = MinimumTrackColor.ToGraphicsColor(Material.Color.Blue); var x = dirtyRect.X; @@ -76,7 +77,7 @@ namespace GraphicsControls var y = (float)((HeightRequest - MaterialFloatThumb) / 2); - canvas.FillColor = new GColor(Material.Color.Blue); + canvas.FillColor = ThumbColor.ToGraphicsColor(Material.Color.Blue); canvas.FillOval(x, y, MaterialFloatThumb, MaterialFloatThumb); diff --git a/src/GraphicsControls/Controls/Switch/Switch.fluent.shared.cs b/src/GraphicsControls/Controls/Switch/Switch.fluent.shared.cs index 95ca275..58f76e7 100644 --- a/src/GraphicsControls/Controls/Switch/Switch.fluent.shared.cs +++ b/src/GraphicsControls/Controls/Switch/Switch.fluent.shared.cs @@ -28,7 +28,12 @@ namespace GraphicsControls canvas.SaveState(); if (IsEnabled) - canvas.FillColor = BackgroundColor.ToGraphicsColor(Fluent.Color.Primary.ThemePrimary); + { + if (IsToggled) + canvas.FillColor = OnColor.ToGraphicsColor(Fluent.Color.Primary.ThemePrimary); + else + canvas.FillColor = BackgroundColor.ToGraphicsColor(Fluent.Color.Primary.ThemePrimary); + } else canvas.FillColor = ColorHelper.GetGraphicsColor(Fluent.Color.Background.NeutralLighter, Fluent.Color.Background.NeutralDark); diff --git a/src/GraphicsControls/GraphicsControls.csproj b/src/GraphicsControls/GraphicsControls.csproj index 938846c..b6a651a 100644 --- a/src/GraphicsControls/GraphicsControls.csproj +++ b/src/GraphicsControls/GraphicsControls.csproj @@ -103,7 +103,8 @@ - + All +