mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-01 23:15:59 +00:00
Added ability to swipe-to-back to replies section.
This commit is contained in:
@@ -407,7 +407,7 @@ RepliesWidget::RepliesWidget(
|
|||||||
|
|
||||||
setupTopicViewer();
|
setupTopicViewer();
|
||||||
setupComposeControls();
|
setupComposeControls();
|
||||||
setupSwipeReply();
|
setupSwipeReplyAndBack();
|
||||||
orderWidgets();
|
orderWidgets();
|
||||||
|
|
||||||
if (_pinnedBar) {
|
if (_pinnedBar) {
|
||||||
@@ -877,7 +877,7 @@ void RepliesWidget::setupComposeControls() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::setupSwipeReply() {
|
void RepliesWidget::setupSwipeReplyAndBack() {
|
||||||
const auto can = [=](not_null<HistoryItem*> still) {
|
const auto can = [=](not_null<HistoryItem*> still) {
|
||||||
const auto canSendReply = _topic
|
const auto canSendReply = _topic
|
||||||
? Data::CanSendAnything(_topic)
|
? Data::CanSendAnything(_topic)
|
||||||
@@ -892,6 +892,25 @@ void RepliesWidget::setupSwipeReply() {
|
|||||||
};
|
};
|
||||||
HistoryView::SetupSwipeHandler(_inner, _scroll.get(), [=](
|
HistoryView::SetupSwipeHandler(_inner, _scroll.get(), [=](
|
||||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||||
|
if (data.translation > 0) {
|
||||||
|
if (!_swipeBackData.callback) {
|
||||||
|
_swipeBackData = HistoryView::SetupSwipeBack(
|
||||||
|
this,
|
||||||
|
[=]() -> std::pair<QColor, QColor> {
|
||||||
|
const auto context = listPreparePaintContext({
|
||||||
|
.theme = listChatTheme(),
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
context.st->msgServiceBg()->c,
|
||||||
|
context.st->msgServiceFg()->c,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_swipeBackData.callback(data);
|
||||||
|
return;
|
||||||
|
} else if (_swipeBackData.lifetime) {
|
||||||
|
_swipeBackData = {};
|
||||||
|
}
|
||||||
const auto changed = (_gestureHorizontal.msgBareId != data.msgBareId)
|
const auto changed = (_gestureHorizontal.msgBareId != data.msgBareId)
|
||||||
|| (_gestureHorizontal.translation != data.translation)
|
|| (_gestureHorizontal.translation != data.translation)
|
||||||
|| (_gestureHorizontal.reachRatio != data.reachRatio);
|
|| (_gestureHorizontal.reachRatio != data.reachRatio);
|
||||||
@@ -907,6 +926,12 @@ void RepliesWidget::setupSwipeReply() {
|
|||||||
}, [=, show = controller()->uiShow()](
|
}, [=, show = controller()->uiShow()](
|
||||||
int cursorTop,
|
int cursorTop,
|
||||||
Qt::LayoutDirection direction) {
|
Qt::LayoutDirection direction) {
|
||||||
|
if (direction == Qt::RightToLeft) {
|
||||||
|
return HistoryView::SwipeHandlerFinishData{
|
||||||
|
.callback = [=] { controller()->showBackFromStack(); },
|
||||||
|
.msgBareId = HistoryView::kMsgBareIdSwipeBack,
|
||||||
|
};
|
||||||
|
}
|
||||||
auto result = HistoryView::SwipeHandlerFinishData();
|
auto result = HistoryView::SwipeHandlerFinishData();
|
||||||
if (_inner->elementInSelectionMode(nullptr).inSelectionMode) {
|
if (_inner->elementInSelectionMode(nullptr).inSelectionMode) {
|
||||||
return result;
|
return result;
|
||||||
|
@@ -234,7 +234,7 @@ private:
|
|||||||
void finishSending();
|
void finishSending();
|
||||||
|
|
||||||
void setupComposeControls();
|
void setupComposeControls();
|
||||||
void setupSwipeReply();
|
void setupSwipeReplyAndBack();
|
||||||
|
|
||||||
void setupRoot();
|
void setupRoot();
|
||||||
void setupRootView();
|
void setupRootView();
|
||||||
@@ -394,6 +394,7 @@ private:
|
|||||||
rpl::lifetime _topicLifetime;
|
rpl::lifetime _topicLifetime;
|
||||||
|
|
||||||
HistoryView::ChatPaintGestureHorizontalData _gestureHorizontal;
|
HistoryView::ChatPaintGestureHorizontalData _gestureHorizontal;
|
||||||
|
HistoryView::SwipeBackResult _swipeBackData;
|
||||||
|
|
||||||
SendPaymentHelper _sendPayment;
|
SendPaymentHelper _sendPayment;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user