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