Keep compact bar insets inside the floating chat window
This commit is contained in:
@@ -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),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user