mirror of https://github.com/procxx/kepka.git
Inject active peer profile on the stack bottom.
Always have active peer profile on the bottom of third column stack.
This commit is contained in:
parent
c872cd76e1
commit
55616a4d1b
|
@ -89,10 +89,6 @@ rpl::producer<Wrap> Controller::wrapValue() const {
|
||||||
return _widget->wrapValue();
|
return _widget->wrapValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Controller::hasStackHistory() const {
|
|
||||||
return _widget->hasStackHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Controller::validateMementoPeer(
|
bool Controller::validateMementoPeer(
|
||||||
not_null<ContentMemento*> memento) const {
|
not_null<ContentMemento*> memento) const {
|
||||||
return memento->peerId() == peerId()
|
return memento->peerId() == peerId()
|
||||||
|
|
|
@ -98,7 +98,6 @@ public:
|
||||||
Wrap wrap() const;
|
Wrap wrap() const;
|
||||||
rpl::producer<Wrap> wrapValue() const;
|
rpl::producer<Wrap> wrapValue() const;
|
||||||
void setSection(not_null<ContentMemento*> memento);
|
void setSection(not_null<ContentMemento*> memento);
|
||||||
bool hasStackHistory() const;
|
|
||||||
|
|
||||||
not_null<Window::Controller*> window() const {
|
not_null<Window::Controller*> window() const {
|
||||||
return _window;
|
return _window;
|
||||||
|
|
|
@ -58,7 +58,7 @@ const style::InfoTopBar &TopBarStyle(Wrap wrap) {
|
||||||
|
|
||||||
struct WrapWidget::StackItem {
|
struct WrapWidget::StackItem {
|
||||||
std::unique_ptr<ContentMemento> section;
|
std::unique_ptr<ContentMemento> section;
|
||||||
std::unique_ptr<ContentMemento> anotherTab;
|
// std::unique_ptr<ContentMemento> anotherTab;
|
||||||
};
|
};
|
||||||
|
|
||||||
WrapWidget::WrapWidget(
|
WrapWidget::WrapWidget(
|
||||||
|
@ -91,7 +91,10 @@ WrapWidget::WrapWidget(
|
||||||
void WrapWidget::restoreHistoryStack(
|
void WrapWidget::restoreHistoryStack(
|
||||||
std::vector<std::unique_ptr<ContentMemento>> stack) {
|
std::vector<std::unique_ptr<ContentMemento>> stack) {
|
||||||
Expects(!stack.empty());
|
Expects(!stack.empty());
|
||||||
Expects(_historyStack.empty());
|
Expects(!hasStackHistory());
|
||||||
|
|
||||||
|
startInjectingActivePeerProfiles();
|
||||||
|
|
||||||
auto content = std::move(stack.back());
|
auto content = std::move(stack.back());
|
||||||
stack.pop_back();
|
stack.pop_back();
|
||||||
if (!stack.empty()) {
|
if (!stack.empty()) {
|
||||||
|
@ -105,6 +108,43 @@ void WrapWidget::restoreHistoryStack(
|
||||||
showNewContent(content.get());
|
showNewContent(content.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WrapWidget::startInjectingActivePeerProfiles() {
|
||||||
|
using namespace rpl::mappers;
|
||||||
|
rpl::combine(
|
||||||
|
_wrap.value(),
|
||||||
|
_controller->window()->activePeer.value())
|
||||||
|
| rpl::filter(($1 == Wrap::Side) && ($2 != nullptr))
|
||||||
|
| rpl::map($2)
|
||||||
|
| rpl::start_with_next([this](not_null<PeerData*> peer) {
|
||||||
|
injectActivePeerProfile(peer);
|
||||||
|
}, lifetime());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void WrapWidget::injectActivePeerProfile(not_null<PeerData*> peer) {
|
||||||
|
auto firstPeerId = hasStackHistory()
|
||||||
|
? _historyStack.front().section->peerId()
|
||||||
|
: _controller->peerId();
|
||||||
|
auto firstSectionType = hasStackHistory()
|
||||||
|
? _historyStack.front().section->section().type()
|
||||||
|
: _controller->section().type();
|
||||||
|
if (firstSectionType != Section::Type::Profile
|
||||||
|
|| firstPeerId != peer->id) {
|
||||||
|
auto injected = StackItem();
|
||||||
|
injected.section = std::move(
|
||||||
|
Memento(peer->id).takeStack().front());
|
||||||
|
_historyStack.insert(
|
||||||
|
_historyStack.begin(),
|
||||||
|
std::move(injected));
|
||||||
|
afterStackHistoryInject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WrapWidget::afterStackHistoryInject() {
|
||||||
|
setupTop();
|
||||||
|
finishShowContent();
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<Controller> WrapWidget::createController(
|
std::unique_ptr<Controller> WrapWidget::createController(
|
||||||
not_null<Window::Controller*> window,
|
not_null<Window::Controller*> window,
|
||||||
not_null<ContentMemento*> memento) {
|
not_null<ContentMemento*> memento) {
|
||||||
|
@ -230,7 +270,7 @@ void WrapWidget::forceContentRepaint() {
|
||||||
void WrapWidget::setupTop() {
|
void WrapWidget::setupTop() {
|
||||||
// This was done for tabs support.
|
// This was done for tabs support.
|
||||||
//
|
//
|
||||||
//if (wrap() == Wrap::Side && _historyStack.empty()) {
|
//if (wrap() == Wrap::Side && !hasStackHistory()) {
|
||||||
// setupTabbedTop();
|
// setupTabbedTop();
|
||||||
//} else {
|
//} else {
|
||||||
// setupTabs(Tab::None);
|
// setupTabs(Tab::None);
|
||||||
|
@ -459,13 +499,13 @@ bool WrapWidget::requireTopBarSearch() const {
|
||||||
void WrapWidget::showBackFromStack() {
|
void WrapWidget::showBackFromStack() {
|
||||||
auto params = Window::SectionShow(
|
auto params = Window::SectionShow(
|
||||||
Window::SectionShow::Way::Backward);
|
Window::SectionShow::Way::Backward);
|
||||||
if (!_historyStack.empty()) {
|
if (hasStackHistory()) {
|
||||||
auto last = std::move(_historyStack.back());
|
auto last = std::move(_historyStack.back());
|
||||||
_historyStack.pop_back();
|
_historyStack.pop_back();
|
||||||
showNewContent(
|
showNewContent(
|
||||||
last.section.get(),
|
last.section.get(),
|
||||||
params);
|
params);
|
||||||
_anotherTabMemento = std::move(last.anotherTab);
|
//_anotherTabMemento = std::move(last.anotherTab);
|
||||||
} else {
|
} else {
|
||||||
_controller->window()->showBackFromStack(params);
|
_controller->window()->showBackFromStack(params);
|
||||||
}
|
}
|
||||||
|
@ -483,12 +523,12 @@ not_null<Ui::RpWidget*> WrapWidget::topWidget() const {
|
||||||
void WrapWidget::showContent(object_ptr<ContentWidget> content) {
|
void WrapWidget::showContent(object_ptr<ContentWidget> content) {
|
||||||
_content = std::move(content);
|
_content = std::move(content);
|
||||||
_content->show();
|
_content->show();
|
||||||
_anotherTabMemento = nullptr;
|
//_anotherTabMemento = nullptr;
|
||||||
finishShowContent();
|
finishShowContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WrapWidget::finishShowContent() {
|
void WrapWidget::finishShowContent() {
|
||||||
_content->setIsStackBottom(_historyStack.empty());
|
_content->setIsStackBottom(!hasStackHistory());
|
||||||
updateContentGeometry();
|
updateContentGeometry();
|
||||||
_desiredHeights.fire(desiredHeightForContent());
|
_desiredHeights.fire(desiredHeightForContent());
|
||||||
_desiredShadowVisibilities.fire(_content->desiredShadowVisibility());
|
_desiredShadowVisibilities.fire(_content->desiredShadowVisibility());
|
||||||
|
@ -528,19 +568,21 @@ rpl::producer<SelectedItems> WrapWidget::selectedListValue() const {
|
||||||
return _selectedLists.events() | rpl::flatten_latest();
|
return _selectedLists.events() | rpl::flatten_latest();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<ContentMemento> WrapWidget::createTabMemento(
|
// Was done for top level tabs support.
|
||||||
Tab tab) {
|
//
|
||||||
switch (tab) {
|
//std::unique_ptr<ContentMemento> WrapWidget::createTabMemento(
|
||||||
case Tab::Profile: return std::make_unique<Profile::Memento>(
|
// Tab tab) {
|
||||||
_controller->peerId(),
|
// switch (tab) {
|
||||||
_controller->migratedPeerId());
|
// case Tab::Profile: return std::make_unique<Profile::Memento>(
|
||||||
case Tab::Media: return std::make_unique<Media::Memento>(
|
// _controller->peerId(),
|
||||||
_controller->peerId(),
|
// _controller->migratedPeerId());
|
||||||
_controller->migratedPeerId(),
|
// case Tab::Media: return std::make_unique<Media::Memento>(
|
||||||
Media::Type::Photo);
|
// _controller->peerId(),
|
||||||
}
|
// _controller->migratedPeerId(),
|
||||||
Unexpected("Tab value in Info::WrapWidget::createInner()");
|
// Media::Type::Photo);
|
||||||
}
|
// }
|
||||||
|
// Unexpected("Tab value in Info::WrapWidget::createInner()");
|
||||||
|
//}
|
||||||
|
|
||||||
object_ptr<ContentWidget> WrapWidget::createContent(
|
object_ptr<ContentWidget> WrapWidget::createContent(
|
||||||
not_null<ContentMemento*> memento,
|
not_null<ContentMemento*> memento,
|
||||||
|
@ -554,7 +596,7 @@ object_ptr<ContentWidget> WrapWidget::createContent(
|
||||||
// Was done for top level tabs support.
|
// Was done for top level tabs support.
|
||||||
//
|
//
|
||||||
//void WrapWidget::convertProfileFromStackToTab() {
|
//void WrapWidget::convertProfileFromStackToTab() {
|
||||||
// if (_historyStack.empty()) {
|
// if (!hasStackHistory()) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// auto &entry = _historyStack[0];
|
// auto &entry = _historyStack[0];
|
||||||
|
@ -641,7 +683,7 @@ bool WrapWidget::showInternal(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto content = infoMemento->content();
|
auto content = infoMemento->content();
|
||||||
auto skipInternal = !_historyStack.empty()
|
auto skipInternal = hasStackHistory()
|
||||||
&& (params.way == Window::SectionShow::Way::ClearStack);
|
&& (params.way == Window::SectionShow::Way::ClearStack);
|
||||||
if (_controller->validateMementoPeer(content)
|
if (_controller->validateMementoPeer(content)
|
||||||
&& infoMemento->stackSize() == 1) {
|
&& infoMemento->stackSize() == 1) {
|
||||||
|
@ -731,9 +773,9 @@ void WrapWidget::showNewContent(
|
||||||
if (saveToStack) {
|
if (saveToStack) {
|
||||||
auto item = StackItem();
|
auto item = StackItem();
|
||||||
item.section = _content->createMemento();
|
item.section = _content->createMemento();
|
||||||
if (_anotherTabMemento) {
|
//if (_anotherTabMemento) {
|
||||||
item.anotherTab = std::move(_anotherTabMemento);
|
// item.anotherTab = std::move(_anotherTabMemento);
|
||||||
}
|
//}
|
||||||
_historyStack.push_back(std::move(item));
|
_historyStack.push_back(std::move(item));
|
||||||
} else if (params.way == Window::SectionShow::Way::ClearStack) {
|
} else if (params.way == Window::SectionShow::Way::ClearStack) {
|
||||||
_historyStack.clear();
|
_historyStack.clear();
|
||||||
|
|
|
@ -98,9 +98,6 @@ public:
|
||||||
return _wrap.value();
|
return _wrap.value();
|
||||||
}
|
}
|
||||||
void setWrap(Wrap wrap);
|
void setWrap(Wrap wrap);
|
||||||
bool hasStackHistory() const {
|
|
||||||
return !_historyStack.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
not_null<Controller*> controller() {
|
not_null<Controller*> controller() {
|
||||||
return _controller.get();
|
return _controller.get();
|
||||||
|
@ -141,15 +138,21 @@ protected:
|
||||||
private:
|
private:
|
||||||
using SlideDirection = Window::SlideDirection;
|
using SlideDirection = Window::SlideDirection;
|
||||||
using SectionSlideParams = Window::SectionSlideParams;
|
using SectionSlideParams = Window::SectionSlideParams;
|
||||||
enum class Tab {
|
//enum class Tab {
|
||||||
Profile,
|
// Profile,
|
||||||
Media,
|
// Media,
|
||||||
None,
|
// None,
|
||||||
};
|
//};
|
||||||
struct StackItem;
|
struct StackItem;
|
||||||
|
|
||||||
|
void startInjectingActivePeerProfiles();
|
||||||
|
void afterStackHistoryInject();
|
||||||
|
void injectActivePeerProfile(not_null<PeerData*> peer);
|
||||||
void restoreHistoryStack(
|
void restoreHistoryStack(
|
||||||
std::vector<std::unique_ptr<ContentMemento>> stack);
|
std::vector<std::unique_ptr<ContentMemento>> stack);
|
||||||
|
bool hasStackHistory() const {
|
||||||
|
return !_historyStack.empty();
|
||||||
|
}
|
||||||
void showBackFromStack();
|
void showBackFromStack();
|
||||||
void showNewContent(not_null<ContentMemento*> memento);
|
void showNewContent(not_null<ContentMemento*> memento);
|
||||||
void showNewContent(
|
void showNewContent(
|
||||||
|
@ -172,7 +175,7 @@ private:
|
||||||
|
|
||||||
//void showTab(Tab tab);
|
//void showTab(Tab tab);
|
||||||
void showContent(object_ptr<ContentWidget> content);
|
void showContent(object_ptr<ContentWidget> content);
|
||||||
std::unique_ptr<ContentMemento> createTabMemento(Tab tab);
|
//std::unique_ptr<ContentMemento> createTabMemento(Tab tab);
|
||||||
object_ptr<ContentWidget> createContent(
|
object_ptr<ContentWidget> createContent(
|
||||||
not_null<ContentMemento*> memento,
|
not_null<ContentMemento*> memento,
|
||||||
not_null<Controller*> controller);
|
not_null<Controller*> controller);
|
||||||
|
@ -205,8 +208,8 @@ private:
|
||||||
base::unique_qptr<Ui::IconButton> _topBarMenuToggle;
|
base::unique_qptr<Ui::IconButton> _topBarMenuToggle;
|
||||||
base::unique_qptr<Ui::DropdownMenu> _topBarMenu;
|
base::unique_qptr<Ui::DropdownMenu> _topBarMenu;
|
||||||
|
|
||||||
Tab _tab = Tab::Profile;
|
// Tab _tab = Tab::Profile;
|
||||||
std::unique_ptr<ContentMemento> _anotherTabMemento;
|
// std::unique_ptr<ContentMemento> _anotherTabMemento;
|
||||||
std::vector<StackItem> _historyStack;
|
std::vector<StackItem> _historyStack;
|
||||||
|
|
||||||
rpl::event_stream<rpl::producer<int>> _desiredHeights;
|
rpl::event_stream<rpl::producer<int>> _desiredHeights;
|
||||||
|
|
Loading…
Reference in New Issue