diff --git a/Telegram/Resources/icons/stories/boost_mini.png b/Telegram/Resources/icons/stories/boost_mini.png new file mode 100644 index 000000000..90a24d8f1 Binary files /dev/null and b/Telegram/Resources/icons/stories/boost_mini.png differ diff --git a/Telegram/Resources/icons/stories/boost_mini@2x.png b/Telegram/Resources/icons/stories/boost_mini@2x.png new file mode 100644 index 000000000..fd746a03a Binary files /dev/null and b/Telegram/Resources/icons/stories/boost_mini@2x.png differ diff --git a/Telegram/Resources/icons/stories/boost_mini@3x.png b/Telegram/Resources/icons/stories/boost_mini@3x.png new file mode 100644 index 000000000..637a5716d Binary files /dev/null and b/Telegram/Resources/icons/stories/boost_mini@3x.png differ diff --git a/Telegram/SourceFiles/ui/controls/userpic_button.cpp b/Telegram/SourceFiles/ui/controls/userpic_button.cpp index 439c94523..224fd7a35 100644 --- a/Telegram/SourceFiles/ui/controls/userpic_button.cpp +++ b/Telegram/SourceFiles/ui/controls/userpic_button.cpp @@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "calls/calls_instance.h" #include "core/application.h" +#include "ui/effects/premium_graphics.h" #include "ui/layers/generic_box.h" #include "ui/text/text_utilities.h" #include "ui/widgets/menu/menu_action.h" @@ -45,6 +46,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_boxes.h" #include "styles/style_chat.h" #include "styles/style_menu_icons.h" +#include "styles/style_premium.h" namespace Ui { namespace { @@ -1107,4 +1109,57 @@ not_null CreateUploadSubButton( return upload; } +object_ptr CreateBoostReplaceUserpics( + not_null parent, + not_null from, + not_null to) { + const auto full = st::boostReplaceUserpic.size.height() + + st::boostReplaceIconAdd.y() + + st::lineWidth; + auto result = object_ptr(parent, full); + const auto raw = result.data(); + const auto &st = st::boostReplaceUserpic; + const auto left = CreateChild(raw, from, st); + const auto right = CreateChild(raw, to, st); + const auto overlay = CreateChild(raw); + raw->widthValue( + ) | rpl::start_with_next([=](int width) { + const auto skip = st::boostReplaceUserpicsSkip; + const auto total = left->width() + skip + right->width(); + left->moveToLeft((width - total) / 2, 0); + right->moveToLeft(left->x() + left->width() + skip, 0); + overlay->setGeometry(QRect(0, 0, width, raw->height())); + }, raw->lifetime()); + overlay->paintRequest( + ) | rpl::start_with_next([=] { + const auto outerw = overlay->width(); + const auto add = st::boostReplaceIconAdd; + const auto skip = st::boostReplaceIconSkip; + const auto w = st::boostReplaceIcon.width() + 2 * skip; + const auto h = st::boostReplaceIcon.height() + 2 * skip; + const auto x = left->x() + left->width() - w + add.x(); + const auto y = left->y() + left->height() - h + add.y(); + const auto stroke = st::boostReplaceIconOutline; + const auto half = stroke / 2.; + auto p = QPainter(overlay); + auto hq = PainterHighQualityEnabler(p); + auto pen = st::windowBg->p; + pen.setWidthF(stroke); + p.setPen(pen); + auto brush = QLinearGradient(QPointF(x + w, y + h), QPointF(x, y)); + brush.setStops(Premium::ButtonGradientStops()); + p.setBrush(brush); + p.drawEllipse(x - half, y - half, w + stroke, h + stroke); + st::boostReplaceIcon.paint(p, x + skip, y + skip, outerw); + + const auto size = st::boostReplaceArrow.size(); + st::boostReplaceArrow.paint( + p, + (outerw - size.width()) / 2, + (left->height() - size.height()) / 2, + outerw); + }, overlay->lifetime()); + return result; +} + } // namespace Ui diff --git a/Telegram/SourceFiles/ui/controls/userpic_button.h b/Telegram/SourceFiles/ui/controls/userpic_button.h index 8d2eb2adf..db3cdd3fd 100644 --- a/Telegram/SourceFiles/ui/controls/userpic_button.h +++ b/Telegram/SourceFiles/ui/controls/userpic_button.h @@ -204,4 +204,9 @@ private: not_null contact, not_null controller); +[[nodiscard]] object_ptr CreateBoostReplaceUserpics( + not_null parent, + not_null from, + not_null to); + } // namespace Ui diff --git a/Telegram/SourceFiles/ui/effects/premium.style b/Telegram/SourceFiles/ui/effects/premium.style index d0eb5cdc5..39bf21ed4 100644 --- a/Telegram/SourceFiles/ui/effects/premium.style +++ b/Telegram/SourceFiles/ui/effects/premium.style @@ -6,6 +6,7 @@ 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"; using "ui/widgets/widgets.style"; using "ui/layers/layers.style"; @@ -230,3 +231,15 @@ boostBox: Box(premiumPreviewDoubledLimitsBox) { font: font(13px semibold); } } + +boostReplaceUserpicsPadding: margins(0px, 18px, 0px, 20px); +boostReplaceUserpicsSkip: 42px; +boostReplaceUserpic: UserpicButton(defaultUserpicButton) { + size: size(60px, 60px); + photoSize: 60px; +} +boostReplaceIcon: icon{{ "stories/boost_mini", windowBg }}; +boostReplaceIconSkip: 3px; +boostReplaceIconOutline: 2px; +boostReplaceIconAdd: point(4px, 2px); +boostReplaceArrow: icon{{ "mediaview/next", windowSubTextFg }}; diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 7f2a4b6f0..4b69e4f2e 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -51,6 +51,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/core_settings.h" #include "core/click_handler_types.h" #include "base/unixtime.h" +#include "ui/controls/userpic_button.h" #include "ui/layers/generic_box.h" #include "ui/text/text_utilities.h" #include "ui/text/format_values.h" // Ui::FormatPhone. @@ -86,6 +87,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_window.h" #include "styles/style_dialogs.h" #include "styles/style_layers.h" // st::boxLabel +#include "styles/style_premium.h" namespace Window { namespace { @@ -728,15 +730,22 @@ void SessionNavigation::replaceBoostConfirm( applyBoostChecked(channel, done); close(); }; - const auto box = uiShow()->show(Ui::MakeConfirmBox({ - .text = tr::lng_boost_now_instead( - lt_channel, - rpl::single(Ui::Text::Bold(from->name())), - lt_other, - rpl::single(Ui::Text::Bold(channel->name())), - Ui::Text::WithEntities), - .confirmed = confirmed, - .confirmText = tr::lng_boost_now_replace(), + const auto box = uiShow()->show(Box([=](not_null box) { + Ui::ConfirmBox(box, { + .text = tr::lng_boost_now_instead( + lt_channel, + rpl::single(Ui::Text::Bold(from->name())), + lt_other, + rpl::single(Ui::Text::Bold(channel->name())), + Ui::Text::WithEntities), + .confirmed = confirmed, + .confirmText = tr::lng_boost_now_replace(), + .labelPadding = st::boxRowPadding, + }); + box->verticalLayout()->insert( + 0, + Ui::CreateBoostReplaceUserpics(box, from, channel), + st::boxRowPadding + st::boostReplaceUserpicsPadding); })); box->boxClosing() | rpl::filter([=] { return !*forwarded;