mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Slightly improved ripple animation for button to gift credits.
This commit is contained in:
parent
08df3b2dff
commit
706f142a98
1 changed files with 42 additions and 10 deletions
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "settings/settings_credits.h"
|
#include "settings/settings_credits.h"
|
||||||
|
|
||||||
#include "api/api_credits.h"
|
#include "api/api_credits.h"
|
||||||
|
#include "base/call_delayed.h"
|
||||||
#include "boxes/star_gift_box.h"
|
#include "boxes/star_gift_box.h"
|
||||||
#include "boxes/gift_credits_box.h"
|
#include "boxes/gift_credits_box.h"
|
||||||
#include "boxes/gift_premium_box.h"
|
#include "boxes/gift_premium_box.h"
|
||||||
|
@ -43,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
#include "styles/style_chat_helpers.h"
|
||||||
#include "styles/style_credits.h"
|
#include "styles/style_credits.h"
|
||||||
#include "styles/style_giveaway.h"
|
#include "styles/style_giveaway.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
|
@ -500,16 +502,46 @@ void Credits::setupContent() {
|
||||||
|
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
|
|
||||||
const auto gift = content->add(
|
{
|
||||||
object_ptr<Ui::RoundButton>(
|
const auto &giftSt = st::creditsSettingsBigBalanceButtonGift;
|
||||||
content,
|
const auto giftDelay = giftSt.ripple.hideDuration * 2;
|
||||||
tr::lng_credits_gift_button(),
|
const auto fakeLoading
|
||||||
st::creditsSettingsBigBalanceButtonGift),
|
= content->lifetime().make_state<rpl::variable<bool>>(false);
|
||||||
st::boxRowPadding);
|
const auto gift = content->add(
|
||||||
gift->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
|
object_ptr<Ui::RoundButton>(
|
||||||
gift->setClickedCallback([=, controller = _controller] {
|
content,
|
||||||
Ui::ShowGiftCreditsBox(controller, paid);
|
rpl::conditional(
|
||||||
});
|
fakeLoading->value(),
|
||||||
|
rpl::single(QString()),
|
||||||
|
tr::lng_credits_gift_button()),
|
||||||
|
giftSt),
|
||||||
|
st::boxRowPadding);
|
||||||
|
gift->setTextTransform(Ui::RoundButton::TextTransform::NoTransform);
|
||||||
|
gift->setClickedCallback([=, controller = _controller] {
|
||||||
|
if (fakeLoading->current()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*fakeLoading = true;
|
||||||
|
base::call_delayed(giftDelay, crl::guard(gift, [=] {
|
||||||
|
*fakeLoading = false;
|
||||||
|
Ui::ShowGiftCreditsBox(controller, paid);
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
{
|
||||||
|
using namespace Info::Statistics;
|
||||||
|
const auto loadingAnimation = InfiniteRadialAnimationWidget(
|
||||||
|
gift,
|
||||||
|
gift->height() / 2,
|
||||||
|
&st::editStickerSetNameLoading);
|
||||||
|
AddChildToWidgetCenter(gift, loadingAnimation);
|
||||||
|
loadingAnimation->showOn(fakeLoading->value());
|
||||||
|
}
|
||||||
|
gift->widthValue() | rpl::filter([=] {
|
||||||
|
return (gift->widthNoMargins() != (content->width() - paddings));
|
||||||
|
}) | rpl::start_with_next([=] {
|
||||||
|
gift->resizeToWidth(content->width() - paddings);
|
||||||
|
}, gift->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
Ui::AddSkip(content);
|
Ui::AddSkip(content);
|
||||||
|
|
Loading…
Add table
Reference in a new issue