feat(video_calls): fixed naviagtion from push notification to call and added wake lock

This commit is contained in:
misha
2026-07-06 11:18:05 +03:00
parent 9ce7b035ff
commit 219908684f
10 changed files with 752 additions and 99 deletions

View File

@@ -4,6 +4,7 @@ import 'package:eatvio_app/core/cubit/base_cubit.dart';
import 'package:eatvio_app/features/video_calls/managers/video_call_manager.dart';
import 'package:eatvio_app/features/video_calls/managers/video_call_manager_snapshot.dart';
import 'package:eatvio_app/features/video_calls/presentation/bloc/video_call_session/video_call_session_state.dart';
import 'package:eatvio_app/features/video_calls/services/video_call_screen_wake_lock_coordinator.dart';
import 'package:eatvio_app/features/video_calls/services/video_call_system_pip_coordinator.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@@ -14,9 +15,12 @@ class VideoCallSessionCubit extends BaseCubit<VideoCallSessionState> {
VideoCallSessionCubit({
required VideoCallManager videoCallManager,
VideoCallSystemPipCoordinator? systemPipCoordinator,
VideoCallScreenWakeLockCoordinator? screenWakeLockCoordinator,
}) : _videoCallManager = videoCallManager,
_systemPipCoordinator =
systemPipCoordinator ?? VideoCallSystemPipCoordinator(),
_screenWakeLock =
screenWakeLockCoordinator ?? VideoCallScreenWakeLockCoordinator(),
super(const VideoCallSessionState()) {
_videoCallManager.addListener(_onManagerSnapshot);
_syncFromManager(_videoCallManager.snapshot);
@@ -24,6 +28,7 @@ class VideoCallSessionCubit extends BaseCubit<VideoCallSessionState> {
final VideoCallManager _videoCallManager;
final VideoCallSystemPipCoordinator _systemPipCoordinator;
final VideoCallScreenWakeLockCoordinator _screenWakeLock;
bool _callScreenRouteVisible = false;
bool _autoEnterInFlight = false;
bool _counterpartPresentWhenLobbyReady = false;
@@ -168,6 +173,7 @@ class VideoCallSessionCubit extends BaseCubit<VideoCallSessionState> {
VideoCallEntryMode entryMode = VideoCallEntryMode.outgoing,
}) async {
_callScreenRouteVisible = true;
await _screenWakeLock.acquire();
final effectiveEntryMode =
state.entryMode == VideoCallEntryMode.incomingAccepted ||
@@ -507,6 +513,7 @@ class VideoCallSessionCubit extends BaseCubit<VideoCallSessionState> {
}
Future<void> endCall() async {
await _screenWakeLock.release();
await _systemPipCoordinator.disarm();
await _videoCallManager.endCall();
}
@@ -567,6 +574,7 @@ class VideoCallSessionCubit extends BaseCubit<VideoCallSessionState> {
}
Future<void> _restoreSystemUiAfterCall() async {
await _screenWakeLock.release();
try {
await SystemChrome.setPreferredOrientations(const <DeviceOrientation>[]);
await SystemChrome.setEnabledSystemUIMode(