Skip to content

Commit df93b6b

Browse files
committed
Fix animation repeating code
1 parent 3619d99 commit df93b6b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Calendar.Plugin/Shared/Controls/MonthDaysView.xaml.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public Style DaysTitleLabelStyle
193193
private readonly List<DayView> _dayViews = new List<DayView>();
194194
private DayModel _selectedDay;
195195
private bool _animating;
196+
private DateTime _lastAnimationTime;
196197

197198
internal MonthDaysView()
198199
{
@@ -269,7 +270,7 @@ internal void UpdateDays()
269270
Animate(() => daysControl.FadeTo(0, 50),
270271
() => daysControl.FadeTo(1, 200),
271272
() => LoadDays(),
272-
() => Year * 100 + Month,
273+
_lastAnimationTime = DateTime.UtcNow,
273274
() => UpdateDays());
274275
}
275276

@@ -372,8 +373,6 @@ private void LoadDays()
372373
foreach (var dayView in _dayViews)
373374
{
374375
var currentDate = monthStart.AddDays(addDays++);
375-
376-
// TODO: add indicator for current date (outline circle)
377376
var dayModel = dayView.BindingContext as DayModel;
378377

379378
dayModel.Date = currentDate.Date;
@@ -390,7 +389,7 @@ private void Animate(
390389
Func<Task> animationIn,
391390
Func<Task> animationOut,
392391
Action afterFirstAnimation,
393-
Func<int> stateGetter,
392+
DateTime animationTime,
394393
Action callAgain)
395394
{
396395
if (_animating)
@@ -400,14 +399,13 @@ private void Animate(
400399

401400
animationIn().ContinueWith(aIn =>
402401
{
403-
var prevState = stateGetter();
404402
afterFirstAnimation();
405403

406404
animationOut().ContinueWith(aOut =>
407405
{
408406
_animating = false;
409407

410-
if (stateGetter() != prevState)
408+
if (animationTime != _lastAnimationTime)
411409
callAgain();
412410
}, TaskScheduler.FromCurrentSynchronizationContext());
413411
}, TaskScheduler.FromCurrentSynchronizationContext());

0 commit comments

Comments
 (0)