mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 17:51:41 -05:00
Move 'Add to contacts' button up in Info.
This commit is contained in:
parent
dd38da7737
commit
729da4a6b4
4 changed files with 47 additions and 24 deletions
|
@ -778,6 +778,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_profile_info_section" = "Info";
|
"lng_profile_info_section" = "Info";
|
||||||
"lng_info_tab_media" = "Media";
|
"lng_info_tab_media" = "Media";
|
||||||
"lng_info_mobile_label" = "Mobile";
|
"lng_info_mobile_label" = "Mobile";
|
||||||
|
"lng_info_mobile_hidden" = "Hidden";
|
||||||
"lng_info_username_label" = "Username";
|
"lng_info_username_label" = "Username";
|
||||||
"lng_info_bio_label" = "Bio";
|
"lng_info_bio_label" = "Bio";
|
||||||
"lng_info_link_label" = "Link";
|
"lng_info_link_label" = "Link";
|
||||||
|
@ -789,7 +790,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_info_channel_title" = "Channel Info";
|
"lng_info_channel_title" = "Channel Info";
|
||||||
"lng_profile_enable_notifications" = "Notifications";
|
"lng_profile_enable_notifications" = "Notifications";
|
||||||
"lng_profile_send_message" = "Send Message";
|
"lng_profile_send_message" = "Send Message";
|
||||||
"lng_info_add_as_contact" = "Add as contact";
|
"lng_info_add_as_contact" = "Add to contacts";
|
||||||
"lng_profile_shared_media" = "Shared media";
|
"lng_profile_shared_media" = "Shared media";
|
||||||
"lng_media_type_photos" = "Photos";
|
"lng_media_type_photos" = "Photos";
|
||||||
"lng_media_type_videos" = "Videos";
|
"lng_media_type_videos" = "Videos";
|
||||||
|
|
|
@ -259,7 +259,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
|
|
||||||
addInfoOneLine(
|
addInfoOneLine(
|
||||||
tr::lng_info_mobile_label(),
|
tr::lng_info_mobile_label(),
|
||||||
PhoneValue(user),
|
PhoneOrHiddenValue(user),
|
||||||
tr::lng_profile_copy_phone(tr::now));
|
tr::lng_profile_copy_phone(tr::now));
|
||||||
if (user->botInfo) {
|
if (user->botInfo) {
|
||||||
addInfoLine(tr::lng_info_about_label(), AboutValue(user));
|
addInfoLine(tr::lng_info_about_label(), AboutValue(user));
|
||||||
|
@ -270,6 +270,14 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
||||||
tr::lng_info_username_label(),
|
tr::lng_info_username_label(),
|
||||||
UsernameValue(user),
|
UsernameValue(user),
|
||||||
tr::lng_context_copy_mention(tr::now));
|
tr::lng_context_copy_mention(tr::now));
|
||||||
|
|
||||||
|
const auto window = &_controller->parentController()->window()->controller();
|
||||||
|
AddMainButton(
|
||||||
|
result,
|
||||||
|
tr::lng_info_add_as_contact(),
|
||||||
|
CanAddContactValue(user),
|
||||||
|
[=] { window->show(Box(EditContactBox, window, user)); },
|
||||||
|
tracker);
|
||||||
} else {
|
} else {
|
||||||
auto linkText = LinkValue(
|
auto linkText = LinkValue(
|
||||||
_peer
|
_peer
|
||||||
|
@ -419,14 +427,6 @@ Ui::MultiSlideTracker DetailsFiller::fillUserButtons(
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
addSendMessageButton();
|
addSendMessageButton();
|
||||||
|
|
||||||
const auto window = &_controller->parentController()->window()->controller();
|
|
||||||
AddMainButton(
|
|
||||||
_wrap,
|
|
||||||
tr::lng_info_add_as_contact(),
|
|
||||||
CanAddContactValue(user),
|
|
||||||
[=] { window->show(Box(EditContactBox, window, user)); },
|
|
||||||
tracker);
|
|
||||||
}
|
}
|
||||||
return tracker;
|
return tracker;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "auth_session.h"
|
#include "auth_session.h"
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
#include "data/data_shared_media.h"
|
#include "data/data_shared_media.h"
|
||||||
#include "data/data_folder.h"
|
#include "data/data_folder.h"
|
||||||
|
@ -24,6 +25,25 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Info {
|
namespace Info {
|
||||||
namespace Profile {
|
namespace Profile {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
auto PlainBioValue(not_null<UserData*> user) {
|
||||||
|
return Notify::PeerUpdateValue(
|
||||||
|
user,
|
||||||
|
Notify::PeerUpdate::Flag::AboutChanged
|
||||||
|
) | rpl::map([=] { return user->about(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
auto PlainUsernameValue(not_null<PeerData*> peer) {
|
||||||
|
return Notify::PeerUpdateValue(
|
||||||
|
peer,
|
||||||
|
Notify::PeerUpdate::Flag::UsernameChanged
|
||||||
|
) | rpl::map([=] {
|
||||||
|
return peer->userName();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> NameValue(not_null<PeerData*> peer) {
|
rpl::producer<TextWithEntities> NameValue(not_null<PeerData*> peer) {
|
||||||
return Notify::PeerUpdateValue(
|
return Notify::PeerUpdateValue(
|
||||||
|
@ -43,11 +63,21 @@ rpl::producer<TextWithEntities> PhoneValue(not_null<UserData*> user) {
|
||||||
}) | Ui::Text::ToWithEntities();
|
}) | Ui::Text::ToWithEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto PlainBioValue(not_null<UserData*> user) {
|
rpl::producer<TextWithEntities> PhoneOrHiddenValue(not_null<UserData*> user) {
|
||||||
return Notify::PeerUpdateValue(
|
return rpl::combine(
|
||||||
user,
|
PhoneValue(user),
|
||||||
Notify::PeerUpdate::Flag::AboutChanged
|
PlainUsernameValue(user),
|
||||||
) | rpl::map([user] { return user->about(); });
|
PlainBioValue(user),
|
||||||
|
tr::lng_info_mobile_hidden()
|
||||||
|
) | rpl::map([](
|
||||||
|
const TextWithEntities &phone,
|
||||||
|
const QString &username,
|
||||||
|
const QString &bio,
|
||||||
|
const QString &hidden) {
|
||||||
|
return (phone.text.isEmpty() && username.isEmpty() && bio.isEmpty())
|
||||||
|
? Ui::Text::WithEntities(hidden)
|
||||||
|
: phone;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> BioValue(not_null<UserData*> user) {
|
rpl::producer<TextWithEntities> BioValue(not_null<UserData*> user) {
|
||||||
|
@ -56,15 +86,6 @@ rpl::producer<TextWithEntities> BioValue(not_null<UserData*> user) {
|
||||||
| Ui::Text::ToWithEntities();
|
| Ui::Text::ToWithEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto PlainUsernameValue(not_null<PeerData*> peer) {
|
|
||||||
return Notify::PeerUpdateValue(
|
|
||||||
peer,
|
|
||||||
Notify::PeerUpdate::Flag::UsernameChanged
|
|
||||||
) | rpl::map([peer] {
|
|
||||||
return peer->userName();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> UsernameValue(not_null<UserData*> user) {
|
rpl::producer<TextWithEntities> UsernameValue(not_null<UserData*> user) {
|
||||||
return PlainUsernameValue(
|
return PlainUsernameValue(
|
||||||
user
|
user
|
||||||
|
|
|
@ -34,6 +34,7 @@ inline auto ToSingleLine() {
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> NameValue(not_null<PeerData*> peer);
|
rpl::producer<TextWithEntities> NameValue(not_null<PeerData*> peer);
|
||||||
rpl::producer<TextWithEntities> PhoneValue(not_null<UserData*> user);
|
rpl::producer<TextWithEntities> PhoneValue(not_null<UserData*> user);
|
||||||
|
rpl::producer<TextWithEntities> PhoneOrHiddenValue(not_null<UserData*> user);
|
||||||
rpl::producer<TextWithEntities> BioValue(not_null<UserData*> user);
|
rpl::producer<TextWithEntities> BioValue(not_null<UserData*> user);
|
||||||
rpl::producer<TextWithEntities> UsernameValue(not_null<UserData*> user);
|
rpl::producer<TextWithEntities> UsernameValue(not_null<UserData*> user);
|
||||||
rpl::producer<TextWithEntities> AboutValue(not_null<PeerData*> peer);
|
rpl::producer<TextWithEntities> AboutValue(not_null<PeerData*> peer);
|
||||||
|
|
Loading…
Add table
Reference in a new issue