mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show personal channel in users profile.
This commit is contained in:
parent
280d69d346
commit
f439443fe5
3 changed files with 74 additions and 0 deletions
|
@ -1330,6 +1330,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_via_link_shared_many#one" = "Link shared with **{count} user**.";
|
"lng_via_link_shared_many#one" = "Link shared with **{count} user**.";
|
||||||
"lng_via_link_shared_many#other" = "Link shared with **{count} users**.";
|
"lng_via_link_shared_many#other" = "Link shared with **{count} users**.";
|
||||||
|
|
||||||
|
"lng_info_personal_channel_label" = "Channel";
|
||||||
"lng_info_mobile_label" = "Mobile";
|
"lng_info_mobile_label" = "Mobile";
|
||||||
"lng_info_mobile_context_menu_fragment_about" = "This number is not tied to a SIM card and was acquired on {link}.";
|
"lng_info_mobile_context_menu_fragment_about" = "This number is not tied to a SIM card and was acquired on {link}.";
|
||||||
"lng_info_mobile_context_menu_fragment_about_link" = "Fragment";
|
"lng_info_mobile_context_menu_fragment_about_link" = "Fragment";
|
||||||
|
|
|
@ -446,6 +446,8 @@ infoSharedMediaButtonIconPosition: point(20px, 3px);
|
||||||
infoGroupMembersIconPosition: point(20px, 10px);
|
infoGroupMembersIconPosition: point(20px, 10px);
|
||||||
infoChannelMembersIconPosition: point(20px, 19px);
|
infoChannelMembersIconPosition: point(20px, 19px);
|
||||||
|
|
||||||
|
infoPersonalChannelIconPosition: point(25px, 20px);
|
||||||
|
|
||||||
infoBlockHeaderLabel: FlatLabel(infoProfileStatus) {
|
infoBlockHeaderLabel: FlatLabel(infoProfileStatus) {
|
||||||
textFg: windowBoldFg;
|
textFg: windowBoldFg;
|
||||||
style: TextStyle(defaultTextStyle) {
|
style: TextStyle(defaultTextStyle) {
|
||||||
|
|
|
@ -661,6 +661,7 @@ public:
|
||||||
object_ptr<Ui::RpWidget> fill();
|
object_ptr<Ui::RpWidget> fill();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
object_ptr<Ui::RpWidget> setupPersonalChannel(not_null<UserData*> user);
|
||||||
object_ptr<Ui::RpWidget> setupInfo();
|
object_ptr<Ui::RpWidget> setupInfo();
|
||||||
object_ptr<Ui::RpWidget> setupMuteToggle();
|
object_ptr<Ui::RpWidget> setupMuteToggle();
|
||||||
void setupMainButtons();
|
void setupMainButtons();
|
||||||
|
@ -1115,6 +1116,73 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object_ptr<Ui::RpWidget> DetailsFiller::setupPersonalChannel(
|
||||||
|
not_null<UserData*> user) {
|
||||||
|
auto result = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||||
|
_wrap,
|
||||||
|
object_ptr<Ui::VerticalLayout>(_wrap));
|
||||||
|
const auto container = result->entity();
|
||||||
|
|
||||||
|
result->toggleOn(PersonalChannelValue(
|
||||||
|
user
|
||||||
|
) | rpl::map(rpl::mappers::_1 != nullptr));
|
||||||
|
result->finishAnimating();
|
||||||
|
|
||||||
|
Ui::AddDivider(container);
|
||||||
|
|
||||||
|
auto channel = PersonalChannelValue(
|
||||||
|
user
|
||||||
|
) | rpl::start_spawning(result->lifetime());
|
||||||
|
auto text = rpl::duplicate(
|
||||||
|
channel
|
||||||
|
) | rpl::map([=](ChannelData *channel) {
|
||||||
|
return channel ? NameValue(channel) : rpl::single(QString());
|
||||||
|
}) | rpl::flatten_latest() | rpl::map([](const QString &name) {
|
||||||
|
return name.isEmpty() ? TextWithEntities() : Ui::Text::Link(name);
|
||||||
|
});
|
||||||
|
auto label = rpl::combine(
|
||||||
|
tr::lng_info_personal_channel_label(Ui::Text::WithEntities),
|
||||||
|
rpl::duplicate(channel)
|
||||||
|
) | rpl::map([](TextWithEntities &&text, ChannelData *channel) {
|
||||||
|
const auto count = channel ? channel->membersCount() : 0;
|
||||||
|
if (count > 1) {
|
||||||
|
text.append(
|
||||||
|
QString::fromUtf8(" \xE2\x80\xA2 ")
|
||||||
|
).append(tr::lng_chat_status_subscribers(
|
||||||
|
tr::now,
|
||||||
|
lt_count_decimal,
|
||||||
|
count));
|
||||||
|
}
|
||||||
|
return text;
|
||||||
|
});
|
||||||
|
auto line = CreateTextWithLabel(
|
||||||
|
result,
|
||||||
|
std::move(label),
|
||||||
|
std::move(text),
|
||||||
|
st::infoLabel,
|
||||||
|
st::infoLabeled,
|
||||||
|
st::infoProfileLabeledPadding);
|
||||||
|
container->add(std::move(line.wrap));
|
||||||
|
|
||||||
|
line.text->setClickHandlerFilter([
|
||||||
|
=,
|
||||||
|
window = _controller->parentController()](
|
||||||
|
const ClickHandlerPtr &handler,
|
||||||
|
Qt::MouseButton button) {
|
||||||
|
if (const auto channelId = user->personalChannelId()) {
|
||||||
|
window->showPeerInfo(peerFromChannel(channelId));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
object_ptr<FloatingIcon>(
|
||||||
|
result,
|
||||||
|
st::infoIconMediaChannel,
|
||||||
|
st::infoPersonalChannelIconPosition);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
object_ptr<Ui::RpWidget> DetailsFiller::setupMuteToggle() {
|
object_ptr<Ui::RpWidget> DetailsFiller::setupMuteToggle() {
|
||||||
const auto peer = _peer;
|
const auto peer = _peer;
|
||||||
const auto topicRootId = _topic ? _topic->rootId() : MsgId();
|
const auto topicRootId = _topic ? _topic->rootId() : MsgId();
|
||||||
|
@ -1349,6 +1417,9 @@ Ui::MultiSlideTracker DetailsFiller::fillChannelButtons(
|
||||||
object_ptr<Ui::RpWidget> DetailsFiller::fill() {
|
object_ptr<Ui::RpWidget> DetailsFiller::fill() {
|
||||||
Expects(!_topic || !_topic->creating());
|
Expects(!_topic || !_topic->creating());
|
||||||
|
|
||||||
|
if (const auto user = _peer->asUser()) {
|
||||||
|
add(setupPersonalChannel(user));
|
||||||
|
}
|
||||||
add(object_ptr<Ui::BoxContentDivider>(_wrap));
|
add(object_ptr<Ui::BoxContentDivider>(_wrap));
|
||||||
add(CreateSkipWidget(_wrap));
|
add(CreateSkipWidget(_wrap));
|
||||||
add(setupInfo());
|
add(setupInfo());
|
||||||
|
|
Loading…
Add table
Reference in a new issue