mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Added initial support of custom top bar for premium settings.
This commit is contained in:
parent
6a8ccde527
commit
00632dff46
2 changed files with 72 additions and 0 deletions
|
@ -17,6 +17,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "settings/cloud_password/settings_cloud_password_email_confirm.h"
|
||||
#include "settings/settings_chat.h"
|
||||
#include "settings/settings_main.h"
|
||||
#include "settings/settings_premium.h"
|
||||
#include "ui/effects/ripple_animation.h" // maskByDrawer.
|
||||
#include "ui/widgets/discrete_sliders.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/shadow.h"
|
||||
|
@ -55,6 +57,12 @@ const style::InfoTopBar &TopBarStyle(Wrap wrap) {
|
|||
: st::infoTopBar;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool HasCustomTopBar(not_null<const Controller*> controller) {
|
||||
const auto section = controller->section();
|
||||
return (section.type() == Section::Type::Settings
|
||||
&& (section.settingsType() == ::Settings::PremiumId()));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
struct WrapWidget::StackItem {
|
||||
|
@ -346,6 +354,10 @@ void WrapWidget::setupTop() {
|
|||
//} else {
|
||||
// createTopBar();
|
||||
//}
|
||||
if (HasCustomTopBar(_controller.get())) {
|
||||
_topBar.destroy();
|
||||
return;
|
||||
}
|
||||
createTopBar();
|
||||
}
|
||||
|
||||
|
@ -957,6 +969,20 @@ void WrapWidget::showNewContent(
|
|||
const auto layer = (wrap() == Wrap::Layer);
|
||||
animationParams.withFade = layer;
|
||||
animationParams.topSkip = layer ? st::boxRadius : 0;
|
||||
|
||||
if (HasCustomTopBar(_controller.get())
|
||||
|| HasCustomTopBar(newController.get())) {
|
||||
|
||||
const auto s = QSize(
|
||||
newContent->width(),
|
||||
animationParams.topSkip);
|
||||
auto image = Ui::RippleAnimation::maskByDrawer(s, false, [&](
|
||||
QPainter &p) {
|
||||
const auto r = QRect(0, 0, s.width(), s.height() * 2);
|
||||
p.drawRoundedRect(r, st::boxRadius, st::boxRadius);
|
||||
});
|
||||
animationParams.topMask = Ui::PixmapFromImage(std::move(image));
|
||||
}
|
||||
}
|
||||
if (saveToStack) {
|
||||
auto item = StackItem();
|
||||
|
|
|
@ -27,6 +27,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "main/main_app_config.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_info.h"
|
||||
#include "styles/style_intro.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_settings.h"
|
||||
|
||||
|
@ -41,6 +43,8 @@ public:
|
|||
|
||||
[[nodiscard]] rpl::producer<QString> title() override;
|
||||
|
||||
[[nodiscard]] QPointer<Ui::RpWidget> createPinnedToTop(
|
||||
not_null<QWidget*> parent) override;
|
||||
[[nodiscard]] QPointer<Ui::RpWidget> createPinnedToBottom(
|
||||
not_null<Ui::RpWidget*> parent) override;
|
||||
|
||||
|
@ -228,6 +232,48 @@ void Premium::setupContent() {
|
|||
|
||||
}
|
||||
|
||||
QPointer<Ui::RpWidget> Premium::createPinnedToTop(
|
||||
not_null<QWidget*> parent) {
|
||||
const auto container = Ui::CreateChild<Ui::VerticalLayout>(parent.get());
|
||||
const auto content = container->add(object_ptr<Ui::RpWidget>(container));
|
||||
content->resize(content->width(), st::introQrStepsTop);
|
||||
|
||||
container->setAttribute(Qt::WA_OpaquePaintEvent, false);
|
||||
content->setAttribute(Qt::WA_OpaquePaintEvent, false);
|
||||
|
||||
content->paintRequest(
|
||||
) | rpl::start_with_next([=](const QRect &paintRect) {
|
||||
Painter p(content);
|
||||
|
||||
p.fillRect(paintRect, Qt::transparent);
|
||||
|
||||
const auto rect = content->rect();
|
||||
auto pathTop = QPainterPath();
|
||||
pathTop.addRoundedRect(rect, st::boxRadius, st::boxRadius);
|
||||
auto pathBottom = QPainterPath();
|
||||
pathBottom.addRect(
|
||||
QRect(
|
||||
QPoint(rect.x(), rect.y() + rect.height() - st::boxRadius),
|
||||
QSize(rect.width(), st::boxRadius)));
|
||||
|
||||
const auto gradientPointTop = rect.height() / 3. * 2.;
|
||||
auto gradient = QLinearGradient(
|
||||
QPointF(0, gradientPointTop),
|
||||
QPointF(rect.width(), rect.height() - gradientPointTop));
|
||||
gradient.setColorAt(0., st::premiumButtonBg1->c);
|
||||
gradient.setColorAt(.6, st::premiumButtonBg2->c);
|
||||
gradient.setColorAt(1., st::premiumButtonBg3->c);
|
||||
|
||||
PainterHighQualityEnabler hq(p);
|
||||
p.fillPath(pathTop + pathBottom, gradient);
|
||||
}, content->lifetime());
|
||||
|
||||
container->setMaximumHeight(st::introQrStepsTop);
|
||||
container->setMinimumHeight(st::infoLayerTopBarHeight);
|
||||
|
||||
return Ui::MakeWeak(not_null<Ui::RpWidget*>{ container });
|
||||
}
|
||||
|
||||
QPointer<Ui::RpWidget> Premium::createPinnedToBottom(
|
||||
not_null<Ui::RpWidget*> parent) {
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue