diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 7207e92a6..bff889fea 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2085,6 +2085,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_group_call_starts_tomorrow" = "tomorrow at {time}"; "lng_group_call_starts_date" = "{date} at {time}"; "lng_group_call_starts_in" = "Starts in"; +"lng_group_call_late_by" = "Late by"; "lng_group_call_starts_short_today" = "Today, {time}"; "lng_group_call_starts_short_tomorrow" = "Tomorrow, {time}"; "lng_group_call_starts_short_date" = "{date}, {time}"; diff --git a/Telegram/SourceFiles/calls/calls_group_panel.cpp b/Telegram/SourceFiles/calls/calls_group_panel.cpp index 91548f2b9..2936e47bd 100644 --- a/Telegram/SourceFiles/calls/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_group_panel.cpp @@ -769,22 +769,37 @@ void Panel::setupRealMuteButtonState(not_null real) { void Panel::setupScheduledLabels(rpl::producer date) { using namespace rpl::mappers; - _startsIn.create( - widget(), - tr::lng_group_call_starts_in(), - st::groupCallStartsIn); date = std::move(date) | rpl::take_while(_1 != 0); _startsWhen.create( widget(), StartsWhenText(rpl::duplicate(date)), st::groupCallStartsWhen); - _countdown = CreateGradientLabel(widget(), std::move( + auto countdownCreated = std::move( date ) | rpl::map([=](TimeId date) { _countdownData = std::make_shared(date); - return _countdownData->text(); + return rpl::empty_value(); + }) | rpl::start_spawning(widget()->lifetime()); + + _countdown = CreateGradientLabel(widget(), rpl::duplicate( + countdownCreated + ) | rpl::map([=] { + return _countdownData->text( + Ui::GroupCallScheduledLeft::Negative::Ignore); }) | rpl::flatten_latest()); + _startsIn.create( + widget(), + rpl::conditional( + std::move( + countdownCreated + ) | rpl::map( + [=] { return _countdownData->late(); } + ) | rpl::flatten_latest(), + tr::lng_group_call_late_by(), + tr::lng_group_call_starts_in()), + st::groupCallStartsIn); + const auto top = [=] { const auto muteTop = widget()->height() - st::groupCallMuteBottomSkip; const auto membersTop = st::groupCallMembersTop; diff --git a/Telegram/SourceFiles/ui/chat/group_call_bar.cpp b/Telegram/SourceFiles/ui/chat/group_call_bar.cpp index 0092d638e..e8de32b97 100644 --- a/Telegram/SourceFiles/ui/chat/group_call_bar.cpp +++ b/Telegram/SourceFiles/ui/chat/group_call_bar.cpp @@ -50,35 +50,46 @@ void GroupCallScheduledLeft::restart() { update(); } -rpl::producer GroupCallScheduledLeft::text() const { - return _text.value(); +rpl::producer GroupCallScheduledLeft::text(Negative negative) const { + return (negative == Negative::Show) + ? _text.value() + : _textNonNegative.value(); +} + +rpl::producer GroupCallScheduledLeft::late() const { + return _late.value(); } void GroupCallScheduledLeft::update() { const auto now = crl::now(); const auto duration = (_datePrecise - now); const auto left = crl::time(std::round(std::abs(duration) / 1000.)); + const auto late = (duration < 0) && (left > 0); + _late = late; constexpr auto kDay = 24 * 60 * 60; if (left >= kDay) { const auto days = ((left / kDay) + 1); - _text = tr::lng_group_call_duration_days( + _textNonNegative = tr::lng_group_call_duration_days( tr::now, lt_count, - (duration < 0) ? (-days) : days); + days); + _text = late + ? tr::lng_group_call_duration_days(tr::now, lt_count, -days) + : _textNonNegative.current(); } else { const auto hours = left / (60 * 60); const auto minutes = (left % (60 * 60)) / 60; const auto seconds = (left % 60); - if (hours > 0) { - _text = (duration < 0 ? u"\x2212%1:%2:%3"_q : u"%1:%2:%3"_q) + _textNonNegative = (hours > 0) + ? (u"%1:%2:%3"_q .arg(hours, 2, 10, QChar('0')) .arg(minutes, 2, 10, QChar('0')) - .arg(seconds, 2, 10, QChar('0')); - } else { - _text = (duration < 0 && left > 0 ? u"\x2212%1:%2"_q : u"%1:%2"_q) + .arg(seconds, 2, 10, QChar('0'))) + : (u"%1:%2"_q .arg(minutes, 2, 10, QChar('0')) - .arg(seconds, 2, 10, QChar('0')); - } + .arg(seconds, 2, 10, QChar('0'))); + _text = (late ? QString(QChar(0x2212)) : QString()) + + _textNonNegative.current(); } if (left >= kDay) { _timer.callOnce((left % kDay) * crl::time(1000)); @@ -186,7 +197,7 @@ void GroupCallBar::refreshScheduledProcess() { _join = nullptr; _open = std::make_unique( _inner.get(), - _scheduledProcess->text(), + _scheduledProcess->text(GroupCallScheduledLeft::Negative::Show), st::groupCallTopBarOpen); setupRightButton(_open.get()); _open->widthValue( diff --git a/Telegram/SourceFiles/ui/chat/group_call_bar.h b/Telegram/SourceFiles/ui/chat/group_call_bar.h index 92dd142e2..1b2d6fc92 100644 --- a/Telegram/SourceFiles/ui/chat/group_call_bar.h +++ b/Telegram/SourceFiles/ui/chat/group_call_bar.h @@ -31,11 +31,16 @@ struct GroupCallBarContent { class GroupCallScheduledLeft final { public: + enum class Negative { + Show, + Ignore, + }; explicit GroupCallScheduledLeft(TimeId date); void setDate(TimeId date); - [[nodiscard]] rpl::producer text() const; + [[nodiscard]] rpl::producer text(Negative negative) const; + [[nodiscard]] rpl::producer late() const; private: [[nodiscard]] crl::time computePreciseDate() const; @@ -43,6 +48,8 @@ private: void update(); rpl::variable _text; + rpl::variable _textNonNegative; + rpl::variable _late; TimeId _date = 0; crl::time _datePrecise = 0; base::Timer _timer; diff --git a/Telegram/SourceFiles/ui/controls/call_mute_button.cpp b/Telegram/SourceFiles/ui/controls/call_mute_button.cpp index b20d06512..87fd85e1f 100644 --- a/Telegram/SourceFiles/ui/controls/call_mute_button.cpp +++ b/Telegram/SourceFiles/ui/controls/call_mute_button.cpp @@ -150,12 +150,7 @@ bool IsConnecting(CallMuteButtonType type) { } bool IsInactive(CallMuteButtonType type) { - return IsConnecting(type) - || (type == CallMuteButtonType::ForceMuted) - || (type == CallMuteButtonType::RaisedHand) - || (type == CallMuteButtonType::ScheduledCanStart) - || (type == CallMuteButtonType::ScheduledNotify) - || (type == CallMuteButtonType::ScheduledSilent); + return IsConnecting(type); } auto Clamp(float64 value) { @@ -744,7 +739,7 @@ void CallMuteButton::init() { for (auto &[type, stops] : copy) { auto firstColor = IsInactive(type) ? st::groupCallBg->c - : stops.stops[0].second; + : stops.stops[(stops.stops.size() - 1) / 2].second; firstColor.setAlpha(kGlowAlpha); stops.stops = QGradientStops{ { 0., std::move(firstColor) }, @@ -1057,25 +1052,16 @@ void CallMuteButton::overridesColors( CallMuteButtonType fromType, CallMuteButtonType toType, float64 progress) { - const auto forceMutedToConnecting = [](CallMuteButtonType &type) { - if (type == CallMuteButtonType::ForceMuted - || type == CallMuteButtonType::RaisedHand - || type == CallMuteButtonType::ScheduledCanStart - || type == CallMuteButtonType::ScheduledNotify - || type == CallMuteButtonType::ScheduledSilent) { - type = CallMuteButtonType::Connecting; - } - }; - forceMutedToConnecting(toType); - forceMutedToConnecting(fromType); const auto toInactive = IsInactive(toType); const auto fromInactive = IsInactive(fromType); if (toInactive && (progress == 1)) { _colorOverrides.fire({ std::nullopt, std::nullopt }); return; } - auto from = _colors.find(fromType)->second.stops[0].second; - auto to = _colors.find(toType)->second.stops[0].second; + const auto &fromStops = _colors.find(fromType)->second.stops; + const auto &toStops = _colors.find(toType)->second.stops; + auto from = fromStops[(fromStops.size() - 1) / 2].second; + auto to = toStops[(toStops.size() - 1) / 2].second; auto fromRipple = from; auto toRipple = to; if (!toInactive) {