incomingCallsNotification static method

void incomingCallsNotification({
  1. required List<CallSession> sessions,
  2. required GlobalKey<NavigatorState> navigatorKey,
})

Implementation

static void incomingCallsNotification({
  required List<CallSession> sessions,
  required GlobalKey<NavigatorState> navigatorKey,
}) {
  if (sessions.isEmpty) return;
  if (PendingCallsScreen.isVisible) {
    return;
  }
  OverlaySupportEntry? entry;
  entry = showSimpleNotification(
    Text(
      "${sessions.length} incoming calls",
      style: const TextStyle(
        color: Colors.white,
        fontWeight: FontWeight.w600,
      ),
    ),
    background: Colors.green.shade700,
    duration: const Duration(seconds: 5),
    leading: const Icon(Icons.call, color: Colors.white),
    trailing: TextButton(
      style: TextButton.styleFrom(
        foregroundColor: Colors.white,
        backgroundColor: Colors.white.withValues(alpha: 0.15),
        padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
      ),
      onPressed: () {
        entry?.dismiss();
        navigatorKey.currentState?.push(
          MaterialPageRoute(builder: (_) => const PendingCallsScreen()),
        );
      },
      child: const Text("VIEW"),
    ),
  );
}