Skip to content

Commit

Permalink
Fix spaces to tabs indentation to match the coding style (xamarin#3745)
Browse files Browse the repository at this point in the history
  • Loading branch information
ylatuya authored and adrianknight89 committed Sep 24, 2018
1 parent b8fc57f commit 5bec882
Show file tree
Hide file tree
Showing 115 changed files with 12,880 additions and 12,880 deletions.
160 changes: 80 additions & 80 deletions Xamarin.Forms.Platform.GTK/Animations/BaseAnimation.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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));
}
}
}
Loading

0 comments on commit 5bec882

Please sign in to comment.