Skip to content

Commit

Permalink
[xam] fix views warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
beto-rodriguez committed Nov 19, 2024
1 parent ef5d97a commit 69bb4fb
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using LiveChartsCore.Kernel.Sketches;
using LiveChartsCore.Measure;
using LiveChartsCore.Motion;
using LiveChartsCore.Painting;
using LiveChartsCore.SkiaSharpView.Drawing;
using LiveChartsCore.SkiaSharpView.SKCharts;
using LiveChartsCore.VisualElements;
Expand Down Expand Up @@ -434,7 +435,7 @@ LvcColor IChartView.BackColor

LvcSize IChartView.ControlSize => new() { Width = (float)canvas.Width, Height = (float)canvas.Height };

/// <inheritdoc cref="IChartView{TDrawingContext}.CoreCanvas" />
/// <inheritdoc cref="IChartView.CoreCanvas" />
public CoreMotionCanvas CoreCanvas => canvas.CanvasCore;

/// <inheritdoc cref="IChartView.SyncContext" />
Expand Down Expand Up @@ -535,21 +536,21 @@ public LegendPosition LegendPosition
set => SetValue(LegendPositionProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.LegendBackgroundPaint" />
/// <inheritdoc cref="IChartView.LegendBackgroundPaint" />
public Paint? LegendBackgroundPaint
{
get => (Paint?)GetValue(LegendBackgroundPaintProperty);
set => SetValue(LegendBackgroundPaintProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.LegendTextPaint" />
/// <inheritdoc cref="IChartView.LegendTextPaint" />
public Paint? LegendTextPaint
{
get => (Paint?)GetValue(LegendTextPaintProperty);
set => SetValue(LegendTextPaintProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.LegendTextSize" />
/// <inheritdoc cref="IChartView.LegendTextSize" />
public double? LegendTextSize
{
get => (double?)GetValue(LegendTextSizeProperty);
Expand Down Expand Up @@ -581,21 +582,21 @@ public FindingStrategy FindingStrategy
set => SetValue(FindingStrategyProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.TooltipBackgroundPaint" />
/// <inheritdoc cref="IChartView.TooltipBackgroundPaint" />
public Paint? TooltipBackgroundPaint
{
get => (Paint?)GetValue(TooltipBackgroundPaintProperty);
set => SetValue(TooltipBackgroundPaintProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.TooltipTextPaint" />
/// <inheritdoc cref="IChartView.TooltipTextPaint" />
public Paint? TooltipTextPaint
{
get => (Paint?)GetValue(TooltipTextPaintProperty);
set => SetValue(TooltipTextPaintProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.TooltipTextSize" />
/// <inheritdoc cref="IChartView.TooltipTextSize" />
public double? TooltipTextSize
{
get => (double?)GetValue(TooltipTextSizeProperty);
Expand All @@ -605,7 +606,7 @@ public double? TooltipTextSize
/// <inheritdoc cref="IChartView{TDrawingContext}.Tooltip" />
public IChartTooltip? Tooltip { get; set; } = new SKDefaultTooltip();

/// <inheritdoc cref="IChartView{TDrawingContext}.AutoUpdateEnabled" />
/// <inheritdoc cref="IChartView.AutoUpdateEnabled" />
public bool AutoUpdateEnabled { get; set; } = true;

/// <inheritdoc cref="IChartView.UpdaterThrottler" />
Expand Down Expand Up @@ -707,10 +708,8 @@ public IEnumerable<IChartElement> GetVisualsAt(LvcPointD point)
: cc.VisualElements.SelectMany(visual => ((VisualElement<SkiaSharpDrawingContext>)visual).IsHitBy(core, new(point)));
}

void IChartView.InvokeOnUIThread(Action action)
{
void IChartView.InvokeOnUIThread(Action action) =>
MainThread.BeginInvokeOnMainThread(action);
}

/// <summary>
/// Initializes the core.
Expand Down Expand Up @@ -751,20 +750,13 @@ protected override void OnParentSet()
core?.Load();
}

private void OnDeepCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
private void OnDeepCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) =>
core?.Update();
}

private void OnDeepCollectionPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
private void OnDeepCollectionPropertyChanged(object? sender, PropertyChangedEventArgs e) =>
core?.Update();
}

private void OnSizeChanged(object? sender, EventArgs e)
{
core?.Update();
}
private void OnSizeChanged(object? sender, EventArgs e) => core?.Update();

private void PanGestureRecognizer_PanUpdated(object? sender, PanUpdatedEventArgs e)
{
Expand Down Expand Up @@ -821,10 +813,7 @@ private void PinchGestureRecognizer_PinchUpdated(object? sender, PinchGestureUpd
c.Zoom(pivot, ZoomDirection.DefinedByScaleFactor, _lastScale < 1 ? 0.99999 : 1.00001, false);
}

private void OnCoreUpdateFinished(IChartView<SkiaSharpDrawingContext> chart)
{
UpdateFinished?.Invoke(this);
}
private void OnCoreUpdateFinished(IChartView<SkiaSharpDrawingContext> chart) => UpdateFinished?.Invoke(this);

private void OnCoreUpdateStarted(IChartView<SkiaSharpDrawingContext> chart)
{
Expand Down Expand Up @@ -869,10 +858,7 @@ private void OnTooltipTimerEllapsed(object sender, ElapsedEventArgs e)
});
}

private void OnCoreMeasuring(IChartView<SkiaSharpDrawingContext> chart)
{
Measuring?.Invoke(this);
}
private void OnCoreMeasuring(IChartView<SkiaSharpDrawingContext> chart) => Measuring?.Invoke(this);

void IChartView.OnDataPointerDown(IEnumerable<ChartPoint> points, LvcPoint pointer)
{
Expand All @@ -894,11 +880,8 @@ void IChartView<SkiaSharpDrawingContext>.OnVisualElementPointerDown(
VisualElementsPointerDownCommand.Execute(args);
}

void IChartView.Invalidate()
{
CoreCanvas.Invalidate();
}
void IChartView.Invalidate() => CoreCanvas.Invalidate();

public void OnHoveredPointsChanged(IEnumerable<ChartPoint>? newItems, IEnumerable<ChartPoint>? oldItems) =>
throw new NotImplementedException();
public void OnHoveredPointsChanged(IEnumerable<ChartPoint>? newItems, IEnumerable<ChartPoint>? oldItems)
{ }
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
using LiveChartsCore.Drawing;
using LiveChartsCore.Geo;
using LiveChartsCore.Kernel;
using LiveChartsCore.Kernel.Events;
using LiveChartsCore.Measure;
using LiveChartsCore.Motion;
using LiveChartsCore.Painting;
using LiveChartsCore.SkiaSharpView.Drawing;
using LiveChartsCore.SkiaSharpView.Painting;
using SkiaSharp;
Expand All @@ -47,7 +47,7 @@ namespace LiveChartsCore.SkiaSharpView.Xamarin.Forms;
public partial class GeoMap : ContentView, IGeoMapView<SkiaSharpDrawingContext>
{
private readonly GeoMap<SkiaSharpDrawingContext> _core;
private CollectionDeepObserver<IGeoSeries> _seriesObserver;
private readonly CollectionDeepObserver<IGeoSeries> _seriesObserver;

/// <summary>
/// Initializes a new instance of the <see cref="GeoMap"/> class.
Expand Down Expand Up @@ -132,7 +132,7 @@ public GeoMap()
public static readonly BindableProperty FillProperty =
BindableProperty.Create(
nameof(Fill), typeof(Paint), typeof(GeoMap),
new SolidColorPaint(new SKColor(240, 240, 240, 255)) { IsFill = true },
new SolidColorPaint(new SKColor(240, 240, 240, 255)) { IsStroke = false },
BindingMode.Default, null, OnBindablePropertyChanged);

/// <summary>
Expand Down Expand Up @@ -215,7 +215,7 @@ public Paint? Fill
get => (Paint)GetValue(FillProperty);
set
{
if (value is not null) value.IsFill = true;
if (value is not null) value.IsStroke = false;
SetValue(FillProperty, value);
}
}
Expand All @@ -240,15 +240,11 @@ protected override void OnParentSet()
}
}

void IGeoMapView<SkiaSharpDrawingContext>.InvokeOnUIThread(Action action)
{
void IGeoMapView<SkiaSharpDrawingContext>.InvokeOnUIThread(Action action) =>
MainThread.BeginInvokeOnMainThread(action);
}

private void GeoMap_SizeChanged(object sender, EventArgs e)
{
private void GeoMap_SizeChanged(object sender, EventArgs e) =>
_core?.Update();
}

private void PanGestureRecognizer_PanUpdated(object? sender, PanUpdatedEventArgs e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using LiveChartsCore.Drawing;
using LiveChartsCore.Kernel;
using LiveChartsCore.Motion;
using LiveChartsCore.Painting;
using LiveChartsCore.SkiaSharpView.Drawing;
using SkiaSharp.Views.Forms;
using Xamarin.Essentials;
Expand Down Expand Up @@ -55,7 +56,7 @@ public MotionCanvas()
/// The paint tasks property
/// </summary>
public static readonly BindableProperty PaintTasksProperty = BindableProperty.Create(
nameof(PaintTasks), typeof(List<PaintSchedule<SkiaSharpDrawingContext>>),
nameof(PaintTasks), typeof(List<PaintSchedule>),
typeof(MotionCanvas), propertyChanged: PaintTasksChanged);

/// <summary>
Expand All @@ -80,9 +81,9 @@ public MotionCanvas()
/// <value>
/// The paint tasks.
/// </value>
public List<PaintSchedule<SkiaSharpDrawingContext>> PaintTasks
public List<PaintSchedule> PaintTasks
{
get => (List<PaintSchedule<SkiaSharpDrawingContext>>)GetValue(PaintTasksProperty);
get => (List<PaintSchedule>)GetValue(PaintTasksProperty);
set => SetValue(PaintTasksProperty, value);
}

Expand All @@ -98,10 +99,8 @@ public List<PaintSchedule<SkiaSharpDrawingContext>> PaintTasks
/// Invalidates this instance.
/// </summary>
/// <returns></returns>
public void Invalidate()
{
public void Invalidate() =>
MainThread.BeginInvokeOnMainThread(RunDrawingLoop);
}

/// <inheritdoc cref="NavigableElement.OnParentSet"/>
protected override void OnParentSet()
Expand Down Expand Up @@ -131,10 +130,8 @@ private void OnGlViewPaintSurface(object sender, SKPaintGLSurfaceEventArgs args)
CanvasCore.DrawFrame(new SkiaSharpDrawingContext(CanvasCore, new SkiaSharp.SKImageInfo((int)Width, (int)Height), args.Surface, args.Surface.Canvas));
}

private void OnCanvasCoreInvalidated(CoreMotionCanvas sender)
{
private void OnCanvasCoreInvalidated(CoreMotionCanvas sender) =>
Invalidate();
}

private void InitializeView()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
using LiveChartsCore.Kernel.Sketches;
using LiveChartsCore.Measure;
using LiveChartsCore.Motion;
using LiveChartsCore.Painting;
using LiveChartsCore.SkiaSharpView.Drawing;
using LiveChartsCore.SkiaSharpView.SKCharts;
using LiveChartsCore.VisualElements;
Expand Down Expand Up @@ -376,7 +377,7 @@ public object SyncContext

LvcSize IChartView.ControlSize => new() { Width = (float)canvas.Width, Height = (float)canvas.Height };

/// <inheritdoc cref="IChartView{TDrawingContext}.CoreCanvas" />
/// <inheritdoc cref="IChartView.CoreCanvas" />
public CoreMotionCanvas CoreCanvas => canvas.CanvasCore;

/// <inheritdoc cref="IChartView.DrawMargin" />
Expand Down Expand Up @@ -463,21 +464,21 @@ public LegendPosition LegendPosition
set => SetValue(LegendPositionProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.LegendBackgroundPaint" />
/// <inheritdoc cref="IChartView.LegendBackgroundPaint" />
public Paint? LegendBackgroundPaint
{
get => (Paint?)GetValue(LegendBackgroundPaintProperty);
set => SetValue(LegendBackgroundPaintProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.LegendTextPaint" />
/// <inheritdoc cref="IChartView.LegendTextPaint" />
public Paint? LegendTextPaint
{
get => (Paint?)GetValue(LegendTextPaintProperty);
set => SetValue(LegendTextPaintProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.LegendTextSize" />
/// <inheritdoc cref="IChartView.LegendTextSize" />
public double? LegendTextSize
{
get => (double?)GetValue(LegendTextSizeProperty);
Expand All @@ -494,21 +495,21 @@ public TooltipPosition TooltipPosition
set => SetValue(TooltipPositionProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.TooltipBackgroundPaint" />
/// <inheritdoc cref="IChartView.TooltipBackgroundPaint" />
public Paint? TooltipBackgroundPaint
{
get => (Paint?)GetValue(TooltipBackgroundPaintProperty);
set => SetValue(TooltipBackgroundPaintProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.TooltipTextPaint" />
/// <inheritdoc cref="IChartView.TooltipTextPaint" />
public Paint? TooltipTextPaint
{
get => (Paint?)GetValue(TooltipTextPaintProperty);
set => SetValue(TooltipTextPaintProperty, value);
}

/// <inheritdoc cref="IChartView{TDrawingContext}.TooltipTextSize" />
/// <inheritdoc cref="IChartView.TooltipTextSize" />
public double? TooltipTextSize
{
get => (double?)GetValue(TooltipTextSizeProperty);
Expand All @@ -518,7 +519,7 @@ public double? TooltipTextSize
/// <inheritdoc cref="IChartView{TDrawingContext}.Tooltip" />
public IChartTooltip? Tooltip { get; set; } = new SKDefaultTooltip();

/// <inheritdoc cref="IChartView{TDrawingContext}.AutoUpdateEnabled" />
/// <inheritdoc cref="IChartView.AutoUpdateEnabled" />
public bool AutoUpdateEnabled { get; set; } = true;

/// <inheritdoc cref="IChartView.UpdaterThrottler" />
Expand Down Expand Up @@ -599,10 +600,8 @@ public IEnumerable<IChartElement> GetVisualsAt(LvcPointD point)
: cc.VisualElements.SelectMany(visual => ((VisualElement<SkiaSharpDrawingContext>)visual).IsHitBy(core, new(point)));
}

void IChartView.InvokeOnUIThread(Action action)
{
void IChartView.InvokeOnUIThread(Action action) =>
MainThread.BeginInvokeOnMainThread(action);
}

/// <summary>
/// Initializes the core.
Expand Down Expand Up @@ -679,10 +678,7 @@ private void OnTooltipTimerEllapsed(object sender, ElapsedEventArgs e)
});
}

private void OnCoreUpdateFinished(IChartView<SkiaSharpDrawingContext> chart)
{
UpdateFinished?.Invoke(this);
}
private void OnCoreUpdateFinished(IChartView<SkiaSharpDrawingContext> chart) => UpdateFinished?.Invoke(this);

private void OnCoreUpdateStarted(IChartView<SkiaSharpDrawingContext> chart)
{
Expand All @@ -695,10 +691,7 @@ private void OnCoreUpdateStarted(IChartView<SkiaSharpDrawingContext> chart)
UpdateStarted?.Invoke(this);
}

private void OnCoreMeasuring(IChartView<SkiaSharpDrawingContext> chart)
{
Measuring?.Invoke(this);
}
private void OnCoreMeasuring(IChartView<SkiaSharpDrawingContext> chart) => Measuring?.Invoke(this);

void IChartView.OnDataPointerDown(IEnumerable<ChartPoint> points, LvcPoint pointer)
{
Expand All @@ -710,8 +703,8 @@ void IChartView.OnDataPointerDown(IEnumerable<ChartPoint> points, LvcPoint point
if (ChartPointPointerDownCommand is not null && ChartPointPointerDownCommand.CanExecute(closest)) ChartPointPointerDownCommand.Execute(closest);
}

public void OnHoveredPointsChanged(IEnumerable<ChartPoint>? newItems, IEnumerable<ChartPoint>? oldItems) =>
throw new NotImplementedException();
public void OnHoveredPointsChanged(IEnumerable<ChartPoint>? newItems, IEnumerable<ChartPoint>? oldItems)
{ }

void IChartView<SkiaSharpDrawingContext>.OnVisualElementPointerDown(
IEnumerable<VisualElement<SkiaSharpDrawingContext>> visualElements, LvcPoint pointer)
Expand All @@ -723,8 +716,5 @@ void IChartView<SkiaSharpDrawingContext>.OnVisualElementPointerDown(
VisualElementsPointerDownCommand.Execute(args);
}

void IChartView.Invalidate()
{
CoreCanvas.Invalidate();
}
void IChartView.Invalidate() => CoreCanvas.Invalidate();
}
Loading

0 comments on commit 69bb4fb

Please sign in to comment.