Added implementation for all swipe dialog actions.

This commit is contained in:
23rd
2025-03-16 23:37:37 +03:00
parent b95035e7a2
commit d7a89ef122
8 changed files with 226 additions and 78 deletions

View File

@@ -690,10 +690,11 @@ void Widget::setupSwipeBack() {
Ui::Controls::SetupSwipeHandler(_inner, _scroll.data(), [=](
Ui::Controls::SwipeContextData data) {
if (data.translation != 0) {
if (data.translation < 0) {
if (_inner) {
_inner->setSwipeContextData(std::move(data));
}
if (data.translation < 0
&& _inner
&& (Core::App().settings().swipeDialogAction()
!= Ui::SwipeDialogAction::Disabled)) {
_inner->setSwipeContextData(std::move(data));
} else {
if (!_swipeBackData.callback) {
_swipeBackData = Ui::Controls::SetupSwipeBack(
@@ -726,16 +727,21 @@ void Widget::setupSwipeBack() {
return Ui::Controls::SwipeHandlerFinishData();
}
const auto isRightToLeft = direction == Qt::RightToLeft;
const auto action = Core::App().settings().swipeDialogAction();
const auto isDisabled = action == Ui::SwipeDialogAction::Disabled;
if (!isRightToLeft && _inner) {
if (const auto key = _inner->calcSwipeKey(top)) {
const auto action
= Core::App().settings().swipeDialogAction();
if (const auto key = _inner->calcSwipeKey(top);
key && !isDisabled) {
_inner->prepareSwipeAction(key, action);
return Ui::Controls::SwipeHandlerFinishData{
.callback = [=, session = &session()] {
auto callback = [=, peerId = PeerId(key)] {
const auto peer = session->data().peer(peerId);
PerformSwipeDialogAction(peer, action);
PerformSwipeDialogAction(
controller(),
peer,
action,
_inner->filterId());
};
base::call_delayed(
st::slideWrapDuration,
@@ -788,7 +794,9 @@ void Widget::setupSwipeBack() {
}
});
}
if (_chatFilters && session().data().chatsFilters().has()) {
if (_chatFilters
&& session().data().chatsFilters().has()
&& isDisabled) {
_swipeBackMirrored = !isRightToLeft;
using namespace Window;
const auto next = !isRightToLeft;