mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Added ability to emplace top bar suggestion later.
This commit is contained in:
parent
8d449f91c6
commit
2eab7044ba
2 changed files with 43 additions and 30 deletions
|
@ -379,36 +379,6 @@ Widget::Widget(
|
|||
OverscrollType::Real);
|
||||
const auto innerList = _scroll->setOwnedWidget(
|
||||
object_ptr<Ui::VerticalLayout>(this));
|
||||
if (_layout != Layout::Child) {
|
||||
TopBarSuggestionValue(
|
||||
innerList,
|
||||
&session()
|
||||
) | rpl::start_with_next([=](Ui::SlideWrap<Ui::RpWidget> *raw) {
|
||||
if (raw) {
|
||||
_topBarSuggestion = innerList->insert(
|
||||
0,
|
||||
object_ptr<Ui::SlideWrap<Ui::RpWidget>>::fromRaw(raw));
|
||||
rpl::combine(
|
||||
_topBarSuggestion->entity()->desiredHeightValue(),
|
||||
_childListShown.value()
|
||||
) | rpl::start_with_next([=](
|
||||
int desiredHeight,
|
||||
float64 shown) {
|
||||
const auto newHeight = desiredHeight * (1. - shown);
|
||||
_topBarSuggestion->entity()->setMaximumHeight(newHeight);
|
||||
_topBarSuggestion->entity()->setMinimumWidth((shown > 0)
|
||||
? width()
|
||||
: 0);
|
||||
_topBarSuggestion->entity()->resize(width(), newHeight);
|
||||
}, _topBarSuggestion->lifetime());
|
||||
} else {
|
||||
if (_topBarSuggestion) {
|
||||
delete _topBarSuggestion;
|
||||
}
|
||||
_topBarSuggestion = nullptr;
|
||||
}
|
||||
}, lifetime());
|
||||
}
|
||||
_inner = innerList->add(object_ptr<InnerWidget>(
|
||||
innerList,
|
||||
controller,
|
||||
|
@ -725,6 +695,7 @@ Widget::Widget(
|
|||
}
|
||||
|
||||
setupFrozenAccountBar();
|
||||
setupTopBarSuggestions(innerList);
|
||||
}
|
||||
|
||||
void Widget::setupSwipeBack() {
|
||||
|
@ -1047,6 +1018,46 @@ void Widget::setupFrozenAccountBar() {
|
|||
}, lifetime());
|
||||
}
|
||||
|
||||
void Widget::setupTopBarSuggestions(not_null<Ui::VerticalLayout*> dialogs) {
|
||||
if (_layout == Layout::Child) {
|
||||
return;
|
||||
}
|
||||
using namespace rpl::mappers;
|
||||
crl::on_main(&session(), [=, session = &session()] {
|
||||
(session->data().chatsListLoaded(nullptr)
|
||||
? rpl::single<Data::Folder*>(nullptr)
|
||||
: session->data().chatsListLoadedEvents()
|
||||
) | rpl::filter(_1 == nullptr) | rpl::map([=] {
|
||||
return TopBarSuggestionValue(dialogs, session);
|
||||
}) | rpl::flatten_latest() | rpl::start_with_next([=](
|
||||
Ui::SlideWrap<Ui::RpWidget> *raw) {
|
||||
if (raw) {
|
||||
_topBarSuggestion = dialogs->insert(
|
||||
0,
|
||||
object_ptr<Ui::SlideWrap<Ui::RpWidget>>::fromRaw(raw));
|
||||
rpl::combine(
|
||||
_topBarSuggestion->entity()->desiredHeightValue(),
|
||||
_childListShown.value()
|
||||
) | rpl::start_with_next([=](
|
||||
int desiredHeight,
|
||||
float64 shown) {
|
||||
const auto newHeight = desiredHeight * (1. - shown);
|
||||
_topBarSuggestion->entity()->setMaximumHeight(newHeight);
|
||||
_topBarSuggestion->entity()->setMinimumWidth((shown > 0)
|
||||
? width()
|
||||
: 0);
|
||||
_topBarSuggestion->entity()->resize(width(), newHeight);
|
||||
}, _topBarSuggestion->lifetime());
|
||||
} else {
|
||||
if (_topBarSuggestion) {
|
||||
delete _topBarSuggestion;
|
||||
}
|
||||
_topBarSuggestion = nullptr;
|
||||
}
|
||||
}, lifetime());
|
||||
});
|
||||
}
|
||||
|
||||
void Widget::updateFrozenAccountBar() {
|
||||
if (_layout == Layout::Child
|
||||
|| _openedForum
|
||||
|
|
|
@ -55,6 +55,7 @@ template <typename Widget>
|
|||
class FadeWrapScaled;
|
||||
template <typename Widget>
|
||||
class SlideWrap;
|
||||
class VerticalLayout;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Window {
|
||||
|
@ -210,6 +211,7 @@ private:
|
|||
void setupShortcuts();
|
||||
void setupStories();
|
||||
void setupSwipeBack();
|
||||
void setupTopBarSuggestions(not_null<Ui::VerticalLayout*> dialogs);
|
||||
void storiesExplicitCollapse();
|
||||
void collectStoriesUserpicsViews(Data::StorySourcesList list);
|
||||
void storiesToggleExplicitExpand(bool expand);
|
||||
|
|
Loading…
Add table
Reference in a new issue