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

98 lines
2.5 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;
class Show;
} // 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 FormatCommission(ushort commission);
[[nodiscard]] QString FormatProgramDuration(int durationMonths);
[[nodiscard]] rpl::producer<TextWithEntities> FormatForProgramDuration(
int durationMonths);
2024-11-29 14:18:30 +04:00
[[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);
[[nodiscard]] object_ptr<Ui::BoxContent> ConfirmEndBox(Fn<void()> finish);
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);
void ConfirmUpdate(
std::shared_ptr<Ui::Show> show,
not_null<UserData*> bot,
const StarRefProgram &program,
bool exists,
Fn<void(Fn<void(bool)> done)> update);
void UpdateProgram(
std::shared_ptr<Ui::Show> show,
not_null<UserData*> bot,
const StarRefProgram &program,
Fn<void(bool)> done);
void FinishProgram(
std::shared_ptr<Ui::Show> show,
not_null<UserData*> bot,
Fn<void(bool)> done);
2024-11-29 14:18:30 +04:00
[[nodiscard]] ConnectedBots Parse(
not_null<Main::Session*> session,
const MTPpayments_ConnectedStarRefBots &bots);
} // namespace Info::BotStarRef