Show poll explanation in box

This commit is contained in:
Eric Kotato 2020-04-24 17:25:02 +03:00
parent 5043a2e301
commit 7356179308
2 changed files with 15 additions and 10 deletions

View file

@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/ripple_animation.h" #include "ui/effects/ripple_animation.h"
#include "ui/effects/fireworks_animation.h" #include "ui/effects/fireworks_animation.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "kotato/boxes/confirm_box.h"
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "data/data_poll.h" #include "data/data_poll.h"
#include "data/data_user.h" #include "data/data_user.h"
@ -442,10 +443,13 @@ void Poll::checkQuizAnswered() {
} }
} }
void Poll::showSolution() const { void Poll::showSolution(bool inBox) const {
if (_poll->solution.text.isEmpty()) { if (_poll->solution.text.isEmpty()) {
return; return;
} }
if (inBox) {
Ui::show(Box<Kotato::InformBox>(_poll->solution));
} else {
auto config = Ui::Toast::Config(); auto config = Ui::Toast::Config();
config.multiline = config.dark = true; config.multiline = config.dark = true;
config.minWidth = st::msgMinWidth; config.minWidth = st::msgMinWidth;
@ -454,6 +458,7 @@ void Poll::showSolution() const {
config.durationMs = CountToastDuration(config.text); config.durationMs = CountToastDuration(config.text);
Ui::Toast::Show(config); Ui::Toast::Show(config);
} }
}
void Poll::updateRecentVoters() { void Poll::updateRecentVoters() {
auto &&sliced = ranges::view::all( auto &&sliced = ranges::view::all(
@ -953,7 +958,7 @@ void Poll::paintShowSolution(
} }
if (!_showSolutionLink) { if (!_showSolutionLink) {
_showSolutionLink = std::make_shared<LambdaClickHandler>( _showSolutionLink = std::make_shared<LambdaClickHandler>(
crl::guard(this, [=] { showSolution(); })); crl::guard(this, [=] { showSolution(true); }));
} }
const auto outbg = _parent->hasOutLayout(); const auto outbg = _parent->hasOutLayout();
const auto &icon = (selection == FullSelection) const auto &icon = (selection == FullSelection)

View file

@ -165,7 +165,7 @@ private:
void sendMultiOptions(); void sendMultiOptions();
void showResults(); void showResults();
void checkQuizAnswered(); void checkQuizAnswered();
void showSolution() const; void showSolution(bool inBox = false) const;
[[nodiscard]] bool canShowSolution() const; [[nodiscard]] bool canShowSolution() const;
[[nodiscard]] bool inShowSolution( [[nodiscard]] bool inShowSolution(