mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Added initial swipe-to-reply to section for replies.
This commit is contained in:
parent
1648c31a22
commit
71e3cd227c
3 changed files with 80 additions and 0 deletions
|
@ -2305,6 +2305,11 @@ void ListWidget::paintUserpics(
|
|||
// paint the userpic if it intersects the painted rect
|
||||
if (userpicTop + st::msgPhotoSize > clip.top()) {
|
||||
const auto item = view->data();
|
||||
const auto hasTranslation = context.gestureHorizontal.ratio
|
||||
&& (context.gestureHorizontal.msgBareId == item->fullId().msg.bare);
|
||||
if (hasTranslation) {
|
||||
p.translate(context.gestureHorizontal.translation, 0);
|
||||
}
|
||||
if (const auto from = item->displayFrom()) {
|
||||
from->paintUserpicLeft(
|
||||
p,
|
||||
|
@ -2337,6 +2342,9 @@ void ListWidget::paintUserpics(
|
|||
} else {
|
||||
Unexpected("Corrupt forwarded information in message.");
|
||||
}
|
||||
if (hasTranslation) {
|
||||
p.translate(-context.gestureHorizontal.translation, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_drag_area.h"
|
||||
#include "history/history_item_components.h"
|
||||
#include "history/history_item_helpers.h" // GetErrorTextForSending.
|
||||
#include "history/history_view_swipe.h"
|
||||
#include "ui/chat/pinned_bar.h"
|
||||
#include "ui/chat/chat_style.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
|
@ -399,6 +400,7 @@ RepliesWidget::RepliesWidget(
|
|||
|
||||
setupTopicViewer();
|
||||
setupComposeControls();
|
||||
setupSwipeReply();
|
||||
orderWidgets();
|
||||
|
||||
if (_pinnedBar) {
|
||||
|
@ -865,6 +867,62 @@ void RepliesWidget::setupComposeControls() {
|
|||
}
|
||||
}
|
||||
|
||||
void RepliesWidget::setupSwipeReply() {
|
||||
const auto can = [=](not_null<HistoryItem*> still) {
|
||||
const auto canSendReply = _topic
|
||||
? Data::CanSendAnything(_topic)
|
||||
: Data::CanSendAnything(_history->peer);
|
||||
const auto allowInAnotherChat = still && still->allowsForward();
|
||||
if (allowInAnotherChat && (_joinGroup || !canSendReply)) {
|
||||
return true;
|
||||
} else if (!_joinGroup && canSendReply) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
HistoryView::SetupSwipeHandler(_inner, _scroll.get(), [=](
|
||||
HistoryView::ChatPaintGestureHorizontalData data) {
|
||||
_gestureHorizontal = data;
|
||||
const auto item = _history->peer->owner().message(
|
||||
_history->peer->id,
|
||||
MsgId{ data.msgBareId });
|
||||
if (item) {
|
||||
_inner->update();
|
||||
// repaintItem(item);
|
||||
}
|
||||
}, [=, show = controller()->uiShow()](int cursorTop) {
|
||||
auto result = HistoryView::SwipeHandlerFinishData();
|
||||
if (_inner->elementInSelectionMode()) {
|
||||
return result;
|
||||
}
|
||||
const auto view = _inner->lookupItemByY(cursorTop);
|
||||
if (!view->data()->isRegular()
|
||||
|| view->data()->isService()) {
|
||||
return result;
|
||||
}
|
||||
if (!can(view->data())) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result.msgBareId = view->data()->fullId().msg.bare;
|
||||
result.callback = [=, itemId = view->data()->fullId()] {
|
||||
const auto still = show->session().data().message(itemId);
|
||||
const auto view = _inner->viewByPosition(still->position());
|
||||
const auto selected = view->selectedQuote(
|
||||
_inner->getSelectedTextRange(still));
|
||||
const auto replyToItemId = (selected.item
|
||||
? selected.item
|
||||
: still)->fullId();
|
||||
_inner->replyToMessageRequestNotify({
|
||||
.messageId = replyToItemId,
|
||||
.quote = selected.text,
|
||||
.quoteOffset = selected.offset,
|
||||
});
|
||||
};
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
void RepliesWidget::chooseAttach(
|
||||
std::optional<bool> overrideSendImagesAsPhotos) {
|
||||
_choosingAttach = false;
|
||||
|
@ -2631,6 +2689,14 @@ void RepliesWidget::listAddTranslatedItems(
|
|||
}
|
||||
}
|
||||
|
||||
Ui::ChatPaintContext RepliesWidget::listPreparePaintContext(
|
||||
Ui::ChatPaintContextArgs &&args) {
|
||||
auto context = WindowListDelegate::listPreparePaintContext(
|
||||
std::move(args));
|
||||
context.gestureHorizontal = _gestureHorizontal;
|
||||
return context;
|
||||
}
|
||||
|
||||
void RepliesWidget::setupEmptyPainter() {
|
||||
Expects(_topic != nullptr);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "window/section_memento.h"
|
||||
#include "history/view/history_view_corner_buttons.h"
|
||||
#include "history/view/history_view_list_widget.h"
|
||||
#include "history/history_view_swipe_data.h"
|
||||
#include "data/data_messages.h"
|
||||
#include "base/timer.h"
|
||||
|
||||
|
@ -180,6 +181,8 @@ public:
|
|||
History *listTranslateHistory() override;
|
||||
void listAddTranslatedItems(
|
||||
not_null<TranslateTracker*> tracker) override;
|
||||
Ui::ChatPaintContext listPreparePaintContext(
|
||||
Ui::ChatPaintContextArgs &&args) override;
|
||||
|
||||
// CornerButtonsDelegate delegate.
|
||||
void cornerButtonsShowAtPosition(
|
||||
|
@ -221,6 +224,7 @@ private:
|
|||
void finishSending();
|
||||
|
||||
void setupComposeControls();
|
||||
void setupSwipeReply();
|
||||
|
||||
void setupRoot();
|
||||
void setupRootView();
|
||||
|
@ -369,6 +373,8 @@ private:
|
|||
HistoryView::CornerButtons _cornerButtons;
|
||||
rpl::lifetime _topicLifetime;
|
||||
|
||||
HistoryView::ChatPaintGestureHorizontalData _gestureHorizontal;
|
||||
|
||||
int _lastScrollTop = 0;
|
||||
int _topicReopenBarHeight = 0;
|
||||
int _scrollTopDelta = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue