Start fullscreen support in SeparatePanel.

This commit is contained in:
John Preston 2024-11-05 18:33:07 +04:00
parent 07e367e1a0
commit c987872be8
4 changed files with 36 additions and 4 deletions

View file

@ -378,6 +378,13 @@ Panel::Panel(
_widget->setWindowFlag(Qt::WindowStaysOnTopHint, false);
_widget->setInnerSize(st::botWebViewPanelSize, true);
_fullscreen.value(
) | rpl::start_with_next([=](bool fullscreen) {
_widget->toggleFullScreen(fullscreen);
layoutButtons();
sendSafeArea();
}, _widget->lifetime());
_widget->closeRequests(
) | rpl::start_with_next([=] {
if (_closeNeedConfirmation) {
@ -612,6 +619,15 @@ bool Panel::showWebview(
.isAttention = true,
});
}
if (_widget->isFullScreen()) {
callback(u"Close Full Screen"_q, [=] {
_fullscreen = false;
}, &st::menuIconPlayerWindowed);
} else {
callback(u"Show Full Screen"_q, [=] {
_fullscreen = true;
}, &st::menuIconPlayerFullScreen);
}
});
return true;
}
@ -619,7 +635,7 @@ bool Panel::showWebview(
void Panel::createWebviewBottom() {
_webviewBottom = std::make_unique<RpWidget>(_widget.get());
const auto bottom = _webviewBottom.get();
bottom->show();
bottom->setVisible(!_fullscreen.current());
const auto &padding = st::paymentsPanelPadding;
const auto label = CreateChild<FlatLabel>(
@ -744,6 +760,8 @@ bool Panel::createWebview(const Webview::ThemeParams &params) {
_themeUpdateForced.fire({});
} else if (command == "web_app_request_viewport") {
sendViewport();
} else if (command == "web_app_request_safe_area") {
sendSafeArea();
} else if (command == "web_app_open_tg_link") {
openTgLink(arguments);
} else if (command == "web_app_open_link") {
@ -828,6 +846,11 @@ void Panel::sendViewport() {
"is_expanded: true }");
}
void Panel::sendSafeArea() {
postEvent("safe_area_changed",
"{ top: 0, right: 0, bottom: 0, left: 0 }");
}
void Panel::setTitle(rpl::producer<QString> title) {
_widget->setTitle(std::move(title));
}
@ -1362,12 +1385,15 @@ void Panel::createButton(std::unique_ptr<Button> &button) {
}
void Panel::layoutButtons() {
if (!_webviewBottom) {
return;
}
const auto inner = _widget->innerGeometry();
const auto shown = [](std::unique_ptr<Button> &button) {
return button && !button->isHidden();
};
const auto any = shown(_mainButton) || shown(_secondaryButton);
_webviewBottom->setVisible(!any);
_webviewBottom->setVisible(!any && !_fullscreen.current());
if (any) {
_bottomButtonsBg->show();
@ -1437,6 +1463,8 @@ void Panel::layoutButtons() {
}
_footerHeight = any
? _bottomButtonsBg->height()
: _fullscreen.current()
? 0
: _webviewBottom->height();
}
@ -1461,7 +1489,7 @@ void Panel::showBox(
&& widget->isHidden()
&& _webview->lastHidingBox == raw) {
widget->show();
_webviewBottom->show();
_webviewBottom->setVisible(!_fullscreen.current());
}
}, _webview->lifetime);
if (hideNow) {

View file

@ -147,6 +147,7 @@ private:
void scheduleCloseWithConfirmation();
void closeWithConfirmation();
void sendViewport();
void sendSafeArea();
using EventData = std::variant<QString, QJsonObject>;
void postEvent(const QString &event);
@ -179,6 +180,7 @@ private:
std::optional<QColor> _bottomBarColor;
rpl::lifetime _headerColorLifetime;
rpl::lifetime _bottomBarColorLifetime;
rpl::variable<bool> _fullscreen = false;
bool _webviewProgress = false;
bool _themeUpdateScheduled = false;
bool _hiddenForPayment = false;

View file

@ -159,6 +159,8 @@ menuIconWinHello: icon {{ "menu/passcode_winhello", menuIconColor }};
menuIconTouchID: icon {{ "menu/passcode_finger", menuIconColor }};
menuIconAppleWatch: icon {{ "menu/passcode_watch", menuIconColor }};
menuIconSystemPwd: menuIconPermissions;
menuIconPlayerFullScreen: icon {{ "player/player_fullscreen", menuIconColor }};
menuIconPlayerWindowed: icon {{ "player/player_minimize", menuIconColor }};
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
menuIconTTLAnyTextPosition: point(11px, 22px);

@ -1 +1 @@
Subproject commit b969b5bd32c339be43732d7f1d34d7fdc3454eab
Subproject commit 967ae393e82eb52174fd25e3a5a15b8029e21938