mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Added userpic of web view bots to box of confirmation to open.
This commit is contained in:
parent
8ac3c2157f
commit
649d242e9a
2 changed files with 57 additions and 52 deletions
|
@ -3315,7 +3315,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_allow_bot" = "Allow";
|
||||
"lng_allow_bot_webview_details" = "More about this bot {emoji}";
|
||||
"lng_allow_bot_webview_details_about" = "To launch this web app, you will connect to its website.\n\nIt will be able to access your **IP address** and basic device info.";
|
||||
"lng_allow_bot_webview" = "{bot_name} would like to open its web app to proceed.\n\nIt will be able to access your **IP address** and basic device info.";
|
||||
"lng_url_auth_open_confirm" = "Do you want to open {link}?";
|
||||
"lng_url_auth_login_option" = "Log in to {domain} as {user}";
|
||||
"lng_url_auth_allow_messages" = "Allow {bot} to send me messages";
|
||||
|
|
|
@ -361,6 +361,52 @@ WebViewContext ResolveContext(
|
|||
return context;
|
||||
}
|
||||
|
||||
void FillBotUsepic(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<PeerData*> bot,
|
||||
base::weak_ptr<Window::SessionController> weak) {
|
||||
auto arrow = Ui::Text::SingleCustomEmoji(
|
||||
bot->owner().customEmojiManager().registerInternalEmoji(
|
||||
st::topicButtonArrow,
|
||||
st::channelEarnLearnArrowMargins,
|
||||
false));
|
||||
auto aboutLabel = Ui::CreateLabelWithCustomEmoji(
|
||||
box->verticalLayout(),
|
||||
tr::lng_allow_bot_webview_details(
|
||||
lt_emoji,
|
||||
rpl::single(std::move(arrow)),
|
||||
Ui::Text::RichLangValue
|
||||
) | rpl::map([](TextWithEntities text) {
|
||||
return Ui::Text::Link(std::move(text), u"internal:"_q);
|
||||
}),
|
||||
{ .session = &bot->session() },
|
||||
st::defaultFlatLabel);
|
||||
const auto userpic = Ui::CreateChild<Ui::UserpicButton>(
|
||||
box->verticalLayout(),
|
||||
bot,
|
||||
st::mainMenuUserpic);
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
aboutLabel->setClickHandlerFilter([=](
|
||||
const ClickHandlerPtr &,
|
||||
Qt::MouseButton) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->showPeerHistory(
|
||||
bot->id,
|
||||
Window::SectionShow::Way::Forward);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
Ui::IconWithTitle(
|
||||
box->verticalLayout(),
|
||||
userpic,
|
||||
Ui::CreateChild<Ui::FlatLabel>(
|
||||
box->verticalLayout(),
|
||||
rpl::single(bot->name()),
|
||||
box->getDelegate()->style().title),
|
||||
aboutLabel);
|
||||
}
|
||||
|
||||
class BotAction final : public Ui::Menu::ItemBase {
|
||||
public:
|
||||
BotAction(
|
||||
|
@ -775,15 +821,16 @@ void WebViewInstance::confirmOpen(Fn<void()> done) {
|
|||
botClose();
|
||||
close();
|
||||
};
|
||||
_parentShow->show(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_allow_bot_webview(
|
||||
tr::now,
|
||||
lt_bot_name,
|
||||
Ui::Text::Bold(_bot->name()),
|
||||
Ui::Text::RichLangValue),
|
||||
.confirmed = crl::guard(this, callback),
|
||||
.cancelled = crl::guard(this, cancel),
|
||||
.confirmText = tr::lng_box_ok(),
|
||||
_parentShow->show(Box([=](not_null<Ui::GenericBox*> box) {
|
||||
FillBotUsepic(box, _bot, _context.controller);
|
||||
Ui::ConfirmBox(box, {
|
||||
.text = tr::lng_allow_bot_webview_details_about(
|
||||
tr::now,
|
||||
Ui::Text::RichLangValue),
|
||||
.confirmed = crl::guard(this, callback),
|
||||
.cancelled = crl::guard(this, cancel),
|
||||
.confirmText = tr::lng_box_ok(),
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -800,48 +847,7 @@ void WebViewInstance::confirmAppOpen(
|
|||
botClose();
|
||||
close();
|
||||
};
|
||||
{
|
||||
auto arrow = Ui::Text::SingleCustomEmoji(
|
||||
_bot->owner().customEmojiManager().registerInternalEmoji(
|
||||
st::topicButtonArrow,
|
||||
st::channelEarnLearnArrowMargins,
|
||||
false));
|
||||
auto aboutLabel = Ui::CreateLabelWithCustomEmoji(
|
||||
box->verticalLayout(),
|
||||
tr::lng_allow_bot_webview_details(
|
||||
lt_emoji,
|
||||
rpl::single(std::move(arrow)),
|
||||
Ui::Text::RichLangValue
|
||||
) | rpl::map([](TextWithEntities text) {
|
||||
return Ui::Text::Link(std::move(text), u"internal:"_q);
|
||||
}),
|
||||
{ .session = &_bot->session() },
|
||||
st::defaultFlatLabel);
|
||||
const auto userpic = Ui::CreateChild<Ui::UserpicButton>(
|
||||
box->verticalLayout(),
|
||||
_bot,
|
||||
st::mainMenuUserpic);
|
||||
Ui::AddSkip(box->verticalLayout());
|
||||
aboutLabel->setClickHandlerFilter([=, weak = _context.controller](
|
||||
const ClickHandlerPtr &,
|
||||
Qt::MouseButton) {
|
||||
if (const auto strong = weak.get()) {
|
||||
strong->showPeerHistory(
|
||||
_bot->id,
|
||||
Window::SectionShow::Way::Forward);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
Ui::IconWithTitle(
|
||||
box->verticalLayout(),
|
||||
userpic,
|
||||
Ui::CreateChild<Ui::FlatLabel>(
|
||||
box->verticalLayout(),
|
||||
rpl::single(_bot->name()),
|
||||
box->getDelegate()->style().title),
|
||||
aboutLabel);
|
||||
}
|
||||
FillBotUsepic(box, _bot, _context.controller);
|
||||
Ui::ConfirmBox(box, {
|
||||
tr::lng_allow_bot_webview_details_about(
|
||||
tr::now,
|
||||
|
|
Loading…
Add table
Reference in a new issue