diff --git a/lib/ui/screens/call_screen.dart b/lib/ui/screens/call_screen.dart index f285d8f..90fbd6d 100644 --- a/lib/ui/screens/call_screen.dart +++ b/lib/ui/screens/call_screen.dart @@ -436,34 +436,50 @@ class _CallScreenState extends SafeState { mainAxisAlignment: MainAxisAlignment.center, children: [ // Toggle audio button - Expanded( - child: IconButton( - icon: Icon(isStreamingAudio && !isAudioMuted - ? Icons.mic - : Icons.mic_off), - onPressed: () => _toggleStreaming(false), - ), + _FooterButton( + onPressed: () => _toggleStreaming(false), + icon: Icon( + isStreamingAudio && !isAudioMuted ? Icons.mic : Icons.mic_off), ), // Hang up call - Expanded( - child: IconButton( - icon: Icon(Icons.phone, color: Colors.red), - onPressed: () => _leaveCall(), - ), + _FooterButton( + icon: Icon(Icons.phone, color: Colors.red), + onPressed: () => _leaveCall(), ), // Toggle video button - Expanded( - child: IconButton( - icon: Icon(isStreamingVideo && !isVideoMuted - ? Icons.videocam - : Icons.videocam_off), - onPressed: () => _toggleStreaming(true), - ), + _FooterButton( + icon: Icon(isStreamingVideo && !isVideoMuted + ? Icons.videocam + : Icons.videocam_off), + onPressed: () => _toggleStreaming(true), ), ], ), ); } } + +class _FooterButton extends StatelessWidget { + final Function() onPressed; + final Widget icon; + + const _FooterButton({ + Key key, + @required this.onPressed, + @required this.icon, + }) : assert(onPressed != null), + assert(icon != null), + super(key: key); + + @override + Widget build(BuildContext context) { + return Expanded( + child: IconButton( + icon: icon, + onPressed: () => onPressed(), + ), + ); + } +}