Added lottie icon and button to dialogs widget when dialogs are empty.

This commit is contained in:
23rd 2025-07-14 09:54:32 +03:00 committed by John Preston
parent a770e47575
commit 38c74bf2cf
6 changed files with 90 additions and 3 deletions

Binary file not shown.

View file

@ -434,6 +434,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_dlg_new_channel_name" = "Channel name";
"lng_dlg_new_bot_name" = "Bot name";
"lng_no_chats" = "Your chats will be here";
"lng_no_conversations" = "You have no\nconversations yet.";
"lng_no_conversations_button" = "New Message";
"lng_no_conversations_subtitle" = "Your contacts on Telegram";
"lng_no_chats_filter" = "No chats currently belong to this folder.";
"lng_no_saved_sublists" = "You can save messages from other chats here.";
"lng_contacts_loading" = "Loading...";

View file

@ -38,6 +38,7 @@
<file alias="topics_tabs.tgs">../../animations/edit_peers/topics_tabs.tgs</file>
<file alias="topics_list.tgs">../../animations/edit_peers/topics_list.tgs</file>
<file alias="direct_messages.tgs">../../animations/edit_peers/direct_messages.tgs</file>
<file alias="no_chats.tgs">../../animations/no_chats.tgs</file>
<file alias="dice_idle.tgs">../../animations/dice/dice_idle.tgs</file>
<file alias="dart_idle.tgs">../../animations/dice/dart_idle.tgs</file>

View file

@ -244,6 +244,17 @@ dialogsEmptyLabel: FlatLabel(defaultFlatLabel) {
align: align(top);
textFg: windowSubTextFg;
}
dialogEmptyButton: RoundButton(defaultActiveButton) {
}
dialogEmptyButtonSkip: 12px;
dialogEmptyButtonLabel: FlatLabel(defaultFlatLabel) {
style: TextStyle(defaultTextStyle) {
font: font(boxFontSize semibold);
}
minWidth: 32px;
align: align(top);
textFg: windowFg;
}
dialogsMenuToggle: IconButton {
width: 40px;

View file

@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h"
#include "ui/text/text_options.h"
#include "ui/dynamic_thumbnails.h"
#include "ui/vertical_list.h"
#include "ui/painter.h"
#include "ui/rect.h"
#include "ui/ui_utility.h"
@ -58,8 +59,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/options.h"
#include "lang/lang_keys.h"
#include "lottie/lottie_icon.h"
#include "mainwindow.h"
#include "mainwidget.h"
#include "settings/settings_common.h"
#include "storage/storage_account.h"
#include "apiwrap.h"
#include "main/main_session.h"
@ -80,6 +80,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "api/api_chat_filters.h"
#include "base/qt/qt_common_adapters.h"
#include "styles/style_dialogs.h"
#include "styles/style_boxes.h"
#include "styles/style_chat.h" // popupMenuExpandedSeparator
#include "styles/style_chat_helpers.h"
#include "styles/style_color_indices.h"
@ -4075,9 +4076,18 @@ void InnerWidget::refreshEmpty() {
if (state == EmptyState::None) {
_emptyState = state;
_empty.destroy();
_emptyList.destroy();
_emptyButton.destroy();
return;
} else if (_emptyState == state) {
_empty->setVisible(_state == WidgetState::Default);
if (_emptyList) {
_emptyList->setVisible(_state == WidgetState::Default);
_empty->setVisible(!_emptyList->isVisible());
}
if (_emptyButton) {
_emptyButton->setVisible(_state == WidgetState::Default);
}
return;
}
_emptyState = state;
@ -4108,7 +4118,6 @@ void InnerWidget::refreshEmpty() {
return result;
});
_empty.create(this, std::move(full), st::dialogsEmptyLabel);
resizeEmpty();
_empty->overrideLinkClickHandler([=] {
if (_emptyState == EmptyState::NoContacts) {
_controller->showAddContact();
@ -4120,6 +4129,58 @@ void InnerWidget::refreshEmpty() {
}
});
_empty->setVisible(_state == WidgetState::Default);
if (state == EmptyState::NoContacts) {
const auto isListVisible = _state == WidgetState::Default;
_emptyList.create(this);
_emptyList->setVisible(isListVisible);
auto icon = ::Settings::CreateLottieIcon(
_emptyList,
{
.name = u"no_chats"_q,
.sizeOverride = Size(st::changePhoneIconSize),
});
const auto iconWidget = _emptyList->add(
object_ptr<Ui::CenterWrap<>>(_emptyList, std::move(icon.widget)));
Ui::AddSkip(_emptyList);
const auto label = _emptyList->add(
object_ptr<Ui::FlatLabel>(
_emptyList,
tr::lng_no_conversations(),
st::dialogEmptyButtonLabel));
if (_state == WidgetState::Default) {
icon.animate(anim::repeat::once);
}
_emptyButton.create(
this,
tr::lng_no_conversations_button(),
st::dialogEmptyButton);
_emptyButton->setTextTransform(
Ui::RoundButton::TextTransform::NoTransform);
_emptyButton->setVisible(isListVisible);
_emptyButton->setClickedCallback([=, window = _controller] {
window->show(PrepareContactsBox(window));
});
geometryValue() | rpl::start_with_next([=](const QRect &r) {
const auto top = r.height()
- _emptyButton->height()
- st::dialogEmptyButtonSkip;
_emptyButton->moveToLeft(st::dialogEmptyButtonSkip, top);
}, _emptyButton->lifetime());
geometryValue() | rpl::start_with_next([=](const QRect &r) {
const auto bottom = _emptyButton
? (_emptyButton->height() + st::dialogEmptyButtonSkip)
: 0;
_emptyList->moveToLeft(
0,
((r.height() - bottom) - _emptyList->height()) / 2);
}, _emptyList->lifetime());
_empty->setVisible(!_emptyList->isVisible());
}
resizeEmpty();
}
void InnerWidget::resizeEmpty() {
@ -4128,6 +4189,13 @@ void InnerWidget::resizeEmpty() {
_empty->resizeToWidth(width() - 2 * skip);
_empty->move(skip, (st::dialogsEmptyHeight - _empty->height()) / 2);
}
if (_emptyList) {
_emptyList->resizeToWidth(width());
}
if (_emptyButton) {
const auto skip = st::dialogEmptyButtonSkip;
_emptyButton->resizeToWidth(width() - 2 * skip);
}
if (_searchEmpty) {
_searchEmpty->resizeToWidth(width());
_searchEmpty->move(0, searchedOffset());

View file

@ -43,6 +43,8 @@ namespace Ui {
class IconButton;
class PopupMenu;
class FlatLabel;
class VerticalLayout;
class RoundButton;
struct ScrollToRequest;
namespace Controls {
enum class QuickDialogAction;
@ -619,6 +621,8 @@ private:
object_ptr<SearchEmpty> _searchEmpty = { nullptr };
SearchState _searchEmptyState;
object_ptr<Ui::FlatLabel> _empty = { nullptr };
object_ptr<Ui::VerticalLayout> _emptyList = { nullptr };
object_ptr<Ui::RoundButton> _emptyButton = { nullptr };
Ui::DraggingScrollManager _draggingScroll;