Improve boosted channel replacement design.

This commit is contained in:
John Preston 2023-09-21 08:59:08 +04:00
parent c5634580f6
commit 09094affed
7 changed files with 91 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

View File

@ -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<Ui::UserpicButton*> CreateUploadSubButton(
return upload;
}
object_ptr<Ui::RpWidget> CreateBoostReplaceUserpics(
not_null<Ui::RpWidget*> parent,
not_null<PeerData*> from,
not_null<PeerData*> to) {
const auto full = st::boostReplaceUserpic.size.height()
+ st::boostReplaceIconAdd.y()
+ st::lineWidth;
auto result = object_ptr<FixedHeightWidget>(parent, full);
const auto raw = result.data();
const auto &st = st::boostReplaceUserpic;
const auto left = CreateChild<UserpicButton>(raw, from, st);
const auto right = CreateChild<UserpicButton>(raw, to, st);
const auto overlay = CreateChild<RpWidget>(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

View File

@ -204,4 +204,9 @@ private:
not_null<UserData*> contact,
not_null<Window::SessionController*> controller);
[[nodiscard]] object_ptr<Ui::RpWidget> CreateBoostReplaceUserpics(
not_null<Ui::RpWidget*> parent,
not_null<PeerData*> from,
not_null<PeerData*> to);
} // namespace Ui

View File

@ -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 }};

View File

@ -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<Ui::GenericBox*> 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;