Show other shared media links in Saved Photos.

This commit is contained in:
John Preston 2017-12-05 16:23:08 +04:00
parent aebdc2fd94
commit e4ce08e64e
4 changed files with 122 additions and 111 deletions

View File

@ -49,109 +49,106 @@ InnerWidget::InnerWidget(
[this] { refreshHeight(); }, [this] { refreshHeight(); },
_empty->lifetime()); _empty->lifetime());
_list = setupList(); _list = setupList();
// Allows showing additional shared media links and tabs.
// Was done for top level tabs support.
//
//setupOtherTypes();
} }
// Allows showing additional shared media links and tabs. // Allows showing additional shared media links and tabs.
// Was done for top level tabs support. // Was done for top level tabs support.
// // Now used for shared media in Saved Messages.
//void InnerWidget::setupOtherTypes() { void InnerWidget::setupOtherTypes() {
// _controller->wrapValue() if (_controller->peer()->isSelf() && _isStackBottom) {
// | rpl::start_with_next([this](Wrap value) { createOtherTypes();
// if (value == Wrap::Side } else {
// && !_controller->hasStackHistory() _otherTypes.destroy();
// && TypeToTabIndex(type())) { refreshHeight();
// createOtherTypes(); }
// } else { //rpl::combine(
// _otherTabs = nullptr; // _controller->wrapValue(),
// _otherTypes.destroy(); // _controller->searchEnabledByContent())
// refreshHeight(); // | rpl::start_with_next([this](Wrap wrap, bool enabled) {
// } // _searchEnabled = enabled;
// }, lifetime()); // refreshSearchField();
// rpl::combine( // }, lifetime());
// _controller->wrapValue(), }
// _controller->searchEnabledByContent())
// | rpl::start_with_next([this](Wrap wrap, bool enabled) { void InnerWidget::createOtherTypes() {
// _searchEnabled = enabled; //_otherTabsShadow.create(this);
// refreshSearchField(); //_otherTabsShadow->show();
// }, lifetime());
//} //_otherTabs = nullptr;
// _otherTypes.create(this);
//void InnerWidget::createOtherTypes() { _otherTypes->show();
// _otherTabsShadow.create(this);
// _otherTabsShadow->show(); createTypeButtons();
// _otherTypes->add(object_ptr<BoxContentDivider>(_otherTypes));
// _otherTabs = nullptr; //createTabs();
// _otherTypes.create(this);
// _otherTypes->show(); _otherTypes->resizeToWidth(width());
// _otherTypes->heightValue()
// createTypeButtons(); | rpl::start_with_next(
// _otherTypes->add(object_ptr<BoxContentDivider>(_otherTypes)); [this] { refreshHeight(); },
// createTabs(); _otherTypes->lifetime());
// }
// _otherTypes->heightValue()
// | rpl::start_with_next( void InnerWidget::createTypeButtons() {
// [this] { refreshHeight(); }, auto wrap = _otherTypes->add(object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
// _otherTypes->lifetime()); _otherTypes,
//} object_ptr<Ui::VerticalLayout>(_otherTypes)));
// auto content = wrap->entity();
//void InnerWidget::createTypeButtons() { content->add(object_ptr<Ui::FixedHeightWidget>(
// auto wrap = _otherTypes->add(object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>( content,
// _otherTypes, st::infoProfileSkip));
// object_ptr<Ui::VerticalLayout>(_otherTypes)));
// auto content = wrap->entity(); auto tracker = Ui::MultiSlideTracker();
// content->add(object_ptr<Ui::FixedHeightWidget>( auto addMediaButton = [&](
// content, Type buttonType,
// st::infoProfileSkip)); const style::icon &icon) {
// if (buttonType == type()) {
// auto tracker = Ui::MultiSlideTracker(); return;
// auto addMediaButton = [&]( }
// Type type, auto result = AddButton(
// const style::icon &icon) { content,
// auto result = AddButton( _controller,
// content, _controller->peer(),
// _controller, _controller->migrated(),
// _controller->peer(), buttonType,
// _controller->migrated(), tracker);
// type, object_ptr<Profile::FloatingIcon>(
// tracker); result,
// object_ptr<Profile::FloatingIcon>( icon,
// result, st::infoSharedMediaButtonIconPosition)->show();
// icon, };
// st::infoSharedMediaButtonIconPosition); //auto addCommonGroupsButton = [&](
// }; // not_null<UserData*> user,
// auto addCommonGroupsButton = [&]( // const style::icon &icon) {
// not_null<UserData*> user, // auto result = AddCommonGroupsButton(
// const style::icon &icon) { // content,
// auto result = AddCommonGroupsButton( // _controller,
// content, // user,
// _controller, // tracker);
// user, // object_ptr<Profile::FloatingIcon>(
// tracker); // result,
// object_ptr<Profile::FloatingIcon>( // icon,
// result, // st::infoSharedMediaButtonIconPosition)->show();
// icon, //};
// st::infoSharedMediaButtonIconPosition);
// }; addMediaButton(Type::Photo, st::infoIconMediaPhoto);
// addMediaButton(Type::Video, st::infoIconMediaVideo);
// addMediaButton(Type::MusicFile, st::infoIconMediaAudio); addMediaButton(Type::File, st::infoIconMediaFile);
// addMediaButton(Type::Link, st::infoIconMediaLink); addMediaButton(Type::MusicFile, st::infoIconMediaAudio);
// if (auto user = _controller->peer()->asUser()) { addMediaButton(Type::Link, st::infoIconMediaLink);
if (auto user = _controller->peer()->asUser()) {
// addCommonGroupsButton(user, st::infoIconMediaGroup); // addCommonGroupsButton(user, st::infoIconMediaGroup);
// } }
// addMediaButton(Type::VoiceFile, st::infoIconMediaVoice); addMediaButton(Type::VoiceFile, st::infoIconMediaVoice);
//// addMediaButton(Type::RoundFile, st::infoIconMediaRound); // addMediaButton(Type::RoundFile, st::infoIconMediaRound);
//
// content->add(object_ptr<Ui::FixedHeightWidget>( content->add(object_ptr<Ui::FixedHeightWidget>(
// content, content,
// st::infoProfileSkip)); st::infoProfileSkip));
// wrap->toggleOn(tracker.atLeastOneShownValue()); wrap->toggleOn(tracker.atLeastOneShownValue());
// wrap->finishAnimating(); wrap->finishAnimating();
//} }
//
//void InnerWidget::createTabs() { //void InnerWidget::createTabs() {
// _otherTabs = _otherTypes->add(object_ptr<Ui::SettingsSlider>( // _otherTabs = _otherTypes->add(object_ptr<Ui::SettingsSlider>(
// this, // this,
@ -305,10 +302,10 @@ int InnerWidget::resizeGetHeight(int newWidth) {
_inResize = true; _inResize = true;
auto guard = gsl::finally([this] { _inResize = false; }); auto guard = gsl::finally([this] { _inResize = false; });
//if (_otherTypes) { if (_otherTypes) {
// _otherTypes->resizeToWidth(newWidth); _otherTypes->resizeToWidth(newWidth);
// _otherTabsShadow->resizeToWidth(newWidth); //_otherTabsShadow->resizeToWidth(newWidth);
//} }
//if (_searchField) { //if (_searchField) {
// _searchField->resizeToWidth(newWidth); // _searchField->resizeToWidth(newWidth);
//} //}
@ -326,11 +323,11 @@ void InnerWidget::refreshHeight() {
int InnerWidget::recountHeight() { int InnerWidget::recountHeight() {
auto top = 0; auto top = 0;
//if (_otherTypes) { if (_otherTypes) {
// _otherTypes->moveToLeft(0, top); _otherTypes->moveToLeft(0, top);
// top += _otherTypes->heightNoMargins() - st::lineWidth; top += _otherTypes->heightNoMargins() - st::lineWidth;
// _otherTabsShadow->moveToLeft(0, top); // _otherTabsShadow->moveToLeft(0, top);
//} }
//if (_searchField) { //if (_searchField) {
// _searchField->moveToLeft(0, top); // _searchField->moveToLeft(0, top);
// top += _searchField->heightNoMargins() - st::lineWidth; // top += _searchField->heightNoMargins() - st::lineWidth;

View File

@ -49,6 +49,10 @@ public:
not_null<Controller*> controller); not_null<Controller*> controller);
bool showInternal(not_null<Memento*> memento); bool showInternal(not_null<Memento*> memento);
void setIsStackBottom(bool isStackBottom) {
_isStackBottom = isStackBottom;
setupOtherTypes();
}
void saveState(not_null<Memento*> memento); void saveState(not_null<Memento*> memento);
void restoreState(not_null<Memento*> memento); void restoreState(not_null<Memento*> memento);
@ -72,10 +76,13 @@ private:
void refreshHeight(); void refreshHeight();
// Allows showing additional shared media links and tabs. // Allows showing additional shared media links and tabs.
// Was done for top level tabs support. // Was done for top level tabs support.
// Now used for shared media in Saved Messages.
void setupOtherTypes();
void createOtherTypes();
void createTypeButtons();
// Allows showing additional shared media links and tabs.
// Was done for top level tabs support.
// //
//void setupOtherTypes();
//void createOtherTypes();
//void createTypeButtons();
//void createTabs(); //void createTabs();
//void switchToTab(Memento &&memento); //void switchToTab(Memento &&memento);
//void refreshSearchField(); //void refreshSearchField();
@ -88,7 +95,7 @@ private:
const not_null<Controller*> _controller; const not_null<Controller*> _controller;
//Ui::SettingsSlider *_otherTabs = nullptr; //Ui::SettingsSlider *_otherTabs = nullptr;
//object_ptr<Ui::VerticalLayout> _otherTypes = { nullptr }; object_ptr<Ui::VerticalLayout> _otherTypes = { nullptr };
//object_ptr<Ui::PlainShadow> _otherTabsShadow = { nullptr }; //object_ptr<Ui::PlainShadow> _otherTabsShadow = { nullptr };
//base::unique_qptr<Ui::RpWidget> _searchField = nullptr; //base::unique_qptr<Ui::RpWidget> _searchField = nullptr;
object_ptr<ListWidget> _list = { nullptr }; object_ptr<ListWidget> _list = { nullptr };
@ -96,6 +103,7 @@ private:
//bool _searchEnabled = false; //bool _searchEnabled = false;
bool _inResize = false; bool _inResize = false;
bool _isStackBottom = false;
rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests; rpl::event_stream<Ui::ScrollToRequest> _scrollToRequests;
rpl::event_stream<rpl::producer<SelectedItems>> _selectedLists; rpl::event_stream<rpl::producer<SelectedItems>> _selectedLists;

View File

@ -102,6 +102,10 @@ void Widget::cancelSelection() {
_inner->cancelSelection(); _inner->cancelSelection();
} }
void Widget::setIsStackBottom(bool isStackBottom) {
_inner->setIsStackBottom(isStackBottom);
}
bool Widget::showInternal(not_null<ContentMemento*> memento) { bool Widget::showInternal(not_null<ContentMemento*> memento) {
if (!controller()->validateMementoPeer(memento)) { if (!controller()->validateMementoPeer(memento)) {
return false; return false;

View File

@ -100,6 +100,8 @@ public:
QWidget *parent, QWidget *parent,
not_null<Controller*> controller); not_null<Controller*> controller);
void setIsStackBottom(bool isStackBottom) override;
bool showInternal( bool showInternal(
not_null<ContentMemento*> memento) override; not_null<ContentMemento*> memento) override;