diff --git a/Telegram/Resources/icons/info_media_file.png b/Telegram/Resources/icons/info_media_file.png new file mode 100644 index 0000000000..b8840c6ebf Binary files /dev/null and b/Telegram/Resources/icons/info_media_file.png differ diff --git a/Telegram/Resources/icons/info_media_file@2x.png b/Telegram/Resources/icons/info_media_file@2x.png new file mode 100644 index 0000000000..80b049a535 Binary files /dev/null and b/Telegram/Resources/icons/info_media_file@2x.png differ diff --git a/Telegram/Resources/icons/info_media_video.png b/Telegram/Resources/icons/info_media_video.png new file mode 100644 index 0000000000..e252c92f97 Binary files /dev/null and b/Telegram/Resources/icons/info_media_video.png differ diff --git a/Telegram/Resources/icons/info_media_video@2x.png b/Telegram/Resources/icons/info_media_video@2x.png new file mode 100644 index 0000000000..20295c958f Binary files /dev/null and b/Telegram/Resources/icons/info_media_video@2x.png differ diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 60be6d1a61..60fa44589e 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -631,6 +631,20 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org "lng_profile_delete_conversation" = "Delete conversation"; "lng_profile_block_user" = "Block user"; "lng_profile_unblock_user" = "Unblock user"; +"lng_media_selected_photo#one" = "{count} Photo"; +"lng_media_selected_photo#other" = "{count} Photos"; +"lng_media_selected_video#one" = "{count} Video"; +"lng_media_selected_video#other" = "{count} Videos"; +"lng_media_selected_song#one" = "{count} Audio file"; +"lng_media_selected_song#other" = "{count} Audio files"; +"lng_media_selected_file#one" = "{count} File"; +"lng_media_selected_file#other" = "{count} Files"; +"lng_media_selected_audio#one" = "{count} Voice message"; +"lng_media_selected_audio#other" = "{count} Voice messages"; +"lng_media_selected_round#one" = "{count} Video message"; +"lng_media_selected_round#other" = "{count} video messages"; +"lng_media_selected_link#one" = "{count} Shared link"; +"lng_media_selected_link#other" = "{count} Shared links"; "lng_report_title" = "Report channel"; "lng_report_group_title" = "Report group"; diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index 16fbc1e931..09fd66c6de 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -209,6 +209,8 @@ infoIconMembers: icon {{ "info_members", infoIconFg }}; infoIconNotifications: icon {{ "info_notifications", infoIconFg }}; infoIconActions: icon {{ "info_actions", infoIconFg }}; infoIconMediaPhoto: icon {{ "info_media_photo", infoIconFg }}; +infoIconMediaVideo: icon {{ "info_media_video", infoIconFg }}; +infoIconMediaFile: icon {{ "info_media_file", infoIconFg }}; infoIconMediaAudio: icon {{ "info_media_audio", infoIconFg }}; infoIconMediaLink: icon {{ "info_media_link", infoIconFg }}; infoIconMediaGroup: icon {{ "info_common_groups", infoIconFg }}; diff --git a/Telegram/SourceFiles/info/info_content_widget.h b/Telegram/SourceFiles/info/info_content_widget.h index e84ccfe05e..2e66622462 100644 --- a/Telegram/SourceFiles/info/info_content_widget.h +++ b/Telegram/SourceFiles/info/info_content_widget.h @@ -54,6 +54,8 @@ public: virtual std::unique_ptr createMemento() = 0; virtual rpl::producer
sectionRequest() const; + virtual void setIsStackBottom(bool isStackBottom) { + } virtual Section section() const = 0; not_null peer() const { diff --git a/Telegram/SourceFiles/info/info_top_bar_override.cpp b/Telegram/SourceFiles/info/info_top_bar_override.cpp index 148586e187..7cd1518663 100644 --- a/Telegram/SourceFiles/info/info_top_bar_override.cpp +++ b/Telegram/SourceFiles/info/info_top_bar_override.cpp @@ -77,13 +77,13 @@ QString TopBarOverride::generateText() const { using Type = Storage::SharedMediaType; auto phrase = [&] { switch (_items.type) { - case Type::Photo: return lng_profile_photos; - case Type::Video: return lng_profile_videos; - case Type::File: return lng_profile_files; - case Type::MusicFile: return lng_profile_songs; - case Type::Link: return lng_profile_shared_links; - case Type::VoiceFile: return lng_profile_audios; - case Type::RoundFile: return lng_profile_rounds; + case Type::Photo: return lng_media_selected_photo; + case Type::Video: return lng_media_selected_video; + case Type::File: return lng_media_selected_file; + case Type::MusicFile: return lng_media_selected_song; + case Type::Link: return lng_media_selected_link; + case Type::VoiceFile: return lng_media_selected_audio; + case Type::RoundFile: return lng_media_selected_round; } Unexpected("Type in TopBarOverride::generateText()"); }(); diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 2800328ccb..d3762efd51 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -300,6 +300,7 @@ void WrapWidget::showContent(object_ptr content) { } void WrapWidget::finishShowContent() { + _content->setIsStackBottom(_historyStack.empty()); updateContentGeometry(); _desiredHeights.fire(desiredHeightForContent()); _desiredShadowVisibilities.fire(_content->desiredShadowVisibility()); diff --git a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp index b9010a5abe..ed0f784709 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.cpp @@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "info/profile/info_profile_inner_widget.h" #include +#include #include #include "info/info_memento.h" #include "info/profile/info_profile_button.h" @@ -100,7 +101,7 @@ object_ptr InnerWidget::setupContent( } else { result->add(std::move(details)); } - result->add(setupSharedMedia(result)); + result->add(setupSharedMedia(result, rpl::duplicate(wrapValue))); result->add(object_ptr(result)); if (auto user = _peer->asUser()) { result->add(setupUserActions(result, user)); @@ -264,66 +265,100 @@ void InnerWidget::setupUserButtons( } object_ptr InnerWidget::setupSharedMedia( - RpWidget *parent) { + RpWidget *parent, + rpl::producer &&wrapValue) { using namespace rpl::mappers; using MediaType = Media::Type; auto content = object_ptr(parent); auto tracker = Ui::MultiSlideTracker(); - auto addMediaButton = [&](MediaType type) { - return Media::AddButton( + auto addMediaButton = [&]( + MediaType type, + const style::icon &icon) { + auto result = Media::AddButton( content, _controller, peer(), type, tracker); + object_ptr( + result, + icon, + st::infoSharedMediaButtonIconPosition); }; - auto addCommonGroupsButton = [&](not_null user) { - return Media::AddCommonGroupsButton( + auto addCommonGroupsButton = [&]( + not_null user, + const style::icon &icon) { + auto result = Media::AddCommonGroupsButton( content, _controller, user, tracker); + object_ptr( + result, + icon, + st::infoSharedMediaButtonIconPosition); }; - addMediaButton(MediaType::Photo); - addMediaButton(MediaType::Video); - addMediaButton(MediaType::File); - addMediaButton(MediaType::MusicFile); - addMediaButton(MediaType::Link); - if (auto user = _peer->asUser()) { - addCommonGroupsButton(user); + addMediaButton(MediaType::Photo, st::infoIconMediaPhoto); + addMediaButton(MediaType::Video, st::infoIconMediaVideo); + addMediaButton(MediaType::File, st::infoIconMediaFile); + addMediaButton(MediaType::MusicFile, st::infoIconMediaAudio); + addMediaButton(MediaType::Link, st::infoIconMediaLink); + if (auto user = peer()->asUser()) { + addCommonGroupsButton(user, st::infoIconMediaGroup); } - addMediaButton(MediaType::VoiceFile); -// addMediaButton(MediaType::RoundFile); + addMediaButton(MediaType::VoiceFile, st::infoIconMediaVoice); +// addMediaButton(MediaType::RoundFile, st::infoIconMediaRound); auto result = object_ptr>( parent, object_ptr(parent) ); - result->toggleOn(tracker.atLeastOneShownValue()); + + //result->toggleOn(rpl::combine( + // tracker.atLeastOneShownValue(), + // std::move(wrapValue), + // _isStackBottom.events(), + // $1 && ($2 != Wrap::Side || !$3))); + + using ToggledData = std::tuple; + rpl::combine( + tracker.atLeastOneShownValue(), + std::move(wrapValue), + _isStackBottom.events()) + | rpl::combine_previous(ToggledData()) + | rpl::start_with_next([wrap = result.data()]( + const ToggledData &was, + const ToggledData &now) { + bool wasOneShown, wasStackBottom, nowOneShown, nowStackBottom; + Wrap wasWrap, nowWrap; + std::tie(wasOneShown, wasWrap, wasStackBottom) = was; + std::tie(nowOneShown, nowWrap, nowStackBottom) = now; + // MSVC Internal Compiler Error + //auto [wasOneShown, wasWrap, wasStackBottom] = was; + //auto [nowOneShown, nowWrap, nowStackBottom] = now; + wrap->toggle( + nowOneShown && (nowWrap != Wrap::Side || !nowStackBottom), + (wasOneShown == nowOneShown && wasWrap == nowWrap) + ? anim::type::normal + : anim::type::instant); + }, result->lifetime()); + auto layout = result->entity(); layout->add(object_ptr(layout)); - _sharedMediaCover = layout->add( - object_ptr(layout)); - if (canHideDetailsEver()) { - _sharedMediaCover->setToggleShown(canHideDetails()); - _sharedMediaWrap = layout->add(object_ptr>( - layout, - std::move(content)) - )->toggleOn(_sharedMediaCover->toggledValue()); - } else { - layout->add(std::move(content)); - } layout->add(object_ptr( layout, st::infoSharedMediaBottomSkip) )->setAttribute(Qt::WA_TransparentForMouseEvents); - object_ptr( - result, - st::infoIconMediaPhoto, - st::infoSharedMediaIconPosition); + layout->add(std::move(content)); + layout->add(object_ptr( + layout, + st::infoSharedMediaBottomSkip) + )->setAttribute(Qt::WA_TransparentForMouseEvents); + + _sharedMediaWrap = result; return std::move(result); } @@ -477,7 +512,7 @@ void InnerWidget::visibleTopBottomUpdated( void InnerWidget::saveState(not_null memento) { memento->setInfoExpanded(_cover->toggled()); - memento->setMediaExpanded(_sharedMediaCover->toggled()); + memento->setMediaExpanded(true); } void InnerWidget::restoreState(not_null memento) { @@ -485,7 +520,6 @@ void InnerWidget::restoreState(not_null memento) { if (_infoWrap) { _infoWrap->finishAnimating(); } - _sharedMediaCover->toggle(memento->mediaExpanded()); if (_sharedMediaWrap) { _sharedMediaWrap->finishAnimating(); } diff --git a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h index b7b600d6c6..371c26ac15 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h +++ b/Telegram/SourceFiles/info/profile/info_profile_inner_widget.h @@ -43,7 +43,6 @@ namespace Profile { class Memento; class Members; class Cover; -class SharedMediaCover; class InnerWidget final : public Ui::RpWidget { public: @@ -60,6 +59,9 @@ public: void saveState(not_null memento); void restoreState(not_null memento); + void setIsStackBottom(bool isStackBottom) { + _isStackBottom.fire_copy(isStackBottom); + } rpl::producer scrollToRequests() const { return _scrollToRequests.events(); } @@ -79,7 +81,9 @@ private: RpWidget *parent, rpl::producer &&wrapValue); object_ptr setupDetails(RpWidget *parent) const; - object_ptr setupSharedMedia(RpWidget *parent); + object_ptr setupSharedMedia( + RpWidget *parent, + rpl::producer &&wrapValue); object_ptr setupMuteToggle(RpWidget *parent) const; object_ptr setupInfo(RpWidget *parent) const; void setupUserButtons( @@ -99,13 +103,14 @@ private: bool canHideDetailsEver() const; rpl::producer canHideDetails() const; + rpl::event_stream _isStackBottom; + not_null _controller; not_null _peer; Members *_members = nullptr; Cover *_cover = nullptr; Ui::SlideWrap *_infoWrap = nullptr; - SharedMediaCover *_sharedMediaCover = nullptr; Ui::SlideWrap *_sharedMediaWrap = nullptr; object_ptr _content; diff --git a/Telegram/SourceFiles/info/profile/info_profile_widget.cpp b/Telegram/SourceFiles/info/profile/info_profile_widget.cpp index 2247f8b612..28b8b89d44 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_widget.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_widget.cpp @@ -63,6 +63,10 @@ Widget::Widget( }, lifetime()); } +void Widget::setIsStackBottom(bool isStackBottom) { + _inner->setIsStackBottom(isStackBottom); +} + Section Widget::section() const { return Section(Section::Type::Profile); } diff --git a/Telegram/SourceFiles/info/profile/info_profile_widget.h b/Telegram/SourceFiles/info/profile/info_profile_widget.h index a46d2c1285..002ad92f61 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_widget.h +++ b/Telegram/SourceFiles/info/profile/info_profile_widget.h @@ -70,6 +70,7 @@ public: not_null controller, not_null peer); + void setIsStackBottom(bool isStackBottom) override; Section section() const override; bool showInternal(