mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Show 'Late by' state and glow in ForceMuted state.
This commit is contained in:
parent
4d91ab7079
commit
0e47c6b415
5 changed files with 59 additions and 39 deletions
|
@ -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}";
|
||||
|
|
|
@ -769,22 +769,37 @@ void Panel::setupRealMuteButtonState(not_null<Data::GroupCall*> real) {
|
|||
|
||||
void Panel::setupScheduledLabels(rpl::producer<TimeId> 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<Ui::GroupCallScheduledLeft>(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;
|
||||
|
|
|
@ -50,35 +50,46 @@ void GroupCallScheduledLeft::restart() {
|
|||
update();
|
||||
}
|
||||
|
||||
rpl::producer<QString> GroupCallScheduledLeft::text() const {
|
||||
return _text.value();
|
||||
rpl::producer<QString> GroupCallScheduledLeft::text(Negative negative) const {
|
||||
return (negative == Negative::Show)
|
||||
? _text.value()
|
||||
: _textNonNegative.value();
|
||||
}
|
||||
|
||||
rpl::producer<bool> 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<RoundButton>(
|
||||
_inner.get(),
|
||||
_scheduledProcess->text(),
|
||||
_scheduledProcess->text(GroupCallScheduledLeft::Negative::Show),
|
||||
st::groupCallTopBarOpen);
|
||||
setupRightButton(_open.get());
|
||||
_open->widthValue(
|
||||
|
|
|
@ -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<QString> text() const;
|
||||
[[nodiscard]] rpl::producer<QString> text(Negative negative) const;
|
||||
[[nodiscard]] rpl::producer<bool> late() const;
|
||||
|
||||
private:
|
||||
[[nodiscard]] crl::time computePreciseDate() const;
|
||||
|
@ -43,6 +48,8 @@ private:
|
|||
void update();
|
||||
|
||||
rpl::variable<QString> _text;
|
||||
rpl::variable<QString> _textNonNegative;
|
||||
rpl::variable<bool> _late;
|
||||
TimeId _date = 0;
|
||||
crl::time _datePrecise = 0;
|
||||
base::Timer _timer;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue