Removed collapsing of shared media.

This commit is contained in:
John Preston 2017-10-20 20:54:51 +03:00
parent be5f4c9a71
commit 6b5e06de50
13 changed files with 106 additions and 43 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

View File

@ -631,6 +631,20 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
"lng_profile_delete_conversation" = "Delete conversation"; "lng_profile_delete_conversation" = "Delete conversation";
"lng_profile_block_user" = "Block user"; "lng_profile_block_user" = "Block user";
"lng_profile_unblock_user" = "Unblock 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_title" = "Report channel";
"lng_report_group_title" = "Report group"; "lng_report_group_title" = "Report group";

View File

@ -209,6 +209,8 @@ infoIconMembers: icon {{ "info_members", infoIconFg }};
infoIconNotifications: icon {{ "info_notifications", infoIconFg }}; infoIconNotifications: icon {{ "info_notifications", infoIconFg }};
infoIconActions: icon {{ "info_actions", infoIconFg }}; infoIconActions: icon {{ "info_actions", infoIconFg }};
infoIconMediaPhoto: icon {{ "info_media_photo", 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 }}; infoIconMediaAudio: icon {{ "info_media_audio", infoIconFg }};
infoIconMediaLink: icon {{ "info_media_link", infoIconFg }}; infoIconMediaLink: icon {{ "info_media_link", infoIconFg }};
infoIconMediaGroup: icon {{ "info_common_groups", infoIconFg }}; infoIconMediaGroup: icon {{ "info_common_groups", infoIconFg }};

View File

