Skip to content

Commit 2d7ee38

Browse files
committed
1 parent c98acbd commit 2d7ee38

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

lib/widgets/compose_box.dart

+36-21
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import 'store.dart';
2020
import 'text.dart';
2121
import 'theme.dart';
2222

23-
const double _inputVerticalPadding = 8;
2423
const double _composeButtonWidth = 44;
2524
const double _composeButtonHeight = 42;
2625

@@ -287,30 +286,46 @@ class _ContentInput extends StatelessWidget {
287286

288287
@override
289288
Widget build(BuildContext context) {
290-
ColorScheme colorScheme = Theme.of(context).colorScheme;
291-
292-
return InputDecorator(
293-
decoration: const InputDecoration(),
294-
child: ConstrainedBox(
295-
constraints: const BoxConstraints(
296-
// TODO constrain this adaptively (i.e. not hard-coded 200)
297-
maxHeight: 200,
298-
),
299-
child: ComposeAutocomplete(
300-
narrow: narrow,
301-
controller: controller,
302-
focusNode: focusNode,
303-
fieldViewBuilder: (context) {
304-
return TextField(
289+
final designVariables = DesignVariables.of(context);
290+
const verticalPadding = 8.0;
291+
const contentLineHeight = 22.0;
292+
293+
return ConstrainedBox(
294+
constraints: const BoxConstraints(
295+
// The minimum height fits a little more than 2 lines to match the spec
296+
// of 54 logical pixels. The bottom padding is not added because it
297+
// is not supposed to extend the compose box.
298+
minHeight: verticalPadding + contentLineHeight * 2.091,
299+
// Reserve space to fully show the first 7th lines and just partially
300+
// clip the 8th line, where the height matches the spec of 178 logical
301+
// pixels. The partial line hints that the content input is scrollable.
302+
// The bottom padding is not added because it is not supposed to extend
303+
// the compose box.
304+
maxHeight: verticalPadding + contentLineHeight * 7 + contentLineHeight * 0.727),
305+
child: ClipRect(
306+
child: ComposeAutocomplete(
307+
narrow: narrow,
308+
controller: controller,
309+
focusNode: focusNode,
310+
fieldViewBuilder: (context) => TextField(
305311
controller: controller,
306312
focusNode: focusNode,
307-
style: TextStyle(color: colorScheme.onSurface),
308-
decoration: InputDecoration.collapsed(hintText: hintText),
313+
// Not clipping content input with [TextField] gives us fine
314+
// control over the clipping behavior. Otherwise, the non-zero
315+
// vertical `contentPadding` would cause the text to be clipped
316+
// by a rectangle shorter than the compose box.
317+
clipBehavior: Clip.none,
318+
style: TextStyle(
319+
fontSize: 17,
320+
height: (contentLineHeight / 17),
321+
color: designVariables.textInput),
309322
maxLines: null,
310323
textCapitalization: TextCapitalization.sentences,
311-
);
312-
}),
313-
));
324+
decoration: InputDecoration(
325+
contentPadding: const EdgeInsets.symmetric(vertical: verticalPadding),
326+
hintText: hintText,
327+
hintStyle: TextStyle(
328+
color: designVariables.textInput.withValues(alpha: 0.5)))))));
314329
}
315330
}
316331

0 commit comments

Comments
 (0)