2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-03 16:05:57 +00:00

Add group calls top bar.

This commit is contained in:
John Preston
2020-11-24 17:40:10 +03:00
parent 8833d3e45b
commit 41591ff2e9
10 changed files with 136 additions and 36 deletions

View File

@@ -254,6 +254,10 @@ MainWidget::MainWidget(
) | rpl::start_with_next([=](Calls::Call *call) {
setCurrentCall(call);
}, lifetime());
Core::App().calls().currentGroupCallValue(
) | rpl::start_with_next([=](Calls::GroupCall *call) {
setCurrentGroupCall(call);
}, lifetime());
if (_callTopBar) {
_callTopBar->finishAnimating();
}
@@ -942,6 +946,9 @@ void MainWidget::playerHeightUpdated() {
}
void MainWidget::setCurrentCall(Calls::Call *call) {
if (!call && _currentGroupCall) {
return;
}
_currentCallLifetime.destroy();
_currentCall = call;
if (_currentCall) {
@@ -959,10 +966,35 @@ void MainWidget::setCurrentCall(Calls::Call *call) {
}
}
void MainWidget::createCallTopBar() {
Expects(_currentCall != nullptr);
void MainWidget::setCurrentGroupCall(Calls::GroupCall *call) {
if (!call && _currentCall) {
return;
}
_currentCallLifetime.destroy();
_currentGroupCall = call;
if (_currentGroupCall) {
_currentGroupCall->stateValue(
) | rpl::start_with_next([=](Calls::GroupCall::State state) {
using State = Calls::GroupCall::State;
if (state == State::Joined) {
createCallTopBar();
} else {
destroyCallTopBar();
}
}, _currentCallLifetime);
} else {
destroyCallTopBar();
}
}
_callTopBar.create(this, object_ptr<Calls::TopBar>(this, _currentCall));
void MainWidget::createCallTopBar() {
Expects(_currentCall != nullptr || _currentGroupCall != nullptr);
_callTopBar.create(
this,
(_currentCall
? object_ptr<Calls::TopBar>(this, _currentCall)
: object_ptr<Calls::TopBar>(this, _currentGroupCall)));
_callTopBar->heightValue(
) | rpl::start_with_next([this](int value) {
callTopBarHeightUpdated(value);
@@ -986,7 +1018,7 @@ void MainWidget::destroyCallTopBar() {
}
void MainWidget::callTopBarHeightUpdated(int callTopBarHeight) {
if (!callTopBarHeight && !_currentCall) {
if (!callTopBarHeight && !_currentCall && !_currentGroupCall) {
_callTopBar.destroyDelayed();
}
if (callTopBarHeight != _callTopBarHeight) {