keepUi method

void keepUi([
  1. bool? enabled
])

Keeps UI open for some amount of time and then hides it if enabled is null, otherwise toggles its state immediately to enabled.

Implementation

void keepUi([bool? enabled]) {
  _uiTimer?.cancel();
  showUi.value = isPanelOpen.value || (enabled ?? true);

  if (!headerHovered) {
    showHeader.value = (enabled ?? true);
  }

  if (state.value == OngoingCallState.active &&
      enabled == null &&
      !isPanelOpen.value) {
    _uiTimer = Timer(const Duration(seconds: _uiDuration), () {
      showUi.value = false;
      showHeader.value = false;

      if (!headerHovered) {
        showHeader.value = false;
      }
    });
  }
}