From ad3d33bb2180ccf8f12df67958afcd4870582161 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Sun, 5 Jun 2022 02:23:40 -0400 Subject: [PATCH] Add rotate button to overlay (#138) --- lib/screens/channel/video_chat.dart | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/screens/channel/video_chat.dart b/lib/screens/channel/video_chat.dart index 7b8a070c..68a37ae7 100644 --- a/lib/screens/channel/video_chat.dart +++ b/lib/screens/channel/video_chat.dart @@ -252,6 +252,8 @@ class _VideoChatState extends State { overlays: SystemUiOverlay.values, ); + SystemChrome.setPreferredOrientations([]); + super.dispose(); } } @@ -430,6 +432,21 @@ class _VideoOverlay extends StatelessWidget { onPressed: () => _showSleepTimerDialog(context), ); + final rotateButton = IconButton( + tooltip: orientation == Orientation.portrait ? 'Enter Landscape Mode (Lock)' : 'Exit Landscape Mode', + onPressed: () { + if (orientation == Orientation.portrait) { + SystemChrome.setPreferredOrientations([ + DeviceOrientation.landscapeRight, + DeviceOrientation.landscapeLeft, + ]); + } else { + SystemChrome.setPreferredOrientations([]); + } + }, + icon: orientation == Orientation.portrait ? const Icon(Icons.screen_lock_rotation) : const Icon(Icons.screen_rotation), + ); + final streamInfo = videoStore.streamInfo; if (streamInfo == null) { return Stack( @@ -583,7 +600,8 @@ class _VideoOverlay extends StatelessWidget { ), if (videoStore.settingsStore.fullScreen && orientation == Orientation.landscape) chatOverlayButton, refreshButton, - if (orientation == Orientation.landscape) fullScreenButton + rotateButton, + if (orientation == Orientation.landscape) fullScreenButton, ], ), )