2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-26 04:07:47 +00:00
tdesktop/Telegram/SourceFiles/info/bot/starref/info_bot_starref_common.h

79 lines
2.0 KiB
C
Raw Normal View History

/*
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
2024-11-29 14:18:30 +04:00
#include "base/object_ptr.h"
#include "data/data_user.h"
namespace Ui {
class AbstractButton;
2024-11-29 14:18:30 +04:00
class RoundButton;
class VerticalLayout;
2024-11-29 14:18:30 +04:00
class BoxContent;
class RpWidget;
} // namespace Ui
2024-11-29 14:18:30 +04:00
namespace style {
struct RoundButton;
} // namespace style
namespace Info::BotStarRef {
2024-11-29 14:18:30 +04:00
struct ConnectedBotState {
StarRefProgram program;
QString link;
TimeId date = 0;
int users = 0;
bool unresolved = false;
2024-11-29 14:18:30 +04:00
bool revoked = false;
};
struct ConnectedBot {
not_null<UserData*> bot;
ConnectedBotState state;
};
using ConnectedBots = std::vector<ConnectedBot>;
[[nodiscard]] QString FormatStarRefCommission(ushort commission);
[[nodiscard]] rpl::producer<TextWithEntities> FormatProgramDuration(
StarRefProgram program);
[[nodiscard]] not_null<Ui::AbstractButton*> AddViewListButton(
not_null<Ui::VerticalLayout*> parent,
rpl::producer<QString> title,
rpl::producer<QString> subtitle);
2024-11-29 14:18:30 +04:00
[[nodiscard]] not_null<Ui::RoundButton*> AddFullWidthButton(
not_null<Ui::BoxContent*> box,
rpl::producer<QString> text,
Fn<void()> callback = nullptr,
const style::RoundButton *stOverride = nullptr);
void AddFullWidthButtonFooter(
not_null<Ui::BoxContent*> box,
not_null<Ui::RpWidget*> button,
rpl::producer<TextWithEntities> text);
[[nodiscard]] object_ptr<Ui::BoxContent> StarRefLinkBox(
ConnectedBot row,
not_null<PeerData*> peer);
[[nodiscard]] object_ptr<Ui::BoxContent> JoinStarRefBox(
ConnectedBot row,
2024-11-29 17:11:47 +04:00
not_null<PeerData*> peer,
Fn<void(ConnectedBotState)> done);
2024-11-29 14:18:30 +04:00
std::unique_ptr<Ui::AbstractButton> MakePeerBubbleButton(
not_null<QWidget*> parent,
not_null<PeerData*> peer,
Ui::RpWidget *right = nullptr);
[[nodiscard]] ConnectedBots Parse(
not_null<Main::Session*> session,
const MTPpayments_ConnectedStarRefBots &bots);
} // namespace Info::BotStarRef