Allow more Info sections swipe-back.

This commit is contained in:
John Preston 2025-03-12 18:01:47 +04:00
parent 31cb2f1999
commit fd718dfd5c
4 changed files with 14 additions and 19 deletions

View file

@ -404,24 +404,14 @@ void ContentWidget::setupSwipeReply() {
_swipeBackData = {};
}
}, [=](int, Qt::LayoutDirection direction) {
const auto can = [&] {
using Type = Section::Type;
if (direction != Qt::RightToLeft) {
return false;
} else if (_controller->wrap() == Wrap::Side) {
return (_controller->section().type() != Type::Profile);
} else if (_controller->wrap() == Wrap::Narrow) {
return true;
} else {
return false;
}
}();
return !can
? Ui::Controls::SwipeHandlerFinishData()
: Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
_controller->showBackFromStack();
});
return (direction == Qt::RightToLeft && _controller->hasBackButton())
? Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
checkBeforeClose(crl::guard(this, [=] {
_controller->parentController()->hideLayer();
_controller->showBackFromStack();
}));
})
: Ui::Controls::SwipeHandlerFinishData();
}, nullptr);
}

View file

@ -358,6 +358,10 @@ void Controller::setSection(not_null<ContentMemento*> memento) {
updateSearchControllers(memento);
}
bool Controller::hasBackButton() const {
return _widget->hasBackButton();
}
void Controller::updateSearchControllers(
not_null<ContentMemento*> memento) {
using Type = Section::Type;

View file

@ -311,6 +311,7 @@ public:
[[nodiscard]] rpl::producer<Wrap> wrapValue() const;
[[nodiscard]] not_null<Ui::RpWidget*> wrapWidget() const;
void setSection(not_null<ContentMemento*> memento);
[[nodiscard]] bool hasBackButton() const;
Ui::SearchFieldController *searchFieldController() const {
return _searchFieldController.get();

View file

@ -122,6 +122,7 @@ public:
object_ptr<Ui::RpWidget> createTopBarSurrogate(QWidget *parent);
[[nodiscard]] bool hasBackButton() const;
[[nodiscard]] bool closeByOutsideClick() const;
void updateGeometry(
@ -181,7 +182,6 @@ private:
void highlightTopBar();
void setupShortcuts();
[[nodiscard]] bool hasBackButton() const;
[[nodiscard]] bool willHaveBackButton(
const Window::SectionShow &params) const;