feat: Add insert content via gboard
This commit is contained in:
parent
1324ce517d
commit
6435e703e4
4 changed files with 67 additions and 24 deletions
|
|
@ -444,13 +444,29 @@ class InputBar extends StatelessWidget {
|
|||
),
|
||||
},
|
||||
child: TypeAheadField<Map<String, String?>>(
|
||||
direction: AxisDirection.up,
|
||||
direction: VerticalDirection.up,
|
||||
hideOnEmpty: true,
|
||||
hideOnLoading: true,
|
||||
keepSuggestionsOnSuggestionSelected: true,
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
hideOnSelect: false,
|
||||
debounceDuration: const Duration(milliseconds: 50),
|
||||
// show suggestions after 50ms idle time (default is 300)
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
builder: (context, controller, focusNode) => TextField(
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
contentInsertionConfiguration: ContentInsertionConfiguration(
|
||||
onContentInserted: (KeyboardInsertedContent content) {
|
||||
final data = content.data;
|
||||
if (data == null) return;
|
||||
final file = MatrixFile(
|
||||
mimeType: content.mimeType,
|
||||
bytes: data,
|
||||
name: 'content-insertion',
|
||||
);
|
||||
room.sendFileEvent(file, shrinkImageMaxDimension: 1600);
|
||||
},
|
||||
),
|
||||
minLines: minLines,
|
||||
maxLines: maxLines,
|
||||
keyboardType: keyboardType!,
|
||||
|
|
@ -461,9 +477,7 @@ class InputBar extends StatelessWidget {
|
|||
// it sets the types for the callback incorrectly
|
||||
onSubmitted!(text);
|
||||
},
|
||||
controller: controller,
|
||||
decoration: decoration!,
|
||||
focusNode: focusNode,
|
||||
onChanged: (text) {
|
||||
// fix for the library for now
|
||||
// it sets the types for the callback incorrectly
|
||||
|
|
@ -474,13 +488,13 @@ class InputBar extends StatelessWidget {
|
|||
suggestionsCallback: getSuggestions,
|
||||
itemBuilder: (c, s) =>
|
||||
buildSuggestion(c, s, Matrix.of(context).client),
|
||||
onSuggestionSelected: (Map<String, String?> suggestion) =>
|
||||
onSelected: (Map<String, String?> suggestion) =>
|
||||
insertSuggestion(context, suggestion),
|
||||
errorBuilder: (BuildContext context, Object? error) =>
|
||||
const SizedBox.shrink(),
|
||||
loadingBuilder: (BuildContext context) => const SizedBox.shrink(),
|
||||
// fix loading briefly flickering a dark box
|
||||
noItemsFoundBuilder: (BuildContext context) => const SizedBox
|
||||
emptyBuilder: (BuildContext context) => const SizedBox
|
||||
.shrink(), // fix loading briefly showing no suggestions
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -18,13 +18,17 @@ class HomeserverAppBar extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TypeAheadField<PublicHomeserver>(
|
||||
suggestionsBoxDecoration: SuggestionsBoxDecoration(
|
||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||
elevation: Theme.of(context).appBarTheme.scrolledUnderElevation ?? 4,
|
||||
shadowColor: Theme.of(context).appBarTheme.shadowColor ?? Colors.black,
|
||||
decorationBuilder: (context, child) => ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxHeight: 256),
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||
elevation: Theme.of(context).appBarTheme.scrolledUnderElevation ?? 4,
|
||||
shadowColor:
|
||||
Theme.of(context).appBarTheme.shadowColor ?? Colors.black,
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
noItemsFoundBuilder: (context) => ListTile(
|
||||
emptyBuilder: (context) => ListTile(
|
||||
leading: const Icon(Icons.search_outlined),
|
||||
title: Text(L10n.of(context)!.nothingFound),
|
||||
),
|
||||
|
|
@ -35,8 +39,7 @@ class HomeserverAppBar extends StatelessWidget {
|
|||
errorBuilder: (context, error) => ListTile(
|
||||
leading: const Icon(Icons.error_outlined),
|
||||
title: Text(
|
||||
error?.toLocalizedString(context) ??
|
||||
L10n.of(context)!.oopsSomethingWentWrong,
|
||||
error.toLocalizedString(context),
|
||||
),
|
||||
),
|
||||
itemBuilder: (context, homeserver) => ListTile(
|
||||
|
|
@ -72,13 +75,15 @@ class HomeserverAppBar extends StatelessWidget {
|
|||
}
|
||||
return matches;
|
||||
},
|
||||
onSuggestionSelected: (suggestion) {
|
||||
onSelected: (suggestion) {
|
||||
controller.homeserverController.text = suggestion.name;
|
||||
controller.checkHomeserverAction();
|
||||
},
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
controller: controller.homeserverController,
|
||||
builder: (context, textEditingController, focusNode) => TextField(
|
||||
enabled: !controller.isLoggingIn,
|
||||
controller: controller.homeserverController,
|
||||
controller: textEditingController,
|
||||
focusNode: focusNode,
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Navigator.of(context).canPop()
|
||||
? IconButton(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue