mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Added ability to provide custom swipe handler to Info::ContentWidget.
This commit is contained in:
parent
f734c0475b
commit
0d085d500f
4 changed files with 29 additions and 0 deletions
|
@ -410,7 +410,19 @@ not_null<Ui::ScrollArea*> ContentWidget::scroll() const {
|
||||||
return _scroll.data();
|
return _scroll.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContentWidget::replaceSwipeHandler(
|
||||||
|
Ui::Controls::SwipeHandlerArgs *incompleteArgs) {
|
||||||
|
_swipeHandlerLifetime.destroy();
|
||||||
|
auto args = std::move(*incompleteArgs);
|
||||||
|
args.widget = _innerWrap;
|
||||||
|
args.scroll = _scroll.data();
|
||||||
|
args.onLifetime = &_swipeHandlerLifetime;
|
||||||
|
Ui::Controls::SetupSwipeHandler(std::move(args));
|
||||||
|
}
|
||||||
|
|
||||||
void ContentWidget::setupSwipeHandler(not_null<Ui::RpWidget*> widget) {
|
void ContentWidget::setupSwipeHandler(not_null<Ui::RpWidget*> widget) {
|
||||||
|
_swipeHandlerLifetime.destroy();
|
||||||
|
|
||||||
auto update = [=](Ui::Controls::SwipeContextData data) {
|
auto update = [=](Ui::Controls::SwipeContextData data) {
|
||||||
if (data.translation > 0) {
|
if (data.translation > 0) {
|
||||||
if (!_swipeBackData.callback) {
|
if (!_swipeBackData.callback) {
|
||||||
|
@ -446,6 +458,7 @@ void ContentWidget::setupSwipeHandler(not_null<Ui::RpWidget*> widget) {
|
||||||
.scroll = _scroll.data(),
|
.scroll = _scroll.data(),
|
||||||
.update = std::move(update),
|
.update = std::move(update),
|
||||||
.init = std::move(init),
|
.init = std::move(init),
|
||||||
|
.onLifetime = &_swipeHandlerLifetime,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,9 @@ enum class SharedMediaType : signed char;
|
||||||
} // namespace Storage
|
} // namespace Storage
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
namespace Controls {
|
||||||
|
struct SwipeHandlerArgs;
|
||||||
|
} // namespace Controls
|
||||||
class RoundRect;
|
class RoundRect;
|
||||||
class ScrollArea;
|
class ScrollArea;
|
||||||
class InputField;
|
class InputField;
|
||||||
|
@ -135,6 +138,8 @@ public:
|
||||||
[[nodiscard]] virtual auto desiredBottomShadowVisibility()
|
[[nodiscard]] virtual auto desiredBottomShadowVisibility()
|
||||||
-> rpl::producer<bool>;
|
-> rpl::producer<bool>;
|
||||||
|
|
||||||
|
void replaceSwipeHandler(Ui::Controls::SwipeHandlerArgs *incompleteArgs);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
template <typename Widget>
|
template <typename Widget>
|
||||||
Widget *setInnerWidget(object_ptr<Widget> inner) {
|
Widget *setInnerWidget(object_ptr<Widget> inner) {
|
||||||
|
@ -196,6 +201,7 @@ private:
|
||||||
style::margins _paintPadding;
|
style::margins _paintPadding;
|
||||||
|
|
||||||
Ui::Controls::SwipeBackResult _swipeBackData;
|
Ui::Controls::SwipeBackResult _swipeBackData;
|
||||||
|
rpl::lifetime _swipeHandlerLifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1059,6 +1059,11 @@ bool WrapWidget::willHaveBackButton(
|
||||||
return (wrap() == Wrap::Narrow) || willHaveStack;
|
return (wrap() == Wrap::Narrow) || willHaveStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WrapWidget::replaceSwipeHandler(
|
||||||
|
Ui::Controls::SwipeHandlerArgs *incompleteArgs) {
|
||||||
|
_content->replaceSwipeHandler(std::move(incompleteArgs));
|
||||||
|
}
|
||||||
|
|
||||||
WrapWidget::~WrapWidget() = default;
|
WrapWidget::~WrapWidget() = default;
|
||||||
|
|
||||||
} // namespace Info
|
} // namespace Info
|
||||||
|
|
|
@ -15,6 +15,9 @@ enum class SharedMediaType : signed char;
|
||||||
} // namespace Storage
|
} // namespace Storage
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
namespace Controls {
|
||||||
|
struct SwipeHandlerArgs;
|
||||||
|
} // namespace Controls
|
||||||
class FadeShadow;
|
class FadeShadow;
|
||||||
class PlainShadow;
|
class PlainShadow;
|
||||||
class PopupMenu;
|
class PopupMenu;
|
||||||
|
@ -140,6 +143,8 @@ public:
|
||||||
return _removeRequests.events();
|
return _removeRequests.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void replaceSwipeHandler(Ui::Controls::SwipeHandlerArgs *incompleteArgs);
|
||||||
|
|
||||||
~WrapWidget();
|
~WrapWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Add table
Reference in a new issue