unfocus textfield when outside tap on mobile
This commit is contained in:
parent
53105025c9
commit
720e538dbc
2 changed files with 501 additions and 473 deletions
|
|
@ -477,7 +477,8 @@ class const Composer(
|
||||||
fontWeight: .bold,
|
fontWeight: .bold,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Padding(
|
return TextFieldTapRegion(
|
||||||
|
child: Padding(
|
||||||
padding: .all(12),
|
padding: .all(12),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -569,7 +570,11 @@ class const Composer(
|
||||||
(context) => EmojiPicker(
|
(context) => EmojiPicker(
|
||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
onSelection:
|
onSelection:
|
||||||
(value, {shortcode, description}) {
|
(
|
||||||
|
value, {
|
||||||
|
shortcode,
|
||||||
|
description,
|
||||||
|
}) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
if (shortcode == null) {
|
if (shortcode == null) {
|
||||||
controller.text += value;
|
controller.text += value;
|
||||||
|
|
@ -622,7 +627,9 @@ class const Composer(
|
||||||
onTap: () => attach(
|
onTap: () => attach(
|
||||||
source == .gallery
|
source == .gallery
|
||||||
? ref
|
? ref
|
||||||
.read(FileDialogHelper.provider)
|
.read(
|
||||||
|
FileDialogHelper.provider,
|
||||||
|
)
|
||||||
.pickFile(images: true)
|
.pickFile(images: true)
|
||||||
: ref
|
: ref
|
||||||
.read(
|
.read(
|
||||||
|
|
@ -692,8 +699,9 @@ class const Composer(
|
||||||
onPick: (picked) {
|
onPick: (picked) {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
draftNotifier.update(
|
draftNotifier.update(
|
||||||
(draft) =>
|
(draft) => draft.copyWith(
|
||||||
draft.copyWith(location: picked),
|
location: picked,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
@ -722,7 +730,8 @@ class const Composer(
|
||||||
removeTooltip: "Remove poll",
|
removeTooltip: "Remove poll",
|
||||||
onRemove: () {
|
onRemove: () {
|
||||||
draftNotifier.update(
|
draftNotifier.update(
|
||||||
(draft) => draft.copyWith(poll: null),
|
(draft) =>
|
||||||
|
draft.copyWith(poll: null),
|
||||||
);
|
);
|
||||||
node?.requestFocus();
|
node?.requestFocus();
|
||||||
},
|
},
|
||||||
|
|
@ -742,7 +751,12 @@ class const Composer(
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
((final shortcode, final image)?, _, _, _) =>
|
(
|
||||||
|
(final shortcode, final image)?,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
_,
|
||||||
|
) =>
|
||||||
ComposerReplacement(
|
ComposerReplacement(
|
||||||
removeTooltip: "Remove sticker",
|
removeTooltip: "Remove sticker",
|
||||||
onRemove: () {
|
onRemove: () {
|
||||||
|
|
@ -829,7 +843,8 @@ class const Composer(
|
||||||
overlay: TaggerOverlay(
|
overlay: TaggerOverlay(
|
||||||
query.value,
|
query.value,
|
||||||
roomId: roomId,
|
roomId: roomId,
|
||||||
triggerCharacter: triggerCharacter.value,
|
triggerCharacter:
|
||||||
|
triggerCharacter.value,
|
||||||
addTag: ({required id, required name}) {
|
addTag: ({required id, required name}) {
|
||||||
controller.addTag(id: id, name: name);
|
controller.addTag(id: id, name: name);
|
||||||
node?.requestFocus();
|
node?.requestFocus();
|
||||||
|
|
@ -842,7 +857,9 @@ class const Composer(
|
||||||
..value = controller.value.replaced(
|
..value = controller.value.replaced(
|
||||||
.new(
|
.new(
|
||||||
start:
|
start:
|
||||||
end - query.value.length - 1,
|
end -
|
||||||
|
query.value.length -
|
||||||
|
1,
|
||||||
end: end,
|
end: end,
|
||||||
),
|
),
|
||||||
"$text ",
|
"$text ",
|
||||||
|
|
@ -851,7 +868,8 @@ class const Composer(
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
controller: controller,
|
controller: controller,
|
||||||
onSearch: (newQuery, newTriggerCharacter) {
|
onSearch:
|
||||||
|
(newQuery, newTriggerCharacter) {
|
||||||
triggerCharacter.value =
|
triggerCharacter.value =
|
||||||
newTriggerCharacter;
|
newTriggerCharacter;
|
||||||
query.value = newQuery;
|
query.value = newQuery;
|
||||||
|
|
@ -881,14 +899,17 @@ class const Composer(
|
||||||
materialTapTargetSize:
|
materialTapTargetSize:
|
||||||
.shrinkWrap,
|
.shrinkWrap,
|
||||||
onDeleted: () =>
|
onDeleted: () =>
|
||||||
removeTextCommand(command),
|
removeTextCommand(
|
||||||
|
command,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
maxLines: 12,
|
maxLines: 12,
|
||||||
minLines: 1,
|
minLines: 1,
|
||||||
textCapitalization: .sentences,
|
textCapitalization:
|
||||||
|
.sentences,
|
||||||
onChanged: pickTypedCommand,
|
onChanged: pickTypedCommand,
|
||||||
autofocus:
|
autofocus:
|
||||||
(Platform.isLinux ||
|
(Platform.isLinux ||
|
||||||
|
|
@ -902,6 +923,9 @@ class const Composer(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
key: key,
|
key: key,
|
||||||
focusNode: node,
|
focusNode: node,
|
||||||
|
// Touch taps outside don't unfocus on mobile by default
|
||||||
|
onTapOutside: (_) =>
|
||||||
|
node?.unfocus(),
|
||||||
// The toolbar's paste button doesn't use the shortcut's action, so replace it too
|
// The toolbar's paste button doesn't use the shortcut's action, so replace it too
|
||||||
contextMenuBuilder:
|
contextMenuBuilder:
|
||||||
(
|
(
|
||||||
|
|
@ -985,6 +1009,7 @@ class const Composer(
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,9 @@ class const TaggerOverlay(
|
||||||
}) extends ConsumerWidget {
|
}) extends ConsumerWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
return Padding(
|
// Lives in an overlay, so taps on it would otherwise unfocus the composer
|
||||||
|
return TextFieldTapRegion(
|
||||||
|
child: Padding(
|
||||||
padding: .all(8),
|
padding: .all(8),
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: .all(.circular(12)),
|
borderRadius: .all(.circular(12)),
|
||||||
|
|
@ -40,6 +42,7 @@ class const TaggerOverlay(
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue