Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Fix spaces to tabs indentation to match the coding style #3745

Merged
merged 1 commit into from Sep 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
160 changes: 80 additions & 80 deletions Xamarin.Forms.Platform.GTK/Animations/BaseAnimation.cs
Expand Up @@ -4,84 +4,84 @@

namespace Xamarin.Forms.Platform.GTK.Animations
{
internal abstract class BaseAnimation
{
private const double AnimationInterval = 1000 / 60.0;

private TimeSpan _totalTime;
private Task _animTask;
private Timer _timer;
private DateTime _startTime;
private bool _isEased;
private double _elapsed;
private double _lerp;

public BaseAnimation(TimeSpan time, bool isEased)
{
_totalTime = time;
_isEased = isEased;

_timer = new Timer();
_timer.Interval = AnimationInterval;
_timer.Elapsed += OnTimerElapsed;
}

protected abstract void AnimationStep(double lerp);

private void OnTimerElapsed(object sender, ElapsedEventArgs e)
{
_elapsed = (e.SignalTime - _startTime).TotalMilliseconds;

_lerp = _elapsed / _totalTime.TotalMilliseconds;

if (_isEased)
{
_lerp = SmoothLerp(0, 1, (float)_lerp);
}

AnimationStep(_lerp);
}

protected static float SmoothLerp(float value1, float value2, float amount)
{
float num = Clamp(amount, 0f, 1f);

return Lerp(value1, value2, (num * num) * (3f - (2f * num)));
}

protected static float Clamp(float value, float min, float max)
{
value = (value > max) ? max : value;
value = (value < min) ? min : value;

return value;
}

protected static float Lerp(float value1, float value2, float amount)
{
return value1 + ((value2 - value1) * amount);
}

public async Task Run()
{
if (_animTask != null)
{
// TODO: Cancel or throw exception
}

_startTime = DateTime.Now;
_timer.Start();
_animTask = Task.Delay(_totalTime);
await _animTask;

if (_animTask.Status == TaskStatus.RanToCompletion)
{
_timer.Stop();

AnimationStep(1);
}

_animTask = null;
}
}
internal abstract class BaseAnimation
{
private const double AnimationInterval = 1000 / 60.0;

private TimeSpan _totalTime;
private Task _animTask;
private Timer _timer;
private DateTime _startTime;
private bool _isEased;
private double _elapsed;
private double _lerp;

public BaseAnimation(TimeSpan time, bool isEased)
{
_totalTime = time;
_isEased = isEased;

_timer = new Timer();
_timer.Interval = AnimationInterval;
_timer.Elapsed += OnTimerElapsed;
}

protected abstract void AnimationStep(double lerp);

private void OnTimerElapsed(object sender, ElapsedEventArgs e)
{
_elapsed = (e.SignalTime - _startTime).TotalMilliseconds;

_lerp = _elapsed / _totalTime.TotalMilliseconds;

if (_isEased)
{
_lerp = SmoothLerp(0, 1, (float)_lerp);
}

AnimationStep(_lerp);
}

protected static float SmoothLerp(float value1, float value2, float amount)
{
float num = Clamp(amount, 0f, 1f);

return Lerp(value1, value2, (num * num) * (3f - (2f * num)));
}

protected static float Clamp(float value, float min, float max)
{
value = (value > max) ? max : value;
value = (value < min) ? min : value;

return value;
}

protected static float Lerp(float value1, float value2, float amount)
{
return value1 + ((value2 - value1) * amount);
}

public async Task Run()
{
if (_animTask != null)
{
// TODO: Cancel or throw exception
}

_startTime = DateTime.Now;
_timer.Start();
_animTask = Task.Delay(_totalTime);
await _animTask;

if (_animTask.Status == TaskStatus.RanToCompletion)
{
_timer.Stop();

AnimationStep(1);
}

_animTask = null;
}
}
}
36 changes: 18 additions & 18 deletions Xamarin.Forms.Platform.GTK/Animations/FloatAnimation.cs
Expand Up @@ -2,23 +2,23 @@

namespace Xamarin.Forms.Platform.GTK.Animations
{
internal class FloatAnimation : BaseAnimation
{
private float _from;
private float _to;
private Action<float> _callback;
internal class FloatAnimation : BaseAnimation
{
private float _from;
private float _to;
private Action<float> _callback;

public FloatAnimation(float from, float to, TimeSpan time, bool isEased, Action<float> callback)
: base(time, isEased)
{
_from = from;
_to = to;
_callback = callback;
}
public FloatAnimation(float from, float to, TimeSpan time, bool isEased, Action<float> callback)
: base(time, isEased)
{
_from = from;
_to = to;
_callback = callback;
}

protected override void AnimationStep(double lerp)
{
_callback(Lerp(_from, _to, (float)lerp));
}
}
}
protected override void AnimationStep(double lerp)
{
_callback(Lerp(_from, _to, (float)lerp));
}
}
}