diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 916146cd65..e5c505e876 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2188,6 +2188,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_polls_create_limit#one" = "You can add {count} more option."; "lng_polls_create_limit#other" = "You can add {count} more options."; "lng_polls_create_maximum" = "You have added the maximum number of options."; +"lng_polls_create_settings" = "Settings"; +"lng_polls_create_hint" = "Tap to select the right option"; +"lng_polls_create_anonymous" = "Anonymous Votes"; +"lng_polls_create_multiple_choice" = "Multiple Choice"; +"lng_polls_create_quiz_mode" = "Quiz Mode"; "lng_polls_create_button" = "Create"; "lng_outdated_title" = "PLEASE UPDATE YOUR OPERATING SYSTEM."; diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index 04e21e28c2..a49e54f57b 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -812,15 +812,15 @@ createPollField: InputField(defaultInputField) { } createPollFieldPadding: margins(22px, 5px, 22px, 5px); createPollOptionField: InputField(createPollField) { - textMargins: margins(22px, 8px, 40px, 8px); + textMargins: margins(22px, 11px, 40px, 11px); placeholderMargins: margins(2px, 0px, 2px, 0px); - heightMax: 64px; + heightMax: 68px; } createPollLimitLabel: FlatLabel(defaultFlatLabel) { minWidth: 274px; align: align(topleft); } -createPollLimitPadding: margins(22px, 10px, 22px, 5px); +createPollLimitPadding: margins(22px, 10px, 22px, 16px); createPollOptionRemove: CrossButton { width: 22px; height: 22px; @@ -841,7 +841,7 @@ createPollOptionRemove: CrossButton { color: windowBgOver; } } -createPollOptionRemovePosition: point(10px, 7px); +createPollOptionRemovePosition: point(11px, 9px); createPollWarning: FlatLabel(defaultFlatLabel) { textFg: windowSubTextFg; palette: TextPalette(defaultTextPalette) { @@ -849,6 +849,8 @@ createPollWarning: FlatLabel(defaultFlatLabel) { } } createPollWarningPosition: point(16px, 6px); +createPollCheckboxMargin: margins(23px, 10px, 23px, 10px); +createPollFieldTitlePadding: margins(22px, 7px, 10px, 6px); callSettingsButton: IconButton { width: 50px; diff --git a/Telegram/SourceFiles/boxes/create_poll_box.cpp b/Telegram/SourceFiles/boxes/create_poll_box.cpp index 66b1e32ccd..b86863d72e 100644 --- a/Telegram/SourceFiles/boxes/create_poll_box.cpp +++ b/Telegram/SourceFiles/boxes/create_poll_box.cpp @@ -12,10 +12,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/toast/toast.h" #include "ui/wrap/vertical_layout.h" #include "ui/wrap/slide_wrap.h" +#include "ui/wrap/fade_wrap.h" #include "ui/widgets/input_fields.h" #include "ui/widgets/shadow.h" #include "ui/widgets/labels.h" #include "ui/widgets/buttons.h" +#include "ui/widgets/checkbox.h" +#include "ui/toast/toast.h" #include "main/main_session.h" #include "chat_helpers/emoji_suggestions_widget.h" #include "chat_helpers/message_field.h" @@ -49,6 +52,8 @@ public: [[nodiscard]] std::vector toPollAnswers() const; void focusFirst(); + void enableChooseCorrect(bool enabled); + [[nodiscard]] rpl::producer usedCount() const; [[nodiscard]] rpl::producer> scrollToWidget() const; [[nodiscard]] rpl::producer<> backspaceInFront() const; @@ -56,23 +61,31 @@ public: private: class Option { public: - static Option Create( + Option( not_null outer, not_null container, not_null session, - int position); + int position, + std::shared_ptr group); + + Option(const Option &other) = delete; + Option &operator=(const Option &other) = delete; void toggleRemoveAlways(bool toggled); + void enableChooseCorrect( + std::shared_ptr group); void show(anim::type animated); void destroy(FnMut done); - //[[nodisacrd]] bool hasShadow() const; - //void destroyShadow(); + [[nodisacrd]] bool hasShadow() const; + void createShadow(); + void destroyShadow(); [[nodiscard]] bool isEmpty() const; [[nodiscard]] bool isGood() const; [[nodiscard]] bool isTooLong() const; + [[nodiscard]] bool isCorrect() const; [[nodiscard]] bool hasFocus() const; void setFocus() const; void clearValue(); @@ -86,29 +99,18 @@ private: [[nodiscard]] rpl::producer removeClicks() const; - inline bool operator<(const Option &other) const { - return field() < other.field(); - } - - friend inline bool operator<( - const Option &option, - Ui::InputField *field) { - return option.field() < field; - } - friend inline bool operator<( - Ui::InputField *field, - const Option &option) { - return field < option.field(); - } - private: - Option() = default; - - void createShadow(); void createRemove(); void createWarning(); + void toggleCorrectSpace(bool visible); + void updateFieldGeometry(); - base::unique_qptr> _field; + base::unique_qptr> _wrap; + not_null _content; + base::unique_qptr> _correct; + Ui::Animations::Simple _correctShown; + bool _hasCorrect = false; + Ui::InputField *_field = nullptr; base::unique_qptr _shadow; base::unique_qptr _remove; rpl::variable *_removeAlways = nullptr; @@ -116,23 +118,24 @@ private: }; [[nodiscard]] bool full() const; - //[[nodiscard]] bool correctShadows() const; - //void fixShadows(); + [[nodiscard]] bool correctShadows() const; + void fixShadows(); void removeEmptyTail(); void addEmptyOption(); void checkLastOption(); void validateState(); void fixAfterErase(); - void destroy(Option &&option); - void removeDestroyed(not_null field); + void destroy(std::unique_ptr