From f24dd1b69a0b2d0aaf45a5847bb7db82e83fad93 Mon Sep 17 00:00:00 2001 From: Bruno D'Luka Date: Sun, 7 Apr 2024 20:24:59 -0300 Subject: [PATCH] fix: Correctly position the video status overlay on limited screens --- lib/screens/layouts/mobile/device_view.dart | 1 - lib/screens/layouts/video_status_label.dart | 38 +++++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/screens/layouts/mobile/device_view.dart b/lib/screens/layouts/mobile/device_view.dart index c43ad6d8..1baa2de8 100644 --- a/lib/screens/layouts/mobile/device_view.dart +++ b/lib/screens/layouts/mobile/device_view.dart @@ -17,7 +17,6 @@ * along with this program. If not, see . */ -import 'package:bluecherry_client/api/api.dart'; import 'package:bluecherry_client/models/device.dart'; import 'package:bluecherry_client/providers/mobile_view_provider.dart'; import 'package:bluecherry_client/providers/settings_provider.dart'; diff --git a/lib/screens/layouts/video_status_label.dart b/lib/screens/layouts/video_status_label.dart index 7f9cc39f..6eaac836 100644 --- a/lib/screens/layouts/video_status_label.dart +++ b/lib/screens/layouts/video_status_label.dart @@ -101,25 +101,27 @@ class _VideoStatusLabelState extends State { event: widget.event, ); final minHeight = label.buildTextSpans(context).length * 15; + + final willLeftOverflow = + position.dx + _DeviceVideoInfo.minWidth > constraints.maxWidth; + + final left = willLeftOverflow + ? (constraints.maxWidth - _DeviceVideoInfo.minWidth - 8.0) + : position.dx; + final top = position.dy > minHeight + 8.0 + ? null + : position.dy + boxSize.height + 8.0; + final bottom = position.dy > minHeight + 8.0 + ? constraints.maxHeight - position.dy + 8.0 + : null; + return Stack(children: [ - if (position.dy > minHeight + 8.0) - Positioned( - bottom: constraints.maxHeight - position.dy + 8.0, - right: constraints.maxWidth - position.dx - boxSize.width, - child: label, - ) - else - () { - final willLeftOverflow = position.dx + _DeviceVideoInfo.minWidth > - constraints.maxWidth; - return Positioned( - top: position.dy + boxSize.height + 8.0, - left: willLeftOverflow - ? (constraints.maxWidth - _DeviceVideoInfo.minWidth - 8.0) - : position.dx, - child: label, - ); - }(), + Positioned( + left: left, + top: top, + bottom: bottom, + child: label, + ), ]); }); });