mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
Added share label and buttons to boost info.
This commit is contained in:
parent
0aa1cd0b52
commit
8041941565
2 changed files with 54 additions and 3 deletions
|
@ -8,14 +8,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "info/boosts/info_boosts_inner_widget.h"
|
||||
|
||||
#include "api/api_statistics.h"
|
||||
#include "boxes/peers/edit_peer_invite_link.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "settings/settings_common.h"
|
||||
#include "statistics/widgets/chart_header_widget.h"
|
||||
#include "ui/boxes/boost_box.h"
|
||||
#include "ui/controls/invite_link_buttons.h"
|
||||
#include "ui/controls/invite_link_label.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "styles/style_info.h"
|
||||
#include "styles/style_statistics.h"
|
||||
|
||||
#include <QtGui/QGuiApplication>
|
||||
|
||||
namespace Info::Boosts {
|
||||
namespace {
|
||||
|
||||
|
@ -133,6 +140,37 @@ void FillOverview(
|
|||
::Settings::AddSkip(content, st::statisticsLayerOverviewMargins.bottom());
|
||||
}
|
||||
|
||||
void FillShareLink(
|
||||
not_null<Ui::VerticalLayout*> content,
|
||||
std::shared_ptr<Ui::Show> show,
|
||||
const QString &link,
|
||||
not_null<PeerData*> peer) {
|
||||
const auto weak = Ui::MakeWeak(content);
|
||||
const auto copyLink = crl::guard(weak, [=] {
|
||||
QGuiApplication::clipboard()->setText(link);
|
||||
show->showToast(tr::lng_channel_public_link_copied(tr::now));
|
||||
});
|
||||
const auto shareLink = crl::guard(weak, [=] {
|
||||
show->showBox(ShareInviteLinkBox(peer, link));
|
||||
});
|
||||
|
||||
const auto label = content->lifetime().make_state<Ui::InviteLinkLabel>(
|
||||
content,
|
||||
rpl::single(link),
|
||||
nullptr);
|
||||
content->add(
|
||||
label->take(),
|
||||
st::inviteLinkFieldPadding);
|
||||
|
||||
label->clicks(
|
||||
) | rpl::start_with_next(copyLink, label->lifetime());
|
||||
const auto copyShareWrap = content->add(
|
||||
object_ptr<Ui::VerticalLayout>(content));
|
||||
Ui::AddCopyShareLinkButtons(copyShareWrap, copyLink, shareLink);
|
||||
copyShareWrap->widgetAt(0)->showChildren();
|
||||
::Settings::AddSkip(content, st::inviteLinkFieldPadding.bottom());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
InnerWidget::InnerWidget(
|
||||
|
@ -141,7 +179,8 @@ InnerWidget::InnerWidget(
|
|||
not_null<PeerData*> peer)
|
||||
: VerticalLayout(parent)
|
||||
, _controller(controller)
|
||||
, _peer(peer) {
|
||||
, _peer(peer)
|
||||
, _show(controller->uiShow()) {
|
||||
const auto api = lifetime().make_state<Api::Boosts>(peer);
|
||||
|
||||
const auto fakeShowed = lifetime().make_state<rpl::event_stream<>>();
|
||||
|
@ -152,11 +191,12 @@ InnerWidget::InnerWidget(
|
|||
) | rpl::start_with_error_done([](const QString &error) {
|
||||
}, [=] {
|
||||
const auto status = api->boostStatus();
|
||||
const auto inner = this;
|
||||
|
||||
Ui::FillBoostLimit(
|
||||
fakeShowed->events(),
|
||||
rpl::single(status.overview.isBoosted),
|
||||
this,
|
||||
inner,
|
||||
Ui::BoostBoxData{
|
||||
.boost = Ui::BoostCounters{
|
||||
.level = status.overview.level,
|
||||
|
@ -169,7 +209,13 @@ InnerWidget::InnerWidget(
|
|||
}
|
||||
});
|
||||
|
||||
FillOverview(this, status);
|
||||
FillOverview(inner, status);
|
||||
|
||||
::Settings::AddSkip(inner);
|
||||
AddHeader(inner, tr::lng_boosts_link_title);
|
||||
FillShareLink(inner, _show, status.link, peer);
|
||||
::Settings::AddSkip(inner);
|
||||
::Settings::AddDividerText(inner, tr::lng_boosts_link_subtext());
|
||||
|
||||
resizeToWidth(width());
|
||||
crl::on_main([=]{ fakeShowed->fire({}); });
|
||||
|
|
|
@ -10,6 +10,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/scroll_area.h"
|
||||
#include "ui/wrap/vertical_layout.h"
|
||||
|
||||
namespace Ui {
|
||||
class Show;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Info {
|
||||
class Controller;
|
||||
} // namespace Info
|
||||
|
@ -38,6 +42,7 @@ public:
|
|||
private:
|
||||
not_null<Controller*> _controller;
|
||||
not_null<PeerData*> _peer;
|
||||
std::shared_ptr<Ui::Show> _show;
|
||||
|
||||
rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
|
||||
rpl::event_stream<ShowRequest> _showRequests;
|
||||
|
|
Loading…
Add table
Reference in a new issue