mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +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/media/info_media_widget.h"
|
||||||
#include "info/common_groups/info_common_groups_widget.h"
|
#include "info/common_groups/info_common_groups_widget.h"
|
||||||
#include "info/info_layer_widget.h"
|
#include "info/info_layer_widget.h"
|
||||||
|
#include "history/history_view_swipe.h"
|
||||||
#include "info/info_section_widget.h"
|
#include "info/info_section_widget.h"
|
||||||
#include "info/info_controller.h"
|
#include "info/info_controller.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
@ -76,6 +77,8 @@ ContentWidget::ContentWidget(
|
||||||
) | rpl::start_with_next([this] {
|
) | rpl::start_with_next([this] {
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
setupSwipeReply();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentWidget::resizeEvent(QResizeEvent *e) {
|
void ContentWidget::resizeEvent(QResizeEvent *e) {
|
||||||
|
@ -381,6 +384,37 @@ not_null<Ui::ScrollArea*> ContentWidget::scroll() const {
|
||||||
return _scroll.data();
|
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 {
|
Key ContentMemento::key() const {
|
||||||
if (const auto topic = this->topic()) {
|
if (const auto topic = this->topic()) {
|
||||||
return Key(topic);
|
return Key(topic);
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "info/info_wrap_widget.h"
|
#include "info/info_wrap_widget.h"
|
||||||
#include "info/statistics/info_statistics_tag.h"
|
#include "info/statistics/info_statistics_tag.h"
|
||||||
|
#include "history/history_view_swipe_data.h"
|
||||||
|
|
||||||
namespace Api {
|
namespace Api {
|
||||||
struct WhoReadList;
|
struct WhoReadList;
|
||||||
|
@ -167,6 +168,7 @@ private:
|
||||||
RpWidget *doSetInnerWidget(object_ptr<RpWidget> inner);
|
RpWidget *doSetInnerWidget(object_ptr<RpWidget> inner);
|
||||||
void updateControlsGeometry();
|
void updateControlsGeometry();
|
||||||
void refreshSearchField(bool shown);
|
void refreshSearchField(bool shown);
|
||||||
|
void setupSwipeReply();
|
||||||
|
|
||||||
virtual std::shared_ptr<ContentMemento> doCreateMemento() = 0;
|
virtual std::shared_ptr<ContentMemento> doCreateMemento() = 0;
|
||||||
|
|
||||||
|
@ -190,6 +192,8 @@ private:
|
||||||
// To paint round edges from content.
|
// To paint round edges from content.
|
||||||
style::margins _paintPadding;
|
style::margins _paintPadding;
|
||||||
|
|
||||||
|
HistoryView::SwipeBackResult _swipeBackData;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ContentMemento {
|
class ContentMemento {
|
||||||
|
|
Loading…
Add table
Reference in a new issue