mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Added initial few action buttons to profile top bar.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M12.009,2.759C17.307,2.759 21.602,6.688 21.602,11.533C21.602,16.379 17.307,20.307 12.009,20.307C10.566,20.307 9.197,20.016 7.969,19.494C7.602,19.784 7.273,20.004 6.98,20.154C6.092,20.609 5.496,20.772 4.144,20.914C3.778,20.952 3.534,20.625 3.819,20.34C4.452,19.708 4.793,18.577 4.966,17.49C3.384,15.925 2.417,13.833 2.417,11.533C2.417,6.688 6.711,2.759 12.009,2.759Z" fill="#FFFFFF" fill-rule="evenodd"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 505 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M11.922,2.528C12.663,2.528 13.264,3.129 13.264,3.87L13.264,4.492C16.232,5.216 18.32,7.681 18.32,10.805L18.32,14.987C18.32,15.133 18.373,15.273 18.47,15.382L19.678,16.735C20.342,17.382 19.668,18.491 18.731,18.491L5.261,18.491C4.324,18.491 3.661,17.382 4.324,16.735L5.532,15.382C5.629,15.273 5.682,15.133 5.682,14.987L5.682,10.805C5.682,7.735 7.675,5.317 10.556,4.538L10.556,3.87C10.556,3.151 11.121,2.564 11.831,2.529L11.922,2.528ZM12.001,21.472C13.159,21.472 14.107,20.558 14.107,19.525L9.895,19.525C9.895,20.558 10.832,21.472 12.001,21.472Z" fill="#FFFFFF"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 661 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M14.107,19.525C14.107,20.558 13.159,21.472 12.001,21.472C10.832,21.472 9.895,20.558 9.895,19.525L14.107,19.525ZM3.505,3.471L20.618,19.654C20.962,19.979 20.977,20.52 20.652,20.864C20.327,21.207 19.786,21.222 19.443,20.898L2.329,4.714C1.986,4.389 1.971,3.848 2.295,3.505C2.62,3.161 3.162,3.146 3.505,3.471ZM5.718,10.105L14.585,18.491L5.261,18.491C4.324,18.491 3.661,17.382 4.324,16.735L5.532,15.382C5.629,15.273 5.682,15.133 5.682,14.987L5.682,10.805C5.682,10.568 5.694,10.334 5.718,10.105ZM11.922,2.528C12.663,2.528 13.264,3.129 13.264,3.87L13.264,4.492C16.232,5.216 18.32,7.681 18.32,10.805L18.32,14.987C18.32,15.133 18.373,15.273 18.47,15.382L18.781,15.73L8.174,5.699C8.862,5.176 9.666,4.779 10.556,4.538L10.556,3.87C10.556,3.151 11.121,2.564 11.831,2.529L11.922,2.528Z" fill="#FFFFFF" fill-rule="nonzero"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 910 B |
@@ -1668,6 +1668,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_profile_changed_photo_title" = "Photo updated";
|
||||
"lng_profile_changed_photo_about" = "You can change it in {link}.";
|
||||
"lng_profile_changed_photo_link" = "Settings";
|
||||
|
||||
"lng_profile_action_short_message" = "Message";
|
||||
"lng_profile_action_short_mute" = "Mute";
|
||||
"lng_profile_action_short_unmute" = "Unmute";
|
||||
|
||||
"lng_media_type_photos" = "Photos";
|
||||
"lng_media_type_gifs" = "GIFs";
|
||||
"lng_media_type_videos" = "Videos";
|
||||
|
||||
@@ -46,6 +46,9 @@
|
||||
<file alias="toast/saved_messages.tgs">../../animations/toast/saved_messages.tgs</file>
|
||||
<file alias="toast/tagged.tgs">../../animations/toast/tagged.tgs</file>
|
||||
|
||||
<file alias="profile_muting.tgs">../../animations/profile/profile_muting.tgs</file>
|
||||
<file alias="profile_unmuting.tgs">../../animations/profile/profile_unmuting.tgs</file>
|
||||
|
||||
<file alias="dice_idle.tgs">../../animations/dice/dice_idle.tgs</file>
|
||||
<file alias="dart_idle.tgs">../../animations/dice/dart_idle.tgs</file>
|
||||
<file alias="bball_idle.tgs">../../animations/dice/bball_idle.tgs</file>
|
||||
|
||||
@@ -368,10 +368,15 @@ infoProfileTopBarActionButtonTextSkip: 4px;
|
||||
|
||||
infoProfileTopBarActionButtonsPadding: margins(12px, 6px, 12px, 12px);
|
||||
infoProfileTopBarActionButtonsHeight: infoProfileTopBarActionButtonSize + infoProfileTopBarActionButtonsPadding.topBottom;
|
||||
infoProfileTopBarActionButtonsSpace: 10px;
|
||||
|
||||
infoProfileTopBarStep2: infoProfileTopBarHeightMax - infoLayerTopBarHeight;
|
||||
infoProfileTopBarStep1: infoProfileTopBarStep2 - infoProfileTopBarActionButtonsHeight;
|
||||
|
||||
infoProfileTopBarActionMessage: icon{{ "profile/message-22x22", premiumButtonFg }};
|
||||
infoProfileTopBarActionMute: icon{{ "profile/mute-22x22", premiumButtonFg }};
|
||||
infoProfileTopBarActionUnmute: icon{{ "profile/unmute-22x22", premiumButtonFg }};
|
||||
|
||||
infoMinimalWidth: 324px;
|
||||
infoDesiredWidth: 392px;
|
||||
infoMinimalLayerMargin: 48px;
|
||||
|
||||
@@ -29,7 +29,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_saved_sublist.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "data/notify/data_notify_settings.h"
|
||||
#include "data/notify/data_peer_notify_settings.h"
|
||||
#include "data/stickers/data_custom_emoji.h"
|
||||
#include "history/history.h"
|
||||
#include "info_profile_actions.h"
|
||||
#include "info/info_controller.h"
|
||||
#include "info/info_memento.h"
|
||||
@@ -37,11 +40,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "info/profile/info_profile_badge.h"
|
||||
#include "info/profile/info_profile_cover.h" // LargeCustomEmojiMargins
|
||||
#include "info/profile/info_profile_status_label.h"
|
||||
#include "info/profile/info_profile_top_bar_action_button.h"
|
||||
#include "info/profile/info_profile_values.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "lottie/lottie_animation.h"
|
||||
#include "lottie/lottie_multi_player.h"
|
||||
#include "main/main_session.h"
|
||||
#include "menu/menu_mute.h"
|
||||
#include "settings/settings_premium.h"
|
||||
#include "ui/boxes/show_or_premium_box.h"
|
||||
#include "ui/color_contrast.h"
|
||||
@@ -55,7 +60,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/top_background_gradient.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/horizontal_fit_container.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
@@ -261,6 +266,7 @@ TopBar::TopBar(
|
||||
setupButtons(controller, descriptor.backToggles.value());
|
||||
setupUserpicButton(controller);
|
||||
setupPinnedToTopGifts();
|
||||
setupActions(controller);
|
||||
if (_topic) {
|
||||
_topicIconView = std::make_unique<TopicIconView>(
|
||||
_topic,
|
||||
@@ -318,6 +324,107 @@ TopBar::TopBar(
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
void TopBar::setupActions(not_null<Controller*> controller) {
|
||||
const auto peer = controller->key().peer();
|
||||
const auto user = peer->asUser();
|
||||
const auto channel = peer->asChannel();
|
||||
const auto chat = peer->asChat();
|
||||
const auto topic = controller->key().topic();
|
||||
_actions = base::make_unique_q<Ui::HorizontalFitContainer>(
|
||||
this,
|
||||
st::infoProfileTopBarActionButtonsSpace);
|
||||
if (user) {
|
||||
const auto message = Ui::CreateChild<TopBarActionButton>(
|
||||
this,
|
||||
tr::lng_profile_action_short_message(tr::now),
|
||||
st::infoProfileTopBarActionMessage);
|
||||
message->setClickedCallback([=, window = controller] {
|
||||
window->showPeerHistory(
|
||||
peer->id,
|
||||
Window::SectionShow::Way::Forward);
|
||||
});
|
||||
_actions->add(message);
|
||||
}
|
||||
{
|
||||
const auto notifications = Ui::CreateChild<TopBarActionButton>(
|
||||
this,
|
||||
tr::lng_profile_action_short_mute(tr::now),
|
||||
st::infoProfileTopBarActionMessage);
|
||||
notifications->convertToToggle(
|
||||
st::infoProfileTopBarActionUnmute,
|
||||
st::infoProfileTopBarActionMute,
|
||||
u"profile_muting"_q,
|
||||
u"profile_unmuting"_q);
|
||||
|
||||
const auto topicRootId = topic ? topic->rootId() : MsgId();
|
||||
const auto makeThread = [=] {
|
||||
return topicRootId
|
||||
? static_cast<Data::Thread*>(peer->forumTopicFor(topicRootId))
|
||||
: peer->owner().history(peer).get();
|
||||
};
|
||||
(topic
|
||||
? NotificationsEnabledValue(topic)
|
||||
: NotificationsEnabledValue(peer)
|
||||
) | rpl::start_with_next([=](bool enabled) {
|
||||
notifications->toggle(enabled);
|
||||
notifications->setText(enabled
|
||||
? tr::lng_profile_action_short_mute(tr::now)
|
||||
: tr::lng_profile_action_short_unmute(tr::now));
|
||||
}, notifications->lifetime());
|
||||
notifications->finishAnimating();
|
||||
|
||||
notifications->setAcceptBoth();
|
||||
const auto notifySettings = &peer->owner().notifySettings();
|
||||
MuteMenu::SetupMuteMenu(
|
||||
notifications,
|
||||
notifications->clicks(
|
||||
) | rpl::filter([=](Qt::MouseButton button) {
|
||||
if (button == Qt::RightButton) {
|
||||
return true;
|
||||
}
|
||||
const auto topic = topicRootId
|
||||
? peer->forumTopicFor(topicRootId)
|
||||
: nullptr;
|
||||
Assert(!topicRootId || topic != nullptr);
|
||||
const auto is = topic
|
||||
? notifySettings->isMuted(topic)
|
||||
: notifySettings->isMuted(peer);
|
||||
if (is) {
|
||||
if (topic) {
|
||||
notifySettings->update(topic, { .unmute = true });
|
||||
} else {
|
||||
notifySettings->update(peer, { .unmute = true });
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}) | rpl::to_empty,
|
||||
makeThread,
|
||||
controller->uiShow());
|
||||
_actions->add(notifications);
|
||||
}
|
||||
const auto padding = st::infoProfileTopBarActionButtonsPadding;
|
||||
sizeValue() | rpl::start_with_next([=](const QSize &size) {
|
||||
const auto ratio = float64(size.height())
|
||||
/ (st::infoProfileTopBarActionButtonsHeight
|
||||
+ st::infoLayerTopBarHeight);
|
||||
const auto h = st::infoProfileTopBarActionButtonSize;
|
||||
const auto resultHeight = (ratio >= 1.)
|
||||
? h
|
||||
: (ratio <= 0.5)
|
||||
? 0
|
||||
: int(h * (ratio - 0.5) / 0.5);
|
||||
_actions->setGeometry(
|
||||
padding.left(),
|
||||
size.height() - resultHeight - padding.bottom(),
|
||||
size.width() - rect::m::sum::h(padding),
|
||||
resultHeight);
|
||||
}, _actions->lifetime());
|
||||
_actions->show();
|
||||
_actions->raise();
|
||||
}
|
||||
|
||||
void TopBar::setupUserpicButton(not_null<Controller*> controller) {
|
||||
_userpicButton = base::make_unique_q<Ui::AbstractButton>(this);
|
||||
rpl::single(
|
||||
@@ -460,11 +567,15 @@ int TopBar::statusMostLeft() const {
|
||||
}
|
||||
|
||||
void TopBar::updateLabelsPosition() {
|
||||
const auto max = QWidget::maximumHeight();
|
||||
const auto min = QWidget::minimumHeight();
|
||||
_progress = (max > min)
|
||||
? ((height() - min) / float64(max - min))
|
||||
: 1.;
|
||||
_progress = [&] {
|
||||
const auto max = QWidget::maximumHeight();
|
||||
const auto min = QWidget::minimumHeight()
|
||||
+ st::infoProfileTopBarActionButtonsHeight;
|
||||
const auto p = (max > min)
|
||||
? ((height() - min) / float64(max - min))
|
||||
: 1.;
|
||||
return std::clamp(p, 0., 1.);
|
||||
}();
|
||||
const auto progressCurrent = _progress.current();
|
||||
|
||||
auto rightButtonsWidth = 0;
|
||||
|
||||
@@ -54,6 +54,7 @@ class RoundButton;
|
||||
class StarsRating;
|
||||
template <typename Widget>
|
||||
class FadeWrap;
|
||||
class HorizontalFitContainer;
|
||||
} //namespace Ui
|
||||
|
||||
namespace Info {
|
||||
@@ -115,6 +116,7 @@ private:
|
||||
not_null<Controller*> controller,
|
||||
const Ui::Menu::MenuCallback &addAction);
|
||||
void setupUserpicButton(not_null<Controller*> controller);
|
||||
void setupActions(not_null<Controller*> controller);
|
||||
void setupButtons(
|
||||
not_null<Controller*> controller,
|
||||
rpl::producer<bool> backToggles);
|
||||
@@ -178,6 +180,8 @@ private:
|
||||
|
||||
base::unique_qptr<Ui::AbstractButton> _userpicButton;
|
||||
|
||||
base::unique_qptr<Ui::HorizontalFitContainer> _actions;
|
||||
|
||||
std::unique_ptr<Lottie::MultiPlayer> _lottiePlayer;
|
||||
struct PinnedToTopGiftEntry {
|
||||
Lottie::Animation *animation = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user