mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Show nice short info box from viewers dropdown.
This commit is contained in:
parent
a2bf0fc511
commit
e41fc69513
11 changed files with 103 additions and 32 deletions
|
@ -24,6 +24,11 @@ UserpicButton {
|
|||
uploadIcon: icon;
|
||||
uploadIconPosition: point;
|
||||
}
|
||||
ShortInfoBox {
|
||||
label: FlatLabel;
|
||||
labeled: FlatLabel;
|
||||
labeledOneLine: FlatLabel;
|
||||
}
|
||||
|
||||
countryRowHeight: 36px;
|
||||
countryRowNameFont: semiboldFont;
|
||||
|
@ -961,3 +966,26 @@ ringtonesBoxSkip: 7px;
|
|||
gradientButtonGlareDuration: 700;
|
||||
gradientButtonGlareTimeout: 2000;
|
||||
gradientButtonGlareWidth: 100px;
|
||||
|
||||
infoLabeledOneLine: FlatLabel(defaultFlatLabel) {
|
||||
maxHeight: 20px;
|
||||
style: TextStyle(defaultTextStyle) {
|
||||
lineHeight: 19px;
|
||||
}
|
||||
margin: margins(5px, 5px, 5px, 5px);
|
||||
}
|
||||
infoLabelSkip: 2px;
|
||||
infoLabeled: FlatLabel(infoLabeledOneLine) {
|
||||
minWidth: 180px;
|
||||
maxHeight: 0px;
|
||||
margin: margins(5px, 5px, 5px, 5px);
|
||||
}
|
||||
infoLabel: FlatLabel(infoLabeled) {
|
||||
textFg: windowSubTextFg;
|
||||
}
|
||||
|
||||
shortInfoBox: ShortInfoBox {
|
||||
label: infoLabel;
|
||||
labeled: infoLabeled;
|
||||
labeledOneLine: infoLabeledOneLine;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "media/streaming/media_streaming_player.h"
|
||||
#include "base/event_filter.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "styles/style_boxes.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_info.h"
|
||||
|
||||
|
@ -614,8 +615,10 @@ PeerShortInfoBox::PeerShortInfoBox(
|
|||
rpl::producer<PeerShortInfoFields> fields,
|
||||
rpl::producer<QString> status,
|
||||
rpl::producer<PeerShortInfoUserpic> userpic,
|
||||
Fn<bool()> videoPaused)
|
||||
: _type(type)
|
||||
Fn<bool()> videoPaused,
|
||||
const style::ShortInfoBox *stOverride)
|
||||
: _st(stOverride ? *stOverride : st::shortInfoBox)
|
||||
, _type(type)
|
||||
, _fields(std::move(fields))
|
||||
, _topRoundBackground(this)
|
||||
, _scroll(this, st::shortInfoScroll)
|
||||
|
@ -691,11 +694,12 @@ void PeerShortInfoBox::prepareRows() {
|
|||
auto addInfoLineGeneric = [&](
|
||||
rpl::producer<QString> &&label,
|
||||
rpl::producer<TextWithEntities> &&text,
|
||||
const style::FlatLabel &textSt = st::infoLabeled) {
|
||||
const style::FlatLabel &textSt) {
|
||||
auto line = CreateTextWithLabel(
|
||||
_rows,
|
||||
rpl::duplicate(label) | Ui::Text::ToWithEntities(),
|
||||
rpl::duplicate(text),
|
||||
_st.label,
|
||||
textSt,
|
||||
st::shortInfoLabeledPadding);
|
||||
_rows->add(object_ptr<Ui::OverrideMargins>(
|
||||
|
@ -715,7 +719,7 @@ void PeerShortInfoBox::prepareRows() {
|
|||
auto addInfoLine = [&](
|
||||
rpl::producer<QString> &&label,
|
||||
rpl::producer<TextWithEntities> &&text,
|
||||
const style::FlatLabel &textSt = st::infoLabeled) {
|
||||
const style::FlatLabel &textSt) {
|
||||
return addInfoLineGeneric(
|
||||
std::move(label),
|
||||
std::move(text),
|
||||
|
@ -728,7 +732,7 @@ void PeerShortInfoBox::prepareRows() {
|
|||
auto result = addInfoLine(
|
||||
std::move(label),
|
||||
std::move(text),
|
||||
st::infoLabeledOneLine);
|
||||
_st.labeledOneLine);
|
||||
result->setDoubleClickSelectsParagraph(true);
|
||||
result->setContextCopyText(contextCopyText);
|
||||
return result;
|
||||
|
@ -744,7 +748,7 @@ void PeerShortInfoBox::prepareRows() {
|
|||
auto label = _fields.current().isBio
|
||||
? tr::lng_info_bio_label()
|
||||
: tr::lng_info_about_label();
|
||||
addInfoLine(std::move(label), aboutValue());
|
||||
addInfoLine(std::move(label), aboutValue(), _st.labeled);
|
||||
addInfoOneLine(
|
||||
tr::lng_info_username_label(),
|
||||
usernameValue() | Ui::Text::ToWithEntities(),
|
||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace style {
|
||||
struct ShortInfoCover;
|
||||
struct ShortInfoBox;
|
||||
} // namespace style
|
||||
|
||||
namespace Media::Streaming {
|
||||
|
@ -144,7 +145,8 @@ public:
|
|||
rpl::producer<PeerShortInfoFields> fields,
|
||||
rpl::producer<QString> status,
|
||||
rpl::producer<PeerShortInfoUserpic> userpic,
|
||||
Fn<bool()> videoPaused);
|
||||
Fn<bool()> videoPaused,
|
||||
const style::ShortInfoBox *stOverride);
|
||||
~PeerShortInfoBox();
|
||||
|
||||
[[nodiscard]] rpl::producer<> openRequests() const;
|
||||
|
@ -166,6 +168,7 @@ private:
|
|||
[[nodiscard]] rpl::producer<QString> usernameValue() const;
|
||||
[[nodiscard]] rpl::producer<TextWithEntities> aboutValue() const;
|
||||
|
||||
const style::ShortInfoBox &_st;
|
||||
const PeerShortInfoType _type = PeerShortInfoType::User;
|
||||
|
||||
rpl::variable<PeerShortInfoFields> _fields;
|
||||
|
|
|
@ -420,7 +420,8 @@ bool ProcessCurrent(
|
|||
object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||
not_null<PeerData*> peer,
|
||||
Fn<void()> open,
|
||||
Fn<bool()> videoPaused) {
|
||||
Fn<bool()> videoPaused,
|
||||
const style::ShortInfoBox *stOverride) {
|
||||
const auto type = peer->isUser()
|
||||
? PeerShortInfoType::User
|
||||
: peer->isBroadcast()
|
||||
|
@ -432,7 +433,8 @@ object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
|||
FieldsValue(peer),
|
||||
StatusValue(peer),
|
||||
std::move(userpic.value),
|
||||
std::move(videoPaused));
|
||||
std::move(videoPaused),
|
||||
stOverride);
|
||||
|
||||
result->openRequests(
|
||||
) | rpl::start_with_next(open, result->lifetime());
|
||||
|
@ -445,7 +447,8 @@ object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
|||
|
||||
object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Window::SessionNavigation*> navigation) {
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
const style::ShortInfoBox *stOverride) {
|
||||
const auto open = [=] { navigation->showPeerHistory(peer); };
|
||||
const auto videoIsPaused = [=] {
|
||||
return navigation->parentController()->isGifPausedAtLeastFor(
|
||||
|
@ -454,7 +457,8 @@ object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
|||
return PrepareShortInfoBox(
|
||||
peer,
|
||||
open,
|
||||
videoIsPaused);
|
||||
videoIsPaused,
|
||||
stOverride);
|
||||
}
|
||||
|
||||
rpl::producer<QString> PrepareShortInfoStatus(not_null<PeerData*> peer) {
|
||||
|
|
|
@ -13,6 +13,7 @@ class PeerData;
|
|||
|
||||
namespace style {
|
||||
struct ShortInfoCover;
|
||||
struct ShortInfoBox;
|
||||
} // namespace style
|
||||
|
||||
namespace Ui {
|
||||
|
@ -33,11 +34,13 @@ struct PreparedShortInfoUserpic {
|
|||
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||
not_null<PeerData*> peer,
|
||||
Fn<void()> open,
|
||||
Fn<bool()> videoPaused);
|
||||
Fn<bool()> videoPaused,
|
||||
const style::ShortInfoBox *stOverride = nullptr);
|
||||
|
||||
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<Window::SessionNavigation*> navigation);
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
const style::ShortInfoBox *stOverride = nullptr);
|
||||
|
||||
[[nodiscard]] rpl::producer<QString> PrepareShortInfoStatus(
|
||||
not_null<PeerData*> peer);
|
||||
|
|
|
@ -389,22 +389,6 @@ infoNotificationsIconPosition: point(20px, 5px);
|
|||
infoSharedMediaButtonIconPosition: point(20px, 3px);
|
||||
infoGroupMembersIconPosition: point(20px, 10px);
|
||||
infoChannelMembersIconPosition: point(20px, 19px);
|
||||
infoLabeledOneLine: FlatLabel(defaultFlatLabel) {
|
||||
maxHeight: 20px;
|
||||
style: TextStyle(defaultTextStyle) {
|
||||
lineHeight: 19px;
|
||||
}
|
||||
margin: margins(5px, 5px, 5px, 5px);
|
||||
}
|
||||
infoLabelSkip: 2px;
|
||||
infoLabeled: FlatLabel(infoLabeledOneLine) {
|
||||
minWidth: 180px;
|
||||
maxHeight: 0px;
|
||||
margin: margins(5px, 5px, 5px, 5px);
|
||||
}
|
||||
infoLabel: FlatLabel(infoLabeled) {
|
||||
textFg: windowSubTextFg;
|
||||
}
|
||||
|
||||
infoBlockHeaderLabel: FlatLabel(infoProfileStatus) {
|
||||
textFg: windowBoldFg;
|
||||
|
|
|
@ -350,6 +350,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|||
result,
|
||||
v::text::take_marked(std::move(label)),
|
||||
std::move(text),
|
||||
st::infoLabel,
|
||||
textSt,
|
||||
padding);
|
||||
tracker.track(result->add(std::move(line.wrap)));
|
||||
|
|
|
@ -22,6 +22,7 @@ TextWithLabel CreateTextWithLabel(
|
|||
QWidget *parent,
|
||||
rpl::producer<TextWithEntities> &&label,
|
||||
rpl::producer<TextWithEntities> &&text,
|
||||
const style::FlatLabel &labelSt,
|
||||
const style::FlatLabel &textSt,
|
||||
const style::margins &padding) {
|
||||
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
|
@ -58,7 +59,7 @@ TextWithLabel CreateTextWithLabel(
|
|||
) | rpl::after_next([=] {
|
||||
layout->resizeToWidth(layout->widthNoMargins());
|
||||
}),
|
||||
st::infoLabel));
|
||||
labelSt));
|
||||
result->finishAnimating();
|
||||
return { std::move(result), labeled, subtext };
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ TextWithLabel CreateTextWithLabel(
|
|||
QWidget *parent,
|
||||
rpl::producer<TextWithEntities> &&label,
|
||||
rpl::producer<TextWithEntities> &&text,
|
||||
const style::FlatLabel &labelSt,
|
||||
const style::FlatLabel &textSt,
|
||||
const style::margins &padding);
|
||||
|
||||
|
|
|
@ -8,17 +8,22 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "media/stories/media_stories_recent_views.h"
|
||||
|
||||
#include "api/api_who_reacted.h" // FormatReadDate.
|
||||
#include "boxes/peers/prepare_short_info_box.h"
|
||||
#include "core/application.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_stories.h"
|
||||
#include "main/main_session.h"
|
||||
#include "media/stories/media_stories_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "ui/chat/group_call_userpics.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/controls/who_reacted_context_action.h"
|
||||
#include "ui/layers/box_content.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "ui/userpic_view.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_media_view.h"
|
||||
|
||||
|
@ -324,8 +329,27 @@ void RecentViews::addMenuRow(Data::StoryView entry, const QDateTime &now) {
|
|||
|
||||
const auto peer = entry.peer;
|
||||
const auto date = Api::FormatReadDate(entry.date, now);
|
||||
const auto show = _controller->uiShow();
|
||||
const auto prepare = [&](Ui::PeerUserpicView &view) {
|
||||
const auto size = st::storiesWhoViewed.photoSize;
|
||||
auto callback = [=] {
|
||||
const auto open = [=] {
|
||||
if (const auto window = Core::App().windowFor(peer)) {
|
||||
window->invokeForSessionController(
|
||||
&peer->session().account(),
|
||||
peer,
|
||||
[&](not_null<Window::SessionController*> controller) {
|
||||
Core::App().hideMediaView();
|
||||
controller->showPeerHistory(peer);
|
||||
});
|
||||
}
|
||||
};
|
||||
show->show(PrepareShortInfoBox(
|
||||
peer,
|
||||
open,
|
||||
[] { return false; },
|
||||
&st::storiesShortInfoBox));
|
||||
};
|
||||
auto userpic = peer->generateUserpicImage(
|
||||
view,
|
||||
size * style::DevicePixelRatio());
|
||||
|
@ -334,7 +358,7 @@ void RecentViews::addMenuRow(Data::StoryView entry, const QDateTime &now) {
|
|||
.text = peer->name(),
|
||||
.date = date,
|
||||
.userpic = std::move(userpic),
|
||||
.callback = [] {},
|
||||
.callback = std::move(callback),
|
||||
};
|
||||
};
|
||||
if (_menuPlaceholderCount > 0) {
|
||||
|
|
|
@ -793,3 +793,21 @@ storiesUnsupportedLabel: FlatLabel(defaultFlatLabel) {
|
|||
align: align(top);
|
||||
}
|
||||
storiesUnsupportedUpdate: themePreviewApplyButton;
|
||||
storiesShortInfoBox: ShortInfoBox(shortInfoBox) {
|
||||
label: FlatLabel(infoLabel) {
|
||||
textFg: storiesComposeGrayText;
|
||||
palette: TextPalette(mediaviewTextPalette) {
|
||||
linkFg: mediaviewTextLinkFg;
|
||||
monoFg: storiesComposeGrayText;
|
||||
spoilerFg: storiesComposeGrayText;
|
||||
}
|
||||
}
|
||||
labeled: FlatLabel(infoLabeled) {
|
||||
textFg: mediaviewCaptionFg;
|
||||
palette: mediaviewTextPalette;
|
||||
}
|
||||
labeledOneLine: FlatLabel(infoLabeledOneLine) {
|
||||
textFg: mediaviewCaptionFg;
|
||||
palette: mediaviewTextPalette;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue