mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improve location picker design.
This commit is contained in:
parent
025ab40687
commit
8e6d7bb190
3 changed files with 54 additions and 25 deletions
|
@ -1423,3 +1423,7 @@ paidTagLabel: FlatLabel(defaultFlatLabel) {
|
||||||
style: semiboldTextStyle;
|
style: semiboldTextStyle;
|
||||||
}
|
}
|
||||||
paidTagPadding: margins(16px, 6px, 16px, 6px);
|
paidTagPadding: margins(16px, 6px, 16px, 6px);
|
||||||
|
|
||||||
|
pickLocationWindow: size(364px, 680px);
|
||||||
|
pickLocationMapHeight: 220px;
|
||||||
|
pickLocationCollapsedHeight: 108px;
|
||||||
|
|
|
@ -10,11 +10,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "core/current_geo_location.h"
|
#include "core/current_geo_location.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/widgets/rp_window.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
|
#include "ui/widgets/separate_panel.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "webview/webview_data_stream_memory.h"
|
#include "webview/webview_data_stream_memory.h"
|
||||||
#include "webview/webview_embed.h"
|
#include "webview/webview_embed.h"
|
||||||
#include "webview/webview_interface.h"
|
#include "webview/webview_interface.h"
|
||||||
|
#include "styles/style_chat_helpers.h"
|
||||||
#include "styles/style_dialogs.h"
|
#include "styles/style_dialogs.h"
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
|
|
||||||
|
@ -117,7 +120,10 @@ QString MapsProviderToken;
|
||||||
LocationPicker::LocationPicker(Descriptor &&descriptor)
|
LocationPicker::LocationPicker(Descriptor &&descriptor)
|
||||||
: _callback(std::move(descriptor.callback))
|
: _callback(std::move(descriptor.callback))
|
||||||
, _quit(std::move(descriptor.quit))
|
, _quit(std::move(descriptor.quit))
|
||||||
, _window(std::make_unique<RpWindow>())
|
, _window(std::make_unique<SeparatePanel>())
|
||||||
|
, _body((_window->setInnerSize(st::pickLocationWindow)
|
||||||
|
, _window->showInner(base::make_unique_q<RpWidget>(_window.get()))
|
||||||
|
, _window->inner()))
|
||||||
, _updateStyles([=] {
|
, _updateStyles([=] {
|
||||||
const auto str = EscapeForScriptString(ComputeStyles());
|
const auto str = EscapeForScriptString(ComputeStyles());
|
||||||
if (_webview) {
|
if (_webview) {
|
||||||
|
@ -148,35 +154,50 @@ void LocationPicker::setup(const Descriptor &descriptor) {
|
||||||
void LocationPicker::setupWindow(const Descriptor &descriptor) {
|
void LocationPicker::setupWindow(const Descriptor &descriptor) {
|
||||||
const auto window = _window.get();
|
const auto window = _window.get();
|
||||||
|
|
||||||
|
window->setWindowFlag(Qt::WindowStaysOnTopHint, false);
|
||||||
|
window->closeRequests() | rpl::start_with_next([=] {
|
||||||
|
close();
|
||||||
|
}, _lifetime);
|
||||||
|
|
||||||
const auto parent = descriptor.parent
|
const auto parent = descriptor.parent
|
||||||
? descriptor.parent->window()->geometry()
|
? descriptor.parent->window()->geometry()
|
||||||
: QGuiApplication::primaryScreen()->availableGeometry();
|
: QGuiApplication::primaryScreen()->availableGeometry();
|
||||||
window->setGeometry(QRect(
|
window->setTitle(tr::lng_maps_point());
|
||||||
parent.x() + (parent.width() - st::windowMinHeight) / 2,
|
window->move(
|
||||||
parent.y() + (parent.height() - st::windowMinWidth) / 2,
|
parent.x() + (parent.width() - window->width()) / 2,
|
||||||
st::windowMinHeight,
|
parent.y() + (parent.height() - window->height()) / 2);
|
||||||
st::windowMinWidth));
|
|
||||||
window->setMinimumSize({ st::windowMinHeight, st::windowMinWidth });
|
|
||||||
|
|
||||||
_container = Ui::CreateChild<Ui::RpWidget>(window->body().get());
|
_container = CreateChild<RpWidget>(_body.get());
|
||||||
const auto button = Ui::CreateChild<FlatButton>(
|
const auto scroll = CreateChild<ScrollArea>(_body.get());
|
||||||
window->body(),
|
const auto controls = scroll->setOwnedWidget(
|
||||||
|
object_ptr<VerticalLayout>(scroll));
|
||||||
|
const auto toppad = controls->add(object_ptr<RpWidget>(controls));
|
||||||
|
|
||||||
|
const auto button = controls->add(object_ptr<FlatButton>(
|
||||||
|
controls,
|
||||||
tr::lng_maps_point_send(tr::now),
|
tr::lng_maps_point_send(tr::now),
|
||||||
st::dialogsUpdateButton);
|
st::dialogsUpdateButton));
|
||||||
button->show();
|
|
||||||
button->setClickedCallback([=] {
|
button->setClickedCallback([=] {
|
||||||
_webview->eval("LocationPicker.send();");
|
_webview->eval("LocationPicker.send();");
|
||||||
});
|
});
|
||||||
window->body()->sizeValue(
|
controls->add(object_ptr<RpWidget>(controls))->resize(
|
||||||
) | rpl::start_with_next([=](QSize size) {
|
st::pickLocationWindow);
|
||||||
_container->setGeometry(QRect(QPoint(), size).marginsRemoved(
|
|
||||||
{ 0, 0, 0, button->height() }));
|
rpl::combine(
|
||||||
button->resizeToWidth(size.width());
|
_body->sizeValue(),
|
||||||
button->setGeometry(
|
scroll->scrollTopValue()
|
||||||
0,
|
) | rpl::start_with_next([=](QSize size, int scrollTop) {
|
||||||
size.height() - button->height(),
|
const auto width = size.width();
|
||||||
button->width(),
|
const auto height = size.height();
|
||||||
button->height());
|
const auto sub = std::min(
|
||||||
|
(st::pickLocationMapHeight - st::pickLocationCollapsedHeight),
|
||||||
|
scrollTop);
|
||||||
|
const auto mapHeight = st::pickLocationMapHeight - sub;
|
||||||
|
const auto scrollHeight = height - mapHeight;
|
||||||
|
button->resizeToWidth(width);
|
||||||
|
_container->setGeometry(0, 0, width, mapHeight);
|
||||||
|
scroll->setGeometry(0, mapHeight, width, scrollHeight);
|
||||||
|
toppad->resize(width, sub);
|
||||||
}, _container->lifetime());
|
}, _container->lifetime());
|
||||||
|
|
||||||
_container->paintRequest() | rpl::start_with_next([=](QRect clip) {
|
_container->paintRequest() | rpl::start_with_next([=](QRect clip) {
|
||||||
|
@ -184,6 +205,9 @@ void LocationPicker::setupWindow(const Descriptor &descriptor) {
|
||||||
}, _container->lifetime());
|
}, _container->lifetime());
|
||||||
|
|
||||||
_container->show();
|
_container->show();
|
||||||
|
scroll->show();
|
||||||
|
controls->show();
|
||||||
|
button->show();
|
||||||
window->show();
|
window->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Window;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
||||||
class RpWindow;
|
class SeparatePanel;
|
||||||
class RpWidget;
|
class RpWidget;
|
||||||
|
|
||||||
struct LocationInfo {
|
struct LocationInfo {
|
||||||
|
@ -56,7 +56,8 @@ private:
|
||||||
|
|
||||||
Fn<void(LocationInfo)> _callback;
|
Fn<void(LocationInfo)> _callback;
|
||||||
Fn<void()> _quit;
|
Fn<void()> _quit;
|
||||||
std::unique_ptr<RpWindow> _window;
|
std::unique_ptr<SeparatePanel> _window;
|
||||||
|
not_null<RpWidget*> _body;
|
||||||
RpWidget *_container = nullptr;
|
RpWidget *_container = nullptr;
|
||||||
std::unique_ptr<Webview::Window> _webview;
|
std::unique_ptr<Webview::Window> _webview;
|
||||||
SingleQueuedInvokation _updateStyles;
|
SingleQueuedInvokation _updateStyles;
|
||||||
|
|
Loading…
Add table
Reference in a new issue