Fixed changing of button style between states within single intro step.
This commit is contained in:
parent
567216f41f
commit
693ff3398e
|
@ -100,10 +100,13 @@ CodeWidget::CodeWidget(
|
||||||
|
|
||||||
_code->setDigitsCountMax(getData()->codeLength);
|
_code->setDigitsCountMax(getData()->codeLength);
|
||||||
|
|
||||||
setTitleText(getData()->codeByFragmentUrl.isEmpty()
|
|
||||||
? rpl::single(Ui::FormatPhone(getData()->phone))
|
|
||||||
: tr::lng_intro_fragment_title());
|
|
||||||
updateDescText();
|
updateDescText();
|
||||||
|
setTitleText(_isFragment.value(
|
||||||
|
) | rpl::map([=](bool isFragment) {
|
||||||
|
return !isFragment
|
||||||
|
? rpl::single(Ui::FormatPhone(getData()->phone))
|
||||||
|
: tr::lng_intro_fragment_title();
|
||||||
|
}) | rpl::flatten_latest());
|
||||||
|
|
||||||
account->setHandleLoginCode([=](const QString &code) {
|
account->setHandleLoginCode([=](const QString &code) {
|
||||||
_code->setText(code);
|
_code->setText(code);
|
||||||
|
@ -126,6 +129,7 @@ int CodeWidget::errorTop() const {
|
||||||
void CodeWidget::updateDescText() {
|
void CodeWidget::updateDescText() {
|
||||||
const auto byTelegram = getData()->codeByTelegram;
|
const auto byTelegram = getData()->codeByTelegram;
|
||||||
const auto isFragment = !getData()->codeByFragmentUrl.isEmpty();
|
const auto isFragment = !getData()->codeByFragmentUrl.isEmpty();
|
||||||
|
_isFragment = isFragment;
|
||||||
setDescriptionText(
|
setDescriptionText(
|
||||||
isFragment
|
isFragment
|
||||||
? tr::lng_intro_fragment_about(
|
? tr::lng_intro_fragment_about(
|
||||||
|
@ -136,8 +140,7 @@ void CodeWidget::updateDescText() {
|
||||||
Ui::Text::RichLangValue)
|
Ui::Text::RichLangValue)
|
||||||
: (byTelegram ? tr::lng_code_from_telegram : tr::lng_code_desc)(
|
: (byTelegram ? tr::lng_code_from_telegram : tr::lng_code_desc)(
|
||||||
Ui::Text::RichLangValue));
|
Ui::Text::RichLangValue));
|
||||||
if (isFragment) {
|
if (getData()->codeByTelegram) {
|
||||||
} else if (getData()->codeByTelegram) {
|
|
||||||
_noTelegramCode->show();
|
_noTelegramCode->show();
|
||||||
_callTimer.cancel();
|
_callTimer.cancel();
|
||||||
} else {
|
} else {
|
||||||
|
@ -420,15 +423,19 @@ void CodeWidget::submitCode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<QString> CodeWidget::nextButtonText() const {
|
rpl::producer<QString> CodeWidget::nextButtonText() const {
|
||||||
return getData()->codeByFragmentUrl.isEmpty()
|
return _isFragment.value(
|
||||||
? Step::nextButtonText()
|
) | rpl::map([=](bool isFragment) {
|
||||||
: tr::lng_intro_fragment_button();
|
return isFragment
|
||||||
|
? tr::lng_intro_fragment_button()
|
||||||
|
: Step::nextButtonText();
|
||||||
|
}) | rpl::flatten_latest();
|
||||||
}
|
}
|
||||||
|
|
||||||
const style::RoundButton *CodeWidget::nextButtonStyle() const {
|
rpl::producer<const style::RoundButton*> CodeWidget::nextButtonStyle() const {
|
||||||
return !getData()->codeByFragmentUrl.isEmpty()
|
return _isFragment.value(
|
||||||
? &st::introFragmentButton
|
) | rpl::map([](bool isFragment) {
|
||||||
: nullptr;
|
return isFragment ? &st::introFragmentButton : nullptr;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeWidget::noTelegramCode() {
|
void CodeWidget::noTelegramCode() {
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
void cancelled() override;
|
void cancelled() override;
|
||||||
void submit() override;
|
void submit() override;
|
||||||
rpl::producer<QString> nextButtonText() const override;
|
rpl::producer<QString> nextButtonText() const override;
|
||||||
const style::RoundButton *nextButtonStyle() const override;
|
rpl::producer<const style::RoundButton*> nextButtonStyle() const override;
|
||||||
|
|
||||||
void updateDescText();
|
void updateDescText();
|
||||||
|
|
||||||
|
@ -96,6 +96,8 @@ private:
|
||||||
QString _sentCode;
|
QString _sentCode;
|
||||||
mtpRequestId _sentRequest = 0;
|
mtpRequestId _sentRequest = 0;
|
||||||
|
|
||||||
|
rpl::variable<bool> _isFragment = false;
|
||||||
|
|
||||||
base::Timer _callTimer;
|
base::Timer _callTimer;
|
||||||
CallStatus _callStatus = CallStatus();
|
CallStatus _callStatus = CallStatus();
|
||||||
int _callTimeout;
|
int _callTimeout;
|
||||||
|
|
|
@ -119,8 +119,8 @@ rpl::producer<QString> Step::nextButtonText() const {
|
||||||
return tr::lng_intro_next();
|
return tr::lng_intro_next();
|
||||||
}
|
}
|
||||||
|
|
||||||
const style::RoundButton *Step::nextButtonStyle() const {
|
rpl::producer<const style::RoundButton*> Step::nextButtonStyle() const {
|
||||||
return nullptr;
|
return rpl::single((const style::RoundButton*)(nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Step::goBack() {
|
void Step::goBack() {
|
||||||
|
|
|
@ -81,7 +81,8 @@ public:
|
||||||
|
|
||||||
virtual void submit() = 0;
|
virtual void submit() = 0;
|
||||||
[[nodiscard]] virtual rpl::producer<QString> nextButtonText() const;
|
[[nodiscard]] virtual rpl::producer<QString> nextButtonText() const;
|
||||||
[[nodiscard]] virtual const style::RoundButton *nextButtonStyle() const;
|
[[nodiscard]] virtual auto nextButtonStyle() const
|
||||||
|
-> rpl::producer<const style::RoundButton*>;
|
||||||
|
|
||||||
[[nodiscard]] int contentLeft() const;
|
[[nodiscard]] int contentLeft() const;
|
||||||
[[nodiscard]] int contentTop() const;
|
[[nodiscard]] int contentTop() const;
|
||||||
|
|
|
@ -342,17 +342,21 @@ void Widget::historyMove(StackAction action, Animate animate) {
|
||||||
hideAndDestroy(std::exchange(_terms, { nullptr }));
|
hideAndDestroy(std::exchange(_terms, { nullptr }));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const auto st = getStep()->nextButtonStyle();
|
getStep()->nextButtonStyle(
|
||||||
const auto nextStyle = st ? st : &st::introNextButton;
|
) | rpl::start_with_next([=](const style::RoundButton *st) {
|
||||||
if (_nextStyle != nextStyle) {
|
const auto nextStyle = st ? st : &st::introNextButton;
|
||||||
_nextStyle = nextStyle;
|
if (_nextStyle != nextStyle) {
|
||||||
_next = nullptr;
|
_nextStyle = nextStyle;
|
||||||
_next.create(
|
const auto wasShown = _next->toggled();
|
||||||
this,
|
_next.destroy();
|
||||||
object_ptr<Ui::RoundButton>(this, nullptr, *nextStyle));
|
_next.create(
|
||||||
showControls();
|
this,
|
||||||
updateControlsGeometry();
|
object_ptr<Ui::RoundButton>(this, nullptr, *nextStyle));
|
||||||
}
|
showControls();
|
||||||
|
updateControlsGeometry();
|
||||||
|
_next->toggle(wasShown, anim::type::instant);
|
||||||
|
}
|
||||||
|
}, _next->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
getStep()->finishInit();
|
getStep()->finishInit();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user