Added loading peer animation to peer list content.
This commit is contained in:
parent
1cc3440fcc
commit
22f45bc1fb
|
@ -273,7 +273,7 @@ notificationsSampleMargin: 2px;
|
||||||
notificationSampleOpacity: 0.5;
|
notificationSampleOpacity: 0.5;
|
||||||
notificationSampleSize: size(64px, 16px);
|
notificationSampleSize: size(64px, 16px);
|
||||||
|
|
||||||
membersAboutLimitPadding: margins(0px, 12px, 0px, 12px);
|
membersAboutLimitPadding: margins(0px, 16px, 0px, 16px);
|
||||||
membersAbout: FlatLabel(defaultFlatLabel) {
|
membersAbout: FlatLabel(defaultFlatLabel) {
|
||||||
minWidth: 240px;
|
minWidth: 240px;
|
||||||
textFg: membersAboutLimitFg;
|
textFg: membersAboutLimitFg;
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
#include "ui/effects/loading_element.h"
|
||||||
#include "ui/effects/round_checkbox.h"
|
#include "ui/effects/round_checkbox.h"
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
#include "ui/empty_userpic.h"
|
#include "ui/empty_userpic.h"
|
||||||
|
@ -355,14 +356,6 @@ void PeerListController::setDescriptionText(const QString &text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerListController::setSearchLoadingText(const QString &text) {
|
|
||||||
if (text.isEmpty()) {
|
|
||||||
setSearchLoading(nullptr);
|
|
||||||
} else {
|
|
||||||
setSearchLoading(object_ptr<Ui::FlatLabel>(nullptr, text, st::membersAbout));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerListController::setSearchNoResultsText(const QString &text) {
|
void PeerListController::setSearchNoResultsText(const QString &text) {
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
setSearchNoResults(nullptr);
|
setSearchNoResults(nullptr);
|
||||||
|
@ -1243,7 +1236,7 @@ int PeerListContent::labelHeight() const {
|
||||||
if (!_filterResults.empty()) {
|
if (!_filterResults.empty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (_controller->isSearchLoading()) {
|
if (_controller->isSearchLoading() && _searchLoading) {
|
||||||
return computeLabelHeight(_searchLoading);
|
return computeLabelHeight(_searchLoading);
|
||||||
}
|
}
|
||||||
return computeLabelHeight(_searchNoResults);
|
return computeLabelHeight(_searchNoResults);
|
||||||
|
@ -1279,12 +1272,21 @@ void PeerListContent::setSearchMode(PeerListSearchMode mode) {
|
||||||
}
|
}
|
||||||
_searchMode = mode;
|
_searchMode = mode;
|
||||||
if (_controller->hasComplexSearch()) {
|
if (_controller->hasComplexSearch()) {
|
||||||
|
if (_mode == Mode::Custom) {
|
||||||
if (!_searchLoading) {
|
if (!_searchLoading) {
|
||||||
setSearchLoading(object_ptr<Ui::FlatLabel>(
|
setSearchLoading(object_ptr<Ui::FlatLabel>(
|
||||||
this,
|
this,
|
||||||
tr::lng_contacts_loading(tr::now),
|
tr::lng_contacts_loading(tr::now),
|
||||||
st::membersAbout));
|
st::membersAbout));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (!_loadingAnimation) {
|
||||||
|
_loadingAnimation = Ui::CreateLoadingPeerListItemWidget(
|
||||||
|
this,
|
||||||
|
_st.item,
|
||||||
|
2);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
clearSearchRows();
|
clearSearchRows();
|
||||||
}
|
}
|
||||||
|
@ -1378,6 +1380,14 @@ int PeerListContent::resizeGetHeight(int newWidth) {
|
||||||
_searchLoading->moveToLeft(st::contactsPadding.left(), labelTop + st::membersAboutLimitPadding.top(), newWidth);
|
_searchLoading->moveToLeft(st::contactsPadding.left(), labelTop + st::membersAboutLimitPadding.top(), newWidth);
|
||||||
_searchLoading->setVisible(!hideAll && showingSearch() && _filterResults.empty() && _controller->isSearchLoading());
|
_searchLoading->setVisible(!hideAll && showingSearch() && _filterResults.empty() && _controller->isSearchLoading());
|
||||||
}
|
}
|
||||||
|
if (_loadingAnimation) {
|
||||||
|
_loadingAnimation->resizeToWidth(newWidth);
|
||||||
|
_loadingAnimation->moveToLeft(0, rowsTop(), newWidth);
|
||||||
|
_loadingAnimation->setVisible(!hideAll
|
||||||
|
&& showingSearch()
|
||||||
|
&& _filterResults.empty()
|
||||||
|
&& _controller->isSearchLoading());
|
||||||
|
}
|
||||||
const auto label = labelHeight();
|
const auto label = labelHeight();
|
||||||
const auto belowTop = (label > 0 || rowsCount > 0)
|
const auto belowTop = (label > 0 || rowsCount > 0)
|
||||||
? (labelTop + label + _st.padding.bottom())
|
? (labelTop + label + _st.padding.bottom())
|
||||||
|
|
|
@ -294,7 +294,6 @@ public:
|
||||||
virtual void peerListSetAdditionalTitle(rpl::producer<QString> title) = 0;
|
virtual void peerListSetAdditionalTitle(rpl::producer<QString> title) = 0;
|
||||||
virtual void peerListSetHideEmpty(bool hide) = 0;
|
virtual void peerListSetHideEmpty(bool hide) = 0;
|
||||||
virtual void peerListSetDescription(object_ptr<Ui::FlatLabel> description) = 0;
|
virtual void peerListSetDescription(object_ptr<Ui::FlatLabel> description) = 0;
|
||||||
virtual void peerListSetSearchLoading(object_ptr<Ui::FlatLabel> loading) = 0;
|
|
||||||
virtual void peerListSetSearchNoResults(object_ptr<Ui::FlatLabel> noResults) = 0;
|
virtual void peerListSetSearchNoResults(object_ptr<Ui::FlatLabel> noResults) = 0;
|
||||||
virtual void peerListSetAboveWidget(object_ptr<TWidget> aboveWidget) = 0;
|
virtual void peerListSetAboveWidget(object_ptr<TWidget> aboveWidget) = 0;
|
||||||
virtual void peerListSetAboveSearchWidget(object_ptr<TWidget> aboveWidget) = 0;
|
virtual void peerListSetAboveSearchWidget(object_ptr<TWidget> aboveWidget) = 0;
|
||||||
|
@ -541,14 +540,10 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDescriptionText(const QString &text);
|
void setDescriptionText(const QString &text);
|
||||||
void setSearchLoadingText(const QString &text);
|
|
||||||
void setSearchNoResultsText(const QString &text);
|
void setSearchNoResultsText(const QString &text);
|
||||||
void setDescription(object_ptr<Ui::FlatLabel> description) {
|
void setDescription(object_ptr<Ui::FlatLabel> description) {
|
||||||
delegate()->peerListSetDescription(std::move(description));
|
delegate()->peerListSetDescription(std::move(description));
|
||||||
}
|
}
|
||||||
void setSearchLoading(object_ptr<Ui::FlatLabel> loading) {
|
|
||||||
delegate()->peerListSetSearchLoading(std::move(loading));
|
|
||||||
}
|
|
||||||
void setSearchNoResults(object_ptr<Ui::FlatLabel> noResults) {
|
void setSearchNoResults(object_ptr<Ui::FlatLabel> noResults) {
|
||||||
delegate()->peerListSetSearchNoResults(std::move(noResults));
|
delegate()->peerListSetSearchNoResults(std::move(noResults));
|
||||||
}
|
}
|
||||||
|
@ -822,6 +817,7 @@ private:
|
||||||
object_ptr<Ui::FlatLabel> _description = { nullptr };
|
object_ptr<Ui::FlatLabel> _description = { nullptr };
|
||||||
object_ptr<Ui::FlatLabel> _searchNoResults = { nullptr };
|
object_ptr<Ui::FlatLabel> _searchNoResults = { nullptr };
|
||||||
object_ptr<Ui::FlatLabel> _searchLoading = { nullptr };
|
object_ptr<Ui::FlatLabel> _searchLoading = { nullptr };
|
||||||
|
object_ptr<Ui::RpWidget> _loadingAnimation = { nullptr };
|
||||||
|
|
||||||
std::vector<std::unique_ptr<PeerListRow>> _searchRows;
|
std::vector<std::unique_ptr<PeerListRow>> _searchRows;
|
||||||
base::Timer _repaintByStatus;
|
base::Timer _repaintByStatus;
|
||||||
|
@ -898,9 +894,6 @@ public:
|
||||||
void peerListSetDescription(object_ptr<Ui::FlatLabel> description) override {
|
void peerListSetDescription(object_ptr<Ui::FlatLabel> description) override {
|
||||||
_content->setDescription(std::move(description));
|
_content->setDescription(std::move(description));
|
||||||
}
|
}
|
||||||
void peerListSetSearchLoading(object_ptr<Ui::FlatLabel> loading) override {
|
|
||||||
_content->setSearchLoading(std::move(loading));
|
|
||||||
}
|
|
||||||
void peerListSetSearchNoResults(object_ptr<Ui::FlatLabel> noResults) override {
|
void peerListSetSearchNoResults(object_ptr<Ui::FlatLabel> noResults) override {
|
||||||
_content->setSearchNoResults(std::move(noResults));
|
_content->setSearchNoResults(std::move(noResults));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue