mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Added ability to swipe-to-back to all info sections with narrow type.
This commit is contained in:
parent
d662a8f2b9
commit
d02e55da06
2 changed files with 38 additions and 0 deletions
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "info/media/info_media_widget.h"
|
||||
#include "info/common_groups/info_common_groups_widget.h"
|
||||
#include "info/info_layer_widget.h"
|
||||
#include "history/history_view_swipe.h"
|
||||
#include "info/info_section_widget.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
|
@ -76,6 +77,8 @@ ContentWidget::ContentWidget(
|
|||
) | rpl::start_with_next([this] {
|
||||
updateControlsGeometry();
|
||||
}, lifetime());
|
||||
|
||||
setupSwipeReply();
|
||||
}
|
||||
|
||||
void ContentWidget::resizeEvent(QResizeEvent *e) {
|
||||
|
@ -381,6 +384,37 @@ not_null<Ui::ScrollArea*> ContentWidget::scroll() const {
|
|||
return _scroll.data();
|
||||
}
|
||||
|
||||
void ContentWidget::setupSwipeReply() {
|
||||
HistoryView::SetupSwipeHandler(this, _scroll.data(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
if (data.translation > 0) {
|
||||
if (!_swipeBackData.callback) {
|
||||
_swipeBackData = HistoryView::SetupSwipeBack(
|
||||
this,
|
||||
[]() -> std::pair<QColor, QColor> {
|
||||
return {
|
||||
st::historyForwardChooseBg->c,
|
||||
st::historyForwardChooseFg->c,
|
||||
};
|
||||
});
|
||||
}
|
||||
_swipeBackData.callback(data);
|
||||
return;
|
||||
} else if (_swipeBackData.lifetime) {
|
||||
_swipeBackData = {};
|
||||
}
|
||||
}, [=](int, Qt::LayoutDirection direction) {
|
||||
if (_controller->wrap() != Wrap::Narrow
|
||||
|| direction != Qt::RightToLeft) {
|
||||
return HistoryView::SwipeHandlerFinishData();
|
||||
}
|
||||
return HistoryView::SwipeHandlerFinishData{
|
||||
.callback = [=] { _controller->showBackFromStack(); },
|
||||
.msgBareId = HistoryView::kMsgBareIdSwipeBack,
|
||||
};
|
||||
}, nullptr);
|
||||
}
|
||||
|
||||
Key ContentMemento::key() const {
|
||||
if (const auto topic = this->topic()) {
|
||||
return Key(topic);
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "info/info_wrap_widget.h"
|
||||
#include "info/statistics/info_statistics_tag.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
|
||||
namespace Api {
|
||||
struct WhoReadList;
|
||||
|
@ -167,6 +168,7 @@ private:
|
|||
RpWidget *doSetInnerWidget(object_ptr<RpWidget> inner);
|
||||
void updateControlsGeometry();
|
||||
void refreshSearchField(bool shown);
|
||||
void setupSwipeReply();
|
||||
|
||||
virtual std::shared_ptr<ContentMemento> doCreateMemento() = 0;
|
||||
|
||||
|
@ -190,6 +192,8 @@ private:
|
|||
// To paint round edges from content.
|
||||
style::margins _paintPadding;
|
||||
|
||||
HistoryView::SwipeBackResult _swipeBackData;
|
||||
|
||||
};
|
||||
|
||||
class ContentMemento {
|
||||
|
|
Loading…
Add table
Reference in a new issue