mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Moved out creation of flexible scroll into info content widget.
This commit is contained in:
@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "info/info_flexible_scroll.h"
|
||||
#include "info/info_wrap_widget.h"
|
||||
#include "info/statistics/info_statistics_tag.h"
|
||||
#include "ui/controls/swipe_handler_data.h"
|
||||
@@ -154,6 +155,42 @@ protected:
|
||||
doSetInnerWidget(std::move(inner)));
|
||||
}
|
||||
|
||||
template <typename Widget, typename FlexibleData>
|
||||
Widget *setupFlexibleInnerWidget(
|
||||
object_ptr<Widget> inner,
|
||||
FlexibleData &flexibleScroll,
|
||||
Fn<void(Ui::RpWidget*)> customSetup = nullptr) {
|
||||
if (inner->hasFlexibleTopBar()) {
|
||||
auto filler = setInnerWidget(object_ptr<Ui::RpWidget>(this));
|
||||
filler->resize(1, 1);
|
||||
|
||||
flexibleScroll.contentHeightValue.events(
|
||||
) | rpl::start_with_next([=](int h) {
|
||||
filler->resize(filler->width(), h);
|
||||
}, filler->lifetime());
|
||||
|
||||
filler->widthValue(
|
||||
) | rpl::start_to_stream(
|
||||
flexibleScroll.fillerWidthValue,
|
||||
lifetime());
|
||||
|
||||
if (customSetup) {
|
||||
customSetup(filler);
|
||||
}
|
||||
|
||||
// ScrollArea -> PaddingWrap -> RpWidget.
|
||||
inner->setParent(filler->parentWidget()->parentWidget());
|
||||
inner->raise();
|
||||
|
||||
using InnerPtr = base::unique_qptr<Widget>;
|
||||
auto owner = filler->lifetime().make_state<InnerPtr>(
|
||||
std::move(inner.release()));
|
||||
return owner->get();
|
||||
} else {
|
||||
return setInnerWidget(std::move(inner));
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] not_null<Controller*> controller() const {
|
||||
return _controller;
|
||||
}
|
||||
|
||||
@@ -96,33 +96,10 @@ Widget::Widget(
|
||||
not_null<Controller*> controller,
|
||||
Origin origin)
|
||||
: ContentWidget(parent, controller)
|
||||
, _inner([&] {
|
||||
auto inner = object_ptr<InnerWidget>(this, controller, origin);
|
||||
if (inner->hasFlexibleTopBar()) {
|
||||
auto filler = setInnerWidget(object_ptr<Ui::RpWidget>(this));
|
||||
filler->resize(1, 1);
|
||||
|
||||
_flexibleScroll.contentHeightValue.events(
|
||||
) | rpl::start_with_next([=](int h) {
|
||||
filler->resize(filler->width(), h);
|
||||
}, filler->lifetime());
|
||||
|
||||
filler->widthValue(
|
||||
) | rpl::start_to_stream(
|
||||
_flexibleScroll.fillerWidthValue,
|
||||
lifetime());
|
||||
|
||||
inner->setParent(filler->parentWidget()->parentWidget());
|
||||
inner->raise();
|
||||
|
||||
using InnerPtr = base::unique_qptr<InnerWidget>;
|
||||
auto owner = filler->lifetime().make_state<InnerPtr>(
|
||||
std::move(inner.release()));
|
||||
return owner->get();
|
||||
} else {
|
||||
return setInnerWidget(std::move(inner));
|
||||
}
|
||||
}())
|
||||
, _inner(
|
||||
setupFlexibleInnerWidget(
|
||||
object_ptr<InnerWidget>(this, controller, origin),
|
||||
_flexibleScroll))
|
||||
, _pinnedToTop(_inner->createPinnedToTop(this))
|
||||
, _pinnedToBottom(_inner->createPinnedToBottom(this)) {
|
||||
controller->setSearchEnabledByContent(false);
|
||||
|
||||
@@ -8,7 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#pragma once
|
||||
|
||||
#include "info/info_content_widget.h"
|
||||
#include "info/info_flexible_scroll.h"
|
||||
#include "ui/effects/animations.h"
|
||||
|
||||
namespace Data {
|
||||
|
||||
@@ -43,46 +43,22 @@ Widget::Widget(
|
||||
: ContentWidget(parent, controller)
|
||||
, _self(controller->key().settingsSelf())
|
||||
, _type(controller->section().settingsType())
|
||||
, _inner([&] {
|
||||
auto inner = _type->create(
|
||||
this,
|
||||
controller->parentController(),
|
||||
scroll(),
|
||||
controller->wrapValue(
|
||||
) | rpl::map([](Wrap wrap) { return (wrap == Wrap::Layer)
|
||||
? ::Settings::Container::Layer
|
||||
: ::Settings::Container::Section; }));
|
||||
if (inner->hasFlexibleTopBar()) {
|
||||
auto filler = setInnerWidget(object_ptr<Ui::RpWidget>(this));
|
||||
filler->resize(1, 1);
|
||||
|
||||
_flexibleScroll.contentHeightValue.events(
|
||||
) | rpl::start_with_next([=](int h) {
|
||||
filler->resize(filler->width(), h);
|
||||
}, filler->lifetime());
|
||||
|
||||
filler->widthValue(
|
||||
) | rpl::start_to_stream(
|
||||
_flexibleScroll.fillerWidthValue,
|
||||
lifetime());
|
||||
|
||||
controller->stepDataReference() = SectionCustomTopBarData{
|
||||
.backButtonEnables = _flexibleScroll.backButtonEnables.events(),
|
||||
.wrapValue = controller->wrapValue(),
|
||||
};
|
||||
|
||||
// ScrollArea -> PaddingWrap -> RpWidget.
|
||||
inner->setParent(filler->parentWidget()->parentWidget());
|
||||
inner->raise();
|
||||
|
||||
using InnerPtr = base::unique_qptr<::Settings::AbstractSection>;
|
||||
auto owner = filler->lifetime().make_state<InnerPtr>(
|
||||
std::move(inner.release()));
|
||||
return owner->get();
|
||||
} else {
|
||||
return setInnerWidget(std::move(inner));
|
||||
}
|
||||
}())
|
||||
, _inner(setupFlexibleInnerWidget(
|
||||
_type->create(
|
||||
this,
|
||||
controller->parentController(),
|
||||
scroll(),
|
||||
controller->wrapValue(
|
||||
) | rpl::map([](Wrap wrap) { return (wrap == Wrap::Layer)
|
||||
? ::Settings::Container::Layer
|
||||
: ::Settings::Container::Section; })),
|
||||
_flexibleScroll,
|
||||
[=](Ui::RpWidget*) {
|
||||
controller->stepDataReference() = SectionCustomTopBarData{
|
||||
.backButtonEnables = _flexibleScroll.backButtonEnables.events(),
|
||||
.wrapValue = controller->wrapValue(),
|
||||
};
|
||||
}))
|
||||
, _pinnedToTop(_inner->createPinnedToTop(this))
|
||||
, _pinnedToBottom(_inner->createPinnedToBottom(this)) {
|
||||
_inner->sectionShowOther(
|
||||
|
||||
Reference in New Issue
Block a user