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?>>(
|
child: TypeAheadField<Map<String, String?>>(
|
||||||
direction: AxisDirection.up,
|
direction: VerticalDirection.up,
|
||||||
hideOnEmpty: true,
|
hideOnEmpty: true,
|
||||||
hideOnLoading: true,
|
hideOnLoading: true,
|
||||||
keepSuggestionsOnSuggestionSelected: true,
|
controller: controller,
|
||||||
|
focusNode: focusNode,
|
||||||
|
hideOnSelect: false,
|
||||||
debounceDuration: const Duration(milliseconds: 50),
|
debounceDuration: const Duration(milliseconds: 50),
|
||||||
// show suggestions after 50ms idle time (default is 300)
|
// 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,
|
minLines: minLines,
|
||||||
maxLines: maxLines,
|
maxLines: maxLines,
|
||||||
keyboardType: keyboardType!,
|
keyboardType: keyboardType!,
|
||||||
|
|
@ -461,9 +477,7 @@ class InputBar extends StatelessWidget {
|
||||||
// it sets the types for the callback incorrectly
|
// it sets the types for the callback incorrectly
|
||||||
onSubmitted!(text);
|
onSubmitted!(text);
|
||||||
},
|
},
|
||||||
controller: controller,
|
|
||||||
decoration: decoration!,
|
decoration: decoration!,
|
||||||
focusNode: focusNode,
|
|
||||||
onChanged: (text) {
|
onChanged: (text) {
|
||||||
// fix for the library for now
|
// fix for the library for now
|
||||||
// it sets the types for the callback incorrectly
|
// it sets the types for the callback incorrectly
|
||||||
|
|
@ -474,13 +488,13 @@ class InputBar extends StatelessWidget {
|
||||||
suggestionsCallback: getSuggestions,
|
suggestionsCallback: getSuggestions,
|
||||||
itemBuilder: (c, s) =>
|
itemBuilder: (c, s) =>
|
||||||
buildSuggestion(c, s, Matrix.of(context).client),
|
buildSuggestion(c, s, Matrix.of(context).client),
|
||||||
onSuggestionSelected: (Map<String, String?> suggestion) =>
|
onSelected: (Map<String, String?> suggestion) =>
|
||||||
insertSuggestion(context, suggestion),
|
insertSuggestion(context, suggestion),
|
||||||
errorBuilder: (BuildContext context, Object? error) =>
|
errorBuilder: (BuildContext context, Object? error) =>
|
||||||
const SizedBox.shrink(),
|
const SizedBox.shrink(),
|
||||||
loadingBuilder: (BuildContext context) => const SizedBox.shrink(),
|
loadingBuilder: (BuildContext context) => const SizedBox.shrink(),
|
||||||
// fix loading briefly flickering a dark box
|
// fix loading briefly flickering a dark box
|
||||||
noItemsFoundBuilder: (BuildContext context) => const SizedBox
|
emptyBuilder: (BuildContext context) => const SizedBox
|
||||||
.shrink(), // fix loading briefly showing no suggestions
|
.shrink(), // fix loading briefly showing no suggestions
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,17 @@ class HomeserverAppBar extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return TypeAheadField<PublicHomeserver>(
|
return TypeAheadField<PublicHomeserver>(
|
||||||
suggestionsBoxDecoration: SuggestionsBoxDecoration(
|
decorationBuilder: (context, child) => ConstrainedBox(
|
||||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
|
||||||
elevation: Theme.of(context).appBarTheme.scrolledUnderElevation ?? 4,
|
|
||||||
shadowColor: Theme.of(context).appBarTheme.shadowColor ?? Colors.black,
|
|
||||||
constraints: const BoxConstraints(maxHeight: 256),
|
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),
|
leading: const Icon(Icons.search_outlined),
|
||||||
title: Text(L10n.of(context)!.nothingFound),
|
title: Text(L10n.of(context)!.nothingFound),
|
||||||
),
|
),
|
||||||
|
|
@ -35,8 +39,7 @@ class HomeserverAppBar extends StatelessWidget {
|
||||||
errorBuilder: (context, error) => ListTile(
|
errorBuilder: (context, error) => ListTile(
|
||||||
leading: const Icon(Icons.error_outlined),
|
leading: const Icon(Icons.error_outlined),
|
||||||
title: Text(
|
title: Text(
|
||||||
error?.toLocalizedString(context) ??
|
error.toLocalizedString(context),
|
||||||
L10n.of(context)!.oopsSomethingWentWrong,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
itemBuilder: (context, homeserver) => ListTile(
|
itemBuilder: (context, homeserver) => ListTile(
|
||||||
|
|
@ -72,13 +75,15 @@ class HomeserverAppBar extends StatelessWidget {
|
||||||
}
|
}
|
||||||
return matches;
|
return matches;
|
||||||
},
|
},
|
||||||
onSuggestionSelected: (suggestion) {
|
onSelected: (suggestion) {
|
||||||
controller.homeserverController.text = suggestion.name;
|
controller.homeserverController.text = suggestion.name;
|
||||||
controller.checkHomeserverAction();
|
controller.checkHomeserverAction();
|
||||||
},
|
},
|
||||||
textFieldConfiguration: TextFieldConfiguration(
|
controller: controller.homeserverController,
|
||||||
|
builder: (context, textEditingController, focusNode) => TextField(
|
||||||
enabled: !controller.isLoggingIn,
|
enabled: !controller.isLoggingIn,
|
||||||
controller: controller.homeserverController,
|
controller: textEditingController,
|
||||||
|
focusNode: focusNode,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
prefixIcon: Navigator.of(context).canPop()
|
prefixIcon: Navigator.of(context).canPop()
|
||||||
? IconButton(
|
? IconButton(
|
||||||
|
|
|
||||||
36
pubspec.lock
36
pubspec.lock
|
|
@ -471,10 +471,10 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: flutter_keyboard_visibility
|
name: flutter_keyboard_visibility
|
||||||
sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb"
|
sha256: "98664be7be0e3ffca00de50f7f6a287ab62c763fc8c762e0a21584584a3ff4f8"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.4.1"
|
version: "6.0.0"
|
||||||
flutter_keyboard_visibility_linux:
|
flutter_keyboard_visibility_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -698,10 +698,10 @@ packages:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: flutter_typeahead
|
name: flutter_typeahead
|
||||||
sha256: b9942bd5b7611a6ec3f0730c477146cffa4cd4b051077983ba67ddfc9e7ee818
|
sha256: d64712c65db240b1057559b952398ebb6e498077baeebf9b0731dade62438a6d
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.8.0"
|
version: "5.2.0"
|
||||||
flutter_web_auth_2:
|
flutter_web_auth_2:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|
@ -1394,10 +1394,34 @@ packages:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: pointer_interceptor
|
name: pointer_interceptor
|
||||||
sha256: adf7a637f97c077041d36801b43be08559fd4322d2127b3f20bb7be1b9eebc22
|
sha256: bd18321519718678d5fa98ad3a3359cbc7a31f018554eab80b73d08a7f0c165a
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.9.3+7"
|
version: "0.10.1"
|
||||||
|
pointer_interceptor_ios:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: pointer_interceptor_ios
|
||||||
|
sha256: "2e73c39452830adc4695757130676a39412a3b7f3c34e3f752791b5384770877"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.10.0+2"
|
||||||
|
pointer_interceptor_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: pointer_interceptor_platform_interface
|
||||||
|
sha256: "0597b0560e14354baeb23f8375cd612e8bd4841bf8306ecb71fcd0bb78552506"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.10.0+1"
|
||||||
|
pointer_interceptor_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: pointer_interceptor_web
|
||||||
|
sha256: "9386e064097fd16419e935c23f08f35b58e6aaec155dd39bd6a003b88f9c14b4"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.10.1+2"
|
||||||
pointycastle:
|
pointycastle:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ dependencies:
|
||||||
flutter_secure_storage: ^9.0.0
|
flutter_secure_storage: ^9.0.0
|
||||||
flutter_shortcuts:
|
flutter_shortcuts:
|
||||||
git: https://github.com/krille-chan/flutter_shortcuts.git
|
git: https://github.com/krille-chan/flutter_shortcuts.git
|
||||||
flutter_typeahead: ^4.8.0
|
flutter_typeahead: ^5.2.0
|
||||||
flutter_web_auth_2: ^3.0.4
|
flutter_web_auth_2: ^3.0.4
|
||||||
flutter_webrtc: ^0.9.46
|
flutter_webrtc: ^0.9.46
|
||||||
future_loading_dialog: ^0.3.0
|
future_loading_dialog: ^0.3.0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue