Prettified fast locking of voice record.

This commit is contained in:
23rd 2020-10-12 17:40:37 +03:00 committed by John Preston
parent 57eb4f8234
commit 367b487a6c
1 changed files with 18 additions and 1 deletions

View File

@ -110,8 +110,11 @@ private:
void init();
void drawProgress(Painter &p);
void setProgress(float64 progress);
void startLockingAnimation(float64 to);
Ui::Animations::Simple _lockAnimation;
Ui::Animations::Simple _lockEnderAnimation;
rpl::variable<float64> _progress = 0.;
};
@ -381,10 +384,24 @@ void RecordLock::drawProgress(Painter &p) {
}
}
void RecordLock::startLockingAnimation(float64 to) {
auto callback = [=](auto value) { setProgress(value); };
const auto duration = st::historyRecordVoiceShowDuration;
_lockEnderAnimation.start(std::move(callback), 0., to, duration);
}
void RecordLock::requestPaintProgress(float64 progress) {
if (isHidden() || isLocked()) {
if (isHidden() || isLocked() || _lockEnderAnimation.animating()) {
return;
}
if (!_progress.current() && (progress > .3)) {
startLockingAnimation(progress);
return;
}
setProgress(progress);
}
void RecordLock::setProgress(float64 progress) {
_progress = progress;
update();
}