mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Fix glitch in Settings > Premium layer scroll-to-bottom.
This commit is contained in:
parent
3c5267f307
commit
e72ca712ec
10 changed files with 73 additions and 17 deletions
|
@ -113,7 +113,7 @@ private:
|
|||
|
||||
style::color _bg;
|
||||
rpl::variable<int> _scrollTopSkip = -1;
|
||||
rpl::variable<int> _scrollBottomSkip = -1;
|
||||
rpl::variable<int> _scrollBottomSkip = 0;
|
||||
rpl::event_stream<int> _scrollTillBottomChanges;
|
||||
object_ptr<Ui::ScrollArea> _scroll;
|
||||
Ui::PaddingWrap<Ui::RpWidget> *_innerWrap = nullptr;
|
||||
|
|
|
@ -299,9 +299,13 @@ QRect LayerWidget::countGeometry(int newWidth) {
|
|||
contentHeight += additionalScroll;
|
||||
_tillBottom = (newTop + desiredHeight >= windowHeight);
|
||||
if (_tillBottom) {
|
||||
contentHeight += contentBottom;
|
||||
additionalScroll += contentBottom;
|
||||
}
|
||||
_contentTillBottom = _tillBottom && !_content->scrollBottomSkip();
|
||||
if (_contentTillBottom) {
|
||||
contentHeight += contentBottom;
|
||||
}
|
||||
const auto bottomPadding = _tillBottom ? 0 : contentBottom;
|
||||
_content->updateGeometry({
|
||||
contentLeft,
|
||||
contentTop,
|
||||
|
@ -328,6 +332,8 @@ void LayerWidget::paintEvent(QPaintEvent *e) {
|
|||
if (clip.intersects({ 0, height() - radius, width(), radius })) {
|
||||
parts |= RectPart::FullBottom;
|
||||
}
|
||||
} else if (!_contentTillBottom) {
|
||||
p.fillRect(0, height() - radius, width(), radius, st::boxBg);
|
||||
}
|
||||
if (_content->animatingShow()) {
|
||||
if (clip.intersects({ 0, 0, width(), radius })) {
|
||||
|
|
|
@ -83,6 +83,7 @@ private:
|
|||
bool _inResize = false;
|
||||
bool _pendingResize = false;
|
||||
bool _tillBottom = false;
|
||||
bool _contentTillBottom = false;
|
||||
|
||||
bool _floatPlayerDelegateRestored = false;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "info/info_layer_widget.h"
|
||||
#include "info/info_memento.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
||||
namespace Info {
|
||||
|
||||
|
@ -42,11 +43,15 @@ SectionWidget::SectionWidget(
|
|||
void SectionWidget::init() {
|
||||
Expects(_connecting == nullptr);
|
||||
|
||||
sizeValue(
|
||||
) | rpl::start_with_next([wrap = _content.data()](QSize size) {
|
||||
rpl::combine(
|
||||
sizeValue(),
|
||||
_content->desiredHeightValue()
|
||||
) | rpl::start_with_next([wrap = _content.data()](QSize size, int) {
|
||||
const auto expanding = false;
|
||||
auto wrapGeometry = QRect{ { 0, 0 }, size };
|
||||
auto additionalScroll = 0;
|
||||
const auto additionalScroll = st::boxRadius;
|
||||
const auto full = !wrap->scrollBottomSkip();
|
||||
const auto height = size.height() - (full ? 0 : st::boxRadius);
|
||||
const auto wrapGeometry = QRect{ 0, 0, size.width(), height };
|
||||
wrap->updateGeometry(wrapGeometry, expanding, additionalScroll);
|
||||
}, _content->lifetime());
|
||||
|
||||
|
@ -88,6 +93,13 @@ void SectionWidget::showAnimatedHook(
|
|||
_topBarSurrogate = _content->createTopBarSurrogate(this);
|
||||
}
|
||||
|
||||
void SectionWidget::paintEvent(QPaintEvent *e) {
|
||||
Window::SectionWidget::paintEvent(e);
|
||||
if (!animatingShow()) {
|
||||
QPainter(this).fillRect(e->rect(), st::windowBg);
|
||||
}
|
||||
}
|
||||
|
||||
bool SectionWidget::showInternal(
|
||||
not_null<Window::SectionMemento*> memento,
|
||||
const Window::SectionShow ¶ms) {
|
||||
|
|
|
@ -63,6 +63,7 @@ protected:
|
|||
|
||||
void showAnimatedHook(
|
||||
const Window::SectionSlideParams ¶ms) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
|
|
@ -645,8 +645,8 @@ void WrapWidget::showContent(object_ptr<ContentWidget> content) {
|
|||
old->setParent(nullptr);
|
||||
old.destroy();
|
||||
}
|
||||
_content->show();
|
||||
_additionalScroll = 0;
|
||||
_content->show();
|
||||
//_anotherTabMemento = nullptr;
|
||||
finishShowContent();
|
||||
}
|
||||
|
@ -1098,6 +1098,10 @@ int WrapWidget::scrollTillBottom(int forHeight) const {
|
|||
return _content->scrollTillBottom(forHeight - topWidget()->height());
|
||||
}
|
||||
|
||||
int WrapWidget::scrollBottomSkip() const {
|
||||
return _content->scrollBottomSkip();
|
||||
}
|
||||
|
||||
rpl::producer<int> WrapWidget::scrollTillBottomChanges() const {
|
||||
return _scrollTillBottomChanges.events_starting_with(
|
||||
_content->scrollTillBottomChanges()
|
||||
|
|
|
@ -125,6 +125,7 @@ public:
|
|||
QRect newGeometry,
|
||||
bool expanding,
|
||||
int additionalScroll);
|
||||
[[nodiscard]] int scrollBottomSkip() const;
|
||||
[[nodiscard]] int scrollTillBottom(int forHeight) const;
|
||||
[[nodiscard]] rpl::producer<int> scrollTillBottomChanges() const;
|
||||
[[nodiscard]] rpl::producer<bool> grabbingForExpanding() const;
|
||||
|
|
|
@ -422,5 +422,5 @@ notifyPreviewChecksSkip: 12px;
|
|||
notifyPreviewBottomSkip: 9px;
|
||||
|
||||
settingsPremiumDescriptionSkip: 3px;
|
||||
settingsPremiumButtonPadding: margins(11px, 11px, 11px, 11px);
|
||||
settingsPremiumButtonPadding: margins(11px, 11px, 11px, 3px);
|
||||
|
||||
|
|
|
@ -12,7 +12,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "settings/settings_premium.h"
|
||||
#include "core/application.h"
|
||||
#include "ui/abstract_button.h"
|
||||
#include "ui/basic_click_handlers.h"
|
||||
#include "ui/effects/gradient.h"
|
||||
#include "ui/effects/premium_graphics.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/widgets/gradient_round_button.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
|
@ -21,6 +23,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/window_session_controller.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "main/main_session.h"
|
||||
#include "main/main_account.h"
|
||||
#include "main/main_app_config.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_layers.h"
|
||||
|
@ -41,22 +45,25 @@ public:
|
|||
not_null<Ui::RpWidget*> parent) override;
|
||||
|
||||
private:
|
||||
void setupContent(not_null<Window::SessionController*> controller);
|
||||
void setupContent();
|
||||
|
||||
const not_null<Window::SessionController*> _controller;
|
||||
|
||||
};
|
||||
|
||||
Premium::Premium(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller)
|
||||
: Section(parent) {
|
||||
setupContent(controller);
|
||||
: Section(parent)
|
||||
, _controller(controller) {
|
||||
setupContent();
|
||||
}
|
||||
|
||||
rpl::producer<QString> Premium::title() {
|
||||
return tr::lng_premium_summary_title();
|
||||
}
|
||||
|
||||
void Premium::setupContent(not_null<Window::SessionController*> controller) {
|
||||
void Premium::setupContent() {
|
||||
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
|
||||
|
||||
content->add(
|
||||
|
@ -221,11 +228,11 @@ QPointer<Ui::RpWidget> Premium::createPinnedToBottom(
|
|||
|
||||
auto result = object_ptr<Ui::GradientButton>(
|
||||
content,
|
||||
QGradientStops{
|
||||
{ 0., st::premiumButtonBg1->c },
|
||||
{ .6, st::premiumButtonBg2->c },
|
||||
{ 1., st::premiumButtonBg3->c },
|
||||
});
|
||||
Ui::Premium::ButtonGradientStops());
|
||||
|
||||
result->setClickedCallback([=] {
|
||||
StartPremiumPayment(_controller, "settings");
|
||||
});
|
||||
|
||||
const auto &st = st::premiumPreviewBox.button;
|
||||
result->resize(content->width(), st.height);
|
||||
|
@ -271,4 +278,21 @@ void ShowPremium(not_null<Main::Session*> session) {
|
|||
}
|
||||
}
|
||||
|
||||
void StartPremiumPayment(
|
||||
not_null<Window::SessionController*> controller,
|
||||
const QString &ref) {
|
||||
const auto account = &controller->session().account();
|
||||
const auto username = account->appConfig().get<QString>(
|
||||
"premium_bot_username",
|
||||
QString());
|
||||
const auto slug = account->appConfig().get<QString>(
|
||||
"premium_invoice_slug",
|
||||
QString());
|
||||
if (!username.isEmpty()) {
|
||||
UrlClickHandler::Open("https://t.me/" + username + "?start=" + ref);
|
||||
} else if (!slug.isEmpty()) {
|
||||
UrlClickHandler::Open("https://t.me/$" + slug);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
|
|
@ -13,11 +13,18 @@ namespace Main {
|
|||
class Session;
|
||||
} // namespace Main
|
||||
|
||||
namespace Window {
|
||||
class SessionController;
|
||||
} // namespace Window
|
||||
|
||||
namespace Settings {
|
||||
|
||||
[[nodiscard]] Type PremiumId();
|
||||
|
||||
void ShowPremium(not_null<::Main::Session*> session);
|
||||
void StartPremiumPayment(
|
||||
not_null<Window::SessionController*> controller,
|
||||
const QString &ref);
|
||||
|
||||
} // namespace Settings
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue