From a33c8d6bbe24d86d6f288a032d6c3a306bdf2fb1 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Tue, 10 Nov 2026 13:37:16 +0000 Subject: [PATCH] Keep compact bar insets inside the floating chat window --- .../chat/workspace/chat_float_window.dart | 4 +++- app/lib/ui/adaptive/window_margins.dart | 6 +++++ app/test/ui/adaptive/window_margins_test.dart | 22 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/lib/features/chat/workspace/chat_float_window.dart b/app/lib/features/chat/workspace/chat_float_window.dart index b3f8ab9d..3e5c103d 100644 --- a/app/lib/features/chat/workspace/chat_float_window.dart +++ b/app/lib/features/chat/workspace/chat_float_window.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import '../../../ui/adaptive/window_margins.dart'; import '../../terminal/terminal_float_frame.dart' show terminalFloatChrome; import 'chat_float_binding.dart'; import 'chat_float_store.dart'; @@ -93,7 +94,8 @@ class ChatFloatWindow extends StatelessWidget { removeBottom: true, removeLeft: true, removeRight: true, - child: child, + // A small window keeps the compact bar insets. + child: WindowMargins.compact(child: child), ), ), ], diff --git a/app/lib/ui/adaptive/window_margins.dart b/app/lib/ui/adaptive/window_margins.dart index 77c6278b..66cf4039 100644 --- a/app/lib/ui/adaptive/window_margins.dart +++ b/app/lib/ui/adaptive/window_margins.dart @@ -44,6 +44,12 @@ class WindowMargins extends StatelessWidget { context.dependOnInheritedWidgetOfExactType<_WindowMarginsScope>()?.wide ?? false; + /// Gives [child] the phone's margins inside a wide window: a small window + /// of its own (a floating chat) whose bars sit close to its frame. It + /// changes only the side inset; the window drops the top padding itself. + static Widget compact({required Widget child}) => + _WindowMarginsScope(wide: false, child: child); + /// A top bar piece's distance from the sides at [context]. static double sideOf(BuildContext context) => wideOf(context) ? wideMargin : narrowSide; diff --git a/app/test/ui/adaptive/window_margins_test.dart b/app/test/ui/adaptive/window_margins_test.dart index 66cdcd8e..dcaf7be5 100644 --- a/app/test/ui/adaptive/window_margins_test.dart +++ b/app/test/ui/adaptive/window_margins_test.dart @@ -75,4 +75,26 @@ void main() { ); expect(side, 12); }); + + testWidgets('a compact window inside a wide one keeps the phone sides', ( + tester, + ) async { + late double side; + await tester.pumpWidget( + MediaQuery( + data: const MediaQueryData(size: Size(1280, 800)), + child: WindowMargins( + child: WindowMargins.compact( + child: Builder( + builder: (context) { + side = WindowMargins.sideOf(context); + return const SizedBox(); + }, + ), + ), + ), + ), + ); + expect(side, 12); + }); }