Skip to content

Commit dd5e48b

Browse files
committed
autocomplete [nfc]: Factor out AutocompleteInputWrapper
The code around ComposeAutocomplete is not specific to the compose input and would be used in other autocomplete fields specifically _TopicInput
1 parent 34e9891 commit dd5e48b

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

lib/widgets/compose_box.dart

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,22 @@ class ComposeContentController extends ComposeController<ContentValidationError>
265265
}
266266
}
267267

268+
class AutocompleteInputWrapper extends StatelessWidget {
269+
const AutocompleteInputWrapper({super.key, required this.child});
270+
271+
final Widget child;
272+
273+
@override
274+
Widget build(BuildContext context) => InputDecorator(
275+
decoration: const InputDecoration(),
276+
child: ConstrainedBox(
277+
constraints: const BoxConstraints(
278+
minHeight: _sendButtonSize - 2 * _inputVerticalPadding,
279+
// TODO constrain this adaptively (i.e. not hard-coded 200)
280+
maxHeight: 200,
281+
), child:child));
282+
}
283+
268284
class _ContentInput extends StatelessWidget {
269285
const _ContentInput({
270286
required this.narrow,
@@ -282,30 +298,18 @@ class _ContentInput extends StatelessWidget {
282298
Widget build(BuildContext context) {
283299
ColorScheme colorScheme = Theme.of(context).colorScheme;
284300

285-
return InputDecorator(
286-
decoration: const InputDecoration(),
287-
child: ConstrainedBox(
288-
constraints: const BoxConstraints(
289-
minHeight: _sendButtonSize - 2 * _inputVerticalPadding,
290-
291-
// TODO constrain this adaptively (i.e. not hard-coded 200)
292-
maxHeight: 200,
293-
),
294-
child: ComposeAutocomplete(
295-
narrow: narrow,
301+
return AutocompleteInputWrapper(
302+
child: ComposeAutocomplete(
303+
narrow: narrow,
304+
controller: controller,
305+
focusNode: focusNode,
306+
fieldViewBuilder: (context) => TextField(
296307
controller: controller,
297308
focusNode: focusNode,
298-
fieldViewBuilder: (context) {
299-
return TextField(
300-
controller: controller,
301-
focusNode: focusNode,
302-
style: TextStyle(color: colorScheme.onSurface),
303-
decoration: InputDecoration.collapsed(hintText: hintText),
304-
maxLines: null,
305-
textCapitalization: TextCapitalization.sentences,
306-
);
307-
}),
308-
));
309+
style: TextStyle(color: colorScheme.onSurface),
310+
decoration: InputDecoration.collapsed(hintText: hintText),
311+
maxLines: null,
312+
textCapitalization: TextCapitalization.sentences)));
309313
}
310314
}
311315

0 commit comments

Comments
 (0)