Added share label and buttons to boost info.
This commit is contained in:
parent
0aa1cd0b52
commit
8041941565
|
@ -8,14 +8,21 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "info/boosts/info_boosts_inner_widget.h"
|
#include "info/boosts/info_boosts_inner_widget.h"
|
||||||
|
|
||||||
#include "api/api_statistics.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 "lang/lang_keys.h"
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
#include "statistics/widgets/chart_header_widget.h"
|
#include "statistics/widgets/chart_header_widget.h"
|
||||||
#include "ui/boxes/boost_box.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/rect.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
|
#include "styles/style_info.h"
|
||||||
#include "styles/style_statistics.h"
|
#include "styles/style_statistics.h"
|
||||||
|
|
||||||
|
#include <QtGui/QGuiApplication>
|
||||||
|
|
||||||
namespace Info::Boosts {
|
namespace Info::Boosts {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -133,6 +140,37 @@ void FillOverview(
|
||||||
::Settings::AddSkip(content, st::statisticsLayerOverviewMargins.bottom());
|
::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
|
} // namespace
|
||||||
|
|
||||||
InnerWidget::InnerWidget(
|
InnerWidget::InnerWidget(
|
||||||
|
@ -141,7 +179,8 @@ InnerWidget::InnerWidget(
|
||||||
not_null<PeerData*> peer)
|
not_null<PeerData*> peer)
|
||||||
: VerticalLayout(parent)
|
: VerticalLayout(parent)
|
||||||
, _controller(controller)
|
, _controller(controller)
|
||||||
, _peer(peer) {
|
, _peer(peer)
|
||||||
|
, _show(controller->uiShow()) {
|
||||||
const auto api = lifetime().make_state<Api::Boosts>(peer);
|
const auto api = lifetime().make_state<Api::Boosts>(peer);
|
||||||
|
|
||||||
const auto fakeShowed = lifetime().make_state<rpl::event_stream<>>();
|
const auto fakeShowed = lifetime().make_state<rpl::event_stream<>>();
|
||||||
|
@ -152,11 +191,12 @@ InnerWidget::InnerWidget(
|
||||||
) | rpl::start_with_error_done([](const QString &error) {
|
) | rpl::start_with_error_done([](const QString &error) {
|
||||||
}, [=] {
|
}, [=] {
|
||||||
const auto status = api->boostStatus();
|
const auto status = api->boostStatus();
|
||||||
|
const auto inner = this;
|
||||||
|
|
||||||
Ui::FillBoostLimit(
|
Ui::FillBoostLimit(
|
||||||
fakeShowed->events(),
|
fakeShowed->events(),
|
||||||
rpl::single(status.overview.isBoosted),
|
rpl::single(status.overview.isBoosted),
|
||||||
this,
|
inner,
|
||||||
Ui::BoostBoxData{
|
Ui::BoostBoxData{
|
||||||
.boost = Ui::BoostCounters{
|
.boost = Ui::BoostCounters{
|
||||||
.level = status.overview.level,
|
.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());
|
resizeToWidth(width());
|
||||||
crl::on_main([=]{ fakeShowed->fire({}); });
|
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/widgets/scroll_area.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class Show;
|
||||||
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Info {
|
namespace Info {
|
||||||
class Controller;
|
class Controller;
|
||||||
} // namespace Info
|
} // namespace Info
|
||||||
|
@ -38,6 +42,7 @@ public:
|
||||||
private:
|
private:
|
||||||
not_null<Controller*> _controller;
|
not_null<Controller*> _controller;
|
||||||
not_null<PeerData*> _peer;
|
not_null<PeerData*> _peer;
|
||||||
|
std::shared_ptr<Ui::Show> _show;
|
||||||
|
|
||||||
rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
|
rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
|
||||||
rpl::event_stream<ShowRequest> _showRequests;
|
rpl::event_stream<ShowRequest> _showRequests;
|
||||||
|
|
Loading…
Reference in New Issue