Skip to content

Commit 2a0df64

Browse files
committed
1 parent a24fa3e commit 2a0df64

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

lib/widgets/compose_box.dart

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

23-
const double _inputVerticalPadding = 8;
24-
const double _sendButtonSize = 36;
2523
const double _composeButtonWidth = 44;
2624
const double _composeButtonHeight = 42;
2725

@@ -288,32 +286,46 @@ class _ContentInput extends StatelessWidget {
288286

289287
@override
290288
Widget build(BuildContext context) {
291-
ColorScheme colorScheme = Theme.of(context).colorScheme;
292-
293-
return InputDecorator(
294-
decoration: const InputDecoration(),
295-
child: ConstrainedBox(
296-
constraints: const BoxConstraints(
297-
minHeight: _sendButtonSize - 2 * _inputVerticalPadding,
298-
299-
// TODO constrain this adaptively (i.e. not hard-coded 200)
300-
maxHeight: 200,
301-
),
302-
child: ComposeAutocomplete(
303-
narrow: narrow,
304-
controller: controller,
305-
focusNode: focusNode,
306-
fieldViewBuilder: (context) {
307-
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(
308311
controller: controller,
309312
focusNode: focusNode,
310-
style: TextStyle(color: colorScheme.onSurface),
311-
decoration: InputDecoration.collapsed(hintText: hintText),
313+
// `contentPadding` causes the text to be clipped by a rect
314+
// shorter than the compose box, because it shrinks the body of
315+
// [TextField]. Overriding this gives us fine control
316+
// over the clipping behavior with [ClipRect].
317+
clipBehavior: Clip.none,
318+
style: TextStyle(
319+
fontSize: 17,
320+
height: (contentLineHeight / 17),
321+
color: designVariables.textInput),
312322
maxLines: null,
313323
textCapitalization: TextCapitalization.sentences,
314-
);
315-
}),
316-
));
324+
decoration: InputDecoration(
325+
contentPadding: const EdgeInsets.symmetric(vertical: verticalPadding),
326+
hintText: hintText,
327+
hintStyle: TextStyle(
328+
color: designVariables.textInput.withValues(alpha: 0.5)))))));
317329
}
318330
}
319331

0 commit comments

Comments
 (0)