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_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";

View File

@ -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 }};

View File

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

View File

@ -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()");
}();

View File

@ -300,6 +300,7 @@ void WrapWidget::showContent(object_ptr<ContentWidget> content) {
}
void WrapWidget::finishShowContent() {
_content->setIsStackBottom(_historyStack.empty());
updateContentGeometry();
_desiredHeights.fire(desiredHeightForContent());
_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 <rpl/combine.h>
#include <rpl/combine_previous.h>
#include <rpl/flatten_latest.h>
#include "info/info_memento.h"
#include "info/profile/info_profile_button.h"
@ -100,7 +101,7 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
} else {
result->add(std::move(details));
}
result->add(setupSharedMedia(result));
result->add(setupSharedMedia(result, rpl::duplicate(wrapValue)));
result->add(object_ptr<BoxContentDivider>(result));
if (auto user = _peer->asUser()) {
result->add(setupUserActions(result, user));
@ -264,66 +265,100 @@ void InnerWidget::setupUserButtons(
}
object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
RpWidget *parent) {
RpWidget *parent,
rpl::producer<Wrap> &&wrapValue) {
using namespace rpl::mappers;
using MediaType = Media::Type;
auto content = object_ptr<Ui::VerticalLayout>(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<Profile::FloatingIcon>(
result,
icon,
st::infoSharedMediaButtonIconPosition);
};
auto addCommonGroupsButton = [&](not_null<UserData*> user) {
return Media::AddCommonGroupsButton(
auto addCommonGroupsButton = [&](
not_null<UserData*> user,
const style::icon &icon) {
auto result = Media::AddCommonGroupsButton(
content,
_controller,
user,
tracker);
object_ptr<Profile::FloatingIcon>(
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<Ui::SlideWrap<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();
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,
st::infoSharedMediaBottomSkip)
)->setAttribute(Qt::WA_TransparentForMouseEvents);
object_ptr<FloatingIcon>(
result,
st::infoIconMediaPhoto,
st::infoSharedMediaIconPosition);
layout->add(std::move(content));
layout->add(object_ptr<Ui::FixedHeightWidget>(
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) {
memento->setInfoExpanded(_cover->toggled());
memento->setMediaExpanded(_sharedMediaCover->toggled());
memento->setMediaExpanded(true);
}
void InnerWidget::restoreState(not_null<Memento*> memento) {
@ -485,7 +520,6 @@ void InnerWidget::restoreState(not_null<Memento*> memento) {
if (_infoWrap) {
_infoWrap->finishAnimating();
}
_sharedMediaCover->toggle(memento->mediaExpanded());
if (_sharedMediaWrap) {
_sharedMediaWrap->finishAnimating();
}

View File

@ -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*> memento);
void restoreState(not_null<Memento*> memento);
void setIsStackBottom(bool isStackBottom) {
_isStackBottom.fire_copy(isStackBottom);
}
rpl::producer<Ui::ScrollToRequest> scrollToRequests() const {
return _scrollToRequests.events();
}
@ -79,7 +81,9 @@ private:
RpWidget *parent,
rpl::producer<Wrap> &&wrapValue);
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> setupInfo(RpWidget *parent) const;
void setupUserButtons(
@ -99,13 +103,14 @@ private:
bool canHideDetailsEver() const;
rpl::producer<bool> canHideDetails() const;
rpl::event_stream<bool> _isStackBottom;
not_null<Window::Controller*> _controller;
not_null<PeerData*> _peer;
Members *_members = nullptr;
Cover *_cover = nullptr;
Ui::SlideWrap<RpWidget> *_infoWrap = nullptr;
SharedMediaCover *_sharedMediaCover = nullptr;
Ui::SlideWrap<RpWidget> *_sharedMediaWrap = nullptr;
object_ptr<RpWidget> _content;

View File

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

View File

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