mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Added ability to open main menu with swipe-to-back.
This commit is contained in:
parent
f57eff4195
commit
3315c9c7f4
2 changed files with 47 additions and 20 deletions
|
@ -677,6 +677,14 @@ Widget::Widget(
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::setupSwipeBack() {
|
void Widget::setupSwipeBack() {
|
||||||
|
const auto isMainList = [=] {
|
||||||
|
const auto current = controller()->activeChatsFilterCurrent();
|
||||||
|
const auto &chatsFilters = session().data().chatsFilters();
|
||||||
|
if (chatsFilters.has()) {
|
||||||
|
return chatsFilters.defaultId() == current;
|
||||||
|
}
|
||||||
|
return !current;
|
||||||
|
};
|
||||||
Ui::Controls::SetupSwipeHandler(_scroll.data(), _scroll.data(), [=](
|
Ui::Controls::SetupSwipeHandler(_scroll.data(), _scroll.data(), [=](
|
||||||
Ui::Controls::SwipeContextData data) {
|
Ui::Controls::SwipeContextData data) {
|
||||||
if (data.translation > 0) {
|
if (data.translation > 0) {
|
||||||
|
@ -688,7 +696,9 @@ void Widget::setupSwipeBack() {
|
||||||
st::historyForwardChooseBg->c,
|
st::historyForwardChooseBg->c,
|
||||||
st::historyForwardChooseFg->c,
|
st::historyForwardChooseFg->c,
|
||||||
};
|
};
|
||||||
});
|
},
|
||||||
|
false,
|
||||||
|
_swipeBackIconMirrored);
|
||||||
}
|
}
|
||||||
_swipeBackData.callback(data);
|
_swipeBackData.callback(data);
|
||||||
return;
|
return;
|
||||||
|
@ -698,29 +708,45 @@ void Widget::setupSwipeBack() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [=](int, Qt::LayoutDirection direction) {
|
}, [=](int, Qt::LayoutDirection direction) {
|
||||||
if ((direction != Qt::RightToLeft)
|
_swipeBackIconMirrored = false;
|
||||||
|| _childListShown.current()
|
if (_childListShown.current()) {
|
||||||
|| (!controller()->isPrimary() && (_layout != Layout::Child))
|
|
||||||
|| (!controller()->shownForum().current()
|
|
||||||
&& !controller()->openedFolder().current())) {
|
|
||||||
return Ui::Controls::SwipeHandlerFinishData();
|
return Ui::Controls::SwipeHandlerFinishData();
|
||||||
}
|
}
|
||||||
return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
|
const auto isRightToLeft = direction == Qt::RightToLeft;
|
||||||
_swipeBackData = {};
|
if (isRightToLeft && controller()->openedFolder().current()) {
|
||||||
if (const auto forum = controller()->shownForum().current()) {
|
return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
|
||||||
const auto id = controller()->windowId();
|
_swipeBackData = {};
|
||||||
const auto initial = id.forum();
|
if (controller()->openedFolder().current()) {
|
||||||
if (!initial) {
|
if (!controller()->windowId().folder()) {
|
||||||
controller()->closeForum();
|
controller()->closeFolder();
|
||||||
} else if (initial != forum) {
|
}
|
||||||
controller()->showForum(initial);
|
|
||||||
}
|
|
||||||
} else if (controller()->openedFolder().current()) {
|
|
||||||
if (!controller()->windowId().folder()) {
|
|
||||||
controller()->closeFolder();
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (isRightToLeft && (controller()->shownForum().current())) {
|
||||||
|
const auto id = controller()->windowId();
|
||||||
|
const auto initial = id.forum();
|
||||||
|
if (initial) {
|
||||||
|
return Ui::Controls::SwipeHandlerFinishData();
|
||||||
}
|
}
|
||||||
});
|
return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
|
||||||
|
_swipeBackData = {};
|
||||||
|
if (const auto forum = controller()->shownForum().current()) {
|
||||||
|
controller()->closeForum();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (isRightToLeft && isMainList()) {
|
||||||
|
_swipeBackIconMirrored = true;
|
||||||
|
return Ui::Controls::DefaultSwipeBackHandlerFinishData([=] {
|
||||||
|
_swipeBackIconMirrored = false;
|
||||||
|
_swipeBackData = {};
|
||||||
|
if (isMainList()) {
|
||||||
|
showMainMenu();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return Ui::Controls::SwipeHandlerFinishData();
|
||||||
}, nullptr);
|
}, nullptr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -386,6 +386,7 @@ private:
|
||||||
ChatTypeFilter _searchQueryFilter = {};
|
ChatTypeFilter _searchQueryFilter = {};
|
||||||
|
|
||||||
Ui::Controls::SwipeBackResult _swipeBackData;
|
Ui::Controls::SwipeBackResult _swipeBackData;
|
||||||
|
bool _swipeBackIconMirrored = false;
|
||||||
|
|
||||||
SearchProcessState _searchProcess;
|
SearchProcessState _searchProcess;
|
||||||
SearchProcessState _migratedProcess;
|
SearchProcessState _migratedProcess;
|
||||||
|
|
Loading…
Add table
Reference in a new issue