mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added simple label for loading state to giveaway box.
This commit is contained in:
parent
d2d69a7a36
commit
d8e38b43d9
2 changed files with 103 additions and 76 deletions
|
@ -56,7 +56,8 @@ void CreateGiveawayBox(
|
|||
not_null<Ui::GenericBox*> box,
|
||||
not_null<Info::Controller*> controller,
|
||||
not_null<PeerData*> peer) {
|
||||
{
|
||||
box->setWidth(st::boxWideWidth);
|
||||
|
||||
const auto bar = box->verticalLayout()->add(
|
||||
object_ptr<Ui::Premium::TopBar>(
|
||||
box,
|
||||
|
@ -65,6 +66,8 @@ void CreateGiveawayBox(
|
|||
tr::lng_giveaway_new_title(),
|
||||
tr::lng_giveaway_new_about(Ui::Text::RichLangValue),
|
||||
true));
|
||||
{
|
||||
bar->setPaused(true);
|
||||
bar->setMaximumHeight(st::giveawayGiftCodeTopHeight);
|
||||
bar->setMinimumHeight(st::infoLayerTopBarHeight);
|
||||
bar->resize(bar->width(), bar->maximumHeight());
|
||||
|
@ -109,10 +112,33 @@ void CreateGiveawayBox(
|
|||
const auto state = box->lifetime().make_state<State>(peer);
|
||||
const auto typeGroup = std::make_shared<GiveawayGroup>();
|
||||
|
||||
box->setWidth(st::boxWideWidth);
|
||||
const auto loading = box->addRow(
|
||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
box,
|
||||
object_ptr<Ui::VerticalLayout>(box)));
|
||||
{
|
||||
loading->toggle(true, anim::type::instant);
|
||||
const auto container = loading->entity();
|
||||
Settings::AddSkip(container);
|
||||
Settings::AddSkip(container);
|
||||
container->add(
|
||||
object_ptr<Ui::CenterWrap<Ui::FlatLabel>>(
|
||||
box,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
box,
|
||||
tr::lng_contacts_loading(),
|
||||
st::giveawayLoadingLabel)));
|
||||
Settings::AddSkip(container);
|
||||
Settings::AddSkip(container);
|
||||
}
|
||||
const auto contentWrap = box->verticalLayout()->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
box,
|
||||
object_ptr<Ui::VerticalLayout>(box)));
|
||||
contentWrap->toggle(false, anim::type::instant);
|
||||
|
||||
{
|
||||
const auto row = box->verticalLayout()->add(
|
||||
const auto row = contentWrap->entity()->add(
|
||||
object_ptr<Giveaway::GiveawayTypeRow>(
|
||||
box,
|
||||
GiveawayType::Random,
|
||||
|
@ -123,7 +149,7 @@ void CreateGiveawayBox(
|
|||
});
|
||||
}
|
||||
{
|
||||
const auto row = box->verticalLayout()->add(
|
||||
const auto row = contentWrap->entity()->add(
|
||||
object_ptr<Giveaway::GiveawayTypeRow>(
|
||||
box,
|
||||
GiveawayType::SpecificUsers,
|
||||
|
@ -170,13 +196,13 @@ void CreateGiveawayBox(
|
|||
});
|
||||
}
|
||||
|
||||
Settings::AddSkip(box->verticalLayout());
|
||||
Settings::AddDivider(box->verticalLayout());
|
||||
Settings::AddSkip(box->verticalLayout());
|
||||
Settings::AddSkip(contentWrap->entity());
|
||||
Settings::AddDivider(contentWrap->entity());
|
||||
Settings::AddSkip(contentWrap->entity());
|
||||
|
||||
const auto randomWrap = box->verticalLayout()->add(
|
||||
const auto randomWrap = contentWrap->entity()->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
box,
|
||||
contentWrap,
|
||||
object_ptr<Ui::VerticalLayout>(box)));
|
||||
state->typeValue.value(
|
||||
) | rpl::start_with_next([=](GiveawayType type) {
|
||||
|
@ -186,9 +212,6 @@ void CreateGiveawayBox(
|
|||
const auto sliderContainer = randomWrap->entity()->add(
|
||||
object_ptr<Ui::VerticalLayout>(randomWrap));
|
||||
const auto fillSliderContainer = [=] {
|
||||
if (sliderContainer->count()) {
|
||||
return;
|
||||
}
|
||||
const auto availablePresets = state->apiOptions.availablePresets();
|
||||
if (availablePresets.empty()) {
|
||||
return;
|
||||
|
@ -465,11 +488,9 @@ void CreateGiveawayBox(
|
|||
}
|
||||
|
||||
const auto durationGroup = std::make_shared<Ui::RadiobuttonGroup>(0);
|
||||
{
|
||||
const auto listOptions = box->verticalLayout()->add(
|
||||
const auto listOptions = contentWrap->entity()->add(
|
||||
object_ptr<Ui::VerticalLayout>(box));
|
||||
const auto rebuildListOptions = [=](int amountUsers) {
|
||||
fillSliderContainer();
|
||||
while (listOptions->count()) {
|
||||
delete listOptions->widgetAt(0);
|
||||
}
|
||||
|
@ -506,30 +527,17 @@ void CreateGiveawayBox(
|
|||
|
||||
box->verticalLayout()->resizeToWidth(box->width());
|
||||
};
|
||||
{
|
||||
|
||||
rpl::combine(
|
||||
state->sliderValue.value(),
|
||||
state->typeValue.value()
|
||||
) | rpl::start_with_next([=](int users, GiveawayType type) {
|
||||
typeGroup->setValue(type);
|
||||
const auto rebuild = [=] {
|
||||
rebuildListOptions((type == GiveawayType::SpecificUsers)
|
||||
? state->selectedToAward.size()
|
||||
: users);
|
||||
};
|
||||
if (!listOptions->count()) {
|
||||
state->lifetimeApi = state->apiOptions.request(
|
||||
) | rpl::start_with_error_done([=](const QString &error) {
|
||||
}, rebuild);
|
||||
} else {
|
||||
rebuild();
|
||||
}
|
||||
}, box->lifetime());
|
||||
state->lifetimeApi = state->apiOptions.request(
|
||||
) | rpl::start_with_error_done([=](const QString &error) {
|
||||
}, [=] {
|
||||
rebuildListOptions(1);
|
||||
});
|
||||
}
|
||||
{
|
||||
// TODO mini-icon.
|
||||
|
@ -603,4 +611,21 @@ void CreateGiveawayBox(
|
|||
box->addButton(std::move(button));
|
||||
}
|
||||
state->typeValue.force_assign(GiveawayType::Random);
|
||||
|
||||
box->setShowFinishedCallback([=] {
|
||||
if (!loading->toggled()) {
|
||||
return;
|
||||
}
|
||||
bar->setPaused(false);
|
||||
state->lifetimeApi = state->apiOptions.request(
|
||||
) | rpl::start_with_error_done([=](const QString &error) {
|
||||
}, [=] {
|
||||
state->lifetimeApi.destroy();
|
||||
loading->toggle(false, anim::type::instant);
|
||||
fillSliderContainer();
|
||||
rebuildListOptions(1);
|
||||
contentWrap->toggle(true, anim::type::instant);
|
||||
contentWrap->resizeToWidth(box->width());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -277,6 +277,8 @@ boostReplaceIconOutline: 2px;
|
|||
boostReplaceIconAdd: point(4px, 2px);
|
||||
boostReplaceArrow: icon{{ "mediaview/next", windowSubTextFg }};
|
||||
|
||||
giveawayLoadingLabel: FlatLabel(membersAbout) {
|
||||
}
|
||||
giveawayGiftCodeTopHeight: 195px;
|
||||
giveawayGiftCodeLink: FlatLabel(defaultFlatLabel) {
|
||||
margin: margins(10px, 12px, 10px, 8px);
|
||||
|
|
Loading…
Add table
Reference in a new issue