mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Fixed handle of dialogs resize for unconfirmed authorizations.
This commit is contained in:
@@ -85,7 +85,7 @@ rpl::producer<Ui::SlideWrap<Ui::RpWidget>*> TopBarSuggestionValue(
|
||||
|
||||
struct State {
|
||||
TopBarSuggestionContent *content = nullptr;
|
||||
Ui::RpWidget *unconfirmedWarning = nullptr;
|
||||
Ui::SlideWrap<Ui::VerticalLayout> *unconfirmedWarning = nullptr;
|
||||
base::unique_qptr<Ui::SlideWrap<Ui::RpWidget>> wrap;
|
||||
rpl::variable<int> leftPadding;
|
||||
rpl::variable<Toggle> desiredWrapToggle;
|
||||
@@ -116,9 +116,10 @@ rpl::producer<Ui::SlideWrap<Ui::RpWidget>*> TopBarSuggestionValue(
|
||||
};
|
||||
const auto ensureWrap = [=](not_null<Ui::RpWidget*> child) {
|
||||
if (!state->wrap) {
|
||||
state->wrap = base::make_unique_q<Ui::SlideWrap<Ui::RpWidget>>(
|
||||
parent,
|
||||
object_ptr<Ui::RpWidget>::fromRaw(child));
|
||||
state->wrap
|
||||
= base::make_unique_q<Ui::SlideWrap<Ui::RpWidget>>(
|
||||
parent,
|
||||
object_ptr<Ui::RpWidget>::fromRaw(child));
|
||||
state->desiredWrapToggle.force_assign(
|
||||
Toggle{ false, anim::type::instant });
|
||||
}
|
||||
@@ -143,17 +144,20 @@ rpl::producer<Ui::SlideWrap<Ui::RpWidget>*> TopBarSuggestionValue(
|
||||
if (!session->api().authorizations().unreviewed().empty()) {
|
||||
state->content = nullptr;
|
||||
state->wrap = nullptr;
|
||||
const auto list = session->api().authorizations().unreviewed();
|
||||
const auto hashes = list
|
||||
| ranges::views::transform([](const auto &auth) {
|
||||
const auto &list
|
||||
= session->api().authorizations().unreviewed();
|
||||
const auto hashes = ranges::views::all(
|
||||
list
|
||||
) | ranges::views::transform([](const auto &auth) {
|
||||
return auth.hash;
|
||||
})
|
||||
| ranges::to<std::vector>();
|
||||
}) | ranges::to_vector;
|
||||
const auto content = CreateUnconfirmedAuthContent(
|
||||
parent,
|
||||
list,
|
||||
[=](bool confirmed) {
|
||||
session->api().authorizations().review(hashes, confirmed);
|
||||
session->api().authorizations().review(
|
||||
hashes,
|
||||
confirmed);
|
||||
});
|
||||
ensureWrap(content);
|
||||
const auto wasUnconfirmedWarning = state->unconfirmedWarning;
|
||||
|
||||
@@ -32,11 +32,24 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace Dialogs {
|
||||
|
||||
not_null<Ui::RpWidget*> CreateUnconfirmedAuthContent(
|
||||
class UnconfirmedAuthWrap : public Ui::SlideWrap<Ui::VerticalLayout> {
|
||||
public:
|
||||
UnconfirmedAuthWrap(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
object_ptr<Ui::VerticalLayout> &&child)
|
||||
: Ui::SlideWrap<Ui::VerticalLayout>(parent, std::move(child)) {
|
||||
}
|
||||
|
||||
rpl::producer<int> desiredHeightValue() const override {
|
||||
return entity()->heightValue();
|
||||
}
|
||||
};
|
||||
|
||||
not_null<Ui::SlideWrap<Ui::VerticalLayout>*> CreateUnconfirmedAuthContent(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
const std::vector<Data::UnreviewedAuth> &list,
|
||||
Fn<void(bool)> callback) {
|
||||
const auto wrap = Ui::CreateChild<Ui::SlideWrap<Ui::VerticalLayout>>(
|
||||
const auto wrap = Ui::CreateChild<UnconfirmedAuthWrap>(
|
||||
parent,
|
||||
object_ptr<Ui::VerticalLayout>(parent));
|
||||
const auto content = wrap->entity();
|
||||
@@ -45,11 +58,6 @@ not_null<Ui::RpWidget*> CreateUnconfirmedAuthContent(
|
||||
p.fillRect(content->rect(), st::dialogsBg);
|
||||
}, content->lifetime());
|
||||
|
||||
parent->widthValue(
|
||||
) | rpl::start_with_next([=](int width) {
|
||||
content->resizeToWidth(width);
|
||||
}, content->lifetime());
|
||||
|
||||
const auto padding = st::dialogsUnconfirmedAuthPadding;
|
||||
|
||||
Ui::AddSkip(content);
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace Ui {
|
||||
class DynamicImage;
|
||||
class IconButton;
|
||||
class VerticalLayout;
|
||||
template<typename Widget>
|
||||
class SlideWrap;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Ui::Text {
|
||||
@@ -25,7 +27,7 @@ struct UnreviewedAuth;
|
||||
|
||||
namespace Dialogs {
|
||||
|
||||
not_null<Ui::RpWidget*> CreateUnconfirmedAuthContent(
|
||||
not_null<Ui::SlideWrap<Ui::VerticalLayout>*> CreateUnconfirmedAuthContent(
|
||||
not_null<Ui::RpWidget*> parent,
|
||||
const std::vector<Data::UnreviewedAuth> &list,
|
||||
Fn<void(bool)> callback);
|
||||
|
||||
Reference in New Issue
Block a user