Add 'Copy Link' and 'Share Link' buttons.

This commit is contained in:
John Preston 2021-01-15 16:57:42 +04:00
parent 7e89ed48c2
commit 8c7030378a
11 changed files with 95 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -12,8 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "api/api_invite_links.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/wrap/padding_wrap.h"
#include "ui/widgets/popup_menu.h"
#include "ui/controls/invite_link_label.h"
#include "ui/controls/invite_link_buttons.h"
#include "ui/toast/toast.h"
#include "lang/lang_keys.h"
#include "apiwrap.h"
@ -88,4 +90,9 @@ void AddPermanentLinkBlock(
label->clicks(
) | rpl::start_with_next(copyLink, label->lifetime());
AddCopyShareLinkButtons(
container,
copyLink,
shareLink);
}

View File

@ -848,4 +848,20 @@ inviteLinkThreeDots: IconButton(defaultIconButton) {
rippleAreaSize: 0px;
}
inviteLinkFieldPadding: margins(22px, 7px, 22px, 9px);
inviteLinkFieldPadding: margins(22px, 7px, 22px, 14px);
inviteLinkButton: RoundButton(defaultActiveButton) {
height: 36px;
textTop: 9px;
}
inviteLinkButtonsPadding: margins(22px, 0px, 22px, 0px);
inviteLinkButtonsSkip: 10px;
inviteLinkCopy: RoundButton(inviteLinkButton) {
icon: icon {{ "info/edit/links_copy", activeButtonFg }};
iconOver: icon {{ "info/edit/links_copy", activeButtonFgOver }};
iconPosition: point(-1px, 2px);
}
inviteLinkShare: RoundButton(inviteLinkCopy) {
icon: icon {{ "info/edit/links_share", activeButtonFg }};
iconOver: icon {{ "info/edit/links_share", activeButtonFgOver }};
}

View File

@ -0,0 +1,50 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "ui/controls/invite_link_buttons.h"
#include "ui/widgets/buttons.h"
#include "ui/wrap/vertical_layout.h"
#include "ui/wrap/padding_wrap.h"
#include "lang/lang_keys.h"
#include "styles/style_info.h"
namespace Ui {
void AddCopyShareLinkButtons(
not_null<VerticalLayout*> container,
Fn<void()> copyLink,
Fn<void()> shareLink) {
const auto wrap = container->add(
object_ptr<FixedHeightWidget>(
container,
st::inviteLinkButton.height),
st::inviteLinkButtonsPadding);
const auto copy = CreateChild<RoundButton>(
wrap,
tr::lng_group_invite_copy(),
st::inviteLinkCopy);
copy->setTextTransform(RoundButton::TextTransform::NoTransform);
copy->setClickedCallback(copyLink);
const auto share = CreateChild<RoundButton>(
wrap,
tr::lng_group_invite_share(),
st::inviteLinkShare);
share->setTextTransform(RoundButton::TextTransform::NoTransform);
share->setClickedCallback(shareLink);
wrap->widthValue(
) | rpl::start_with_next([=](int width) {
const auto buttonWidth = (width - st::inviteLinkButtonsSkip) / 2;
copy->setFullWidth(buttonWidth);
share->setFullWidth(buttonWidth);
copy->moveToLeft(0, 0, width);
share->moveToRight(0, 0, width);
}, wrap->lifetime());
}
} // namespace Ui

View File

@ -0,0 +1,19 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Ui {
class VerticalLayout;
void AddCopyShareLinkButtons(
not_null<VerticalLayout*> container,
Fn<void()> copyLink,
Fn<void()> shareLink);
} // namespace Ui

View File

@ -88,6 +88,8 @@ PRIVATE
ui/chat/pinned_bar.h
ui/controls/emoji_button.cpp
ui/controls/emoji_button.h
ui/controls/invite_link_buttons.cpp
ui/controls/invite_link_buttons.h
ui/controls/invite_link_label.cpp
ui/controls/invite_link_label.h
ui/controls/send_button.cpp