From a45a9e65158c22aa762a4ce899c7073881b11ca8 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 20 Mar 2024 01:02:36 +0300 Subject: [PATCH] Added initial learn about as divider text to channel earn info section. --- .../earn/channel_earn.style | 11 ++++ .../earn/info_earn_inner_widget.cpp | 51 ++++++++++++++++++- Telegram/cmake/td_ui.cmake | 1 + 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style b/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style new file mode 100644 index 000000000..38c562408 --- /dev/null +++ b/Telegram/SourceFiles/info/channel_statistics/earn/channel_earn.style @@ -0,0 +1,11 @@ +/* +This file is part of Telegram Desktop, +the official desktop application for the Telegram messaging service. + +For license and copyright information please follow this link: +https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL +*/ +using "ui/basic.style"; +using "boxes/boxes.style"; + +channelEarnLearnArrowMargins: margins(-2px, 5px, 0px, 0px); diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp b/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp index a52a51627..f58ec6b6e 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/earn/info_earn_inner_widget.cpp @@ -7,7 +7,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "info/channel_statistics/earn/info_earn_inner_widget.h" +#include "core/ui_integration.h" // Core::MarkedTextContext. +#include "data/data_peer.h" +#include "data/data_session.h" +#include "data/data_session.h" +#include "data/stickers/data_custom_emoji.h" #include "info/info_controller.h" +#include "lang/lang_keys.h" +#include "main/main_session.h" +#include "ui/text/text_utilities.h" +#include "ui/vertical_list.h" +#include "ui/widgets/labels.h" +#include "styles/style_channel_earn.h" +#include "styles/style_chat.h" +#include "styles/style_layers.h" namespace Info::ChannelEarn { namespace { @@ -27,6 +40,42 @@ void InnerWidget::load() { } void InnerWidget::fill() { + const auto container = this; + + const auto session = &_peer->session(); + { + const auto emoji = Ui::Text::SingleCustomEmoji( + session->data().customEmojiManager().registerInternalEmoji( + st::topicButtonArrow, + st::channelEarnLearnArrowMargins, + false)); + auto label = object_ptr( + container, + st::boxDividerLabel); + const auto raw = label.data(); + tr::lng_channel_earn_about( + lt_link, + tr::lng_channel_earn_about_link( + lt_emoji, + rpl::single(emoji), + Ui::Text::RichLangValue + ) | rpl::map([](TextWithEntities text) { + return Ui::Text::Link(std::move(text), 1); + }), + Ui::Text::RichLangValue + ) | rpl::start_with_next([=](const TextWithEntities &text) { + raw->setMarkedText( + text, + Core::MarkedTextContext{ .session = session }); + }, label->lifetime()); + label->setLink(1, std::make_shared([=] { + })); + container->add(object_ptr( + container, + std::move(label), + st::defaultBoxDividerLabelPadding, + RectPart::Top | RectPart::Bottom)); + } } void InnerWidget::saveState(not_null memento) { @@ -36,7 +85,7 @@ void InnerWidget::saveState(not_null memento) { void InnerWidget::restoreState(not_null memento) { // _state = memento->state(); // if (!_state.link.isEmpty()) { - // fill(); + fill(); // } else { // load(); // } diff --git a/Telegram/cmake/td_ui.cmake b/Telegram/cmake/td_ui.cmake index b77a7f1b7..aaad4c10c 100644 --- a/Telegram/cmake/td_ui.cmake +++ b/Telegram/cmake/td_ui.cmake @@ -24,6 +24,7 @@ set(style_files export/view/export.style info/info.style info/channel_statistics/boosts/giveaway/giveaway.style + info/channel_statistics/earn/channel_earn.style info/userpic/info_userpic_builder.style intro/intro.style iv/iv.style