@ -54,6 +54,8 @@ public:
virtual std::unique_ptr<ContentMemento> createMemento() = 0; virtual std::unique_ptr<ContentMemento> createMemento() = 0;
virtual rpl::producer<Section> sectionRequest() const; virtual rpl::producer<Section> sectionRequest() const;
virtual void setIsStackBottom(bool isStackBottom) {
}
virtual Section section() const = 0; virtual Section section() const = 0;
not_null<PeerData*> peer() const { not_null<PeerData*> peer() const {

View File

@ -77,13 +77,13 @@ QString TopBarOverride::generateText() const {
using Type = Storage::SharedMediaType; using Type = Storage::SharedMediaType;
auto phrase = [&] { auto phrase = [&] {
switch (_items.type) { switch (_items.type) {
case Type::Photo: return lng_profile_photos; case Type::Photo: return lng_media_selected_photo;
case Type::Video: return lng_profile_videos; case Type::Video: return lng_media_selected_video;
case Type::File: return lng_profile_files; case Type::File: return lng_media_selected_file;
case Type::MusicFile: return lng_profile_songs; case Type::MusicFile: return lng_media_selected_song;
case Type::Link: return lng_profile_shared_links; case Type::Link: return lng_media_selected_link;
case Type::VoiceFile: return lng_profile_audios; case Type::VoiceFile: return lng_media_selected_audio;
case Type::RoundFile: return lng_profile_rounds; case Type::RoundFile: return lng_media_selected_round;
} }
Unexpected("Type in TopBarOverride::generateText()"); Unexpected("Type in TopBarOverride::generateText()");
}(); }();

View File

@ -300,6 +300,7 @@ void WrapWidget::showContent(object_ptr<ContentWidget> content) {
} }
void WrapWidget::finishShowContent() { void WrapWidget::finishShowContent() {
_content->setIsStackBottom(_historyStack.empty());
updateContentGeometry(); updateContentGeometry();
_desiredHeights.fire(desiredHeightForContent()); _desiredHeights.fire(desiredHeightForContent());
_desiredShadowVisibilities.fire(_content->desiredShadowVisibility()); _desiredShadowVisibilities.fire(_content->desiredShadowVisibility());

View File

@ -21,6 +21,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include "info/profile/info_profile_inner_widget.h" #include "info/profile/info_profile_inner_widget.h"
#include <rpl/combine.h> #include <rpl/combine.h>
#include <rpl/combine_previous.h>
#include <rpl/flatten_latest.h> #include <rpl/flatten_latest.h>
#include "info/info_memento.h" #include "info/info_memento.h"
#include "info/profile/info_profile_button.h" #include "info/profile/info_profile_button.h"
@ -100,7 +101,7 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
} else { } else {
result->add(std::move(details)); result->add(std::move(details));
} }
result->add(setupSharedMedia(result)); result->add(setupSharedMedia(result, rpl::duplicate(wrapValue)));
result->add(object_ptr<BoxContentDivider>(result)); result->add(object_ptr<BoxContentDivider>(result));
if (auto user = _peer->asUser()) { if (auto user = _peer->asUser()) {
result->add(setupUserActions(result, user)); result->add(setupUserActions(result, user));
@ -264,66 +265,100 @@ void InnerWidget::setupUserButtons(
} }
object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia( object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
RpWidget *parent) { RpWidget *parent,
rpl::producer<Wrap> &&wrapValue) {
using namespace rpl::mappers; using namespace rpl::mappers;
using MediaType = Media::Type; using MediaType = Media::Type;
auto content = object_ptr<Ui::VerticalLayout>(parent); auto content = object_ptr<Ui::VerticalLayout>(parent);
auto tracker = Ui::MultiSlideTracker(); auto tracker = Ui::MultiSlideTracker();
auto addMediaButton = [&](MediaType type) { auto addMediaButton = [&](
return Media::AddButton( MediaType type,
const style::icon &icon) {
auto result = Media::AddButton(
content, content,
_controller, _controller,
peer(), peer(),
type, type,
tracker); tracker);
object_ptr<Profile::FloatingIcon>(
result,
icon,
st::infoSharedMediaButtonIconPosition);
}; };
auto addCommonGroupsButton = [&](not_null<UserData*> user) { auto addCommonGroupsButton = [&](
return Media::AddCommonGroupsButton( not_null<UserData*> user,
const style::icon &icon) {
auto result = Media::AddCommonGroupsButton(
content, content,
_controller, _controller,
user, user,
tracker); tracker);
object_ptr<Profile::FloatingIcon>(
result,
icon,
st::infoSharedMediaButtonIconPosition);
}; };
addMediaButton(MediaType::Photo); addMediaButton(MediaType::Photo, st::infoIconMediaPhoto);
addMediaButton(MediaType::Video); addMediaButton(MediaType::Video, st::infoIconMediaVideo);
addMediaButton(MediaType::File); addMediaButton(MediaType::File, st::infoIconMediaFile);
addMediaButton(MediaType::MusicFile); addMediaButton(MediaType::MusicFile, st::infoIconMediaAudio);
addMediaButton(MediaType::Link); addMediaButton(MediaType::Link, st::infoIconMediaLink);
if (auto user = _peer->asUser()) { if (auto user = peer()->asUser()) {
addCommonGroupsButton(user); addCommonGroupsButton(user, st::infoIconMediaGroup);
} }
addMediaButton(MediaType::VoiceFile); addMediaButton(MediaType::VoiceFile, st::infoIconMediaVoice);
// addMediaButton(MediaType::RoundFile); // addMediaButton(MediaType::RoundFile, st::infoIconMediaRound);
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>( auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
parent, parent,
object_ptr<Ui::VerticalLayout>(parent) object_ptr<Ui::VerticalLayout>(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<bool, Wrap, bool>;
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(); auto layout = result->entity();
layout->add(object_ptr<BoxContentDivider>(layout)); layout->add(object_ptr<BoxContentDivider>(layout));
_sharedMediaCover = layout->add(
object_ptr<SharedMediaCover>(layout));
if (canHideDetailsEver()) {
_sharedMediaCover->setToggleShown(canHideDetails());
_sharedMediaWrap = layout->add(object_ptr<Ui::SlideWrap<>>(
layout,
std::move(content))
)->toggleOn(_sharedMediaCover->toggledValue());
} else {
layout->add(std::move(content));
}
layout->add(object_ptr<Ui::FixedHeightWidget>( layout->add(object_ptr<Ui::FixedHeightWidget>(
layout, layout,
st::infoSharedMediaBottomSkip) st::infoSharedMediaBottomSkip)
)->setAttribute(Qt::WA_TransparentForMouseEvents); )->setAttribute(Qt::WA_TransparentForMouseEvents);
object_ptr<FloatingIcon>( layout->add(std::move(content));
result, layout->add(object_ptr<Ui::FixedHeightWidget>(
st::infoIconMediaPhoto, layout,
st::infoSharedMediaIconPosition); st::infoSharedMediaBottomSkip)
)->setAttribute(Qt::WA_TransparentForMouseEvents);
_sharedMediaWrap = result;
return std::move(result); return std::move(result);
} }
@ -477,7 +512,7 @@ void InnerWidget::visibleTopBottomUpdated(
void InnerWidget::saveState(not_null<Memento*> memento) { void InnerWidget::saveState(not_null<Memento*> memento) {
memento->setInfoExpanded(_cover->toggled()); memento->setInfoExpanded(_cover->toggled());
memento->setMediaExpanded(_sharedMediaCover->toggled()); memento->setMediaExpanded(true);
} }
void InnerWidget::restoreState(not_null<Memento*> memento) { void InnerWidget::restoreState(not_null<Memento*> memento) {
@ -485,7 +520,6 @@ void InnerWidget::restoreState(not_null<Memento*> memento) {
if (_infoWrap) { if (_infoWrap) {
_infoWrap->finishAnimating(); _infoWrap->finishAnimating();
} }
_sharedMediaCover->toggle(memento->mediaExpanded());
if (_sharedMediaWrap) { if (_sharedMediaWrap) {
_sharedMediaWrap->finishAnimating(); _sharedMediaWrap->finishAnimating();
} }

View File

@ -43,7 +43,6 @@ namespace Profile {
class Memento; class Memento;
class Members; class Members;
class Cover; class Cover;
class SharedMediaCover;
class InnerWidget final : public Ui::RpWidget { class InnerWidget final : public Ui::RpWidget {
public: public:
@ -60,6 +59,9 @@ public:
void saveState(not_null<Memento*> memento); void saveState(not_null<Memento*> memento);
void restoreState(not_null<Memento*> memento); void restoreState(not_null<Memento*> memento);
void setIsStackBottom(bool isStackBottom) {
_isStackBottom.fire_copy(isStackBottom);
}
rpl::producer<Ui::ScrollToRequest> scrollToRequests() const { rpl::producer<Ui::ScrollToRequest> scrollToRequests() const {
return _scrollToRequests.events(); return _scrollToRequests.events();
} }
@ -79,7 +81,9 @@ private:
RpWidget *parent, RpWidget *parent,
rpl::producer<Wrap> &&wrapValue); rpl::producer<Wrap> &&wrapValue);
object_ptr<RpWidget> setupDetails(RpWidget *parent) const; object_ptr<RpWidget> setupDetails(RpWidget *parent) const;
object_ptr<RpWidget> setupSharedMedia(RpWidget *parent); object_ptr<RpWidget> setupSharedMedia(
RpWidget *parent,
rpl::producer<Wrap> &&wrapValue);
object_ptr<RpWidget> setupMuteToggle(RpWidget *parent) const; object_ptr<RpWidget> setupMuteToggle(RpWidget *parent) const;
object_ptr<RpWidget> setupInfo(RpWidget *parent) const; object_ptr<RpWidget> setupInfo(RpWidget *parent) const;
void setupUserButtons( void setupUserButtons(
@ -99,13 +103,14 @@ private:
bool canHideDetailsEver() const; bool canHideDetailsEver() const;
rpl::producer<bool> canHideDetails() const; rpl::producer<bool> canHideDetails() const;
rpl::event_stream<bool> _isStackBottom;
not_null<Window::Controller*> _controller; not_null<Window::Controller*> _controller;
not_null<PeerData*> _peer; not_null<PeerData*> _peer;
Members *_members = nullptr; Members *_members = nullptr;
Cover *_cover = nullptr; Cover *_cover = nullptr;
Ui::SlideWrap<RpWidget> *_infoWrap = nullptr; Ui::SlideWrap<RpWidget> *_infoWrap = nullptr;
SharedMediaCover *_sharedMediaCover = nullptr;
Ui::SlideWrap<RpWidget> *_sharedMediaWrap = nullptr; Ui::SlideWrap<RpWidget> *_sharedMediaWrap = nullptr;
object_ptr<RpWidget> _content; object_ptr<RpWidget> _content;

View File

@ -63,6 +63,10 @@ Widget::Widget(
}, lifetime()); }, lifetime());
} }
void Widget::setIsStackBottom(bool isStackBottom) {
_inner->setIsStackBottom(isStackBottom);
}
Section Widget::section() const { Section Widget::section() const {
return Section(Section::Type::Profile); return Section(Section::Type::Profile);
} }

View File

@ -70,6 +70,7 @@ public:
not_null<Window::Controller*> controller, not_null<Window::Controller*> controller,
not_null<PeerData*> peer); not_null<PeerData*> peer);
void setIsStackBottom(bool isStackBottom) override;
Section section() const override; Section section() const override;
bool showInternal( bool showInternal(