2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Always show footer in webview in payments.

This commit is contained in:
John Preston
2021-04-01 18:39:44 +04:00
parent cd4a9d7c16
commit 491ec2db7f
8 changed files with 48 additions and 8 deletions

View File

@@ -167,7 +167,10 @@ void CheckoutProcess::handleFormUpdate(const FormUpdate &update) {
_submitState = SubmitState::Validated;
requestPassword();
}, [&](const VerificationNeeded &data) {
if (!_panel->showWebview(data.url, false)) {
auto bottomText = tr::lng_payments_processed_by(
lt_provider,
rpl::single(_form->invoice().provider));
if (!_panel->showWebview(data.url, false, std::move(bottomText))) {
File::OpenUrl(data.url);
close();
}

View File

@@ -405,6 +405,7 @@ void Form::refreshPaymentMethodDetails() {
const auto &saved = _paymentMethod.savedCredentials;
const auto &entered = _paymentMethod.newCredentials;
_paymentMethod.ui.title = entered ? entered.title : saved.title;
_paymentMethod.ui.provider = _invoice.provider;
_paymentMethod.ui.ready = entered || saved;
_paymentMethod.ui.native.defaultCountry = defaultCountry();
_paymentMethod.ui.canSaveInformation

View File

@@ -28,6 +28,9 @@ paymentsTitle: FlatLabel(paymentsDescription) {
paymentsSeller: FlatLabel(paymentsDescription) {
textFg: windowSubTextFg;
}
paymentsWebviewBottom: FlatLabel(defaultFlatLabel) {
textFg: windowSubTextFg;
}
paymentsPriceLabel: paymentsDescription;
paymentsPriceAmount: defaultFlatLabel;
paymentsFullPriceLabel: paymentsTitle;

View File

@@ -189,7 +189,7 @@ not_null<RpWidget*> EditInformation::setupContent() {
: emailToProvider
? tr::lng_payments_to_provider_email
: tr::lng_payments_to_provider_phone)(
lt_bot_name,
lt_provider,
rpl::single(_invoice.provider)),
st::paymentsToProviderLabel),
st::paymentsToProviderPadding);

View File

@@ -235,10 +235,15 @@ void Panel::chooseTips(const Invoice &invoice) {
}
void Panel::showEditPaymentMethod(const PaymentMethodDetails &method) {
auto bottomText = method.canSaveInformation
? rpl::producer<QString>()
: tr::lng_payments_processed_by(
lt_provider,
rpl::single(method.provider));
_widget->setTitle(tr::lng_payments_card_title());
if (method.native.supported) {
showEditCard(method.native, CardField::Number);
} else if (!showWebview(method.url, true)) {
} else if (!showWebview(method.url, true, std::move(bottomText))) {
// #TODO payments errors not supported
} else if (method.canSaveInformation) {
const auto &padding = st::paymentsPanelPadding;
@@ -255,12 +260,33 @@ void Panel::showEditPaymentMethod(const PaymentMethodDetails &method) {
}
}
bool Panel::showWebview(const QString &url, bool allowBack) {
bool Panel::showWebview(
const QString &url,
bool allowBack,
rpl::producer<QString> bottomText) {
if (!_webview && !createWebview()) {
return false;
}
_webview->navigate(url);
_widget->setBackAllowed(allowBack);
if (bottomText) {
const auto &padding = st::paymentsPanelPadding;
const auto label = CreateChild<FlatLabel>(
_webviewBottom.get(),
std::move(bottomText),
st::paymentsWebviewBottom);
const auto height = padding.top()
+ label->heightNoMargins()
+ padding.bottom();
rpl::combine(
_webviewBottom->widthValue(),
label->widthValue()
) | rpl::start_with_next([=](int outerWidth, int width) {
label->move((outerWidth - width) / 2, padding.top());
}, label->lifetime());
label->show();
_webviewBottom->resize(_webviewBottom->width(), height);
}
return true;
}

View File

@@ -69,7 +69,10 @@ public:
void choosePaymentMethod(const PaymentMethodDetails &method);
void askSetPassword();
bool showWebview(const QString &url, bool allowBack);
bool showWebview(
const QString &url,
bool allowBack,
rpl::producer<QString> bottomText);
[[nodiscard]] rpl::producer<> backRequests() const;

View File

@@ -162,6 +162,7 @@ struct PaymentMethodDetails {
QString title;
NativeMethodDetails native;
QString url;
QString provider;
bool ready = false;
bool canSaveInformation = false;
};