mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Improve empty / archived stories section.
This commit is contained in:
parent
d2dd63e90a
commit
19d0bf142c
10 changed files with 73 additions and 33 deletions
BIN
Telegram/Resources/icons/info/info_media_story_empty.png
Normal file
BIN
Telegram/Resources/icons/info/info_media_story_empty.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
Telegram/Resources/icons/info/info_media_story_empty@2x.png
Normal file
BIN
Telegram/Resources/icons/info/info_media_story_empty@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
BIN
Telegram/Resources/icons/info/info_media_story_empty@3x.png
Normal file
BIN
Telegram/Resources/icons/info/info_media_story_empty@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
|
@ -3818,6 +3818,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_stories_archive_button" = "Stories Archive";
|
||||
"lng_stories_recent_button" = "Recent Stories";
|
||||
"lng_stories_archive_title" = "Stories Archive";
|
||||
"lng_stories_archive_about" = "Only you can see archived stories unless you choose to save them to your profile.";
|
||||
"lng_stories_reply_sent" = "Message Sent";
|
||||
"lng_stories_hidden_to_contacts" = "Those stories are now shown only in your Contacts list.";
|
||||
"lng_stories_shown_in_chats" = "Those stories are now shown in your Chats list.";
|
||||
|
|
|
@ -345,6 +345,7 @@ Content State::next() {
|
|||
.thumbnail = std::move(userpic),
|
||||
.unread = info.unread,
|
||||
.hidden = info.hidden,
|
||||
.profile = true,
|
||||
.skipSmall = user->isSelf(),
|
||||
});
|
||||
}
|
||||
|
@ -419,7 +420,7 @@ rpl::producer<Content> LastForPeer(not_null<PeerData*> peer) {
|
|||
return;
|
||||
}
|
||||
auto resolving = false;
|
||||
auto result = Content();
|
||||
auto result = Content{ .full = true };
|
||||
for (const auto id : ids) {
|
||||
const auto storyId = FullStoryId{ peerId, id };
|
||||
const auto maybe = stories->lookup(storyId);
|
||||
|
|
|
@ -763,9 +763,11 @@ void List::contextMenuEvent(QContextMenuEvent *e) {
|
|||
|
||||
const auto id = item.element.id;
|
||||
const auto hidden = item.element.hidden;
|
||||
_menu->addAction(tr::lng_context_view_profile(tr::now), [=] {
|
||||
_showProfileRequests.fire_copy(id);
|
||||
});
|
||||
if (item.element.profile) {
|
||||
_menu->addAction(tr::lng_context_view_profile(tr::now), [=] {
|
||||
_showProfileRequests.fire_copy(id);
|
||||
});
|
||||
}
|
||||
if (!_content.full || hidden) {
|
||||
_menu->addAction(hidden
|
||||
? tr::lng_stories_show_in_chats(tr::now)
|
||||
|
|
|
@ -36,6 +36,7 @@ struct Element {
|
|||
std::shared_ptr<Thumbnail> thumbnail;
|
||||
bool unread = false;
|
||||
bool hidden = false;
|
||||
bool profile = false;
|
||||
bool skipSmall = false;
|
||||
|
||||
friend inline bool operator==(
|
||||
|
|
|
@ -576,6 +576,7 @@ infoEmptyAudio: icon {{ "info/info_media_audio_empty", infoEmptyFg }};
|
|||
infoEmptyFile: icon {{ "info/info_media_file_empty", infoEmptyFg }};
|
||||
infoEmptyVoice: icon {{ "info/info_media_voice_empty", infoEmptyFg }};
|
||||
infoEmptyLink: icon {{ "info/info_media_link_empty", infoEmptyFg }};
|
||||
infoEmptyStories: icon {{ "info/info_media_story_empty", infoEmptyFg }};
|
||||
infoEmptyIconTop: 120px;
|
||||
infoEmptyLabelTop: 40px;
|
||||
infoEmptyLabelSkip: 20px;
|
||||
|
@ -584,6 +585,14 @@ infoEmptyLabel: FlatLabel(defaultFlatLabel) {
|
|||
textFg: windowSubTextFg;
|
||||
}
|
||||
|
||||
infoStoriesAboutArchive: FlatLabel(defaultFlatLabel) {
|
||||
minWidth: 245px;
|
||||
align: align(top);
|
||||
textFg: windowSubTextFg;
|
||||
style: defaultTextStyle;
|
||||
}
|
||||
infoStoriesAboutArchivePadding: margins(22px, 8px, 22px, 16px);
|
||||
|
||||
editPeerBottomButtonsLayoutMargins: margins(0px, 7px, 0px, 0px);
|
||||
|
||||
editPeerTopButtonsLayoutSkip: 13px;
|
||||
|
|
|
@ -59,7 +59,7 @@ void EmptyWidget::setFullHeight(rpl::producer<int> fullHeightValue) {
|
|||
) | rpl::start_with_next([this](int fullHeight) {
|
||||
// Make icon center be on 1/3 height.
|
||||
auto iconCenter = fullHeight / 3;
|
||||
auto iconHeight = st::infoEmptyFile.height();
|
||||
auto iconHeight = st::infoEmptyStories.height();
|
||||
auto iconTop = iconCenter - iconHeight / 2;
|
||||
_height = iconTop + st::infoEmptyIconTop;
|
||||
resizeToWidth(width());
|
||||
|
@ -81,9 +81,9 @@ int EmptyWidget::resizeGetHeight(int newWidth) {
|
|||
void EmptyWidget::paintEvent(QPaintEvent *e) {
|
||||
auto p = QPainter(this);
|
||||
|
||||
const auto iconLeft = (width() - st::infoEmptyFile.width()) / 2;
|
||||
const auto iconLeft = (width() - st::infoEmptyStories.width()) / 2;
|
||||
const auto iconTop = height() - st::infoEmptyIconTop;
|
||||
st::infoEmptyFile.paint(p, iconLeft, iconTop, width());
|
||||
st::infoEmptyStories.paint(p, iconLeft, iconTop, width());
|
||||
}
|
||||
|
||||
InnerWidget::InnerWidget(
|
||||
|
@ -99,28 +99,31 @@ InnerWidget::InnerWidget(
|
|||
_list = setupList();
|
||||
}
|
||||
|
||||
void InnerWidget::setupArchive() {
|
||||
void InnerWidget::setupTop() {
|
||||
const auto key = _controller->key();
|
||||
const auto peer = key.storiesPeer();
|
||||
if (peer
|
||||
&& peer->isSelf()
|
||||
&& key.storiesTab() == Stories::Tab::Saved
|
||||
&& _isStackBottom) {
|
||||
createArchiveButton();
|
||||
createButtons();
|
||||
} else if (key.storiesTab() == Stories::Tab::Archive) {
|
||||
createAboutArchive();
|
||||
} else {
|
||||
_buttons.destroy();
|
||||
_top.destroy();
|
||||
refreshHeight();
|
||||
}
|
||||
}
|
||||
|
||||
void InnerWidget::createArchiveButton() {
|
||||
_buttons.create(this);
|
||||
_buttons->show();
|
||||
void InnerWidget::createButtons() {
|
||||
_top.create(this);
|
||||
_top->show();
|
||||
_topHeight = _top->heightValue();
|
||||
|
||||
const auto stories = &_controller->session().data().stories();
|
||||
const auto self = _controller->session().user();
|
||||
const auto archive = ::Settings::AddButton(
|
||||
_buttons,
|
||||
_top,
|
||||
tr::lng_stories_archive_button(),
|
||||
st::infoSharedMediaButton);
|
||||
archive->addClickHandler([=] {
|
||||
|
@ -144,11 +147,11 @@ void InnerWidget::createArchiveButton() {
|
|||
st::infoIconMediaStoriesArchive,
|
||||
st::infoSharedMediaButtonIconPosition)->show();
|
||||
|
||||
const auto recentWrap = _buttons->add(
|
||||
const auto recentWrap = _top->add(
|
||||
object_ptr<Ui::SlideWrap<Ui::SettingsButton>>(
|
||||
_buttons,
|
||||
_top,
|
||||
::Settings::CreateButton(
|
||||
_buttons,
|
||||
_top,
|
||||
tr::lng_stories_recent_button(),
|
||||
st::infoSharedMediaButton)));
|
||||
|
||||
|
@ -204,16 +207,36 @@ void InnerWidget::createArchiveButton() {
|
|||
return !content.elements.empty();
|
||||
}));
|
||||
|
||||
_buttons->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
_buttons,
|
||||
_top->add(object_ptr<Ui::FixedHeightWidget>(
|
||||
_top,
|
||||
st::infoProfileSkip));
|
||||
_buttons->add(object_ptr<Ui::BoxContentDivider>(_buttons));
|
||||
_top->add(object_ptr<Ui::BoxContentDivider>(_top));
|
||||
|
||||
_buttons->resizeToWidth(width());
|
||||
_buttons->heightValue(
|
||||
_top->resizeToWidth(width());
|
||||
_top->heightValue(
|
||||
) | rpl::start_with_next([=] {
|
||||
refreshHeight();
|
||||
}, _buttons->lifetime());
|
||||
}, _top->lifetime());
|
||||
}
|
||||
|
||||
void InnerWidget::createAboutArchive() {
|
||||
_top.create(this);
|
||||
_top->show();
|
||||
_topHeight = _top->heightValue();
|
||||
|
||||
_top->add(object_ptr<Ui::DividerLabel>(
|
||||
_top,
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
_top,
|
||||
tr::lng_stories_archive_about(),
|
||||
st::infoStoriesAboutArchive),
|
||||
st::infoStoriesAboutArchivePadding));
|
||||
|
||||
_top->resizeToWidth(width());
|
||||
_top->heightValue(
|
||||
) | rpl::start_with_next([=] {
|
||||
refreshHeight();
|
||||
}, _top->lifetime());
|
||||
}
|
||||
|
||||
void InnerWidget::visibleTopBottomUpdated(
|
||||
|
@ -277,8 +300,8 @@ int InnerWidget::resizeGetHeight(int newWidth) {
|
|||
_inResize = true;
|
||||
auto guard = gsl::finally([this] { _inResize = false; });
|
||||
|
||||
if (_buttons) {
|
||||
_buttons->resizeToWidth(newWidth);
|
||||
if (_top) {
|
||||
_top->resizeToWidth(newWidth);
|
||||
}
|
||||
_list->resizeToWidth(newWidth);
|
||||
_empty->resizeToWidth(newWidth);
|
||||
|
@ -294,9 +317,9 @@ void InnerWidget::refreshHeight() {
|
|||
|
||||
int InnerWidget::recountHeight() {
|
||||
auto top = 0;
|
||||
if (_buttons) {
|
||||
_buttons->moveToLeft(0, top);
|
||||
top += _buttons->heightNoMargins() - st::lineWidth;
|
||||
if (_top) {
|
||||
_top->moveToLeft(0, top);
|
||||
top += _top->heightNoMargins() - st::lineWidth;
|
||||
}
|
||||
auto listHeight = 0;
|
||||
if (_list) {
|
||||
|
@ -321,7 +344,8 @@ void InnerWidget::setScrollHeightValue(rpl::producer<int> value) {
|
|||
_listTops.events_starting_with(
|
||||
_list->topValue()
|
||||
) | rpl::flatten_latest(),
|
||||
_1 - _2));
|
||||
_topHeight.value(),
|
||||
_1 - _2 + _3));
|
||||
}
|
||||
|
||||
rpl::producer<Ui::ScrollToRequest> InnerWidget::scrollToRequests() const {
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
bool showInternal(not_null<Memento*> memento);
|
||||
void setIsStackBottom(bool isStackBottom) {
|
||||
_isStackBottom = isStackBottom;
|
||||
setupArchive();
|
||||
setupTop();
|
||||
}
|
||||
|
||||
void saveState(not_null<Memento*> memento);
|
||||
|
@ -64,14 +64,15 @@ private:
|
|||
int recountHeight();
|
||||
void refreshHeight();
|
||||
|
||||
void setupArchive();
|
||||
void createArchiveButton();
|
||||
void setupTop();
|
||||
void createButtons();
|
||||
void createAboutArchive();
|
||||
|
||||
object_ptr<Media::ListWidget> setupList();
|
||||
|
||||
const not_null<Controller*> _controller;
|
||||
|
||||
object_ptr<Ui::VerticalLayout> _buttons = { nullptr };
|
||||
object_ptr<Ui::VerticalLayout> _top = { nullptr };
|
||||
object_ptr<Media::ListWidget> _list = { nullptr };
|
||||
object_ptr<EmptyWidget> _empty;
|
||||
|
||||
|
@ -81,6 +82,7 @@ private:
|
|||
rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
|
||||
rpl::event_stream<rpl::producer<SelectedItems>> _selectedLists;
|
||||
rpl::event_stream<rpl::producer<int>> _listTops;
|
||||
rpl::variable<int> _topHeight;
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue