Skip to content

Commit

Permalink
入力補完の外をタップしたときにフォーカスを外す
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon committed Nov 26, 2023
1 parent 5a733a4 commit f881b05
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 40 deletions.
85 changes: 46 additions & 39 deletions lib/view/common/note_create/input_completation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,50 +87,57 @@ class InputComplementState extends ConsumerState<InputComplement> {
return Container();
}

return DecoratedBox(
decoration: BoxDecoration(
border:
Border(top: BorderSide(color: Theme.of(context).primaryColor))),
child: Row(
children: [
Expanded(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: ConstrainedBox(
constraints:
BoxConstraints(minWidth: MediaQuery.of(context).size.width),
child: switch (inputCompletionType) {
Basic() => BasicKeyboard(
controller: widget.controller,
focusNode: focusNode,
),
Emoji() => EmojiKeyboard(
account: account,
controller: widget.controller,
focusNode: focusNode,
),
MfmFn() => MfmFnKeyboard(
controller: widget.controller,
focusNode: focusNode,
parentContext: context,
),
Hashtag() => HashtagKeyboard(
account: account,
controller: widget.controller,
focusNode: focusNode,
),
},
return TextFieldTapRegion(
onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
child: DecoratedBox(
decoration: BoxDecoration(
border: Border(
top: BorderSide(color: Theme.of(context).primaryColor),
),
),
child: Row(
children: [
Expanded(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: ConstrainedBox(
constraints: BoxConstraints(
minWidth: MediaQuery.of(context).size.width,
),
child: switch (inputCompletionType) {
Basic() => BasicKeyboard(
controller: widget.controller,
focusNode: focusNode,
),
Emoji() => EmojiKeyboard(
account: account,
controller: widget.controller,
focusNode: focusNode,
),
MfmFn() => MfmFnKeyboard(
controller: widget.controller,
focusNode: focusNode,
parentContext: context,
),
Hashtag() => HashtagKeyboard(
account: account,
controller: widget.controller,
focusNode: focusNode,
),
},
),
),
),
),
if (defaultTargetPlatform == TargetPlatform.android ||
defaultTargetPlatform == TargetPlatform.iOS)
IconButton(
if (defaultTargetPlatform == TargetPlatform.android ||
defaultTargetPlatform == TargetPlatform.iOS)
IconButton(
onPressed: () {
FocusManager.instance.primaryFocus?.unfocus();
},
icon: const Icon(Icons.keyboard_arrow_down)),
],
icon: const Icon(Icons.keyboard_arrow_down),
),
],
),
),
);
}
Expand Down
1 change: 0 additions & 1 deletion lib/view/time_line_page/timeline_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class TimelineNoteFieldState extends ConsumerState<TimelineNoteField> {
maxLines: null,
controller: ref.watch(timelineNoteProvider),
decoration: noteStyle,
// onTapOutside: (_) => FocusManager.instance.primaryFocus?.unfocus(),
),
);
}
Expand Down

0 comments on commit f881b05

Please sign in to comment.