Skip to content

Commit

Permalink
Merge pull request #2076 from nextcloud/feat/neon_talk/mention-autoco…
Browse files Browse the repository at this point in the history
…mplete
  • Loading branch information
provokateurin authored Jun 6, 2024
2 parents a691917 + 7c1fcf2 commit 76abd34
Show file tree
Hide file tree
Showing 18 changed files with 511 additions and 136 deletions.
88 changes: 88 additions & 0 deletions packages/app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.0-beta.2"
flutter_keyboard_visibility:
dependency: transitive
description:
name: flutter_keyboard_visibility
sha256: "98664be7be0e3ffca00de50f7f6a287ab62c763fc8c762e0a21584584a3ff4f8"
url: "https://pub.dev"
source: hosted
version: "6.0.0"
flutter_keyboard_visibility_linux:
dependency: transitive
description:
name: flutter_keyboard_visibility_linux
sha256: "6fba7cd9bb033b6ddd8c2beb4c99ad02d728f1e6e6d9b9446667398b2ac39f08"
url: "https://pub.dev"
source: hosted
version: "1.0.0"
flutter_keyboard_visibility_macos:
dependency: transitive
description:
name: flutter_keyboard_visibility_macos
sha256: c5c49b16fff453dfdafdc16f26bdd8fb8d55812a1d50b0ce25fc8d9f2e53d086
url: "https://pub.dev"
source: hosted
version: "1.0.0"
flutter_keyboard_visibility_platform_interface:
dependency: transitive
description:
name: flutter_keyboard_visibility_platform_interface
sha256: e43a89845873f7be10cb3884345ceb9aebf00a659f479d1c8f4293fcb37022a4
url: "https://pub.dev"
source: hosted
version: "2.0.0"
flutter_keyboard_visibility_web:
dependency: transitive
description:
name: flutter_keyboard_visibility_web
sha256: d3771a2e752880c79203f8d80658401d0c998e4183edca05a149f5098ce6e3d1
url: "https://pub.dev"
source: hosted
version: "2.0.0"
flutter_keyboard_visibility_windows:
dependency: transitive
description:
name: flutter_keyboard_visibility_windows
sha256: fc4b0f0b6be9b93ae527f3d527fb56ee2d918cd88bbca438c478af7bcfd0ef73
url: "https://pub.dev"
source: hosted
version: "1.0.0"
flutter_local_notifications:
dependency: transitive
description:
Expand Down Expand Up @@ -509,6 +557,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_typeahead:
dependency: transitive
description:
name: flutter_typeahead
sha256: d64712c65db240b1057559b952398ebb6e498077baeebf9b0731dade62438a6d
url: "https://pub.dev"
source: hosted
version: "5.2.0"
flutter_web_plugins:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -1009,6 +1065,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
pointer_interceptor:
dependency: transitive
description:
name: pointer_interceptor
sha256: d0a8e660d1204eaec5bd34b34cc92174690e076d2e4f893d9d68c486a13b07c4
url: "https://pub.dev"
source: hosted
version: "0.10.1+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: a6237528b46c411d8d55cdfad8fcb3269fc4cbb26060b14bff94879165887d1e
url: "https://pub.dev"
source: hosted
version: "0.10.2"
pointycastle:
dependency: transitive
description:
Expand Down
63 changes: 2 additions & 61 deletions packages/neon/neon_talk/lib/src/pages/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import 'package:flutter/material.dart';
import 'package:intersperse/intersperse.dart';
import 'package:intl/intl.dart';
import 'package:neon_framework/blocs.dart';
import 'package:neon_framework/theme.dart';
import 'package:neon_framework/utils.dart';
import 'package:neon_framework/widgets.dart';
import 'package:neon_talk/l10n/localizations.dart';
import 'package:neon_talk/src/blocs/room.dart';
import 'package:neon_talk/src/theme.dart';
import 'package:neon_talk/src/widgets/message.dart';
import 'package:neon_talk/src/widgets/message_input.dart';
import 'package:neon_talk/src/widgets/room_avatar.dart';
import 'package:nextcloud/utils.dart';
import 'package:timezone/timezone.dart' as tz;
Expand All @@ -31,9 +30,6 @@ class TalkRoomPage extends StatefulWidget {
class _TalkRoomPageState extends State<TalkRoomPage> {
late final TalkRoomBloc bloc;
late final StreamSubscription<Object> errorsSubscription;
final messageFormKey = GlobalKey<FormState>();
final messageController = TextEditingController();
final messageFocus = FocusNode();

@override
void initState() {
Expand All @@ -49,21 +45,10 @@ class _TalkRoomPageState extends State<TalkRoomPage> {
@override
void dispose() {
unawaited(errorsSubscription.cancel());
messageController.dispose();
messageFocus.dispose();
bloc.dispose();
super.dispose();
}

void sendMessage() {
final message = messageController.text;
if (messageFormKey.currentState!.validate()) {
bloc.sendMessage(message);
messageController.clear();
}
messageFocus.requestFocus();
}

@override
Widget build(BuildContext context) {
return ResultBuilder.behaviorSubject(
Expand Down Expand Up @@ -186,32 +171,6 @@ class _TalkRoomPageState extends State<TalkRoomPage> {
);

if (room.readOnly == 0) {
Widget? emojiButton;
// On cupertino the keyboard always has an option to insert emojis, so we don't need to add it
if (!isCupertino(context)) {
emojiButton = IconButton(
tooltip: TalkLocalizations.of(context).roomMessageAddEmoji,
onPressed: () async {
final emoji = await showDialog<String>(
context: context,
builder: (context) => const NeonEmojiPickerDialog(),
);
if (emoji != null) {
final text = messageController.text;
final textSelection = messageController.selection;

messageController
..text = text.replaceRange(textSelection.start, textSelection.end, emoji)
..selection = textSelection.copyWith(
baseOffset: textSelection.start + emoji.length,
extentOffset: textSelection.start + emoji.length,
);
}
},
icon: const Icon(Icons.emoji_emotions_outlined),
);
}

body = Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.end,
Expand All @@ -224,25 +183,7 @@ class _TalkRoomPageState extends State<TalkRoomPage> {
child: Center(
child: ConstrainedBox(
constraints: Theme.of(context).extension<TalkTheme>()!.messageConstraints,
child: Form(
key: messageFormKey,
child: TextFormField(
controller: messageController,
focusNode: messageFocus,
textInputAction: TextInputAction.send,
decoration: InputDecoration(
prefixIcon: emojiButton,
suffixIcon: IconButton(
tooltip: TalkLocalizations.of(context).roomMessageSend,
icon: Icon(AdaptiveIcons.send),
onPressed: sendMessage,
),
hintText: TalkLocalizations.of(context).roomWriteMessage,
),
validator: (input) => validateNotEmpty(context, input),
onFieldSubmitted: (_) => sendMessage(),
),
),
child: const TalkMessageInput(),
),
),
),
Expand Down
Loading

0 comments on commit 76abd34

Please sign in to comment.