Move 'Add to contacts' button up in Info.

This commit is contained in:
John Preston 2019-07-04 12:07:32 +02:00
parent dd38da7737
commit 729da4a6b4
4 changed files with 47 additions and 24 deletions

View File

@ -778,6 +778,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_profile_info_section" = "Info";
"lng_info_tab_media" = "Media";
"lng_info_mobile_label" = "Mobile";
"lng_info_mobile_hidden" = "Hidden";
"lng_info_username_label" = "Username";
"lng_info_bio_label" = "Bio";
"lng_info_link_label" = "Link";
@ -789,7 +790,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_info_channel_title" = "Channel Info";
"lng_profile_enable_notifications" = "Notifications";
"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_media_type_photos" = "Photos";
"lng_media_type_videos" = "Videos";

View File

@ -259,7 +259,7 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
addInfoOneLine(
tr::lng_info_mobile_label(),
PhoneValue(user),
PhoneOrHiddenValue(user),
tr::lng_profile_copy_phone(tr::now));
if (user->botInfo) {
addInfoLine(tr::lng_info_about_label(), AboutValue(user));
@ -270,6 +270,14 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
tr::lng_info_username_label(),
UsernameValue(user),
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 {
auto linkText = LinkValue(
_peer
@ -419,14 +427,6 @@ Ui::MultiSlideTracker DetailsFiller::fillUserButtons(
);
} else {
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;
}

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "auth_session.h"
#include "ui/wrap/slide_wrap.h"
#include "ui/text/text_utilities.h"
#include "lang/lang_keys.h"
#include "data/data_peer_values.h"
#include "data/data_shared_media.h"
#include "data/data_folder.h"
@ -24,6 +25,25 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Info {
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) {
return Notify::PeerUpdateValue(
@ -43,11 +63,21 @@ rpl::producer<TextWithEntities> PhoneValue(not_null<UserData*> user) {
}) | Ui::Text::ToWithEntities();
}
auto PlainBioValue(not_null<UserData*> user) {
return Notify::PeerUpdateValue(
user,
Notify::PeerUpdate::Flag::AboutChanged
) | rpl::map([user] { return user->about(); });
rpl::producer<TextWithEntities> PhoneOrHiddenValue(not_null<UserData*> user) {
return rpl::combine(
PhoneValue(user),
PlainUsernameValue(user),
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) {
@ -56,15 +86,6 @@ rpl::producer<TextWithEntities> BioValue(not_null<UserData*> user) {
| 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) {
return PlainUsernameValue(
user

View File

@ -34,6 +34,7 @@ inline auto ToSingleLine() {
rpl::producer<TextWithEntities> NameValue(not_null<PeerData*> peer);
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> UsernameValue(not_null<UserData*> user);
rpl::producer<TextWithEntities> AboutValue(not_null<PeerData*> peer);